@fluidframework/shared-object-base 0.53.0 → 0.54.2
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/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sharedObject.d.ts +6 -0
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +15 -3
- package/dist/sharedObject.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sharedObject.d.ts +6 -0
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +15 -3
- package/lib/sharedObject.js.map +1 -1
- package/package.json +9 -9
- package/src/packageVersion.ts +1 -1
- package/src/sharedObject.ts +24 -3
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/shared-object-base";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "0.54.2";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/shared-object-base";
|
|
11
|
-
exports.pkgVersion = "0.
|
|
11
|
+
exports.pkgVersion = "0.54.2";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/shared-object-base\";\nexport const pkgVersion = \"0.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/shared-object-base\";\nexport const pkgVersion = \"0.54.2\";\n"]}
|
package/dist/sharedObject.d.ts
CHANGED
|
@@ -127,6 +127,12 @@ export declare abstract class SharedObject<TEvent extends ISharedObjectEvents =
|
|
|
127
127
|
* Derived classes must override this to provide custom list of references to other GC nodes.
|
|
128
128
|
*/
|
|
129
129
|
protected getGCDataCore(): IGarbageCollectionData;
|
|
130
|
+
/**
|
|
131
|
+
* Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
|
|
132
|
+
* to another object in the container.
|
|
133
|
+
* @param decodedHandle - The handle of the Fluid object that is decoded.
|
|
134
|
+
*/
|
|
135
|
+
protected handleDecoded(decodedHandle: IFluidHandle): void;
|
|
130
136
|
/**
|
|
131
137
|
* Gets a form of the object that can be serialized.
|
|
132
138
|
* @returns A tree representing the snapshot of the shared object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAo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ject.js
CHANGED
|
@@ -41,7 +41,7 @@ class SharedObject extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
41
41
|
this._isSummarizing = false;
|
|
42
42
|
this.handle = new handle_1.SharedObjectHandle(this, id, runtime.IFluidHandleContext);
|
|
43
43
|
this.logger = telemetry_utils_1.ChildLogger.create(runtime.logger, undefined, { all: { sharedObjectId: uuid_1.v4() } });
|
|
44
|
-
this._serializer = new runtime_utils_1.FluidSerializer(this.runtime.channelsRoutingContext);
|
|
44
|
+
this._serializer = new runtime_utils_1.FluidSerializer(this.runtime.channelsRoutingContext, (handle) => this.handleDecoded(handle));
|
|
45
45
|
this.attachListeners();
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -173,7 +173,7 @@ class SharedObject extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
173
173
|
this._isSummarizing = true;
|
|
174
174
|
let summaryTree;
|
|
175
175
|
try {
|
|
176
|
-
const serializer = new summarySerializer_1.SummarySerializer(this.runtime.channelsRoutingContext);
|
|
176
|
+
const serializer = new summarySerializer_1.SummarySerializer(this.runtime.channelsRoutingContext, (handle) => this.handleDecoded(handle));
|
|
177
177
|
const snapshot = this.snapshotCore(serializer);
|
|
178
178
|
summaryTree = runtime_utils_1.convertToSummaryTreeWithStats(snapshot, fullTree);
|
|
179
179
|
common_utils_1.assert(this._isSummarizing, 0x077 /* "Possible re-entrancy! Summary should have been in progress." */);
|
|
@@ -210,7 +210,7 @@ class SharedObject extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
210
210
|
// We run the full summarize logic to get the list of outbound routes from this object. This is a little
|
|
211
211
|
// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.
|
|
212
212
|
// See: https://github.com/microsoft/FluidFramework/issues/4547
|
|
213
|
-
const serializer = new summarySerializer_1.SummarySerializer(this.runtime.channelsRoutingContext);
|
|
213
|
+
const serializer = new summarySerializer_1.SummarySerializer(this.runtime.channelsRoutingContext, (handle) => this.handleDecoded(handle));
|
|
214
214
|
this.snapshotCore(serializer);
|
|
215
215
|
// The GC data for this shared object contains a single GC node. The outbound routes of this node are the
|
|
216
216
|
// routes of handles serialized during snapshot.
|
|
@@ -218,6 +218,18 @@ class SharedObject extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
218
218
|
gcNodes: { "/": serializer.getSerializedRoutes() },
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
|
|
223
|
+
* to another object in the container.
|
|
224
|
+
* @param decodedHandle - The handle of the Fluid object that is decoded.
|
|
225
|
+
*/
|
|
226
|
+
handleDecoded(decodedHandle) {
|
|
227
|
+
var _a, _b, _c;
|
|
228
|
+
if (this.isAttached()) {
|
|
229
|
+
// This represents an outbound reference from this object to the node represented by decodedHandle.
|
|
230
|
+
(_c = (_a = this.services) === null || _a === void 0 ? void 0 : (_b = _a.deltaConnection).addedGCOutboundReference) === null || _c === void 0 ? void 0 : _c.call(_b, this.handle, decodedHandle);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
221
233
|
/**
|
|
222
234
|
* Allows the distributed data type to perform custom local loading.
|
|
223
235
|
*/
|
package/dist/sharedObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAElC,+DAA6E;AAC7E,iFAAoE;AAapE,iEAA+F;AAC/F,qEAA6F;AAC7F,qEAAsE;AACtE,qCAA8C;AAC9C,2DAAwD;AAGxD;;GAEG;AACH,MAAsB,YAClB,SAAQ,+CAAqC;IA0E7C;;;;OAIG;IACH,YACW,EAAU,EACP,OAA+B,EACzB,UAA8B;QAE9C,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAM,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CAAC,CAA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,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACK,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACnD,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CAGJ;AApdD,oCAodC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, EventEmitterEventType } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IFluidHandle, IFluidSerializer } from \"@fluidframework/core-interfaces\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, ITree } from \"@fluidframework/protocol-definitions\";\nimport {\n IGarbageCollectionData,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport { convertToSummaryTreeWithStats, FluidSerializer } from \"@fluidframework/runtime-utils\";\nimport { ChildLogger, EventEmitterWithErrorHandling } from \"@fluidframework/telemetry-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { SharedObjectHandle } from \"./handle\";\nimport { SummarySerializer } from \"./summarySerializer\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types\";\n\n/**\n * Base class from which all shared objects derive\n */\nexport abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {\n /**\n * @param obj - The thing to check if it is a SharedObject\n * @returns Returns true if the thing is a SharedObject\n */\n public static is(obj: any): obj is SharedObject {\n return obj?.ISharedObject !== undefined;\n }\n\n public get ISharedObject() { return this; }\n public get IChannel() { return this; }\n public get IFluidLoadable() { return this; }\n\n /**\n * The handle referring to this SharedObject\n */\n public readonly handle: IFluidHandle;\n\n /**\n * Telemetry logger for the shared object\n */\n protected readonly logger: ITelemetryLogger;\n\n /**\n * Connection state\n */\n private _connected = false;\n\n /**\n * Services used by the shared object\n */\n private services: IChannelServices | undefined;\n\n /**\n * True if the dds is bound to its parent.\n */\n private _isBoundToContext: boolean = false;\n\n /**\n * True while we are summarizing this object's data.\n */\n private _isSummarizing: boolean = false;\n\n /**\n * Tracks error that closed this object.\n */\n private closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n /**\n * Gets the connection state\n * @returns The state of the connection\n */\n public get connected(): boolean {\n return this._connected;\n }\n\n protected get serializer(): IFluidSerializer {\n /**\n * During summarize, the SummarySerializer keeps track of IFluidHandles that are serialized. These handles\n * represent references to other Fluid objects and are used for garbage collection.\n *\n * This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content\n * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n */\n assert(!this._isSummarizing,\n 0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */);\n return this._serializer;\n }\n\n /**\n * The serializer to use to serialize / parse handles, if any.\n */\n private readonly _serializer: IFluidSerializer;\n\n /**\n * @param id - The id of the shared object\n * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n * @param attributes - Attributes of the shared object\n */\n constructor(\n public id: string,\n protected runtime: IFluidDataStoreRuntime,\n public readonly attributes: IChannelAttributes)\n {\n super((event: EventEmitterEventType, e: any) => this.eventListenerErrorHandler(event, e));\n\n this.handle = new SharedObjectHandle(\n this,\n id,\n runtime.IFluidHandleContext);\n\n this.logger = ChildLogger.create(\n runtime.logger,\n undefined,\n { all: { sharedObjectId: uuid() } },\n );\n\n this._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);\n\n this.attachListeners();\n }\n\n /**\n * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n * would result in same error thrown. If called multiple times, only first error is remembered.\n * @param error - error object that is thrown whenever an attempt is made to modify this object\n */\n private closeWithError(error: any) {\n if (this.closeError === undefined) {\n this.closeError = error;\n }\n }\n\n /**\n * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n */\n private verifyNotClosed() {\n if (this.closeError !== undefined) {\n throw this.closeError;\n }\n }\n\n /**\n * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n * It wraps error with DataProcessingError, closes this object and throws resulting error.\n * See closeWithError() for more details\n * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n * allow processing of ops or local changes, which very quickly results in container closure.\n */\n private eventListenerErrorHandler(event: EventEmitterEventType, e: any) {\n const error = DataProcessingError.wrapIfUnrecognized(\n e,\n \"SharedObjectEventListenerException\");\n error.addTelemetryProperties({ emittedEventName: String(event) });\n\n this.closeWithError(error);\n throw error;\n }\n\n private attachListeners() {\n // Only listen to these events if not attached.\n if (!this.isAttached()) {\n this.runtime.once(\"attaching\", () => {\n // Calling this will let the dds to do any custom processing based on attached\n // like starting generating ops.\n this.didAttach();\n });\n }\n }\n\n /**\n * A shared object, after construction, can either be loaded in the case that it is already part of\n * a shared document. Or later attached if it is being newly added.\n * @param services - Services used by the shared object\n */\n public async load(services: IChannelServices): Promise<void> {\n if (this.runtime.attachState !== AttachState.Detached) {\n this.services = services;\n }\n await this.loadCore(services.objectStorage);\n if (this.runtime.attachState !== AttachState.Detached) {\n this.attachDeltaHandler();\n }\n }\n\n /**\n * Initializes the object as a local, non-shared object. This object can become shared after\n * it is attached to the document.\n */\n public initializeLocal(): void {\n this.initializeLocalCore();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).bindToContext}\n */\n public bindToContext(): void {\n if (this._isBoundToContext) {\n return;\n }\n\n this._isBoundToContext = true;\n\n // Allow derived classes to perform custom processing prior to registering this object\n this.registerCore();\n\n this.runtime.bindChannel(this);\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).connect}\n */\n public connect(services: IChannelServices) {\n this.services = services;\n this.attachDeltaHandler();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).isAttached}\n */\n public isAttached(): boolean {\n return this.services !== undefined && this.runtime.attachState !== AttachState.Detached;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).summarize}\n */\n public summarize(fullTree: boolean = false, trackState: boolean = false): ISummaryTreeWithStats {\n // Set _isSummarizing to true. This flag is used to ensure that we only use SummarySerializer (created below)\n // to serialize handles in this object's data. The routes of these serialized handles are outbound routes\n // to other Fluid objects.\n assert(!this._isSummarizing, 0x076 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isSummarizing = true;\n\n let summaryTree: ISummaryTreeWithStats;\n try {\n const serializer = new SummarySerializer(this.runtime.channelsRoutingContext);\n const snapshot: ITree = this.snapshotCore(serializer);\n summaryTree = convertToSummaryTreeWithStats(snapshot, fullTree);\n assert(this._isSummarizing, 0x077 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isSummarizing = false;\n }\n return summaryTree;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).getGCData}\n */\n public getGCData(fullGC: boolean = false): IGarbageCollectionData {\n // Set _isSummarizing to true. This flag is used to ensure that we only use SummarySerializer (created in\n // getGCDataCore) to serialize handles in this object's data.\n assert(!this._isSummarizing, 0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isSummarizing = true;\n\n let gcData: IGarbageCollectionData;\n try {\n gcData = this.getGCDataCore();\n assert(this._isSummarizing, 0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isSummarizing = false;\n }\n\n return gcData;\n }\n\n /**\n * Returns the GC data for this shared object. It contains a list of GC nodes that contains references to\n * other GC nodes.\n * Derived classes must override this to provide custom list of references to other GC nodes.\n */\n protected getGCDataCore(): IGarbageCollectionData {\n // We run the full summarize logic to get the list of outbound routes from this object. This is a little\n // expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n // See: https://github.com/microsoft/FluidFramework/issues/4547\n const serializer = new SummarySerializer(this.runtime.channelsRoutingContext);\n this.snapshotCore(serializer);\n\n // The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n // routes of handles serialized during snapshot.\n return {\n gcNodes: { \"/\": serializer.getSerializedRoutes() },\n };\n }\n\n /**\n * Gets a form of the object that can be serialized.\n * @returns A tree representing the snapshot of the shared object.\n */\n protected abstract snapshotCore(serializer: IFluidSerializer): ITree;\n\n /**\n * Allows the distributed data type to perform custom loading\n * @param services - Storage used by the shared object\n */\n protected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n /**\n * Allows the distributed data type to perform custom local loading.\n */\n protected initializeLocalCore() {\n return;\n }\n\n /**\n * Allows the distributed data type the ability to perform custom processing once an attach has happened.\n */\n protected abstract registerCore();\n\n /**\n * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n * Also called after non-local data type get loaded.\n */\n protected didAttach() {\n return;\n }\n\n /**\n * Derived classes must override this to do custom processing on a remote message.\n * @param message - The message to process\n * @param local - True if the shared object is local\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n protected abstract processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown);\n\n /**\n * Called when the object has disconnected from the delta stream.\n */\n protected abstract onDisconnect();\n\n /**\n * Submits a message by the local client to the runtime.\n * @param content - Content of the message\n * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n */\n protected submitLocalMessage(content: any, localOpMetadata: unknown = undefined): void {\n this.verifyNotClosed();\n if (this.isAttached()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.submit(content, localOpMetadata);\n }\n }\n\n /**\n * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n * that want to be part of summary but does not generate ops.\n */\n protected dirty(): void {\n if (!this.isAttached()) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.dirty();\n }\n\n /**\n * Called when the object has fully connected to the delta stream\n * Default implementation for DDS, override if different behavior is required.\n */\n protected onConnect() { }\n\n /**\n * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n * The default implementation here is to resubmit the same message. The client can override if different behavior\n * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n * anything at all.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n this.submitLocalMessage(content, localOpMetadata);\n }\n\n /**\n * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n * the Promise will reject.\n * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n */\n protected async newAckBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n // Note: rejectBecauseDispose will never be undefined here\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n\n private attachDeltaHandler() {\n // Services should already be there in case we are attaching delta handler.\n assert(this.services !== undefined, 0x07a /* \"Services should be there to attach delta handler\" */);\n this._isBoundToContext = true;\n // Allows objects to do any custom processing if it is attached.\n this.didAttach();\n\n // attachDeltaHandler is only called after services is assigned\n this.services.deltaConnection.attach({\n process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => {\n this.process(message, local, localOpMetadata);\n },\n setConnectionState: (connected: boolean) => {\n this.setConnectionState(connected);\n },\n reSubmit: (content: any, localOpMetadata: unknown) => {\n this.reSubmit(content, localOpMetadata);\n },\n applyStashedOp: (content: any): unknown => {\n return this.applyStashedOp(content);\n },\n });\n\n // Trigger initial state\n // attachDeltaHandler is only called after services is assigned\n this.setConnectionState(this.services.deltaConnection.connected);\n }\n\n /**\n * Set the state of connection to services.\n * @param connected - true if connected, false otherwise.\n */\n private setConnectionState(connected: boolean) {\n if (this._connected === connected) {\n // Not changing state, nothing the same.\n return;\n }\n\n // Should I change the state at the end? So that we *can't* send new stuff before we send old?\n this._connected = connected;\n\n if (!connected) {\n // Things that are true now...\n // - if we had a connection we can no longer send messages over it\n // - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n //\n // - nack could get a new msn - but might as well do it in the join?\n this.onDisconnect();\n } else {\n // Call this for now so that DDSes like ConsensesOrderedCollection that maintain their own pending\n // messages will work.\n this.onConnect();\n }\n }\n\n /**\n * Handles a message being received from the remote delta server.\n * @param message - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n private process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n this.verifyNotClosed(); // This will result in container closure.\n this.emit(\"pre-op\", message, local, this);\n this.processCore(message, local, localOpMetadata);\n this.emit(\"op\", message, local, this);\n }\n\n /**\n * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n * reconnection.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n private reSubmit(content: any, localOpMetadata: unknown) {\n this.reSubmitCore(content, localOpMetadata);\n }\n\n protected abstract applyStashedOp(content: any): unknown;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"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cAAc,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;SACJ,CAAC,CAAC;QAEH,wBAAwB;QACxB,+DAA+D;QAC/D,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACrE,CAAC;IAED;;;OAGG;IACK,kBAAkB,CAAC,SAAkB;QACzC,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE;YAC/B,wCAAwC;YACxC,OAAO;SACV;QAED,8FAA8F;QAC9F,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,SAAS,EAAE;YACZ,8BAA8B;YAC9B,kEAAkE;YAClE,4FAA4F;YAC5F,EAAE;YACF,oEAAoE;YACpE,IAAI,CAAC,YAAY,EAAE,CAAC;SACvB;aAAM;YACH,kGAAkG;YAClG,sBAAsB;YACtB,IAAI,CAAC,SAAS,EAAE,CAAC;SACpB;IACL,CAAC;IAED;;;;;;OAMG;IACK,OAAO,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QACxF,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,yCAAyC;QACjE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACK,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACnD,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CAGJ;AAzeD,oCAyeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, EventEmitterEventType } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IFluidHandle, IFluidSerializer } from \"@fluidframework/core-interfaces\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, ITree } from \"@fluidframework/protocol-definitions\";\nimport {\n IGarbageCollectionData,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport { convertToSummaryTreeWithStats, FluidSerializer } from \"@fluidframework/runtime-utils\";\nimport { ChildLogger, EventEmitterWithErrorHandling } from \"@fluidframework/telemetry-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { SharedObjectHandle } from \"./handle\";\nimport { SummarySerializer } from \"./summarySerializer\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types\";\n\n/**\n * Base class from which all shared objects derive\n */\nexport abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {\n /**\n * @param obj - The thing to check if it is a SharedObject\n * @returns Returns true if the thing is a SharedObject\n */\n public static is(obj: any): obj is SharedObject {\n return obj?.ISharedObject !== undefined;\n }\n\n public get ISharedObject() { return this; }\n public get IChannel() { return this; }\n public get IFluidLoadable() { return this; }\n\n /**\n * The handle referring to this SharedObject\n */\n public readonly handle: IFluidHandle;\n\n /**\n * Telemetry logger for the shared object\n */\n protected readonly logger: ITelemetryLogger;\n\n /**\n * Connection state\n */\n private _connected = false;\n\n /**\n * Services used by the shared object\n */\n private services: IChannelServices | undefined;\n\n /**\n * True if the dds is bound to its parent.\n */\n private _isBoundToContext: boolean = false;\n\n /**\n * True while we are summarizing this object's data.\n */\n private _isSummarizing: boolean = false;\n\n /**\n * Tracks error that closed this object.\n */\n private closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n /**\n * Gets the connection state\n * @returns The state of the connection\n */\n public get connected(): boolean {\n return this._connected;\n }\n\n protected get serializer(): IFluidSerializer {\n /**\n * During summarize, the SummarySerializer keeps track of IFluidHandles that are serialized. These handles\n * represent references to other Fluid objects and are used for garbage collection.\n *\n * This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content\n * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n */\n assert(!this._isSummarizing,\n 0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */);\n return this._serializer;\n }\n\n /**\n * The serializer to use to serialize / parse handles, if any.\n */\n private readonly _serializer: IFluidSerializer;\n\n /**\n * @param id - The id of the shared object\n * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n * @param attributes - Attributes of the shared object\n */\n constructor(\n public id: string,\n protected runtime: IFluidDataStoreRuntime,\n public readonly attributes: IChannelAttributes)\n {\n super((event: EventEmitterEventType, e: any) => this.eventListenerErrorHandler(event, e));\n\n this.handle = new SharedObjectHandle(\n this,\n id,\n runtime.IFluidHandleContext);\n\n this.logger = ChildLogger.create(\n runtime.logger,\n undefined,\n { all: { sharedObjectId: uuid() } },\n );\n\n this._serializer = new FluidSerializer(\n this.runtime.channelsRoutingContext,\n (handle: IFluidHandle) => this.handleDecoded(handle),\n );\n\n this.attachListeners();\n }\n\n /**\n * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n * would result in same error thrown. If called multiple times, only first error is remembered.\n * @param error - error object that is thrown whenever an attempt is made to modify this object\n */\n private closeWithError(error: any) {\n if (this.closeError === undefined) {\n this.closeError = error;\n }\n }\n\n /**\n * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n */\n private verifyNotClosed() {\n if (this.closeError !== undefined) {\n throw this.closeError;\n }\n }\n\n /**\n * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n * It wraps error with DataProcessingError, closes this object and throws resulting error.\n * See closeWithError() for more details\n * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n * allow processing of ops or local changes, which very quickly results in container closure.\n */\n private eventListenerErrorHandler(event: EventEmitterEventType, e: any) {\n const error = DataProcessingError.wrapIfUnrecognized(\n e,\n \"SharedObjectEventListenerException\");\n error.addTelemetryProperties({ emittedEventName: String(event) });\n\n this.closeWithError(error);\n throw error;\n }\n\n private attachListeners() {\n // Only listen to these events if not attached.\n if (!this.isAttached()) {\n this.runtime.once(\"attaching\", () => {\n // Calling this will let the dds to do any custom processing based on attached\n // like starting generating ops.\n this.didAttach();\n });\n }\n }\n\n /**\n * A shared object, after construction, can either be loaded in the case that it is already part of\n * a shared document. Or later attached if it is being newly added.\n * @param services - Services used by the shared object\n */\n public async load(services: IChannelServices): Promise<void> {\n if (this.runtime.attachState !== AttachState.Detached) {\n this.services = services;\n }\n await this.loadCore(services.objectStorage);\n if (this.runtime.attachState !== AttachState.Detached) {\n this.attachDeltaHandler();\n }\n }\n\n /**\n * Initializes the object as a local, non-shared object. This object can become shared after\n * it is attached to the document.\n */\n public initializeLocal(): void {\n this.initializeLocalCore();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).bindToContext}\n */\n public bindToContext(): void {\n if (this._isBoundToContext) {\n return;\n }\n\n this._isBoundToContext = true;\n\n // Allow derived classes to perform custom processing prior to registering this object\n this.registerCore();\n\n this.runtime.bindChannel(this);\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).connect}\n */\n public connect(services: IChannelServices) {\n this.services = services;\n this.attachDeltaHandler();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).isAttached}\n */\n public isAttached(): boolean {\n return this.services !== undefined && this.runtime.attachState !== AttachState.Detached;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).summarize}\n */\n public summarize(fullTree: boolean = false, trackState: boolean = false): ISummaryTreeWithStats {\n // Set _isSummarizing to true. This flag is used to ensure that we only use SummarySerializer (created below)\n // to serialize handles in this object's data. The routes of these serialized handles are outbound routes\n // to other Fluid objects.\n assert(!this._isSummarizing, 0x076 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isSummarizing = true;\n\n let summaryTree: ISummaryTreeWithStats;\n try {\n const serializer = new SummarySerializer(\n this.runtime.channelsRoutingContext,\n (handle: IFluidHandle) => this.handleDecoded(handle),\n );\n const snapshot: ITree = this.snapshotCore(serializer);\n summaryTree = convertToSummaryTreeWithStats(snapshot, fullTree);\n assert(this._isSummarizing, 0x077 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isSummarizing = false;\n }\n return summaryTree;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).getGCData}\n */\n public getGCData(fullGC: boolean = false): IGarbageCollectionData {\n // Set _isSummarizing to true. This flag is used to ensure that we only use SummarySerializer (created in\n // getGCDataCore) to serialize handles in this object's data.\n assert(!this._isSummarizing, 0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isSummarizing = true;\n\n let gcData: IGarbageCollectionData;\n try {\n gcData = this.getGCDataCore();\n assert(this._isSummarizing, 0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isSummarizing = false;\n }\n\n return gcData;\n }\n\n /**\n * Returns the GC data for this shared object. It contains a list of GC nodes that contains references to\n * other GC nodes.\n * Derived classes must override this to provide custom list of references to other GC nodes.\n */\n protected getGCDataCore(): IGarbageCollectionData {\n // We run the full summarize logic to get the list of outbound routes from this object. This is a little\n // expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n // See: https://github.com/microsoft/FluidFramework/issues/4547\n const serializer = new SummarySerializer(\n this.runtime.channelsRoutingContext,\n (handle: IFluidHandle) => this.handleDecoded(handle),\n );\n this.snapshotCore(serializer);\n\n // The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n // routes of handles serialized during snapshot.\n return {\n gcNodes: { \"/\": serializer.getSerializedRoutes() },\n };\n }\n\n /**\n * Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference\n * to another object in the container.\n * @param decodedHandle - The handle of the Fluid object that is decoded.\n */\n protected handleDecoded(decodedHandle: IFluidHandle) {\n if (this.isAttached()) {\n // This represents an outbound reference from this object to the node represented by decodedHandle.\n this.services?.deltaConnection.addedGCOutboundReference?.(this.handle, decodedHandle);\n }\n }\n\n /**\n * Gets a form of the object that can be serialized.\n * @returns A tree representing the snapshot of the shared object.\n */\n protected abstract snapshotCore(serializer: IFluidSerializer): ITree;\n\n /**\n * Allows the distributed data type to perform custom loading\n * @param services - Storage used by the shared object\n */\n protected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n /**\n * Allows the distributed data type to perform custom local loading.\n */\n protected initializeLocalCore() {\n return;\n }\n\n /**\n * Allows the distributed data type the ability to perform custom processing once an attach has happened.\n */\n protected abstract registerCore();\n\n /**\n * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n * Also called after non-local data type get loaded.\n */\n protected didAttach() {\n return;\n }\n\n /**\n * Derived classes must override this to do custom processing on a remote message.\n * @param message - The message to process\n * @param local - True if the shared object is local\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n protected abstract processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown);\n\n /**\n * Called when the object has disconnected from the delta stream.\n */\n protected abstract onDisconnect();\n\n /**\n * Submits a message by the local client to the runtime.\n * @param content - Content of the message\n * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n */\n protected submitLocalMessage(content: any, localOpMetadata: unknown = undefined): void {\n this.verifyNotClosed();\n if (this.isAttached()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.submit(content, localOpMetadata);\n }\n }\n\n /**\n * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n * that want to be part of summary but does not generate ops.\n */\n protected dirty(): void {\n if (!this.isAttached()) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.dirty();\n }\n\n /**\n * Called when the object has fully connected to the delta stream\n * Default implementation for DDS, override if different behavior is required.\n */\n protected onConnect() { }\n\n /**\n * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n * The default implementation here is to resubmit the same message. The client can override if different behavior\n * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n * anything at all.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n this.submitLocalMessage(content, localOpMetadata);\n }\n\n /**\n * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n * the Promise will reject.\n * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n */\n protected async newAckBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n // Note: rejectBecauseDispose will never be undefined here\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n\n private attachDeltaHandler() {\n // Services should already be there in case we are attaching delta handler.\n assert(this.services !== undefined, 0x07a /* \"Services should be there to attach delta handler\" */);\n this._isBoundToContext = true;\n // Allows objects to do any custom processing if it is attached.\n this.didAttach();\n\n // attachDeltaHandler is only called after services is assigned\n this.services.deltaConnection.attach({\n process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => {\n this.process(message, local, localOpMetadata);\n },\n setConnectionState: (connected: boolean) => {\n this.setConnectionState(connected);\n },\n reSubmit: (content: any, localOpMetadata: unknown) => {\n this.reSubmit(content, localOpMetadata);\n },\n applyStashedOp: (content: any): unknown => {\n return this.applyStashedOp(content);\n },\n });\n\n // Trigger initial state\n // attachDeltaHandler is only called after services is assigned\n this.setConnectionState(this.services.deltaConnection.connected);\n }\n\n /**\n * Set the state of connection to services.\n * @param connected - true if connected, false otherwise.\n */\n private setConnectionState(connected: boolean) {\n if (this._connected === connected) {\n // Not changing state, nothing the same.\n return;\n }\n\n // Should I change the state at the end? So that we *can't* send new stuff before we send old?\n this._connected = connected;\n\n if (!connected) {\n // Things that are true now...\n // - if we had a connection we can no longer send messages over it\n // - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n //\n // - nack could get a new msn - but might as well do it in the join?\n this.onDisconnect();\n } else {\n // Call this for now so that DDSes like ConsensesOrderedCollection that maintain their own pending\n // messages will work.\n this.onConnect();\n }\n }\n\n /**\n * Handles a message being received from the remote delta server.\n * @param message - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n private process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n this.verifyNotClosed(); // This will result in container closure.\n this.emit(\"pre-op\", message, local, this);\n this.processCore(message, local, localOpMetadata);\n this.emit(\"op\", message, local, this);\n }\n\n /**\n * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n * reconnection.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n private reSubmit(content: any, localOpMetadata: unknown) {\n this.reSubmitCore(content, localOpMetadata);\n }\n\n protected abstract applyStashedOp(content: any): unknown;\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/shared-object-base";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "0.54.2";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/shared-object-base\";\nexport const pkgVersion = \"0.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/shared-object-base\";\nexport const pkgVersion = \"0.54.2\";\n"]}
|
package/lib/sharedObject.d.ts
CHANGED
|
@@ -127,6 +127,12 @@ export declare abstract class SharedObject<TEvent extends ISharedObjectEvents =
|
|
|
127
127
|
* Derived classes must override this to provide custom list of references to other GC nodes.
|
|
128
128
|
*/
|
|
129
129
|
protected getGCDataCore(): IGarbageCollectionData;
|
|
130
|
+
/**
|
|
131
|
+
* Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
|
|
132
|
+
* to another object in the container.
|
|
133
|
+
* @param decodedHandle - The handle of the Fluid object that is decoded.
|
|
134
|
+
*/
|
|
135
|
+
protected handleDecoded(decodedHandle: IFluidHandle): void;
|
|
130
136
|
/**
|
|
131
137
|
* Gets a form of the object that can be serialized.
|
|
132
138
|
* @returns A tree representing the snapshot of the shared object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EACnB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACxB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAe,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAI7F,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE7D;;GAEG;AACH,8BAAsB,YAAY,CAAC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB,CACvF,SAAQ,6BAA6B,CAAC,MAAM,CAAE,YAAW,aAAa,CAAC,MAAM,CAAC;IAgFnE,EAAE,EAAE,MAAM;IACjB,SAAS,CAAC,OAAO,EAAE,sBAAsB;aACzB,UAAU,EAAE,kBAAkB;IAjFlD;;;OAGG;WACW,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,YAAY;IAI/C,IAAW,aAAa,SAAmB;IAC3C,IAAW,QAAQ,SAAmB;IACtC,IAAW,cAAc,SAAmB;IAE5C;;OAEG;IACH,SAAgB,MAAM,EAAE,YAAY,CAAC;IAErC;;OAEG;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AI,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,GACjG,OAAO,CAAC,CAAC,CAAC;IAmBb,OAAO,CAAC,kBAAkB;IA4B1B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAuB1B;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAOf;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAIhB,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;CAC3D"}
|
package/lib/sharedObject.js
CHANGED
|
@@ -38,7 +38,7 @@ export class SharedObject extends EventEmitterWithErrorHandling {
|
|
|
38
38
|
this._isSummarizing = false;
|
|
39
39
|
this.handle = new SharedObjectHandle(this, id, runtime.IFluidHandleContext);
|
|
40
40
|
this.logger = ChildLogger.create(runtime.logger, undefined, { all: { sharedObjectId: uuid() } });
|
|
41
|
-
this._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);
|
|
41
|
+
this._serializer = new FluidSerializer(this.runtime.channelsRoutingContext, (handle) => this.handleDecoded(handle));
|
|
42
42
|
this.attachListeners();
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -170,7 +170,7 @@ export class SharedObject extends EventEmitterWithErrorHandling {
|
|
|
170
170
|
this._isSummarizing = true;
|
|
171
171
|
let summaryTree;
|
|
172
172
|
try {
|
|
173
|
-
const serializer = new SummarySerializer(this.runtime.channelsRoutingContext);
|
|
173
|
+
const serializer = new SummarySerializer(this.runtime.channelsRoutingContext, (handle) => this.handleDecoded(handle));
|
|
174
174
|
const snapshot = this.snapshotCore(serializer);
|
|
175
175
|
summaryTree = convertToSummaryTreeWithStats(snapshot, fullTree);
|
|
176
176
|
assert(this._isSummarizing, 0x077 /* "Possible re-entrancy! Summary should have been in progress." */);
|
|
@@ -207,7 +207,7 @@ export class SharedObject extends EventEmitterWithErrorHandling {
|
|
|
207
207
|
// We run the full summarize logic to get the list of outbound routes from this object. This is a little
|
|
208
208
|
// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.
|
|
209
209
|
// See: https://github.com/microsoft/FluidFramework/issues/4547
|
|
210
|
-
const serializer = new SummarySerializer(this.runtime.channelsRoutingContext);
|
|
210
|
+
const serializer = new SummarySerializer(this.runtime.channelsRoutingContext, (handle) => this.handleDecoded(handle));
|
|
211
211
|
this.snapshotCore(serializer);
|
|
212
212
|
// The GC data for this shared object contains a single GC node. The outbound routes of this node are the
|
|
213
213
|
// routes of handles serialized during snapshot.
|
|
@@ -215,6 +215,18 @@ export class SharedObject extends EventEmitterWithErrorHandling {
|
|
|
215
215
|
gcNodes: { "/": serializer.getSerializedRoutes() },
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
|
|
220
|
+
* to another object in the container.
|
|
221
|
+
* @param decodedHandle - The handle of the Fluid object that is decoded.
|
|
222
|
+
*/
|
|
223
|
+
handleDecoded(decodedHandle) {
|
|
224
|
+
var _a, _b, _c;
|
|
225
|
+
if (this.isAttached()) {
|
|
226
|
+
// This represents an outbound reference from this object to the node represented by decodedHandle.
|
|
227
|
+
(_c = (_a = this.services) === null || _a === void 0 ? void 0 : (_b = _a.deltaConnection).addedGCOutboundReference) === null || _c === void 0 ? void 0 : _c.call(_b, this.handle, decodedHandle);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
218
230
|
/**
|
|
219
231
|
* Allows the distributed data type to perform custom local loading.
|
|
220
232
|
*/
|
package/lib/sharedObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAyB,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,WAAW,EAA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;YAC/B,wCAAwC;YACxC,OAAO;SACV;QAED,8FAA8F;QAC9F,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,SAAS,EAAE;YACZ,8BAA8B;YAC9B,kEAAkE;YAClE,4FAA4F;YAC5F,EAAE;YACF,oEAAoE;YACpE,IAAI,CAAC,YAAY,EAAE,CAAC;SACvB;aAAM;YACH,kGAAkG;YAClG,sBAAsB;YACtB,IAAI,CAAC,SAAS,EAAE,CAAC;SACpB;IACL,CAAC;IAED;;;;;;OAMG;IACK,OAAO,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QACxF,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,yCAAyC;QACjE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACK,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACnD,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CAGJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, EventEmitterEventType } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IFluidHandle, IFluidSerializer } from \"@fluidframework/core-interfaces\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, ITree } from \"@fluidframework/protocol-definitions\";\nimport {\n IGarbageCollectionData,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport { convertToSummaryTreeWithStats, FluidSerializer } from \"@fluidframework/runtime-utils\";\nimport { ChildLogger, EventEmitterWithErrorHandling } from \"@fluidframework/telemetry-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { SharedObjectHandle } from \"./handle\";\nimport { SummarySerializer } from \"./summarySerializer\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types\";\n\n/**\n * Base class from which all shared objects derive\n */\nexport abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {\n /**\n * @param obj - The thing to check if it is a SharedObject\n * @returns Returns true if the thing is a SharedObject\n */\n public static is(obj: any): obj is SharedObject {\n return obj?.ISharedObject !== undefined;\n }\n\n public get ISharedObject() { return this; }\n public get IChannel() { return this; }\n public get IFluidLoadable() { return this; }\n\n /**\n * The handle referring to this SharedObject\n */\n public readonly handle: IFluidHandle;\n\n /**\n * Telemetry logger for the shared object\n */\n protected readonly logger: ITelemetryLogger;\n\n /**\n * Connection state\n */\n private _connected = false;\n\n /**\n * Services used by the shared object\n */\n private services: IChannelServices | undefined;\n\n /**\n * True if the dds is bound to its parent.\n */\n private _isBoundToContext: boolean = false;\n\n /**\n * True while we are summarizing this object's data.\n */\n private _isSummarizing: boolean = false;\n\n /**\n * Tracks error that closed this object.\n */\n private closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n /**\n * Gets the connection state\n * @returns The state of the connection\n */\n public get connected(): boolean {\n return this._connected;\n }\n\n protected get serializer(): IFluidSerializer {\n /**\n * During summarize, the SummarySerializer keeps track of IFluidHandles that are serialized. These handles\n * represent references to other Fluid objects and are used for garbage collection.\n *\n * This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content\n * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n */\n assert(!this._isSummarizing,\n 0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */);\n return this._serializer;\n }\n\n /**\n * The serializer to use to serialize / parse handles, if any.\n */\n private readonly _serializer: IFluidSerializer;\n\n /**\n * @param id - The id of the shared object\n * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n * @param attributes - Attributes of the shared object\n */\n constructor(\n public id: string,\n protected runtime: IFluidDataStoreRuntime,\n public readonly attributes: IChannelAttributes)\n {\n super((event: EventEmitterEventType, e: any) => this.eventListenerErrorHandler(event, e));\n\n this.handle = new SharedObjectHandle(\n this,\n id,\n runtime.IFluidHandleContext);\n\n this.logger = ChildLogger.create(\n runtime.logger,\n undefined,\n { all: { sharedObjectId: uuid() } },\n );\n\n this._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);\n\n this.attachListeners();\n }\n\n /**\n * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n * would result in same error thrown. If called multiple times, only first error is remembered.\n * @param error - error object that is thrown whenever an attempt is made to modify this object\n */\n private closeWithError(error: any) {\n if (this.closeError === undefined) {\n this.closeError = error;\n }\n }\n\n /**\n * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n */\n private verifyNotClosed() {\n if (this.closeError !== undefined) {\n throw this.closeError;\n }\n }\n\n /**\n * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n * It wraps error with DataProcessingError, closes this object and throws resulting error.\n * See closeWithError() for more details\n * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n * allow processing of ops or local changes, which very quickly results in container closure.\n */\n private eventListenerErrorHandler(event: EventEmitterEventType, e: any) {\n const error = DataProcessingError.wrapIfUnrecognized(\n e,\n \"SharedObjectEventListenerException\");\n error.addTelemetryProperties({ emittedEventName: String(event) });\n\n this.closeWithError(error);\n throw error;\n }\n\n private attachListeners() {\n // Only listen to these events if not attached.\n if (!this.isAttached()) {\n this.runtime.once(\"attaching\", () => {\n // Calling this will let the dds to do any custom processing based on attached\n // like starting generating ops.\n this.didAttach();\n });\n }\n }\n\n /**\n * A shared object, after construction, can either be loaded in the case that it is already part of\n * a shared document. Or later attached if it is being newly added.\n * @param services - Services used by the shared object\n */\n public async load(services: IChannelServices): Promise<void> {\n if (this.runtime.attachState !== AttachState.Detached) {\n this.services = services;\n }\n await this.loadCore(services.objectStorage);\n if (this.runtime.attachState !== AttachState.Detached) {\n this.attachDeltaHandler();\n }\n }\n\n /**\n * Initializes the object as a local, non-shared object. This object can become shared after\n * it is attached to the document.\n */\n public initializeLocal(): void {\n this.initializeLocalCore();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).bindToContext}\n */\n public bindToContext(): void {\n if (this._isBoundToContext) {\n return;\n }\n\n this._isBoundToContext = true;\n\n // Allow derived classes to perform custom processing prior to registering this object\n this.registerCore();\n\n this.runtime.bindChannel(this);\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).connect}\n */\n public connect(services: IChannelServices) {\n this.services = services;\n this.attachDeltaHandler();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).isAttached}\n */\n public isAttached(): boolean {\n return this.services !== undefined && this.runtime.attachState !== AttachState.Detached;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).summarize}\n */\n public summarize(fullTree: boolean = false, trackState: boolean = false): ISummaryTreeWithStats {\n // Set _isSummarizing to true. This flag is used to ensure that we only use SummarySerializer (created below)\n // to serialize handles in this object's data. The routes of these serialized handles are outbound routes\n // to other Fluid objects.\n assert(!this._isSummarizing, 0x076 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isSummarizing = true;\n\n let summaryTree: ISummaryTreeWithStats;\n try {\n const serializer = new SummarySerializer(this.runtime.channelsRoutingContext);\n const snapshot: ITree = this.snapshotCore(serializer);\n summaryTree = convertToSummaryTreeWithStats(snapshot, fullTree);\n assert(this._isSummarizing, 0x077 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isSummarizing = false;\n }\n return summaryTree;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).getGCData}\n */\n public getGCData(fullGC: boolean = false): IGarbageCollectionData {\n // Set _isSummarizing to true. This flag is used to ensure that we only use SummarySerializer (created in\n // getGCDataCore) to serialize handles in this object's data.\n assert(!this._isSummarizing, 0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isSummarizing = true;\n\n let gcData: IGarbageCollectionData;\n try {\n gcData = this.getGCDataCore();\n assert(this._isSummarizing, 0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isSummarizing = false;\n }\n\n return gcData;\n }\n\n /**\n * Returns the GC data for this shared object. It contains a list of GC nodes that contains references to\n * other GC nodes.\n * Derived classes must override this to provide custom list of references to other GC nodes.\n */\n protected getGCDataCore(): IGarbageCollectionData {\n // We run the full summarize logic to get the list of outbound routes from this object. This is a little\n // expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n // See: https://github.com/microsoft/FluidFramework/issues/4547\n const serializer = new SummarySerializer(this.runtime.channelsRoutingContext);\n this.snapshotCore(serializer);\n\n // The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n // routes of handles serialized during snapshot.\n return {\n gcNodes: { \"/\": serializer.getSerializedRoutes() },\n };\n }\n\n /**\n * Gets a form of the object that can be serialized.\n * @returns A tree representing the snapshot of the shared object.\n */\n protected abstract snapshotCore(serializer: IFluidSerializer): ITree;\n\n /**\n * Allows the distributed data type to perform custom loading\n * @param services - Storage used by the shared object\n */\n protected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n /**\n * Allows the distributed data type to perform custom local loading.\n */\n protected initializeLocalCore() {\n return;\n }\n\n /**\n * Allows the distributed data type the ability to perform custom processing once an attach has happened.\n */\n protected abstract registerCore();\n\n /**\n * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n * Also called after non-local data type get loaded.\n */\n protected didAttach() {\n return;\n }\n\n /**\n * Derived classes must override this to do custom processing on a remote message.\n * @param message - The message to process\n * @param local - True if the shared object is local\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n protected abstract processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown);\n\n /**\n * Called when the object has disconnected from the delta stream.\n */\n protected abstract onDisconnect();\n\n /**\n * Submits a message by the local client to the runtime.\n * @param content - Content of the message\n * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n */\n protected submitLocalMessage(content: any, localOpMetadata: unknown = undefined): void {\n this.verifyNotClosed();\n if (this.isAttached()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.submit(content, localOpMetadata);\n }\n }\n\n /**\n * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n * that want to be part of summary but does not generate ops.\n */\n protected dirty(): void {\n if (!this.isAttached()) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.dirty();\n }\n\n /**\n * Called when the object has fully connected to the delta stream\n * Default implementation for DDS, override if different behavior is required.\n */\n protected onConnect() { }\n\n /**\n * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n * The default implementation here is to resubmit the same message. The client can override if different behavior\n * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n * anything at all.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n this.submitLocalMessage(content, localOpMetadata);\n }\n\n /**\n * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n * the Promise will reject.\n * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n */\n protected async newAckBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n // Note: rejectBecauseDispose will never be undefined here\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n\n private attachDeltaHandler() {\n // Services should already be there in case we are attaching delta handler.\n assert(this.services !== undefined, 0x07a /* \"Services should be there to attach delta handler\" */);\n this._isBoundToContext = true;\n // Allows objects to do any custom processing if it is attached.\n this.didAttach();\n\n // attachDeltaHandler is only called after services is assigned\n this.services.deltaConnection.attach({\n process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => {\n this.process(message, local, localOpMetadata);\n },\n setConnectionState: (connected: boolean) => {\n this.setConnectionState(connected);\n },\n reSubmit: (content: any, localOpMetadata: unknown) => {\n this.reSubmit(content, localOpMetadata);\n },\n applyStashedOp: (content: any): unknown => {\n return this.applyStashedOp(content);\n },\n });\n\n // Trigger initial state\n // attachDeltaHandler is only called after services is assigned\n this.setConnectionState(this.services.deltaConnection.connected);\n }\n\n /**\n * Set the state of connection to services.\n * @param connected - true if connected, false otherwise.\n */\n private setConnectionState(connected: boolean) {\n if (this._connected === connected) {\n // Not changing state, nothing the same.\n return;\n }\n\n // Should I change the state at the end? So that we *can't* send new stuff before we send old?\n this._connected = connected;\n\n if (!connected) {\n // Things that are true now...\n // - if we had a connection we can no longer send messages over it\n // - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n //\n // - nack could get a new msn - but might as well do it in the join?\n this.onDisconnect();\n } else {\n // Call this for now so that DDSes like ConsensesOrderedCollection that maintain their own pending\n // messages will work.\n this.onConnect();\n }\n }\n\n /**\n * Handles a message being received from the remote delta server.\n * @param message - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n private process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n this.verifyNotClosed(); // This will result in container closure.\n this.emit(\"pre-op\", message, local, this);\n this.processCore(message, local, localOpMetadata);\n this.emit(\"op\", message, local, this);\n }\n\n /**\n * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n * reconnection.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n private reSubmit(content: any, localOpMetadata: unknown) {\n this.reSubmitCore(content, localOpMetadata);\n }\n\n protected abstract applyStashedOp(content: any): unknown;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAyB,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAapE,OAAO,EAAE,6BAA6B,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;GAEG;AACH,MAAM,OAAgB,YAClB,SAAQ,6BAAqC;IA0E7C;;;;OAIG;IACH,YACW,EAAU,EACP,OAA+B,EACzB,UAA8B;QAE9C,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAM,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,C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EAAE;YACZ,8BAA8B;YAC9B,kEAAkE;YAClE,4FAA4F;YAC5F,EAAE;YACF,oEAAoE;YACpE,IAAI,CAAC,YAAY,EAAE,CAAC;SACvB;aAAM;YACH,kGAAkG;YAClG,sBAAsB;YACtB,IAAI,CAAC,SAAS,EAAE,CAAC;SACpB;IACL,CAAC;IAED;;;;;;OAMG;IACK,OAAO,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QACxF,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,yCAAyC;QACjE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACK,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACnD,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CAGJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, EventEmitterEventType } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IFluidHandle, IFluidSerializer } from \"@fluidframework/core-interfaces\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, ITree } from \"@fluidframework/protocol-definitions\";\nimport {\n IGarbageCollectionData,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport { convertToSummaryTreeWithStats, FluidSerializer } from \"@fluidframework/runtime-utils\";\nimport { ChildLogger, EventEmitterWithErrorHandling } from \"@fluidframework/telemetry-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { SharedObjectHandle } from \"./handle\";\nimport { SummarySerializer } from \"./summarySerializer\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types\";\n\n/**\n * Base class from which all shared objects derive\n */\nexport abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {\n /**\n * @param obj - The thing to check if it is a SharedObject\n * @returns Returns true if the thing is a SharedObject\n */\n public static is(obj: any): obj is SharedObject {\n return obj?.ISharedObject !== undefined;\n }\n\n public get ISharedObject() { return this; }\n public get IChannel() { return this; }\n public get IFluidLoadable() { return this; }\n\n /**\n * The handle referring to this SharedObject\n */\n public readonly handle: IFluidHandle;\n\n /**\n * Telemetry logger for the shared object\n */\n protected readonly logger: ITelemetryLogger;\n\n /**\n * Connection state\n */\n private _connected = false;\n\n /**\n * Services used by the shared object\n */\n private services: IChannelServices | undefined;\n\n /**\n * True if the dds is bound to its parent.\n */\n private _isBoundToContext: boolean = false;\n\n /**\n * True while we are summarizing this object's data.\n */\n private _isSummarizing: boolean = false;\n\n /**\n * Tracks error that closed this object.\n */\n private closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n /**\n * Gets the connection state\n * @returns The state of the connection\n */\n public get connected(): boolean {\n return this._connected;\n }\n\n protected get serializer(): IFluidSerializer {\n /**\n * During summarize, the SummarySerializer keeps track of IFluidHandles that are serialized. These handles\n * represent references to other Fluid objects and are used for garbage collection.\n *\n * This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content\n * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n */\n assert(!this._isSummarizing,\n 0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */);\n return this._serializer;\n }\n\n /**\n * The serializer to use to serialize / parse handles, if any.\n */\n private readonly _serializer: IFluidSerializer;\n\n /**\n * @param id - The id of the shared object\n * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n * @param attributes - Attributes of the shared object\n */\n constructor(\n public id: string,\n protected runtime: IFluidDataStoreRuntime,\n public readonly attributes: IChannelAttributes)\n {\n super((event: EventEmitterEventType, e: any) => this.eventListenerErrorHandler(event, e));\n\n this.handle = new SharedObjectHandle(\n this,\n id,\n runtime.IFluidHandleContext);\n\n this.logger = ChildLogger.create(\n runtime.logger,\n undefined,\n { all: { sharedObjectId: uuid() } },\n );\n\n this._serializer = new FluidSerializer(\n this.runtime.channelsRoutingContext,\n (handle: IFluidHandle) => this.handleDecoded(handle),\n );\n\n this.attachListeners();\n }\n\n /**\n * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n * would result in same error thrown. If called multiple times, only first error is remembered.\n * @param error - error object that is thrown whenever an attempt is made to modify this object\n */\n private closeWithError(error: any) {\n if (this.closeError === undefined) {\n this.closeError = error;\n }\n }\n\n /**\n * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n */\n private verifyNotClosed() {\n if (this.closeError !== undefined) {\n throw this.closeError;\n }\n }\n\n /**\n * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n * It wraps error with DataProcessingError, closes this object and throws resulting error.\n * See closeWithError() for more details\n * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n * allow processing of ops or local changes, which very quickly results in container closure.\n */\n private eventListenerErrorHandler(event: EventEmitterEventType, e: any) {\n const error = DataProcessingError.wrapIfUnrecognized(\n e,\n \"SharedObjectEventListenerException\");\n error.addTelemetryProperties({ emittedEventName: String(event) });\n\n this.closeWithError(error);\n throw error;\n }\n\n private attachListeners() {\n // Only listen to these events if not attached.\n if (!this.isAttached()) {\n this.runtime.once(\"attaching\", () => {\n // Calling this will let the dds to do any custom processing based on attached\n // like starting generating ops.\n this.didAttach();\n });\n }\n }\n\n /**\n * A shared object, after construction, can either be loaded in the case that it is already part of\n * a shared document. Or later attached if it is being newly added.\n * @param services - Services used by the shared object\n */\n public async load(services: IChannelServices): Promise<void> {\n if (this.runtime.attachState !== AttachState.Detached) {\n this.services = services;\n }\n await this.loadCore(services.objectStorage);\n if (this.runtime.attachState !== AttachState.Detached) {\n this.attachDeltaHandler();\n }\n }\n\n /**\n * Initializes the object as a local, non-shared object. This object can become shared after\n * it is attached to the document.\n */\n public initializeLocal(): void {\n this.initializeLocalCore();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).bindToContext}\n */\n public bindToContext(): void {\n if (this._isBoundToContext) {\n return;\n }\n\n this._isBoundToContext = true;\n\n // Allow derived classes to perform custom processing prior to registering this object\n this.registerCore();\n\n this.runtime.bindChannel(this);\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).connect}\n */\n public connect(services: IChannelServices) {\n this.services = services;\n this.attachDeltaHandler();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).isAttached}\n */\n public isAttached(): boolean {\n return this.services !== undefined && this.runtime.attachState !== AttachState.Detached;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).summarize}\n */\n public summarize(fullTree: boolean = false, trackState: boolean = false): ISummaryTreeWithStats {\n // Set _isSummarizing to true. This flag is used to ensure that we only use SummarySerializer (created below)\n // to serialize handles in this object's data. The routes of these serialized handles are outbound routes\n // to other Fluid objects.\n assert(!this._isSummarizing, 0x076 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isSummarizing = true;\n\n let summaryTree: ISummaryTreeWithStats;\n try {\n const serializer = new SummarySerializer(\n this.runtime.channelsRoutingContext,\n (handle: IFluidHandle) => this.handleDecoded(handle),\n );\n const snapshot: ITree = this.snapshotCore(serializer);\n summaryTree = convertToSummaryTreeWithStats(snapshot, fullTree);\n assert(this._isSummarizing, 0x077 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isSummarizing = false;\n }\n return summaryTree;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).getGCData}\n */\n public getGCData(fullGC: boolean = false): IGarbageCollectionData {\n // Set _isSummarizing to true. This flag is used to ensure that we only use SummarySerializer (created in\n // getGCDataCore) to serialize handles in this object's data.\n assert(!this._isSummarizing, 0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isSummarizing = true;\n\n let gcData: IGarbageCollectionData;\n try {\n gcData = this.getGCDataCore();\n assert(this._isSummarizing, 0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isSummarizing = false;\n }\n\n return gcData;\n }\n\n /**\n * Returns the GC data for this shared object. It contains a list of GC nodes that contains references to\n * other GC nodes.\n * Derived classes must override this to provide custom list of references to other GC nodes.\n */\n protected getGCDataCore(): IGarbageCollectionData {\n // We run the full summarize logic to get the list of outbound routes from this object. This is a little\n // expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n // See: https://github.com/microsoft/FluidFramework/issues/4547\n const serializer = new SummarySerializer(\n this.runtime.channelsRoutingContext,\n (handle: IFluidHandle) => this.handleDecoded(handle),\n );\n this.snapshotCore(serializer);\n\n // The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n // routes of handles serialized during snapshot.\n return {\n gcNodes: { \"/\": serializer.getSerializedRoutes() },\n };\n }\n\n /**\n * Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference\n * to another object in the container.\n * @param decodedHandle - The handle of the Fluid object that is decoded.\n */\n protected handleDecoded(decodedHandle: IFluidHandle) {\n if (this.isAttached()) {\n // This represents an outbound reference from this object to the node represented by decodedHandle.\n this.services?.deltaConnection.addedGCOutboundReference?.(this.handle, decodedHandle);\n }\n }\n\n /**\n * Gets a form of the object that can be serialized.\n * @returns A tree representing the snapshot of the shared object.\n */\n protected abstract snapshotCore(serializer: IFluidSerializer): ITree;\n\n /**\n * Allows the distributed data type to perform custom loading\n * @param services - Storage used by the shared object\n */\n protected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n /**\n * Allows the distributed data type to perform custom local loading.\n */\n protected initializeLocalCore() {\n return;\n }\n\n /**\n * Allows the distributed data type the ability to perform custom processing once an attach has happened.\n */\n protected abstract registerCore();\n\n /**\n * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n * Also called after non-local data type get loaded.\n */\n protected didAttach() {\n return;\n }\n\n /**\n * Derived classes must override this to do custom processing on a remote message.\n * @param message - The message to process\n * @param local - True if the shared object is local\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n protected abstract processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown);\n\n /**\n * Called when the object has disconnected from the delta stream.\n */\n protected abstract onDisconnect();\n\n /**\n * Submits a message by the local client to the runtime.\n * @param content - Content of the message\n * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n */\n protected submitLocalMessage(content: any, localOpMetadata: unknown = undefined): void {\n this.verifyNotClosed();\n if (this.isAttached()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.submit(content, localOpMetadata);\n }\n }\n\n /**\n * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n * that want to be part of summary but does not generate ops.\n */\n protected dirty(): void {\n if (!this.isAttached()) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.dirty();\n }\n\n /**\n * Called when the object has fully connected to the delta stream\n * Default implementation for DDS, override if different behavior is required.\n */\n protected onConnect() { }\n\n /**\n * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n * The default implementation here is to resubmit the same message. The client can override if different behavior\n * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n * anything at all.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n this.submitLocalMessage(content, localOpMetadata);\n }\n\n /**\n * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n * the Promise will reject.\n * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n */\n protected async newAckBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n // Note: rejectBecauseDispose will never be undefined here\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n\n private attachDeltaHandler() {\n // Services should already be there in case we are attaching delta handler.\n assert(this.services !== undefined, 0x07a /* \"Services should be there to attach delta handler\" */);\n this._isBoundToContext = true;\n // Allows objects to do any custom processing if it is attached.\n this.didAttach();\n\n // attachDeltaHandler is only called after services is assigned\n this.services.deltaConnection.attach({\n process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => {\n this.process(message, local, localOpMetadata);\n },\n setConnectionState: (connected: boolean) => {\n this.setConnectionState(connected);\n },\n reSubmit: (content: any, localOpMetadata: unknown) => {\n this.reSubmit(content, localOpMetadata);\n },\n applyStashedOp: (content: any): unknown => {\n return this.applyStashedOp(content);\n },\n });\n\n // Trigger initial state\n // attachDeltaHandler is only called after services is assigned\n this.setConnectionState(this.services.deltaConnection.connected);\n }\n\n /**\n * Set the state of connection to services.\n * @param connected - true if connected, false otherwise.\n */\n private setConnectionState(connected: boolean) {\n if (this._connected === connected) {\n // Not changing state, nothing the same.\n return;\n }\n\n // Should I change the state at the end? So that we *can't* send new stuff before we send old?\n this._connected = connected;\n\n if (!connected) {\n // Things that are true now...\n // - if we had a connection we can no longer send messages over it\n // - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n //\n // - nack could get a new msn - but might as well do it in the join?\n this.onDisconnect();\n } else {\n // Call this for now so that DDSes like ConsensesOrderedCollection that maintain their own pending\n // messages will work.\n this.onConnect();\n }\n }\n\n /**\n * Handles a message being received from the remote delta server.\n * @param message - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n private process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n this.verifyNotClosed(); // This will result in container closure.\n this.emit(\"pre-op\", message, local, this);\n this.processCore(message, local, localOpMetadata);\n this.emit(\"op\", message, local, this);\n }\n\n /**\n * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n * reconnection.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n private reSubmit(content: any, localOpMetadata: unknown) {\n this.reSubmitCore(content, localOpMetadata);\n }\n\n protected abstract applyStashedOp(content: any): unknown;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/shared-object-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.2",
|
|
4
4
|
"description": "Fluid base class for shared distributed data structures",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": "https://github.com/microsoft/FluidFramework",
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
33
33
|
"@fluidframework/common-utils": "^0.32.1",
|
|
34
|
-
"@fluidframework/container-definitions": "^0.
|
|
35
|
-
"@fluidframework/container-utils": "^0.
|
|
34
|
+
"@fluidframework/container-definitions": "^0.44.0",
|
|
35
|
+
"@fluidframework/container-utils": "^0.54.2",
|
|
36
36
|
"@fluidframework/core-interfaces": "^0.41.0",
|
|
37
|
-
"@fluidframework/datastore": "^0.
|
|
38
|
-
"@fluidframework/datastore-definitions": "^0.
|
|
37
|
+
"@fluidframework/datastore": "^0.54.2",
|
|
38
|
+
"@fluidframework/datastore-definitions": "^0.54.2",
|
|
39
39
|
"@fluidframework/protocol-definitions": "^0.1026.0",
|
|
40
|
-
"@fluidframework/runtime-definitions": "^0.
|
|
41
|
-
"@fluidframework/runtime-utils": "^0.
|
|
42
|
-
"@fluidframework/telemetry-utils": "^0.
|
|
40
|
+
"@fluidframework/runtime-definitions": "^0.54.2",
|
|
41
|
+
"@fluidframework/runtime-utils": "^0.54.2",
|
|
42
|
+
"@fluidframework/telemetry-utils": "^0.54.2",
|
|
43
43
|
"uuid": "^8.3.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@fluidframework/build-common": "^0.23.0",
|
|
47
47
|
"@fluidframework/eslint-config-fluid": "^0.24.0",
|
|
48
48
|
"@microsoft/api-extractor": "^7.16.1",
|
|
49
|
-
"@types/node": "^
|
|
49
|
+
"@types/node": "^14.18.0",
|
|
50
50
|
"@typescript-eslint/eslint-plugin": "~4.14.0",
|
|
51
51
|
"@typescript-eslint/parser": "~4.14.0",
|
|
52
52
|
"concurrently": "^6.2.0",
|
package/src/packageVersion.ts
CHANGED
package/src/sharedObject.ts
CHANGED
|
@@ -127,7 +127,10 @@ export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedO
|
|
|
127
127
|
{ all: { sharedObjectId: uuid() } },
|
|
128
128
|
);
|
|
129
129
|
|
|
130
|
-
this._serializer = new FluidSerializer(
|
|
130
|
+
this._serializer = new FluidSerializer(
|
|
131
|
+
this.runtime.channelsRoutingContext,
|
|
132
|
+
(handle: IFluidHandle) => this.handleDecoded(handle),
|
|
133
|
+
);
|
|
131
134
|
|
|
132
135
|
this.attachListeners();
|
|
133
136
|
}
|
|
@@ -249,7 +252,10 @@ export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedO
|
|
|
249
252
|
|
|
250
253
|
let summaryTree: ISummaryTreeWithStats;
|
|
251
254
|
try {
|
|
252
|
-
const serializer = new SummarySerializer(
|
|
255
|
+
const serializer = new SummarySerializer(
|
|
256
|
+
this.runtime.channelsRoutingContext,
|
|
257
|
+
(handle: IFluidHandle) => this.handleDecoded(handle),
|
|
258
|
+
);
|
|
253
259
|
const snapshot: ITree = this.snapshotCore(serializer);
|
|
254
260
|
summaryTree = convertToSummaryTreeWithStats(snapshot, fullTree);
|
|
255
261
|
assert(this._isSummarizing, 0x077 /* "Possible re-entrancy! Summary should have been in progress." */);
|
|
@@ -288,7 +294,10 @@ export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedO
|
|
|
288
294
|
// We run the full summarize logic to get the list of outbound routes from this object. This is a little
|
|
289
295
|
// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.
|
|
290
296
|
// See: https://github.com/microsoft/FluidFramework/issues/4547
|
|
291
|
-
const serializer = new SummarySerializer(
|
|
297
|
+
const serializer = new SummarySerializer(
|
|
298
|
+
this.runtime.channelsRoutingContext,
|
|
299
|
+
(handle: IFluidHandle) => this.handleDecoded(handle),
|
|
300
|
+
);
|
|
292
301
|
this.snapshotCore(serializer);
|
|
293
302
|
|
|
294
303
|
// The GC data for this shared object contains a single GC node. The outbound routes of this node are the
|
|
@@ -298,6 +307,18 @@ export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedO
|
|
|
298
307
|
};
|
|
299
308
|
}
|
|
300
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
|
|
312
|
+
* to another object in the container.
|
|
313
|
+
* @param decodedHandle - The handle of the Fluid object that is decoded.
|
|
314
|
+
*/
|
|
315
|
+
protected handleDecoded(decodedHandle: IFluidHandle) {
|
|
316
|
+
if (this.isAttached()) {
|
|
317
|
+
// This represents an outbound reference from this object to the node represented by decodedHandle.
|
|
318
|
+
this.services?.deltaConnection.addedGCOutboundReference?.(this.handle, decodedHandle);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
301
322
|
/**
|
|
302
323
|
* Gets a form of the object that can be serialized.
|
|
303
324
|
* @returns A tree representing the snapshot of the shared object.
|