@fluidframework/shared-object-base 2.80.0 → 2.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- 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.map +1 -1
- package/dist/sharedObject.js +1 -0
- package/dist/sharedObject.js.map +1 -1
- package/dist/sharedObjectKernel.js +1 -1
- package/dist/sharedObjectKernel.js.map +1 -1
- package/eslint.config.mts +5 -30
- 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.map +1 -1
- package/lib/sharedObject.js +1 -0
- package/lib/sharedObject.js.map +1 -1
- package/lib/sharedObjectKernel.js +1 -1
- package/lib/sharedObjectKernel.js.map +1 -1
- package/package.json +19 -19
- package/src/packageVersion.ts +1 -1
- package/src/sharedObject.ts +1 -0
- package/src/sharedObjectKernel.ts +1 -1
- package/.eslintrc.cjs +0 -24
package/CHANGELOG.md
CHANGED
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 = "2.
|
|
8
|
+
export declare const pkgVersion = "2.81.0";
|
|
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 = "2.
|
|
11
|
+
exports.pkgVersion = "2.81.0";
|
|
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 = \"2.
|
|
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 = \"2.81.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,KAAK,EACX,oBAAoB,EACpB,cAAc,EACd,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EACX,gBAAgB,EAChB,sBAAsB,EAEtB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EAGt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AW,gBAAgB,CAAC,GAAG,CAAC,aAAa,GAAG,OAAO,CAC5D,SAAQ,UAAU,CAAC,SAAS,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAChE;;;OAGG;IACH,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,IAAI,cAAc,GAAG,aAAa,CAAC;CACnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EACnD,OAAO,EAAE,CAAC,UAAU,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7E,iBAAiB,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAiBpE"}
|
package/dist/sharedObject.js
CHANGED
|
@@ -121,6 +121,7 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
121
121
|
* @param error - error object that is thrown whenever an attempt is made to modify this object
|
|
122
122
|
*/
|
|
123
123
|
closeWithError(error) {
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy
|
|
124
125
|
if (this.closeError === undefined) {
|
|
125
126
|
this.closeError = error;
|
|
126
127
|
}
|
package/dist/sharedObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iFAAoE;AAOpE,kEAA6D;AAe7D,2EASsD;AACtD,qEAGgD;AAChD,uEAYkD;AAClD,+BAAkC;AAElC,6DAAuD;AACvD,2CAAiD;AACjD,mDAAyE;AAEzE,yCAAgF;AAWhF;;;;;;;;;;;;;;GAcG;AACH,MAAsB,gBAGrB,SAAQ,wCAAqC;IAG7C,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAuCD;;;OAGG;IACH,IAAW,SAAS;QACnB,OAAO,IAAI,C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AE,CAAC;QACtB,CAAC;QAED,MAAM,CAAC,OAA+B,EAAE,EAAW;YAClD,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAkB,CAAC;QACjE,CAAC;QAED,EAAE,CAAC,KAAqB;YACvB,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;QACnE,CAAC;KACD,CAAC;IAEF,OAAO,MAAyD,CAAC;AAClE,CAAC;AAnBD,wDAmBC;AAED,SAAS,SAAS,CAAC,QAAwB;IAC1C,oGAAoG;IACpG,OAAQ,QAAqB,CAAC,UAAU,KAAK,SAAS,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport type { ITelemetryBaseProperties, ErasedType } from \"@fluidframework/core-interfaces\";\nimport type {\n\tIFluidHandleInternal,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelServices,\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIDeltaHandler,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype IGarbageCollectionData,\n\tblobCountPropertyName,\n\ttotalBlobSizePropertyName,\n\ttype IRuntimeMessageCollection,\n\ttype IRuntimeMessagesContent,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttoDeltaManagerInternal,\n\ttype TelemetryContext,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tDataProcessingError,\n\tEventEmitterWithErrorHandling,\n\ttype MonitoringContext,\n\tSampledTelemetryHelper,\n\tcreateChildLogger,\n\tloggerToMonitoringContext,\n\ttagCodeArtifacts,\n\ttype ICustomData,\n\ttype IFluidErrorBase,\n\tLoggingError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { GCHandleVisitor } from \"./gcHandleVisitor.js\";\nimport { SharedObjectHandle } from \"./handle.js\";\nimport { FluidSerializer, type IFluidSerializer } from \"./serializer.js\";\nimport type { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nimport { bindHandles, makeHandlesSerializable, parseHandles } from \"./utils.js\";\n\n/**\n * Custom telemetry properties used in {@link SharedObjectCore} to instantiate {@link TelemetryEventBatcher} class.\n * This interface is used to define the properties that will be passed to the {@link TelemetryEventBatcher.measure} function\n * which is called in the {@link SharedObjectCore.process} method.\n */\ninterface ProcessTelemetryProperties {\n\tsequenceDifference: number;\n}\n\n/**\n * Base class from which all {@link ISharedObject|shared objects} derive.\n * @remarks\n * This class implements common behaviors that implementations of {@link ISharedObject} may want to reuse.\n * Even more such behaviors are implemented in the {@link SharedObject} class.\n * @privateRemarks\n * Currently some documentation (like the above) implies that this is supposed to be the only implementation of ISharedObject, which is both package-exported and not `@sealed`.\n * This situation should be clarified to indicate if other implementations of ISharedObject are allowed and just currently don't exist,\n * or if the intention is that no other implementations should exist and creating some might break things.\n * As part of this, any existing implementations of ISharedObject (via SharedObjectCore or otherwise) in use by legacy API users will need to be considered.\n *\n * TODO:\n * This class should eventually be made internal, as custom subclasses of it outside this repository are intended to be made unsupported in the future.\n * @legacy @beta\n */\nexport abstract class SharedObjectCore<\n\t\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n\t>\n\textends EventEmitterWithErrorHandling<TEvent>\n\timplements ISharedObject<TEvent>\n{\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly opProcessingHelper: SampledTelemetryHelper<\n\t\tvoid,\n\t\tProcessTelemetryProperties\n\t>;\n\tprivate readonly callbacksHelper: SampledTelemetryHelper<boolean>;\n\n\t/**\n\t * The handle referring to this SharedObject\n\t */\n\tpublic readonly handle: IFluidHandleInternal;\n\n\t/**\n\t * Telemetry logger for the shared object\n\t */\n\tprotected readonly logger: ITelemetryLoggerExt;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Connection state\n\t */\n\tprivate _connected = false;\n\n\t/**\n\t * Services used by the shared object\n\t */\n\tprivate services: IChannelServices | undefined;\n\n\t/**\n\t * True if the dds is bound to its parent.\n\t */\n\tprivate _isBoundToContext: boolean = false;\n\n\t/**\n\t * Tracks error that closed this object.\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * Gets the connection state\n\t * @returns The state of the connection\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\tconstructor(\n\t\t/**\n\t\t * The ID of the shared object.\n\t\t */\n\t\tpublic id: string,\n\t\t/**\n\t\t * The runtime instance that contains the Shared Object.\n\t\t */\n\t\tprotected runtime: IFluidDataStoreRuntime,\n\t\t/**\n\t\t * The attributes of the Shared Object.\n\t\t */\n\t\tpublic readonly attributes: IChannelAttributes,\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) =>\n\t\t\tthis.eventListenerErrorHandler(event, e),\n\t\t);\n\n\t\tassert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n\t\tthis.handle = new SharedObjectHandle(this, id, runtime);\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: runtime.logger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\tsharedObjectId: uuid(),\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tddsType: this.attributes.type,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.mc = loggerToMonitoringContext(this.logger);\n\n\t\tconst { opProcessingHelper, callbacksHelper } = this.setUpSampledTelemetryHelpers();\n\t\tthis.opProcessingHelper = opProcessingHelper;\n\t\tthis.callbacksHelper = callbacksHelper;\n\t}\n\n\t/**\n\t * Accessor for `this.runtime`'s {@link @fluidframework/datastore-definitions#IFluidDataStoreRuntime.deltaManager} as a {@link @fluidframework/container-definitions/internal#IDeltaManager}\n\t */\n\tprotected get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n\t\treturn toDeltaManagerInternal(this.runtime.deltaManager);\n\t}\n\n\t/**\n\t * This function is only supposed to be called from SharedObjectCore's constructor and\n\t * depends on a few things being set already. assert() calls make sure of it.\n\t * @returns The telemetry sampling helpers, so the constructor can be the one to assign them\n\t * to variables to avoid complaints from TypeScript.\n\t */\n\tprivate setUpSampledTelemetryHelpers(): {\n\t\topProcessingHelper: SampledTelemetryHelper<void, ProcessTelemetryProperties>;\n\t\tcallbacksHelper: SampledTelemetryHelper<boolean>;\n\t} {\n\t\tassert(\n\t\t\tthis.mc !== undefined && this.logger !== undefined,\n\t\t\t0x349 /* this.mc and/or this.logger has not been set */,\n\t\t);\n\t\tconst opProcessingHelper = new SampledTelemetryHelper<void, ProcessTelemetryProperties>(\n\t\t\t{\n\t\t\t\teventName: \"ddsOpProcessing\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.OpProcessingTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t\tnew Map<string, ITelemetryBaseProperties>([\n\t\t\t\t[\"local\", { localOp: true }],\n\t\t\t\t[\"remote\", { localOp: false }],\n\t\t\t]),\n\t\t);\n\t\tconst callbacksHelper = new SampledTelemetryHelper<boolean>(\n\t\t\t{\n\t\t\t\teventName: \"ddsEventCallbacks\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.DdsCallbacksTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t);\n\n\t\tthis.runtime.once(\"dispose\", () => {\n\t\t\tthis.callbacksHelper.dispose();\n\t\t\tthis.opProcessingHelper.dispose();\n\t\t});\n\n\t\treturn { opProcessingHelper, callbacksHelper };\n\t}\n\n\t/**\n\t * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n\t * would result in same error thrown. If called multiple times, only first error is remembered.\n\t * @param error - error object that is thrown whenever an attempt is made to modify this object\n\t */\n\tprivate closeWithError(error: IFluidErrorBase | undefined): void {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n\t * It wraps error with DataProcessingError, closes this object and throws resulting error.\n\t * See closeWithError() for more details\n\t * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n\t * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n\t * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n\t * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n\t * allow processing of ops or local changes, which very quickly results in container closure.\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(\n\t\t\te,\n\t\t\t\"SharedObjectEventListenerException\",\n\t\t);\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\tprivate setBoundAndHandleAttach(): void {\n\t\t// Ensure didAttach is only called once, and we only register a single event\n\t\t// but we still call setConnectionState as our existing mocks don't\n\t\t// always propagate connection state\n\t\tthis.setBoundAndHandleAttach = () => this.setConnectionState(this.runtime.connected);\n\t\tthis._isBoundToContext = true;\n\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\tconst runDidAttach: () => void = () => {\n\t\t\t// Allows objects to do any custom processing if it is attached.\n\t\t\tthis.didAttach();\n\t\t\tthis.setConnectionState(this.runtime.connected);\n\t\t};\n\t\tif (this.isAttached()) {\n\t\t\trunDidAttach();\n\t\t} else {\n\t\t\tthis.runtime.once(\"attaching\", runDidAttach);\n\t\t}\n\t}\n\n\t/**\n\t * A shared object, after construction, can either be loaded in the case that it is already part of\n\t * a shared document. Or later attached if it is being newly added.\n\t * @param services - Services used by the shared object\n\t */\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tthis.services = services;\n\t\t// set this before load so that isAttached is true\n\t\t// for attached runtimes when load core is running\n\t\tthis._isBoundToContext = true;\n\t\tawait this.loadCore(services.objectStorage);\n\t\tthis.attachDeltaHandler();\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * Initializes the object as a local, non-shared object. This object can become shared after\n\t * it is attached to the document.\n\t */\n\tpublic initializeLocal(): void {\n\t\tthis.initializeLocalCore();\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).bindToContext}\n\t */\n\tpublic bindToContext(): void {\n\t\t// ensure the method only runs once by removing the implementation\n\t\t// without this the method suffers from re-entrancy issues\n\t\tthis.bindToContext = () => {};\n\t\tif (!this._isBoundToContext) {\n\t\t\tthis.runtime.bindChannel(this);\n\t\t\t// must set after bind channel so isAttached doesn't report true\n\t\t\t// before binding is complete\n\t\t\tthis.setBoundAndHandleAttach();\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n\t */\n\tpublic connect(services: IChannelServices): void {\n\t\t// handle the case where load is called\n\t\t// before connect; loading detached data stores\n\t\tif (this.services === undefined) {\n\t\t\tthis.services = services;\n\t\t\tthis.attachDeltaHandler();\n\t\t}\n\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n\t */\n\tpublic isAttached(): boolean {\n\t\treturn this._isBoundToContext && this.runtime.attachState !== AttachState.Detached;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic abstract getAttachSummary(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic abstract summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}\n\t */\n\tpublic abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the distributed data type to perform custom loading\n\t * @param services - Storage used by the shared object\n\t */\n\tprotected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n\t/**\n\t * Allows the distributed data type to perform custom local loading.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n\t * Also called after non-local data type get loaded.\n\t */\n\tprotected didAttach(): void {\n\t\treturn;\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Derived classes must override this to do custom processing on a 'bunch' of remote messages.\n\t * @remarks\n\t * A 'bunch' is a group of messages that have the following properties:\n\t * - They are all part of the same grouped batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t * - They are not interleaved with messages from other DDS in the container.\n\t * Derived classes should override this if they need to do custom processing on a 'bunch' of remote messages.\n\t * @param messageCollection - The collection of messages to process.\n\t *\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tprotected abstract processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\n\tprotected abstract onDisconnect(): void;\n\n\t/**\n\t * The serializer to serialize / parse handles.\n\t */\n\tprotected abstract get serializer(): IFluidSerializer;\n\n\t/**\n\t * Submits a message by the local client to the runtime.\n\t * @param content - Content of the message. Note: handles contained in the\n\t * message object should not be encoded in any way\n\t * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t */\n\tprotected submitLocalMessage(content: unknown, localOpMetadata: unknown = undefined): void {\n\t\tthis.verifyNotClosed();\n\t\tif (this.isAttached()) {\n\t\t\t// NOTE: We may also be encoding in the ContainerRuntime layer.\n\t\t\t// Once the layer-compat window passes we can remove the encoding codepath here altogether\n\t\t\tconst onlyBind =\n\t\t\t\t(this.runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t\t.submitMessagesWithoutEncodingHandles === true;\n\t\t\tconst contentToSubmit = onlyBind\n\t\t\t\t? bindHandles(content, this.handle)\n\t\t\t\t: makeHandlesSerializable(content, this.serializer, this.handle);\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(contentToSubmit, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n\t * that want to be part of summary but does not generate ops.\n\t */\n\tprotected dirty(): void {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.services!.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Called when the object has fully connected to the delta stream\n\t * Default implementation for DDS, override if different behavior is required.\n\t */\n\tprotected onConnect(): void {}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n\t * The default implementation here is to resubmit the same message. The client can override if different behavior\n\t * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n\t * anything at all.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.submitLocalMessage(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted but its content should be \"squashed\" if any subsequent pending changes\n\t * override the content in the fashion described on {@link @fluidframework/datastore-definitions#IDeltaHandler.reSubmit}.\n\t *\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitSquashed(content: unknown, localOpMetadata: unknown): void {\n\t\tconst allowStagingModeWithoutSquashing =\n\t\t\tloggerToMonitoringContext(this.logger).config.getBoolean(\n\t\t\t\t\"Fluid.SharedObject.AllowStagingModeWithoutSquashing\",\n\t\t\t) ??\n\t\t\t(this.runtime.options.allowStagingModeWithoutSquashing as boolean | undefined) ??\n\t\t\ttrue;\n\t\tif (allowStagingModeWithoutSquashing) {\n\t\t\tthis.reSubmitCore(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.throwUnsupported(\"reSubmitSquashed\");\n\t\t}\n\t}\n\n\t/**\n\t * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n\t * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n\t * the Promise will reject.\n\t * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n\t */\n\tprotected async newAckBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: unknown) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.runtime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.runtime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\t// Note: rejectBecauseDispose will never be undefined here\n\t\t\tthis.runtime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n\n\tprivate attachDeltaHandler(): void {\n\t\t// Services should already be there in case we are attaching delta handler.\n\t\tassert(\n\t\t\tthis.services !== undefined,\n\t\t\t0x07a /* \"Services should be there to attach delta handler\" */,\n\t\t);\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.services.deltaConnection.attach({\n\t\t\tprocessMessages: (messagesCollection: IRuntimeMessageCollection) => {\n\t\t\t\tthis.processMessages(messagesCollection);\n\t\t\t},\n\t\t\tsetConnectionState: (connected: boolean) => {\n\t\t\t\tthis.setConnectionState(connected);\n\t\t\t},\n\t\t\treSubmit: (content: unknown, localOpMetadata: unknown, squash: boolean) => {\n\t\t\t\tthis.reSubmit(content, localOpMetadata, squash);\n\t\t\t},\n\t\t\tapplyStashedOp: (content: unknown): void => {\n\t\t\t\tthis.applyStashedOp(parseHandles(content, this.serializer));\n\t\t\t},\n\t\t\trollback: (content: unknown, localOpMetadata: unknown) => {\n\t\t\t\tthis.rollback(content, localOpMetadata);\n\t\t\t},\n\t\t} satisfies IDeltaHandler);\n\t}\n\n\t/**\n\t * Set the state of connection to services.\n\t * @param connected - true if connected, false otherwise.\n\t */\n\tprivate setConnectionState(connected: boolean): void {\n\t\t// only an attached shared object can transition its\n\t\t// connected state. This is defensive, as some\n\t\t// of our test harnesses don't handle this correctly\n\t\tif (!this.isAttached() || this._connected === connected) {\n\t\t\t// Not changing state, nothing the same.\n\t\t\treturn;\n\t\t}\n\n\t\t// Should I change the state at the end? So that we *can't* send new stuff before we send old?\n\t\tthis._connected = connected;\n\n\t\tif (connected) {\n\t\t\t// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending\n\t\t\t// messages will work.\n\t\t\tthis.onConnect();\n\t\t} else {\n\t\t\t// Things that are true now...\n\t\t\t// - if we had a connection we can no longer send messages over it\n\t\t\t// - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n\t\t\t//\n\t\t\t// - nack could get a new msn - but might as well do it in the join?\n\t\t\tthis.onDisconnect();\n\t\t}\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Process a bunch of messages for this shared object. A bunch is group of messages that have the following properties:\n\t * - They are all part of the same grouped batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t * - They are not interleaved with messages from other DDS in the container.\n\t * @param messageCollection - The collection of messages to process.\n\t *\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tprivate processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.verifyNotClosed(); // This will result in container closure.\n\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\n\t\t// Decode any handles in the contents before processing the messages.\n\t\tconst decodedMessagesContent: IRuntimeMessagesContent[] = [];\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tconst decodedMessageContent: IRuntimeMessagesContent = {\n\t\t\t\tcontents: parseHandles(contents, this.serializer),\n\t\t\t\tlocalOpMetadata,\n\t\t\t\tclientSequenceNumber,\n\t\t\t};\n\t\t\tdecodedMessagesContent.push(decodedMessageContent);\n\t\t}\n\n\t\tconst emitEvents = (event: \"pre-op\" | \"op\"): void => {\n\t\t\tfor (const { contents, clientSequenceNumber } of decodedMessagesContent) {\n\t\t\t\tconst message: ISequencedDocumentMessage = {\n\t\t\t\t\t...envelope,\n\t\t\t\t\tcontents,\n\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t};\n\t\t\t\tthis.emitInternal(event, message, local);\n\t\t\t}\n\t\t};\n\n\t\temitEvents(\"pre-op\");\n\t\tthis.opProcessingHelper.measure(\n\t\t\t(): ICustomData<ProcessTelemetryProperties> => {\n\t\t\t\tconst decodedMessagesCollection: IRuntimeMessageCollection = {\n\t\t\t\t\tenvelope,\n\t\t\t\t\tlocal,\n\t\t\t\t\tmessagesContent: decodedMessagesContent,\n\t\t\t\t};\n\t\t\t\tthis.processMessagesCore(decodedMessagesCollection);\n\t\t\t\tconst telemetryProperties: ProcessTelemetryProperties = {\n\t\t\t\t\tsequenceDifference: envelope.sequenceNumber - envelope.referenceSequenceNumber,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tcustomData: telemetryProperties,\n\t\t\t\t};\n\t\t\t},\n\t\t\tlocal ? \"local\" : \"remote\",\n\t\t);\n\t\temitEvents(\"op\");\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n\t * reconnection.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t * @param squash - If `true`, the message will be resubmitted in a squashed form. If `false`,\n\t * the legacy behavior (no squashing) will be used.\n\t */\n\tprivate reSubmit(content: unknown, localOpMetadata: unknown, squash: boolean): void {\n\t\tif (squash) {\n\t\t\tthis.reSubmitSquashed(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.reSubmitCore(content, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.throwUnsupported(\"rollback\");\n\t}\n\n\t/**\n\t * Apply changes from the provided op content just as if a local client has made the change,\n\t * including submitting the op. Used when rehydrating an attached container\n\t * with pending changes. The rehydration process replays all remote ops\n\t * and applies stashed ops after the remote op with a sequence number\n\t * that matches that of the stashed op is applied. This ensures\n\t * stashed ops are applied at the same state they were originally created.\n\t *\n\t * It is possible that stashed ops have been sent in the past, and will be found when\n\t * the shared object catches up with remotes ops.\n\t * So this prepares the SharedObject for seeing potentially seeing the ACK.\n\t * If no matching remote op is found, all the applied stashed ops will go\n\t * through the normal resubmit flow upon reconnection, which allows the dds\n\t * to rebase them to the latest state, and then resubmit them.\n\t *\n\t * @param content - Contents of a stashed op.\n\t */\n\tprotected abstract applyStashedOp(content: unknown): void;\n\n\t/**\n\t * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,\n\t * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners\n\t * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events\n\t * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the\n\t * future.\n\t * @param event - The event to emit.\n\t * @param args - Arguments to pass to the event listeners.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t */\n\tpublic emit(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn this.callbacksHelper.measure(() => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn super.emit(event, ...args);\n\t\t});\n\t}\n\n\t/**\n\t * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement\n\t * done on the duration of the callbacks. Simply calls `super.emit()`.\n\t * @param event - Event to emit\n\t * @param args - Arguments for the event\n\t * @returns Whatever `super.emit()` returns.\n\t */\n\tprivate emitInternal(event: EventEmitterEventType, ...args: unknown[]): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n\n\tprivate throwUnsupported(featureName: string): never {\n\t\tthrow new LoggingError(\"Unsupported DDS feature\", {\n\t\t\tfeatureName,\n\t\t\t...tagCodeArtifacts({ ddsType: this.attributes.type }),\n\t\t});\n\t}\n}\n\n/**\n * Helper for implementing {@link ISharedObject} with simplified, synchronous summarization and garbage collection.\n * @remarks\n * DDS implementations with async and incremental summarization should extend {@link SharedObjectCore} directly instead.\n * @privateRemarks\n * TODO:\n * This class is badly named.\n * Once it becomes `@internal` \"SharedObjectCore\" should probably become \"SharedObject\"\n * and this class should be renamed to something like \"SharedObjectSynchronous\".\n * @legacy @beta\n */\nexport abstract class SharedObject<\n\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n> extends SharedObjectCore<TEvent> {\n\t/**\n\t * True while we are garbage collecting this object's data.\n\t */\n\tprivate _isGCing: boolean = false;\n\n\t/**\n\t * The serializer to use to serialize / parse handles, if any.\n\t */\n\tprivate readonly _serializer: IFluidSerializer;\n\n\tprotected get serializer(): IFluidSerializer {\n\t\t/**\n\t\t * During garbage collection, the GCHandleVisitor \"serializer\" keeps track of IFluidHandles that are serialized. These\n\t\t * handles represent references to other Fluid objects.\n\t\t *\n\t\t * This is fine for now. However, if we implement delay loading in DDSes, they may load and de-serialize content\n\t\t * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n\t\t */\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */,\n\t\t);\n\t\treturn this._serializer;\n\t}\n\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\t/**\n\t\t * The prefix to use for telemetry events emitted by this object.\n\t\t */\n\t\tprivate readonly telemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes);\n\n\t\tthis._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic getAttachSummary(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tundefined /* incrementalSummaryContext */,\n\t\t\tfullTree,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\t// Set _isGCing to true. This flag is used to ensure that we only use GCHandleVisitor in this codepath and not when trying to truly serialize.\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */,\n\t\t);\n\t\tthis._isGCing = true;\n\n\t\tlet gcData: IGarbageCollectionData;\n\t\ttry {\n\t\t\tconst handleVisitor = new GCHandleVisitor(this.runtime.channelsRoutingContext);\n\t\t\tthis.processGCDataCore(handleVisitor);\n\t\t\t// The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n\t\t\t// routes of handles serialized during summarization.\n\t\t\tgcData = { gcNodes: { \"/\": handleVisitor.getVisitedHandlePaths() } };\n\t\t\tassert(\n\t\t\t\tthis._isGCing,\n\t\t\t\t0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis._isGCing = false;\n\t\t}\n\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Calls the serializer over all data in this object that reference other GC nodes.\n\t * Derived classes must override this to provide custom list of references to other GC nodes.\n\t *\n\t * @remarks Serialization itself doesn't matter (the result is ignored). We're tapping into the serialization infrastructure\n\t * as a way to visit all the content in this content that may reference other objects via handle.\n\t *\n\t * @param serializer - The \"serializer\" (more like handle visitor) to use.\n\t * Implementations should ensure that serialize is called on all handles, as the way to visit them.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\t// We run the full summarize logic to get the list of outbound routes from this object. This is a little\n\t\t// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n\t\t// See: https://github.com/microsoft/FluidFramework/issues/4547\n\t\tthis.summarizeCore(serializer);\n\t}\n\n\t/**\n\t * Gets a form of the object that can be serialized.\n\t * @returns A tree representing the snapshot of the shared object.\n\t */\n\tprotected abstract summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\tprivate incrementTelemetryMetric(\n\t\tpropertyName: string,\n\t\tincrementBy: number,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): void {\n\t\tif (telemetryContext !== undefined) {\n\t\t\t// TelemetryContext needs to implment a get function\n\t\t\tassert(\n\t\t\t\t\"get\" in telemetryContext && typeof telemetryContext.get === \"function\",\n\t\t\t\t0x97e /* received context must have a get function */,\n\t\t\t);\n\n\t\t\tconst prevTotal = ((telemetryContext as TelemetryContext).get(\n\t\t\t\tthis.telemetryContextPrefix,\n\t\t\t\tpropertyName,\n\t\t\t) ?? 0) as number;\n\t\t\ttelemetryContext.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n\t\t}\n\t}\n}\n\n/**\n * Defines a kind of shared object.\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n *\n * @remarks\n * For use internally and in the \"encapsulated API\".\n * See {@link SharedObjectKind} for the type erased version for use in the public declarative API.\n *\n * @privateRemarks\n * This does not extend {@link SharedObjectKind} since doing so would prevent implementing this interface in type safe code.\n * Any implementation of this can safely be used as a {@link SharedObjectKind} with an explicit type conversion,\n * but doing so is typically not needed as {@link createSharedObjectKind} is used to produce values that are both types simultaneously.\n * @legacy @beta\n */\nexport interface ISharedObjectKind<TSharedObject> {\n\t/**\n\t * Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.\n\t * @remarks\n\t * The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels.\n\t * To create new shared objects use:\n\t *\n\t * - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.\n\t *\n\t * - {@link ISharedObjectKind.create} if using a custom container definitions (and thus not using {@link @fluidframework/fluid-static#IFluidContainer}).\n\t */\n\tgetFactory(): IChannelFactory<TSharedObject>;\n\n\t/**\n\t * Create a shared object.\n\t * @param runtime - The data store runtime that the new shared object belongs to.\n\t * @param id - Optional name of the shared object.\n\t * @returns Newly created shared object.\n\t *\n\t * @example\n\t * To create a `SharedTree`, call the static create method:\n\t *\n\t * ```typescript\n\t * const myTree = SharedTree.create(this.runtime, id);\n\t * ```\n\t * @remarks\n\t * The created object is local (detached): insert a handle to it into an attached object to share (attach) it.\n\t * If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.\n\t *\n\t * @privateRemarks\n\t * This can only be used with a `MockFluidDataStoreRuntime` when that mock is created with a `registry` containing a factory for this shared object.\n\t */\n\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;\n}\n\n/**\n * Defines a kind of shared object.\n * @remarks\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n * See {@link @fluidframework/fluid-static#IFluidContainer.create} and {@link @fluidframework/fluid-static#ContainerSchema} for details.\n * @privateRemarks\n * Part of the \"declarative API\".\n * Type erased reference to an {@link ISharedObjectKind} or a DataObject class in for use in\n * `fluid-static`'s `IFluidContainer` and `ContainerSchema`.\n * Use {@link createSharedObjectKind} to creating an instance of this type.\n * @sealed\n * @public\n */\nexport interface SharedObjectKind<out TSharedObject = unknown>\n\textends ErasedType<readonly [\"SharedObjectKind\", TSharedObject]> {\n\t/**\n\t * Check whether an {@link @fluidframework/core-interfaces#IFluidLoadable} is an instance of this shared object kind.\n\t * @remarks This should be used in place of `instanceof` checks for shared objects, as their actual classes are not exported in Fluid's public API.\n\t */\n\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject;\n}\n\n/**\n * Utility for creating ISharedObjectKind instances.\n * @remarks\n * This takes in a class which implements IChannelFactory,\n * and uses it to return a a single value which is intended to be used as the API entry point for the corresponding shared object type.\n * The returned value implements {@link ISharedObjectKind} for use in the encapsulated API, as well as the type erased {@link SharedObjectKind} used by the declarative API.\n * See {@link @fluidframework/fluid-static#ContainerSchema} for how this is used in the declarative API.\n * @internal\n */\nexport function createSharedObjectKind<TSharedObject>(\n\tfactory: (new () => IChannelFactory<TSharedObject>) & { readonly Type: string },\n): ISharedObjectKind<TSharedObject> & SharedObjectKind<TSharedObject> {\n\tconst result: ISharedObjectKind<TSharedObject> &\n\t\tOmit<SharedObjectKind<TSharedObject>, \"brand\"> = {\n\t\tgetFactory(): IChannelFactory<TSharedObject> {\n\t\t\treturn new factory();\n\t\t},\n\n\t\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject {\n\t\t\treturn runtime.createChannel(id, factory.Type) as TSharedObject;\n\t\t},\n\n\t\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject {\n\t\t\treturn isChannel(value) && value.attributes.type === factory.Type;\n\t\t},\n\t};\n\n\treturn result as typeof result & SharedObjectKind<TSharedObject>;\n}\n\nfunction isChannel(loadable: IFluidLoadable): loadable is IChannel {\n\t// This assumes no other IFluidLoadable has an `attributes` field, and thus may not be fully robust.\n\treturn (loadable as IChannel).attributes !== undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iFAAoE;AAOpE,kEAA6D;AAe7D,2EASsD;AACtD,qEAGgD;AAChD,uEAYkD;AAClD,+BAAkC;AAElC,6DAAuD;AACvD,2CAAiD;AACjD,mDAAyE;AAEzE,yCAAgF;AAWhF;;;;;;;;;;;;;;GAcG;AACH,MAAsB,gBAGrB,SAAQ,wCAAqC;IAG7C,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAuCD;;;OAGG;IACH,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED;IACC;;OAEG;IACI,EAAU;IACjB;;OAEG;IACO,OAA+B;IACzC;;OAEG;IACa,UAA8B;QAE9C,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAU,EAAE,EAAE,CAClD,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CAAC,CACxC,CAAC;QAZK,OAAE,GAAF,EAAE,CAAQ;QAIP,YAAO,GAAP,OAAO,CAAwB;QAIzB,eAAU,GAAV,UAAU,CAAoB;QAxC/C;;WAEG;QACK,eAAU,GAAG,KAAK,CAAC;QAO3B;;WAEG;QACK,sBAAiB,GAAY,KAAK,CAAC;QAiC1C,IAAA,iBAAM,EAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAEjE,IAAI,CAAC,MAAM,GAAG,IAAI,8BAA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I,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAaO,wBAAwB,CAC/B,YAAoB,EACpB,WAAmB,EACnB,gBAAoC;QAEpC,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACpC,oDAAoD;YACpD,IAAA,iBAAM,EACL,KAAK,IAAI,gBAAgB,IAAI,OAAO,gBAAgB,CAAC,GAAG,KAAK,UAAU,EACvE,KAAK,CAAC,+CAA+C,CACrD,CAAC;YAEF,MAAM,SAAS,GAAG,CAAE,gBAAqC,CAAC,GAAG,CAC5D,IAAI,CAAC,sBAAsB,EAC3B,YAAY,CACZ,IAAI,CAAC,CAAW,CAAC;YAClB,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;QAC1F,CAAC;IACF,CAAC;CACD;AA7KD,oCA6KC;AAyED;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACrC,OAA+E;IAE/E,MAAM,MAAM,GACsC;QACjD,UAAU;YACT,OAAO,IAAI,OAAO,EAAE,CAAC;QACtB,CAAC;QAED,MAAM,CAAC,OAA+B,EAAE,EAAW;YAClD,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAkB,CAAC;QACjE,CAAC;QAED,EAAE,CAAC,KAAqB;YACvB,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;QACnE,CAAC;KACD,CAAC;IAEF,OAAO,MAAyD,CAAC;AAClE,CAAC;AAnBD,wDAmBC;AAED,SAAS,SAAS,CAAC,QAAwB;IAC1C,oGAAoG;IACpG,OAAQ,QAAqB,CAAC,UAAU,KAAK,SAAS,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport type { ITelemetryBaseProperties, ErasedType } from \"@fluidframework/core-interfaces\";\nimport type {\n\tIFluidHandleInternal,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelServices,\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIDeltaHandler,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype IGarbageCollectionData,\n\tblobCountPropertyName,\n\ttotalBlobSizePropertyName,\n\ttype IRuntimeMessageCollection,\n\ttype IRuntimeMessagesContent,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttoDeltaManagerInternal,\n\ttype TelemetryContext,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tDataProcessingError,\n\tEventEmitterWithErrorHandling,\n\ttype MonitoringContext,\n\tSampledTelemetryHelper,\n\tcreateChildLogger,\n\tloggerToMonitoringContext,\n\ttagCodeArtifacts,\n\ttype ICustomData,\n\ttype IFluidErrorBase,\n\tLoggingError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { GCHandleVisitor } from \"./gcHandleVisitor.js\";\nimport { SharedObjectHandle } from \"./handle.js\";\nimport { FluidSerializer, type IFluidSerializer } from \"./serializer.js\";\nimport type { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nimport { bindHandles, makeHandlesSerializable, parseHandles } from \"./utils.js\";\n\n/**\n * Custom telemetry properties used in {@link SharedObjectCore} to instantiate {@link TelemetryEventBatcher} class.\n * This interface is used to define the properties that will be passed to the {@link TelemetryEventBatcher.measure} function\n * which is called in the {@link SharedObjectCore.process} method.\n */\ninterface ProcessTelemetryProperties {\n\tsequenceDifference: number;\n}\n\n/**\n * Base class from which all {@link ISharedObject|shared objects} derive.\n * @remarks\n * This class implements common behaviors that implementations of {@link ISharedObject} may want to reuse.\n * Even more such behaviors are implemented in the {@link SharedObject} class.\n * @privateRemarks\n * Currently some documentation (like the above) implies that this is supposed to be the only implementation of ISharedObject, which is both package-exported and not `@sealed`.\n * This situation should be clarified to indicate if other implementations of ISharedObject are allowed and just currently don't exist,\n * or if the intention is that no other implementations should exist and creating some might break things.\n * As part of this, any existing implementations of ISharedObject (via SharedObjectCore or otherwise) in use by legacy API users will need to be considered.\n *\n * TODO:\n * This class should eventually be made internal, as custom subclasses of it outside this repository are intended to be made unsupported in the future.\n * @legacy @beta\n */\nexport abstract class SharedObjectCore<\n\t\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n\t>\n\textends EventEmitterWithErrorHandling<TEvent>\n\timplements ISharedObject<TEvent>\n{\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly opProcessingHelper: SampledTelemetryHelper<\n\t\tvoid,\n\t\tProcessTelemetryProperties\n\t>;\n\tprivate readonly callbacksHelper: SampledTelemetryHelper<boolean>;\n\n\t/**\n\t * The handle referring to this SharedObject\n\t */\n\tpublic readonly handle: IFluidHandleInternal;\n\n\t/**\n\t * Telemetry logger for the shared object\n\t */\n\tprotected readonly logger: ITelemetryLoggerExt;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Connection state\n\t */\n\tprivate _connected = false;\n\n\t/**\n\t * Services used by the shared object\n\t */\n\tprivate services: IChannelServices | undefined;\n\n\t/**\n\t * True if the dds is bound to its parent.\n\t */\n\tprivate _isBoundToContext: boolean = false;\n\n\t/**\n\t * Tracks error that closed this object.\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * Gets the connection state\n\t * @returns The state of the connection\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\tconstructor(\n\t\t/**\n\t\t * The ID of the shared object.\n\t\t */\n\t\tpublic id: string,\n\t\t/**\n\t\t * The runtime instance that contains the Shared Object.\n\t\t */\n\t\tprotected runtime: IFluidDataStoreRuntime,\n\t\t/**\n\t\t * The attributes of the Shared Object.\n\t\t */\n\t\tpublic readonly attributes: IChannelAttributes,\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) =>\n\t\t\tthis.eventListenerErrorHandler(event, e),\n\t\t);\n\n\t\tassert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n\t\tthis.handle = new SharedObjectHandle(this, id, runtime);\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: runtime.logger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\tsharedObjectId: uuid(),\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tddsType: this.attributes.type,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.mc = loggerToMonitoringContext(this.logger);\n\n\t\tconst { opProcessingHelper, callbacksHelper } = this.setUpSampledTelemetryHelpers();\n\t\tthis.opProcessingHelper = opProcessingHelper;\n\t\tthis.callbacksHelper = callbacksHelper;\n\t}\n\n\t/**\n\t * Accessor for `this.runtime`'s {@link @fluidframework/datastore-definitions#IFluidDataStoreRuntime.deltaManager} as a {@link @fluidframework/container-definitions/internal#IDeltaManager}\n\t */\n\tprotected get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n\t\treturn toDeltaManagerInternal(this.runtime.deltaManager);\n\t}\n\n\t/**\n\t * This function is only supposed to be called from SharedObjectCore's constructor and\n\t * depends on a few things being set already. assert() calls make sure of it.\n\t * @returns The telemetry sampling helpers, so the constructor can be the one to assign them\n\t * to variables to avoid complaints from TypeScript.\n\t */\n\tprivate setUpSampledTelemetryHelpers(): {\n\t\topProcessingHelper: SampledTelemetryHelper<void, ProcessTelemetryProperties>;\n\t\tcallbacksHelper: SampledTelemetryHelper<boolean>;\n\t} {\n\t\tassert(\n\t\t\tthis.mc !== undefined && this.logger !== undefined,\n\t\t\t0x349 /* this.mc and/or this.logger has not been set */,\n\t\t);\n\t\tconst opProcessingHelper = new SampledTelemetryHelper<void, ProcessTelemetryProperties>(\n\t\t\t{\n\t\t\t\teventName: \"ddsOpProcessing\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.OpProcessingTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t\tnew Map<string, ITelemetryBaseProperties>([\n\t\t\t\t[\"local\", { localOp: true }],\n\t\t\t\t[\"remote\", { localOp: false }],\n\t\t\t]),\n\t\t);\n\t\tconst callbacksHelper = new SampledTelemetryHelper<boolean>(\n\t\t\t{\n\t\t\t\teventName: \"ddsEventCallbacks\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.DdsCallbacksTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t);\n\n\t\tthis.runtime.once(\"dispose\", () => {\n\t\t\tthis.callbacksHelper.dispose();\n\t\t\tthis.opProcessingHelper.dispose();\n\t\t});\n\n\t\treturn { opProcessingHelper, callbacksHelper };\n\t}\n\n\t/**\n\t * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n\t * would result in same error thrown. If called multiple times, only first error is remembered.\n\t * @param error - error object that is thrown whenever an attempt is made to modify this object\n\t */\n\tprivate closeWithError(error: IFluidErrorBase | undefined): void {\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n\t * It wraps error with DataProcessingError, closes this object and throws resulting error.\n\t * See closeWithError() for more details\n\t * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n\t * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n\t * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n\t * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n\t * allow processing of ops or local changes, which very quickly results in container closure.\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(\n\t\t\te,\n\t\t\t\"SharedObjectEventListenerException\",\n\t\t);\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\tprivate setBoundAndHandleAttach(): void {\n\t\t// Ensure didAttach is only called once, and we only register a single event\n\t\t// but we still call setConnectionState as our existing mocks don't\n\t\t// always propagate connection state\n\t\tthis.setBoundAndHandleAttach = () => this.setConnectionState(this.runtime.connected);\n\t\tthis._isBoundToContext = true;\n\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\tconst runDidAttach: () => void = () => {\n\t\t\t// Allows objects to do any custom processing if it is attached.\n\t\t\tthis.didAttach();\n\t\t\tthis.setConnectionState(this.runtime.connected);\n\t\t};\n\t\tif (this.isAttached()) {\n\t\t\trunDidAttach();\n\t\t} else {\n\t\t\tthis.runtime.once(\"attaching\", runDidAttach);\n\t\t}\n\t}\n\n\t/**\n\t * A shared object, after construction, can either be loaded in the case that it is already part of\n\t * a shared document. Or later attached if it is being newly added.\n\t * @param services - Services used by the shared object\n\t */\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tthis.services = services;\n\t\t// set this before load so that isAttached is true\n\t\t// for attached runtimes when load core is running\n\t\tthis._isBoundToContext = true;\n\t\tawait this.loadCore(services.objectStorage);\n\t\tthis.attachDeltaHandler();\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * Initializes the object as a local, non-shared object. This object can become shared after\n\t * it is attached to the document.\n\t */\n\tpublic initializeLocal(): void {\n\t\tthis.initializeLocalCore();\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).bindToContext}\n\t */\n\tpublic bindToContext(): void {\n\t\t// ensure the method only runs once by removing the implementation\n\t\t// without this the method suffers from re-entrancy issues\n\t\tthis.bindToContext = () => {};\n\t\tif (!this._isBoundToContext) {\n\t\t\tthis.runtime.bindChannel(this);\n\t\t\t// must set after bind channel so isAttached doesn't report true\n\t\t\t// before binding is complete\n\t\t\tthis.setBoundAndHandleAttach();\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n\t */\n\tpublic connect(services: IChannelServices): void {\n\t\t// handle the case where load is called\n\t\t// before connect; loading detached data stores\n\t\tif (this.services === undefined) {\n\t\t\tthis.services = services;\n\t\t\tthis.attachDeltaHandler();\n\t\t}\n\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n\t */\n\tpublic isAttached(): boolean {\n\t\treturn this._isBoundToContext && this.runtime.attachState !== AttachState.Detached;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic abstract getAttachSummary(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic abstract summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}\n\t */\n\tpublic abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the distributed data type to perform custom loading\n\t * @param services - Storage used by the shared object\n\t */\n\tprotected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n\t/**\n\t * Allows the distributed data type to perform custom local loading.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n\t * Also called after non-local data type get loaded.\n\t */\n\tprotected didAttach(): void {\n\t\treturn;\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Derived classes must override this to do custom processing on a 'bunch' of remote messages.\n\t * @remarks\n\t * A 'bunch' is a group of messages that have the following properties:\n\t * - They are all part of the same grouped batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t * - They are not interleaved with messages from other DDS in the container.\n\t * Derived classes should override this if they need to do custom processing on a 'bunch' of remote messages.\n\t * @param messageCollection - The collection of messages to process.\n\t *\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tprotected abstract processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\n\tprotected abstract onDisconnect(): void;\n\n\t/**\n\t * The serializer to serialize / parse handles.\n\t */\n\tprotected abstract get serializer(): IFluidSerializer;\n\n\t/**\n\t * Submits a message by the local client to the runtime.\n\t * @param content - Content of the message. Note: handles contained in the\n\t * message object should not be encoded in any way\n\t * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t */\n\tprotected submitLocalMessage(content: unknown, localOpMetadata: unknown = undefined): void {\n\t\tthis.verifyNotClosed();\n\t\tif (this.isAttached()) {\n\t\t\t// NOTE: We may also be encoding in the ContainerRuntime layer.\n\t\t\t// Once the layer-compat window passes we can remove the encoding codepath here altogether\n\t\t\tconst onlyBind =\n\t\t\t\t(this.runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t\t.submitMessagesWithoutEncodingHandles === true;\n\t\t\tconst contentToSubmit = onlyBind\n\t\t\t\t? bindHandles(content, this.handle)\n\t\t\t\t: makeHandlesSerializable(content, this.serializer, this.handle);\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(contentToSubmit, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n\t * that want to be part of summary but does not generate ops.\n\t */\n\tprotected dirty(): void {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.services!.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Called when the object has fully connected to the delta stream\n\t * Default implementation for DDS, override if different behavior is required.\n\t */\n\tprotected onConnect(): void {}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n\t * The default implementation here is to resubmit the same message. The client can override if different behavior\n\t * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n\t * anything at all.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.submitLocalMessage(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted but its content should be \"squashed\" if any subsequent pending changes\n\t * override the content in the fashion described on {@link @fluidframework/datastore-definitions#IDeltaHandler.reSubmit}.\n\t *\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitSquashed(content: unknown, localOpMetadata: unknown): void {\n\t\tconst allowStagingModeWithoutSquashing =\n\t\t\tloggerToMonitoringContext(this.logger).config.getBoolean(\n\t\t\t\t\"Fluid.SharedObject.AllowStagingModeWithoutSquashing\",\n\t\t\t) ??\n\t\t\t(this.runtime.options.allowStagingModeWithoutSquashing as boolean | undefined) ??\n\t\t\ttrue;\n\t\tif (allowStagingModeWithoutSquashing) {\n\t\t\tthis.reSubmitCore(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.throwUnsupported(\"reSubmitSquashed\");\n\t\t}\n\t}\n\n\t/**\n\t * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n\t * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n\t * the Promise will reject.\n\t * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n\t */\n\tprotected async newAckBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: unknown) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.runtime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.runtime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\t// Note: rejectBecauseDispose will never be undefined here\n\t\t\tthis.runtime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n\n\tprivate attachDeltaHandler(): void {\n\t\t// Services should already be there in case we are attaching delta handler.\n\t\tassert(\n\t\t\tthis.services !== undefined,\n\t\t\t0x07a /* \"Services should be there to attach delta handler\" */,\n\t\t);\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.services.deltaConnection.attach({\n\t\t\tprocessMessages: (messagesCollection: IRuntimeMessageCollection) => {\n\t\t\t\tthis.processMessages(messagesCollection);\n\t\t\t},\n\t\t\tsetConnectionState: (connected: boolean) => {\n\t\t\t\tthis.setConnectionState(connected);\n\t\t\t},\n\t\t\treSubmit: (content: unknown, localOpMetadata: unknown, squash: boolean) => {\n\t\t\t\tthis.reSubmit(content, localOpMetadata, squash);\n\t\t\t},\n\t\t\tapplyStashedOp: (content: unknown): void => {\n\t\t\t\tthis.applyStashedOp(parseHandles(content, this.serializer));\n\t\t\t},\n\t\t\trollback: (content: unknown, localOpMetadata: unknown) => {\n\t\t\t\tthis.rollback(content, localOpMetadata);\n\t\t\t},\n\t\t} satisfies IDeltaHandler);\n\t}\n\n\t/**\n\t * Set the state of connection to services.\n\t * @param connected - true if connected, false otherwise.\n\t */\n\tprivate setConnectionState(connected: boolean): void {\n\t\t// only an attached shared object can transition its\n\t\t// connected state. This is defensive, as some\n\t\t// of our test harnesses don't handle this correctly\n\t\tif (!this.isAttached() || this._connected === connected) {\n\t\t\t// Not changing state, nothing the same.\n\t\t\treturn;\n\t\t}\n\n\t\t// Should I change the state at the end? So that we *can't* send new stuff before we send old?\n\t\tthis._connected = connected;\n\n\t\tif (connected) {\n\t\t\t// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending\n\t\t\t// messages will work.\n\t\t\tthis.onConnect();\n\t\t} else {\n\t\t\t// Things that are true now...\n\t\t\t// - if we had a connection we can no longer send messages over it\n\t\t\t// - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n\t\t\t//\n\t\t\t// - nack could get a new msn - but might as well do it in the join?\n\t\t\tthis.onDisconnect();\n\t\t}\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Process a bunch of messages for this shared object. A bunch is group of messages that have the following properties:\n\t * - They are all part of the same grouped batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t * - They are not interleaved with messages from other DDS in the container.\n\t * @param messageCollection - The collection of messages to process.\n\t *\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tprivate processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.verifyNotClosed(); // This will result in container closure.\n\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\n\t\t// Decode any handles in the contents before processing the messages.\n\t\tconst decodedMessagesContent: IRuntimeMessagesContent[] = [];\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tconst decodedMessageContent: IRuntimeMessagesContent = {\n\t\t\t\tcontents: parseHandles(contents, this.serializer),\n\t\t\t\tlocalOpMetadata,\n\t\t\t\tclientSequenceNumber,\n\t\t\t};\n\t\t\tdecodedMessagesContent.push(decodedMessageContent);\n\t\t}\n\n\t\tconst emitEvents = (event: \"pre-op\" | \"op\"): void => {\n\t\t\tfor (const { contents, clientSequenceNumber } of decodedMessagesContent) {\n\t\t\t\tconst message: ISequencedDocumentMessage = {\n\t\t\t\t\t...envelope,\n\t\t\t\t\tcontents,\n\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t};\n\t\t\t\tthis.emitInternal(event, message, local);\n\t\t\t}\n\t\t};\n\n\t\temitEvents(\"pre-op\");\n\t\tthis.opProcessingHelper.measure(\n\t\t\t(): ICustomData<ProcessTelemetryProperties> => {\n\t\t\t\tconst decodedMessagesCollection: IRuntimeMessageCollection = {\n\t\t\t\t\tenvelope,\n\t\t\t\t\tlocal,\n\t\t\t\t\tmessagesContent: decodedMessagesContent,\n\t\t\t\t};\n\t\t\t\tthis.processMessagesCore(decodedMessagesCollection);\n\t\t\t\tconst telemetryProperties: ProcessTelemetryProperties = {\n\t\t\t\t\tsequenceDifference: envelope.sequenceNumber - envelope.referenceSequenceNumber,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tcustomData: telemetryProperties,\n\t\t\t\t};\n\t\t\t},\n\t\t\tlocal ? \"local\" : \"remote\",\n\t\t);\n\t\temitEvents(\"op\");\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n\t * reconnection.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t * @param squash - If `true`, the message will be resubmitted in a squashed form. If `false`,\n\t * the legacy behavior (no squashing) will be used.\n\t */\n\tprivate reSubmit(content: unknown, localOpMetadata: unknown, squash: boolean): void {\n\t\tif (squash) {\n\t\t\tthis.reSubmitSquashed(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.reSubmitCore(content, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.throwUnsupported(\"rollback\");\n\t}\n\n\t/**\n\t * Apply changes from the provided op content just as if a local client has made the change,\n\t * including submitting the op. Used when rehydrating an attached container\n\t * with pending changes. The rehydration process replays all remote ops\n\t * and applies stashed ops after the remote op with a sequence number\n\t * that matches that of the stashed op is applied. This ensures\n\t * stashed ops are applied at the same state they were originally created.\n\t *\n\t * It is possible that stashed ops have been sent in the past, and will be found when\n\t * the shared object catches up with remotes ops.\n\t * So this prepares the SharedObject for seeing potentially seeing the ACK.\n\t * If no matching remote op is found, all the applied stashed ops will go\n\t * through the normal resubmit flow upon reconnection, which allows the dds\n\t * to rebase them to the latest state, and then resubmit them.\n\t *\n\t * @param content - Contents of a stashed op.\n\t */\n\tprotected abstract applyStashedOp(content: unknown): void;\n\n\t/**\n\t * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,\n\t * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners\n\t * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events\n\t * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the\n\t * future.\n\t * @param event - The event to emit.\n\t * @param args - Arguments to pass to the event listeners.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t */\n\tpublic emit(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn this.callbacksHelper.measure(() => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn super.emit(event, ...args);\n\t\t});\n\t}\n\n\t/**\n\t * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement\n\t * done on the duration of the callbacks. Simply calls `super.emit()`.\n\t * @param event - Event to emit\n\t * @param args - Arguments for the event\n\t * @returns Whatever `super.emit()` returns.\n\t */\n\tprivate emitInternal(event: EventEmitterEventType, ...args: unknown[]): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n\n\tprivate throwUnsupported(featureName: string): never {\n\t\tthrow new LoggingError(\"Unsupported DDS feature\", {\n\t\t\tfeatureName,\n\t\t\t...tagCodeArtifacts({ ddsType: this.attributes.type }),\n\t\t});\n\t}\n}\n\n/**\n * Helper for implementing {@link ISharedObject} with simplified, synchronous summarization and garbage collection.\n * @remarks\n * DDS implementations with async and incremental summarization should extend {@link SharedObjectCore} directly instead.\n * @privateRemarks\n * TODO:\n * This class is badly named.\n * Once it becomes `@internal` \"SharedObjectCore\" should probably become \"SharedObject\"\n * and this class should be renamed to something like \"SharedObjectSynchronous\".\n * @legacy @beta\n */\nexport abstract class SharedObject<\n\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n> extends SharedObjectCore<TEvent> {\n\t/**\n\t * True while we are garbage collecting this object's data.\n\t */\n\tprivate _isGCing: boolean = false;\n\n\t/**\n\t * The serializer to use to serialize / parse handles, if any.\n\t */\n\tprivate readonly _serializer: IFluidSerializer;\n\n\tprotected get serializer(): IFluidSerializer {\n\t\t/**\n\t\t * During garbage collection, the GCHandleVisitor \"serializer\" keeps track of IFluidHandles that are serialized. These\n\t\t * handles represent references to other Fluid objects.\n\t\t *\n\t\t * This is fine for now. However, if we implement delay loading in DDSes, they may load and de-serialize content\n\t\t * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n\t\t */\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */,\n\t\t);\n\t\treturn this._serializer;\n\t}\n\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\t/**\n\t\t * The prefix to use for telemetry events emitted by this object.\n\t\t */\n\t\tprivate readonly telemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes);\n\n\t\tthis._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic getAttachSummary(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tundefined /* incrementalSummaryContext */,\n\t\t\tfullTree,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\t// Set _isGCing to true. This flag is used to ensure that we only use GCHandleVisitor in this codepath and not when trying to truly serialize.\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */,\n\t\t);\n\t\tthis._isGCing = true;\n\n\t\tlet gcData: IGarbageCollectionData;\n\t\ttry {\n\t\t\tconst handleVisitor = new GCHandleVisitor(this.runtime.channelsRoutingContext);\n\t\t\tthis.processGCDataCore(handleVisitor);\n\t\t\t// The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n\t\t\t// routes of handles serialized during summarization.\n\t\t\tgcData = { gcNodes: { \"/\": handleVisitor.getVisitedHandlePaths() } };\n\t\t\tassert(\n\t\t\t\tthis._isGCing,\n\t\t\t\t0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis._isGCing = false;\n\t\t}\n\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Calls the serializer over all data in this object that reference other GC nodes.\n\t * Derived classes must override this to provide custom list of references to other GC nodes.\n\t *\n\t * @remarks Serialization itself doesn't matter (the result is ignored). We're tapping into the serialization infrastructure\n\t * as a way to visit all the content in this content that may reference other objects via handle.\n\t *\n\t * @param serializer - The \"serializer\" (more like handle visitor) to use.\n\t * Implementations should ensure that serialize is called on all handles, as the way to visit them.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\t// We run the full summarize logic to get the list of outbound routes from this object. This is a little\n\t\t// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n\t\t// See: https://github.com/microsoft/FluidFramework/issues/4547\n\t\tthis.summarizeCore(serializer);\n\t}\n\n\t/**\n\t * Gets a form of the object that can be serialized.\n\t * @returns A tree representing the snapshot of the shared object.\n\t */\n\tprotected abstract summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\tprivate incrementTelemetryMetric(\n\t\tpropertyName: string,\n\t\tincrementBy: number,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): void {\n\t\tif (telemetryContext !== undefined) {\n\t\t\t// TelemetryContext needs to implment a get function\n\t\t\tassert(\n\t\t\t\t\"get\" in telemetryContext && typeof telemetryContext.get === \"function\",\n\t\t\t\t0x97e /* received context must have a get function */,\n\t\t\t);\n\n\t\t\tconst prevTotal = ((telemetryContext as TelemetryContext).get(\n\t\t\t\tthis.telemetryContextPrefix,\n\t\t\t\tpropertyName,\n\t\t\t) ?? 0) as number;\n\t\t\ttelemetryContext.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n\t\t}\n\t}\n}\n\n/**\n * Defines a kind of shared object.\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n *\n * @remarks\n * For use internally and in the \"encapsulated API\".\n * See {@link SharedObjectKind} for the type erased version for use in the public declarative API.\n *\n * @privateRemarks\n * This does not extend {@link SharedObjectKind} since doing so would prevent implementing this interface in type safe code.\n * Any implementation of this can safely be used as a {@link SharedObjectKind} with an explicit type conversion,\n * but doing so is typically not needed as {@link createSharedObjectKind} is used to produce values that are both types simultaneously.\n * @legacy @beta\n */\nexport interface ISharedObjectKind<TSharedObject> {\n\t/**\n\t * Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.\n\t * @remarks\n\t * The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels.\n\t * To create new shared objects use:\n\t *\n\t * - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.\n\t *\n\t * - {@link ISharedObjectKind.create} if using a custom container definitions (and thus not using {@link @fluidframework/fluid-static#IFluidContainer}).\n\t */\n\tgetFactory(): IChannelFactory<TSharedObject>;\n\n\t/**\n\t * Create a shared object.\n\t * @param runtime - The data store runtime that the new shared object belongs to.\n\t * @param id - Optional name of the shared object.\n\t * @returns Newly created shared object.\n\t *\n\t * @example\n\t * To create a `SharedTree`, call the static create method:\n\t *\n\t * ```typescript\n\t * const myTree = SharedTree.create(this.runtime, id);\n\t * ```\n\t * @remarks\n\t * The created object is local (detached): insert a handle to it into an attached object to share (attach) it.\n\t * If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.\n\t *\n\t * @privateRemarks\n\t * This can only be used with a `MockFluidDataStoreRuntime` when that mock is created with a `registry` containing a factory for this shared object.\n\t */\n\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;\n}\n\n/**\n * Defines a kind of shared object.\n * @remarks\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n * See {@link @fluidframework/fluid-static#IFluidContainer.create} and {@link @fluidframework/fluid-static#ContainerSchema} for details.\n * @privateRemarks\n * Part of the \"declarative API\".\n * Type erased reference to an {@link ISharedObjectKind} or a DataObject class in for use in\n * `fluid-static`'s `IFluidContainer` and `ContainerSchema`.\n * Use {@link createSharedObjectKind} to creating an instance of this type.\n * @sealed\n * @public\n */\nexport interface SharedObjectKind<out TSharedObject = unknown>\n\textends ErasedType<readonly [\"SharedObjectKind\", TSharedObject]> {\n\t/**\n\t * Check whether an {@link @fluidframework/core-interfaces#IFluidLoadable} is an instance of this shared object kind.\n\t * @remarks This should be used in place of `instanceof` checks for shared objects, as their actual classes are not exported in Fluid's public API.\n\t */\n\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject;\n}\n\n/**\n * Utility for creating ISharedObjectKind instances.\n * @remarks\n * This takes in a class which implements IChannelFactory,\n * and uses it to return a a single value which is intended to be used as the API entry point for the corresponding shared object type.\n * The returned value implements {@link ISharedObjectKind} for use in the encapsulated API, as well as the type erased {@link SharedObjectKind} used by the declarative API.\n * See {@link @fluidframework/fluid-static#ContainerSchema} for how this is used in the declarative API.\n * @internal\n */\nexport function createSharedObjectKind<TSharedObject>(\n\tfactory: (new () => IChannelFactory<TSharedObject>) & { readonly Type: string },\n): ISharedObjectKind<TSharedObject> & SharedObjectKind<TSharedObject> {\n\tconst result: ISharedObjectKind<TSharedObject> &\n\t\tOmit<SharedObjectKind<TSharedObject>, \"brand\"> = {\n\t\tgetFactory(): IChannelFactory<TSharedObject> {\n\t\t\treturn new factory();\n\t\t},\n\n\t\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject {\n\t\t\treturn runtime.createChannel(id, factory.Type) as TSharedObject;\n\t\t},\n\n\t\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject {\n\t\t\treturn isChannel(value) && value.attributes.type === factory.Type;\n\t\t},\n\t};\n\n\treturn result as typeof result & SharedObjectKind<TSharedObject>;\n}\n\nfunction isChannel(loadable: IFluidLoadable): loadable is IChannel {\n\t// This assumes no other IFluidLoadable has an `attributes` field, and thus may not be fully robust.\n\treturn (loadable as IChannel).attributes !== undefined;\n}\n"]}
|
|
@@ -101,7 +101,7 @@ _SharedObjectFromKernel_lazyData = new WeakMap(), _SharedObjectFromKernel_kernel
|
|
|
101
101
|
// Make `this` implement TOut.
|
|
102
102
|
mergeAPIs(this, data.view);
|
|
103
103
|
}, _SharedObjectFromKernel_kernel_get = function _SharedObjectFromKernel_kernel_get() {
|
|
104
|
-
return (__classPrivateFieldGet(this, _SharedObjectFromKernel_lazyData, "f") ?? (0, internal_1.fail)(
|
|
104
|
+
return (__classPrivateFieldGet(this, _SharedObjectFromKernel_lazyData, "f") ?? (0, internal_1.fail)(0xcb0 /* must initializeData first */)).kernel;
|
|
105
105
|
};
|
|
106
106
|
/**
|
|
107
107
|
* When present on a method, it indicates the methods return value should be replaced with `this` (the wrapper)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObjectKernel.js","sourceRoot":"","sources":["../src/sharedObjectKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAIH,kEAAmE;AAqBnE,uDAK2B;AAmE3B;;;;;;;;;;;GAWG;AACH,MAAM,sBAGJ,SAAQ,8BAAoB;IAW7B,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EACd,OAAkC,EAClD,sBAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC;;QAHvC,YAAO,GAAP,OAAO,CAA2B;QAdnD;;;;;WAKG;QACH,2CAA0C,SAAS,EAAC;QAE3C,qDAAwB;QAWhC,uBAAA,IAAI,sCAAe;YAClB,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,kBAAkB,EAAE,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,CAC3C,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,eAAe,CAAC;YAC7C,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB;YAC9D,qBAAqB,EAAE,IAAI,CAAC,YAAY,CAAC,qBAAqB;YAE9D,+HAA+H;YAC/H,8HAA8H;YAC9H,4HAA4H;YAC5H,4HAA4H;YAC5H,uBAAuB;YACvB,mBAAmB,EAAG,OAAgD;iBACpE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,EACV,QAA0B,EAC1B,UAA8B;YAE9B,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,UAAU,EACV,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YACF,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,MAAiC,CAAC;QAC1C,CAAC;QAED;;WAEG;QACI,MAAM,CAAC,OAA+B,EAAE,EAAU;YACxD,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,cAAc,CAAC,UAAU,EACzB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YAEF,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,OAAO,MAAiC,CAAC;QAC1C,CAAC;;IA3DD;;OAEG;IACoB,mBAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;OAEG;IACoB,yBAAU,GAAuB,OAAO,CAAC,UAAU,CAAC;IAsD5E,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CACnC,OAA+B;IAE/B,OAAO,IAAA,wCAAsB,EAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIChannelServices,\n\tIFluidDataStoreRuntime,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n\tIRuntimeMessageCollection,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { IFluidSerializer } from \"./serializer.js\";\nimport {\n\tcreateSharedObjectKind,\n\tSharedObject,\n\ttype ISharedObjectKind,\n\ttype SharedObjectKind,\n} from \"./sharedObject.js\";\nimport type { ISharedObjectEvents, ISharedObject } from \"./types.js\";\nimport type { IChannelView } from \"./utils.js\";\n\n/**\n * Functionality specific to a particular kind of {@link ISharedObject}.\n * @remarks\n * Shared objects expose APIs for two consumers:\n *\n * 1. The runtime, which uses {@link @fluidframework/datastore-definitions#IChannel} to summarize and apply ops and {@link @fluidframework/datastore-definitions#IChannelFactory} to create the load summaries.\n *\n * 2. The app, which uses shared object kind specific APIs to read and write data.\n *\n * There is some common functionality all shared objects use, provided by {@link SharedObject} and {@link SharedObjectCore}.\n * SharedKernel describes the portion of the behavior required by the runtime which\n * differs between different kinds of shared objects.\n *\n * {@link makeSharedObjectKind} is then used to wrap up the kernel into a full {@link ISharedObject} implementation.\n * The runtime specific APIs are then type erased into a {@link SharedObjectKind}.\n * @privateRemarks\n * Unlike the `SharedObject` class, this interface is internal, and thus can be adjusted more easily.\n * Therefore this interface is not intended to address all needs, and will likely need small changes as it gets more adoption.\n *\n * @internal\n */\nexport interface SharedKernel {\n\t/**\n\t * {@inheritDoc SharedObject.summarizeCore}\n\t */\n\tsummarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.onDisconnect}\n\t */\n\tonDisconnect(): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.reSubmitCore}\n\t */\n\treSubmitCore(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.applyStashedOp}\n\t */\n\tapplyStashedOp(content: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.processMessagesCore}\n\t */\n\tprocessMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.rollback}\n\t */\n\trollback?(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.didAttach}\n\t */\n\tdidAttach?(): void;\n}\n\n/**\n * SharedObject implementation that delegates to a SharedKernel.\n * @typeParam TOut - The type of the object exposed to the app.\n * Once initialized, instances of this class forward properties to the `TOut` value provided by the factory.\n * See {@link mergeAPIs} for more limitations.\n *\n * @remarks\n * The App facing API (TOut) needs to be implemented by this object which also has to implement the runtime facing API (ISharedObject).\n *\n * Requiring both of these to be implemented by the same object adds some otherwise unnecessary coupling.\n * This class is a workaround for that, which takes separate implementations of the two APIs and merges them into one using {@link mergeAPIs}.\n */\nclass SharedObjectFromKernel<\n\tTOut extends object,\n\tTEvent extends ISharedObjectEvents,\n> extends SharedObject<TEvent> {\n\t/**\n\t * Lazy init here so kernel can be constructed in loadCore when loading from existing data.\n\t *\n\t * Explicit initialization to undefined is done so Proxy knows this property is from this class (via `Reflect.has`),\n\t * not from the grafted APIs.\n\t */\n\t#lazyData: FactoryOut<TOut> | undefined = undefined;\n\n\treadonly #kernelArgs: KernelArgs;\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tpublic readonly factory: SharedKernelFactory<TOut>,\n\t\ttelemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.#kernelArgs = {\n\t\t\tsharedObject: this,\n\t\t\tserializer: this.serializer,\n\t\t\tsubmitLocalMessage: (op, localOpMetadata) =>\n\t\t\t\tthis.submitLocalMessage(op, localOpMetadata),\n\t\t\teventEmitter: this,\n\t\t\tlogger: this.logger,\n\t\t\tidCompressor: runtime.idCompressor,\n\t\t\tlastSequenceNumber: () => this.deltaManager.lastSequenceNumber,\n\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\n\t\t\t// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern\n\t\t\t// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes\n\t\t\t// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the\n\t\t\t// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler\n\t\t\t// would emit an error.\n\t\t\tminVersionForCollab: (runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t.minVersionForCollab,\n\t\t};\n\t}\n\n\tprotected override summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats {\n\t\treturn this.#kernel.summarizeCore(\n\t\t\tserializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t}\n\n\tprotected override initializeLocalCore(): void {\n\t\tthis.#initializeData(this.factory.create(this.#kernelArgs));\n\t}\n\n\t#initializeData(data: FactoryOut<TOut>): void {\n\t\tassert(\n\t\t\tthis.#lazyData === undefined,\n\t\t\t0xb99 /* initializeData must be called first and only once */,\n\t\t);\n\t\tthis.#lazyData = data;\n\n\t\t// Make `this` implement TOut.\n\t\tmergeAPIs(this, data.view);\n\t}\n\n\tget #kernel(): SharedKernel {\n\t\treturn (this.#lazyData ?? fail(\"must initializeData first\")).kernel;\n\t}\n\n\tprotected override async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tthis.#initializeData(await this.factory.loadCore(this.#kernelArgs, storage));\n\t}\n\n\tprotected override onDisconnect(): void {\n\t\tthis.#kernel.onDisconnect();\n\t}\n\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.#kernel.reSubmitCore(content, localOpMetadata);\n\t}\n\n\tprotected override applyStashedOp(content: unknown): void {\n\t\tthis.#kernel.applyStashedOp(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.#kernel.processMessagesCore(messagesCollection);\n\t}\n\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tif (this.#kernel.rollback === undefined) {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.#kernel.rollback(content, localOpMetadata);\n\t\t}\n\t}\n\n\tprotected override didAttach(): void {\n\t\tthis.#kernel.didAttach?.();\n\t}\n}\n\n/**\n * When present on a method, it indicates the methods return value should be replaced with `this` (the wrapper)\n * when wrapping the object with the method.\n * @remarks\n * This is useful when using {@link mergeAPIs} with methods where the return type is `this`, like `Map.set`.\n * @internal\n */\nexport const thisWrap: unique symbol = Symbol(\"selfWrap\");\n\n/**\n * A {@link SharedKernel} providing the implementation of some distributed data structure (DDS) and the needed runtime facing APIs,\n * and a separate view object which exposes the app facing APIs (`T`)\n * for reading and writing data which are specific to this particular data structure.\n * @remarks\n * Output from {@link SharedKernelFactory}.\n * This is an alternative to defining DDSs by sub-classing {@link SharedObject}.\n * @internal\n */\nexport interface FactoryOut<T extends object> {\n\treadonly kernel: SharedKernel;\n\treadonly view: T;\n}\n\n/**\n * A factory for creating DDSs.\n * @remarks\n * Outputs {@link FactoryOut}.\n * This is an alternative to directly implementing {@link @fluidframework/datastore-definitions#IChannelFactory}.\n * Use with {@link makeSharedObjectKind} to create a {@link SharedObjectKind}.\n * @internal\n */\nexport interface SharedKernelFactory<T extends object> {\n\tcreate(args: KernelArgs): FactoryOut<T>;\n\n\t/**\n\t * Create combined with {@link SharedObjectCore.loadCore}.\n\t */\n\tloadCore(args: KernelArgs, storage: IChannelStorageService): Promise<FactoryOut<T>>;\n}\n\n/**\n * Inputs for building a {@link SharedKernel} via {@link SharedKernelFactory}.\n * @internal\n */\nexport interface KernelArgs {\n\t/**\n\t * The shared object whose behavior is being implemented.\n\t */\n\treadonly sharedObject: IChannelView & IFluidLoadable;\n\t/**\n\t * {@inheritdoc SharedObject.serializer}\n\t */\n\treadonly serializer: IFluidSerializer;\n\t/**\n\t * {@inheritdoc SharedObjectCore.submitLocalMessage}\n\t */\n\treadonly submitLocalMessage: (op: unknown, localOpMetadata: unknown) => void;\n\t/**\n\t * Top level emitter for events for this object.\n\t * @remarks\n\t * This is needed since the separate kernel and view from {@link FactoryOut} currently have to be recombined,\n\t * and having this as its own thing helps accomplish that.\n\t */\n\treadonly eventEmitter: TypedEventEmitter<ISharedObjectEvents>;\n\t/**\n\t * {@inheritdoc SharedObjectCore.logger}\n\t */\n\treadonly logger: ITelemetryLoggerExt;\n\t/**\n\t * {@inheritdoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.idCompressor}\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.lastSequenceNumber}\n\t */\n\treadonly lastSequenceNumber: () => number;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.initialSequenceNumber}\n\t */\n\treadonly initialSequenceNumber: number;\n\t/**\n\t * Minimum version of the FF runtime that is required to collaborate on new documents. Used so that a\n\t * compatible set of feature flags and formats can be enabled in the SharedObject implementation.\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.minVersionForCollab} for more details.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab | undefined;\n}\n\n/**\n * Add getters to `base` which forward own properties from `extra`.\n * @remarks\n * This only handles use of \"get\" and \"has\".\n * Therefore, APIs involving setting properties should not be used as `Extra`.\n *\n * Functions from `extra` are bound to the `extra` object and support {@link thisWrap}.\n *\n * Asserts when properties collide.\n * @internal\n */\nexport function mergeAPIs<const Base extends object, const Extra extends object>(\n\tbase: Base,\n\textra: Extra,\n): asserts base is Base & Extra {\n\tfor (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(extra))) {\n\t\tassert(!Reflect.has(base, key), 0xb9a /* colliding properties */);\n\n\t\t// Detect and special case functions.\n\t\t// Currently this is done eagerly (when mergeAPIs is called) rather than lazily (when the property is read):\n\t\t// this eager approach should result in slightly better performance,\n\t\t// but if functions on `extra` are reassigned over time it will produce incorrect behavior.\n\t\t// If this functionality is required, the design can be changed.\n\t\tlet getter: () => unknown;\n\t\t// Bind functions to the extra object and handle thisWrap.\n\t\tif (typeof descriptor.value === \"function\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst fromExtra: () => Extra | Base = descriptor.value;\n\t\t\tgetter = () => forwardMethod(fromExtra, extra, base);\n\t\t\t// To catch (and error on) cases where the function is reassigned and this eager binding approach is not appropriate, make it non-writable.\n\t\t\tObject.defineProperty(extra, key, { ...descriptor, writable: false });\n\t\t} else {\n\t\t\tgetter = () => extra[key];\n\t\t}\n\n\t\tObject.defineProperty(base, key, {\n\t\t\tconfigurable: false,\n\t\t\tenumerable: descriptor.enumerable,\n\t\t\tget: getter,\n\t\t\t// If setters become required, support them here.\n\t\t});\n\t}\n}\n\n/**\n * Wrap a method `f` of `oldThis` to be a method of `newThis`.\n * @remarks\n * The wrapped function will be called with `oldThis` as the `this` parameter.\n * It also accounts for when `f` is marked with {@link thisWrap}.\n */\nfunction forwardMethod<TArgs extends [], TReturn>(\n\tf: (...args: TArgs) => TReturn,\n\toldThis: TReturn,\n\tnewThis: TReturn,\n): (...args: TArgs) => TReturn {\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (thisWrap in f) {\n\t\treturn (...args: TArgs) => {\n\t\t\tconst result = f.call(oldThis, ...args);\n\t\t\tassert(result === oldThis, 0xb9b /* methods returning thisWrap should return this */);\n\t\t\treturn newThis;\n\t\t};\n\t} else {\n\t\treturn f.bind(oldThis);\n\t}\n}\n\n/**\n * Options for creating a {@link SharedObjectKind} via {@link makeSharedObjectKind}.\n * @typeParam T - The type of the object exposed to the app.\n * This can optionally include members from {@link ISharedObject} which will be provided automatically.\n * @internal\n */\nexport interface SharedObjectOptions<T extends object> {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\treadonly type: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\treadonly attributes: IChannelAttributes;\n\n\t/**\n\t * The factory used to create the kernel and its view.\n\t * @remarks\n\t * The view produced by this factory will be grafted onto the {@link SharedObject} using {@link mergeAPIs}.\n\t * See {@link mergeAPIs} for more information on limitations that apply.\n\t */\n\treadonly factory: SharedKernelFactory<Omit<T, keyof ISharedObject>>;\n\n\t/**\n\t * {@inheritDoc SharedObject.telemetryContextPrefix}\n\t */\n\treadonly telemetryContextPrefix: string;\n}\n\n/**\n * Utility to create a {@link @fluidframework/datastore-definitions#IChannelFactory} classes.\n * @remarks\n * Use {@link makeSharedObjectKind} instead unless exposing the factory is required for legacy API compatibility.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction makeChannelFactory<T extends object>(options: SharedObjectOptions<T>) {\n\tclass ChannelFactory implements IChannelFactory<T> {\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic static readonly Type = options.type;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic static readonly Attributes: IChannelAttributes = options.attributes;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic get type(): string {\n\t\t\treturn ChannelFactory.Type;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic get attributes(): IChannelAttributes {\n\t\t\treturn ChannelFactory.Attributes;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t\t */\n\t\tpublic async load(\n\t\t\truntime: IFluidDataStoreRuntime,\n\t\t\tid: string,\n\t\t\tservices: IChannelServices,\n\t\t\tattributes: IChannelAttributes,\n\t\t): Promise<T & IChannel> {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tattributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\t\t\tawait shared.load(services);\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t\t */\n\t\tpublic create(runtime: IFluidDataStoreRuntime, id: string): T & IChannel {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tChannelFactory.Attributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\n\t\t\tshared.initializeLocal();\n\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\t}\n\n\treturn ChannelFactory;\n}\n\n/**\n * Utility to create a {@link SharedObjectKind}.\n * @privateRemarks\n * Using this API avoids having to subclasses any Fluid Framework types,\n * reducing the coupling between the framework and the SharedObject implementation.\n * @internal\n */\nexport function makeSharedObjectKind<T extends object>(\n\toptions: SharedObjectOptions<T>,\n): ISharedObjectKind<T> & SharedObjectKind<T> {\n\treturn createSharedObjectKind<T>(makeChannelFactory(options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedObjectKernel.js","sourceRoot":"","sources":["../src/sharedObjectKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAIH,kEAAmE;AAqBnE,uDAK2B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AC,UAAU,EACzB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YAEF,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,OAAO,MAAiC,CAAC;QAC1C,CAAC;;IA3DD;;OAEG;IACoB,mBAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;OAEG;IACoB,yBAAU,GAAuB,OAAO,CAAC,UAAU,CAAC;IAsD5E,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CACnC,OAA+B;IAE/B,OAAO,IAAA,wCAAsB,EAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIChannelServices,\n\tIFluidDataStoreRuntime,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n\tIRuntimeMessageCollection,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { IFluidSerializer } from \"./serializer.js\";\nimport {\n\tcreateSharedObjectKind,\n\tSharedObject,\n\ttype ISharedObjectKind,\n\ttype SharedObjectKind,\n} from \"./sharedObject.js\";\nimport type { ISharedObjectEvents, ISharedObject } from \"./types.js\";\nimport type { IChannelView } from \"./utils.js\";\n\n/**\n * Functionality specific to a particular kind of {@link ISharedObject}.\n * @remarks\n * Shared objects expose APIs for two consumers:\n *\n * 1. The runtime, which uses {@link @fluidframework/datastore-definitions#IChannel} to summarize and apply ops and {@link @fluidframework/datastore-definitions#IChannelFactory} to create the load summaries.\n *\n * 2. The app, which uses shared object kind specific APIs to read and write data.\n *\n * There is some common functionality all shared objects use, provided by {@link SharedObject} and {@link SharedObjectCore}.\n * SharedKernel describes the portion of the behavior required by the runtime which\n * differs between different kinds of shared objects.\n *\n * {@link makeSharedObjectKind} is then used to wrap up the kernel into a full {@link ISharedObject} implementation.\n * The runtime specific APIs are then type erased into a {@link SharedObjectKind}.\n * @privateRemarks\n * Unlike the `SharedObject` class, this interface is internal, and thus can be adjusted more easily.\n * Therefore this interface is not intended to address all needs, and will likely need small changes as it gets more adoption.\n *\n * @internal\n */\nexport interface SharedKernel {\n\t/**\n\t * {@inheritDoc SharedObject.summarizeCore}\n\t */\n\tsummarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.onDisconnect}\n\t */\n\tonDisconnect(): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.reSubmitCore}\n\t */\n\treSubmitCore(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.applyStashedOp}\n\t */\n\tapplyStashedOp(content: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.processMessagesCore}\n\t */\n\tprocessMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.rollback}\n\t */\n\trollback?(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.didAttach}\n\t */\n\tdidAttach?(): void;\n}\n\n/**\n * SharedObject implementation that delegates to a SharedKernel.\n * @typeParam TOut - The type of the object exposed to the app.\n * Once initialized, instances of this class forward properties to the `TOut` value provided by the factory.\n * See {@link mergeAPIs} for more limitations.\n *\n * @remarks\n * The App facing API (TOut) needs to be implemented by this object which also has to implement the runtime facing API (ISharedObject).\n *\n * Requiring both of these to be implemented by the same object adds some otherwise unnecessary coupling.\n * This class is a workaround for that, which takes separate implementations of the two APIs and merges them into one using {@link mergeAPIs}.\n */\nclass SharedObjectFromKernel<\n\tTOut extends object,\n\tTEvent extends ISharedObjectEvents,\n> extends SharedObject<TEvent> {\n\t/**\n\t * Lazy init here so kernel can be constructed in loadCore when loading from existing data.\n\t *\n\t * Explicit initialization to undefined is done so Proxy knows this property is from this class (via `Reflect.has`),\n\t * not from the grafted APIs.\n\t */\n\t#lazyData: FactoryOut<TOut> | undefined = undefined;\n\n\treadonly #kernelArgs: KernelArgs;\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tpublic readonly factory: SharedKernelFactory<TOut>,\n\t\ttelemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.#kernelArgs = {\n\t\t\tsharedObject: this,\n\t\t\tserializer: this.serializer,\n\t\t\tsubmitLocalMessage: (op, localOpMetadata) =>\n\t\t\t\tthis.submitLocalMessage(op, localOpMetadata),\n\t\t\teventEmitter: this,\n\t\t\tlogger: this.logger,\n\t\t\tidCompressor: runtime.idCompressor,\n\t\t\tlastSequenceNumber: () => this.deltaManager.lastSequenceNumber,\n\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\n\t\t\t// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern\n\t\t\t// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes\n\t\t\t// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the\n\t\t\t// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler\n\t\t\t// would emit an error.\n\t\t\tminVersionForCollab: (runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t.minVersionForCollab,\n\t\t};\n\t}\n\n\tprotected override summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats {\n\t\treturn this.#kernel.summarizeCore(\n\t\t\tserializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t}\n\n\tprotected override initializeLocalCore(): void {\n\t\tthis.#initializeData(this.factory.create(this.#kernelArgs));\n\t}\n\n\t#initializeData(data: FactoryOut<TOut>): void {\n\t\tassert(\n\t\t\tthis.#lazyData === undefined,\n\t\t\t0xb99 /* initializeData must be called first and only once */,\n\t\t);\n\t\tthis.#lazyData = data;\n\n\t\t// Make `this` implement TOut.\n\t\tmergeAPIs(this, data.view);\n\t}\n\n\tget #kernel(): SharedKernel {\n\t\treturn (this.#lazyData ?? fail(0xcb0 /* must initializeData first */)).kernel;\n\t}\n\n\tprotected override async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tthis.#initializeData(await this.factory.loadCore(this.#kernelArgs, storage));\n\t}\n\n\tprotected override onDisconnect(): void {\n\t\tthis.#kernel.onDisconnect();\n\t}\n\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.#kernel.reSubmitCore(content, localOpMetadata);\n\t}\n\n\tprotected override applyStashedOp(content: unknown): void {\n\t\tthis.#kernel.applyStashedOp(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.#kernel.processMessagesCore(messagesCollection);\n\t}\n\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tif (this.#kernel.rollback === undefined) {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.#kernel.rollback(content, localOpMetadata);\n\t\t}\n\t}\n\n\tprotected override didAttach(): void {\n\t\tthis.#kernel.didAttach?.();\n\t}\n}\n\n/**\n * When present on a method, it indicates the methods return value should be replaced with `this` (the wrapper)\n * when wrapping the object with the method.\n * @remarks\n * This is useful when using {@link mergeAPIs} with methods where the return type is `this`, like `Map.set`.\n * @internal\n */\nexport const thisWrap: unique symbol = Symbol(\"selfWrap\");\n\n/**\n * A {@link SharedKernel} providing the implementation of some distributed data structure (DDS) and the needed runtime facing APIs,\n * and a separate view object which exposes the app facing APIs (`T`)\n * for reading and writing data which are specific to this particular data structure.\n * @remarks\n * Output from {@link SharedKernelFactory}.\n * This is an alternative to defining DDSs by sub-classing {@link SharedObject}.\n * @internal\n */\nexport interface FactoryOut<T extends object> {\n\treadonly kernel: SharedKernel;\n\treadonly view: T;\n}\n\n/**\n * A factory for creating DDSs.\n * @remarks\n * Outputs {@link FactoryOut}.\n * This is an alternative to directly implementing {@link @fluidframework/datastore-definitions#IChannelFactory}.\n * Use with {@link makeSharedObjectKind} to create a {@link SharedObjectKind}.\n * @internal\n */\nexport interface SharedKernelFactory<T extends object> {\n\tcreate(args: KernelArgs): FactoryOut<T>;\n\n\t/**\n\t * Create combined with {@link SharedObjectCore.loadCore}.\n\t */\n\tloadCore(args: KernelArgs, storage: IChannelStorageService): Promise<FactoryOut<T>>;\n}\n\n/**\n * Inputs for building a {@link SharedKernel} via {@link SharedKernelFactory}.\n * @internal\n */\nexport interface KernelArgs {\n\t/**\n\t * The shared object whose behavior is being implemented.\n\t */\n\treadonly sharedObject: IChannelView & IFluidLoadable;\n\t/**\n\t * {@inheritdoc SharedObject.serializer}\n\t */\n\treadonly serializer: IFluidSerializer;\n\t/**\n\t * {@inheritdoc SharedObjectCore.submitLocalMessage}\n\t */\n\treadonly submitLocalMessage: (op: unknown, localOpMetadata: unknown) => void;\n\t/**\n\t * Top level emitter for events for this object.\n\t * @remarks\n\t * This is needed since the separate kernel and view from {@link FactoryOut} currently have to be recombined,\n\t * and having this as its own thing helps accomplish that.\n\t */\n\treadonly eventEmitter: TypedEventEmitter<ISharedObjectEvents>;\n\t/**\n\t * {@inheritdoc SharedObjectCore.logger}\n\t */\n\treadonly logger: ITelemetryLoggerExt;\n\t/**\n\t * {@inheritdoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.idCompressor}\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.lastSequenceNumber}\n\t */\n\treadonly lastSequenceNumber: () => number;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.initialSequenceNumber}\n\t */\n\treadonly initialSequenceNumber: number;\n\t/**\n\t * Minimum version of the FF runtime that is required to collaborate on new documents. Used so that a\n\t * compatible set of feature flags and formats can be enabled in the SharedObject implementation.\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.minVersionForCollab} for more details.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab | undefined;\n}\n\n/**\n * Add getters to `base` which forward own properties from `extra`.\n * @remarks\n * This only handles use of \"get\" and \"has\".\n * Therefore, APIs involving setting properties should not be used as `Extra`.\n *\n * Functions from `extra` are bound to the `extra` object and support {@link thisWrap}.\n *\n * Asserts when properties collide.\n * @internal\n */\nexport function mergeAPIs<const Base extends object, const Extra extends object>(\n\tbase: Base,\n\textra: Extra,\n): asserts base is Base & Extra {\n\tfor (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(extra))) {\n\t\tassert(!Reflect.has(base, key), 0xb9a /* colliding properties */);\n\n\t\t// Detect and special case functions.\n\t\t// Currently this is done eagerly (when mergeAPIs is called) rather than lazily (when the property is read):\n\t\t// this eager approach should result in slightly better performance,\n\t\t// but if functions on `extra` are reassigned over time it will produce incorrect behavior.\n\t\t// If this functionality is required, the design can be changed.\n\t\tlet getter: () => unknown;\n\t\t// Bind functions to the extra object and handle thisWrap.\n\t\tif (typeof descriptor.value === \"function\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst fromExtra: () => Extra | Base = descriptor.value;\n\t\t\tgetter = () => forwardMethod(fromExtra, extra, base);\n\t\t\t// To catch (and error on) cases where the function is reassigned and this eager binding approach is not appropriate, make it non-writable.\n\t\t\tObject.defineProperty(extra, key, { ...descriptor, writable: false });\n\t\t} else {\n\t\t\tgetter = () => extra[key];\n\t\t}\n\n\t\tObject.defineProperty(base, key, {\n\t\t\tconfigurable: false,\n\t\t\tenumerable: descriptor.enumerable,\n\t\t\tget: getter,\n\t\t\t// If setters become required, support them here.\n\t\t});\n\t}\n}\n\n/**\n * Wrap a method `f` of `oldThis` to be a method of `newThis`.\n * @remarks\n * The wrapped function will be called with `oldThis` as the `this` parameter.\n * It also accounts for when `f` is marked with {@link thisWrap}.\n */\nfunction forwardMethod<TArgs extends [], TReturn>(\n\tf: (...args: TArgs) => TReturn,\n\toldThis: TReturn,\n\tnewThis: TReturn,\n): (...args: TArgs) => TReturn {\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (thisWrap in f) {\n\t\treturn (...args: TArgs) => {\n\t\t\tconst result = f.call(oldThis, ...args);\n\t\t\tassert(result === oldThis, 0xb9b /* methods returning thisWrap should return this */);\n\t\t\treturn newThis;\n\t\t};\n\t} else {\n\t\treturn f.bind(oldThis);\n\t}\n}\n\n/**\n * Options for creating a {@link SharedObjectKind} via {@link makeSharedObjectKind}.\n * @typeParam T - The type of the object exposed to the app.\n * This can optionally include members from {@link ISharedObject} which will be provided automatically.\n * @internal\n */\nexport interface SharedObjectOptions<T extends object> {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\treadonly type: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\treadonly attributes: IChannelAttributes;\n\n\t/**\n\t * The factory used to create the kernel and its view.\n\t * @remarks\n\t * The view produced by this factory will be grafted onto the {@link SharedObject} using {@link mergeAPIs}.\n\t * See {@link mergeAPIs} for more information on limitations that apply.\n\t */\n\treadonly factory: SharedKernelFactory<Omit<T, keyof ISharedObject>>;\n\n\t/**\n\t * {@inheritDoc SharedObject.telemetryContextPrefix}\n\t */\n\treadonly telemetryContextPrefix: string;\n}\n\n/**\n * Utility to create a {@link @fluidframework/datastore-definitions#IChannelFactory} classes.\n * @remarks\n * Use {@link makeSharedObjectKind} instead unless exposing the factory is required for legacy API compatibility.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction makeChannelFactory<T extends object>(options: SharedObjectOptions<T>) {\n\tclass ChannelFactory implements IChannelFactory<T> {\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic static readonly Type = options.type;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic static readonly Attributes: IChannelAttributes = options.attributes;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic get type(): string {\n\t\t\treturn ChannelFactory.Type;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic get attributes(): IChannelAttributes {\n\t\t\treturn ChannelFactory.Attributes;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t\t */\n\t\tpublic async load(\n\t\t\truntime: IFluidDataStoreRuntime,\n\t\t\tid: string,\n\t\t\tservices: IChannelServices,\n\t\t\tattributes: IChannelAttributes,\n\t\t): Promise<T & IChannel> {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tattributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\t\t\tawait shared.load(services);\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t\t */\n\t\tpublic create(runtime: IFluidDataStoreRuntime, id: string): T & IChannel {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tChannelFactory.Attributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\n\t\t\tshared.initializeLocal();\n\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\t}\n\n\treturn ChannelFactory;\n}\n\n/**\n * Utility to create a {@link SharedObjectKind}.\n * @privateRemarks\n * Using this API avoids having to subclasses any Fluid Framework types,\n * reducing the coupling between the framework and the SharedObject implementation.\n * @internal\n */\nexport function makeSharedObjectKind<T extends object>(\n\toptions: SharedObjectOptions<T>,\n): ISharedObjectKind<T> & SharedObjectKind<T> {\n\treturn createSharedObjectKind<T>(makeChannelFactory(options));\n}\n"]}
|
package/eslint.config.mts
CHANGED
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* To regenerate: pnpm tsx scripts/generate-flat-eslint-configs.ts --typescript
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
5
4
|
*/
|
|
5
|
+
|
|
6
6
|
import type { Linter } from "eslint";
|
|
7
7
|
import { recommended } from "../../../common/build/eslint-config-fluid/flat.mts";
|
|
8
8
|
|
|
9
|
-
const config: Linter.Config[] = [
|
|
10
|
-
...recommended,
|
|
11
|
-
{
|
|
12
|
-
rules: {
|
|
13
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
14
|
-
"error",
|
|
15
|
-
{
|
|
16
|
-
"fixStyle": "inline-type-imports",
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
files: ["**/*.{ts,tsx}"],
|
|
24
|
-
ignores: ["**/src/test/**", "**/tests/**", "**/*.spec.ts", "**/*.test.ts"],
|
|
25
|
-
rules: {
|
|
26
|
-
"@typescript-eslint/consistent-type-exports": [
|
|
27
|
-
"error",
|
|
28
|
-
{
|
|
29
|
-
"fixMixedExportsWithInlineTypeSpecifier": true,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
];
|
|
9
|
+
const config: Linter.Config[] = [...recommended];
|
|
35
10
|
|
|
36
11
|
export default config;
|
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 = "2.
|
|
8
|
+
export declare const pkgVersion = "2.81.0";
|
|
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 = \"2.
|
|
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 = \"2.81.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,KAAK,EACX,oBAAoB,EACpB,cAAc,EACd,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EACX,gBAAgB,EAChB,sBAAsB,EAEtB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EAGtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACX,gBAAgB,EAChB,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,KAAK,sCAAsC,EAC3C,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAG3B,KAAK,yBAAyB,EAE9B,MAAM,8CAA8C,CAAC;AAKtD,OAAO,EACN,KAAK,mBAAmB,EAExB,6BAA6B,EAS7B,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,mB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AAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAiBpE"}
|
package/lib/sharedObject.js
CHANGED
|
@@ -118,6 +118,7 @@ export class SharedObjectCore extends EventEmitterWithErrorHandling {
|
|
|
118
118
|
* @param error - error object that is thrown whenever an attempt is made to modify this object
|
|
119
119
|
*/
|
|
120
120
|
closeWithError(error) {
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy
|
|
121
122
|
if (this.closeError === undefined) {
|
|
122
123
|
this.closeError = error;
|
|
123
124
|
}
|
package/lib/sharedObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAOpE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAe7D,OAAO,EAKN,qBAAqB,EACrB,yBAAyB,GAGzB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,sBAAsB,GAEtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAEN,mBAAmB,EACnB,6BAA6B,EAE7B,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAGhB,YAAY,GACZ,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAyB,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAWhF;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAgB,gBAGrB,SAAQ,6BAAqC;IAG7C,IAAW,c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W;YAClD,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAkB,CAAC;QACjE,CAAC;QAED,EAAE,CAAC,KAAqB;YACvB,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;QACnE,CAAC;KACD,CAAC;IAEF,OAAO,MAAyD,CAAC;AAClE,CAAC;AAED,SAAS,SAAS,CAAC,QAAwB;IAC1C,oGAAoG;IACpG,OAAQ,QAAqB,CAAC,UAAU,KAAK,SAAS,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport type { ITelemetryBaseProperties, ErasedType } from \"@fluidframework/core-interfaces\";\nimport type {\n\tIFluidHandleInternal,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelServices,\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIDeltaHandler,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype IGarbageCollectionData,\n\tblobCountPropertyName,\n\ttotalBlobSizePropertyName,\n\ttype IRuntimeMessageCollection,\n\ttype IRuntimeMessagesContent,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttoDeltaManagerInternal,\n\ttype TelemetryContext,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tDataProcessingError,\n\tEventEmitterWithErrorHandling,\n\ttype MonitoringContext,\n\tSampledTelemetryHelper,\n\tcreateChildLogger,\n\tloggerToMonitoringContext,\n\ttagCodeArtifacts,\n\ttype ICustomData,\n\ttype IFluidErrorBase,\n\tLoggingError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { GCHandleVisitor } from \"./gcHandleVisitor.js\";\nimport { SharedObjectHandle } from \"./handle.js\";\nimport { FluidSerializer, type IFluidSerializer } from \"./serializer.js\";\nimport type { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nimport { bindHandles, makeHandlesSerializable, parseHandles } from \"./utils.js\";\n\n/**\n * Custom telemetry properties used in {@link SharedObjectCore} to instantiate {@link TelemetryEventBatcher} class.\n * This interface is used to define the properties that will be passed to the {@link TelemetryEventBatcher.measure} function\n * which is called in the {@link SharedObjectCore.process} method.\n */\ninterface ProcessTelemetryProperties {\n\tsequenceDifference: number;\n}\n\n/**\n * Base class from which all {@link ISharedObject|shared objects} derive.\n * @remarks\n * This class implements common behaviors that implementations of {@link ISharedObject} may want to reuse.\n * Even more such behaviors are implemented in the {@link SharedObject} class.\n * @privateRemarks\n * Currently some documentation (like the above) implies that this is supposed to be the only implementation of ISharedObject, which is both package-exported and not `@sealed`.\n * This situation should be clarified to indicate if other implementations of ISharedObject are allowed and just currently don't exist,\n * or if the intention is that no other implementations should exist and creating some might break things.\n * As part of this, any existing implementations of ISharedObject (via SharedObjectCore or otherwise) in use by legacy API users will need to be considered.\n *\n * TODO:\n * This class should eventually be made internal, as custom subclasses of it outside this repository are intended to be made unsupported in the future.\n * @legacy @beta\n */\nexport abstract class SharedObjectCore<\n\t\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n\t>\n\textends EventEmitterWithErrorHandling<TEvent>\n\timplements ISharedObject<TEvent>\n{\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly opProcessingHelper: SampledTelemetryHelper<\n\t\tvoid,\n\t\tProcessTelemetryProperties\n\t>;\n\tprivate readonly callbacksHelper: SampledTelemetryHelper<boolean>;\n\n\t/**\n\t * The handle referring to this SharedObject\n\t */\n\tpublic readonly handle: IFluidHandleInternal;\n\n\t/**\n\t * Telemetry logger for the shared object\n\t */\n\tprotected readonly logger: ITelemetryLoggerExt;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Connection state\n\t */\n\tprivate _connected = false;\n\n\t/**\n\t * Services used by the shared object\n\t */\n\tprivate services: IChannelServices | undefined;\n\n\t/**\n\t * True if the dds is bound to its parent.\n\t */\n\tprivate _isBoundToContext: boolean = false;\n\n\t/**\n\t * Tracks error that closed this object.\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * Gets the connection state\n\t * @returns The state of the connection\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\tconstructor(\n\t\t/**\n\t\t * The ID of the shared object.\n\t\t */\n\t\tpublic id: string,\n\t\t/**\n\t\t * The runtime instance that contains the Shared Object.\n\t\t */\n\t\tprotected runtime: IFluidDataStoreRuntime,\n\t\t/**\n\t\t * The attributes of the Shared Object.\n\t\t */\n\t\tpublic readonly attributes: IChannelAttributes,\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) =>\n\t\t\tthis.eventListenerErrorHandler(event, e),\n\t\t);\n\n\t\tassert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n\t\tthis.handle = new SharedObjectHandle(this, id, runtime);\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: runtime.logger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\tsharedObjectId: uuid(),\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tddsType: this.attributes.type,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.mc = loggerToMonitoringContext(this.logger);\n\n\t\tconst { opProcessingHelper, callbacksHelper } = this.setUpSampledTelemetryHelpers();\n\t\tthis.opProcessingHelper = opProcessingHelper;\n\t\tthis.callbacksHelper = callbacksHelper;\n\t}\n\n\t/**\n\t * Accessor for `this.runtime`'s {@link @fluidframework/datastore-definitions#IFluidDataStoreRuntime.deltaManager} as a {@link @fluidframework/container-definitions/internal#IDeltaManager}\n\t */\n\tprotected get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n\t\treturn toDeltaManagerInternal(this.runtime.deltaManager);\n\t}\n\n\t/**\n\t * This function is only supposed to be called from SharedObjectCore's constructor and\n\t * depends on a few things being set already. assert() calls make sure of it.\n\t * @returns The telemetry sampling helpers, so the constructor can be the one to assign them\n\t * to variables to avoid complaints from TypeScript.\n\t */\n\tprivate setUpSampledTelemetryHelpers(): {\n\t\topProcessingHelper: SampledTelemetryHelper<void, ProcessTelemetryProperties>;\n\t\tcallbacksHelper: SampledTelemetryHelper<boolean>;\n\t} {\n\t\tassert(\n\t\t\tthis.mc !== undefined && this.logger !== undefined,\n\t\t\t0x349 /* this.mc and/or this.logger has not been set */,\n\t\t);\n\t\tconst opProcessingHelper = new SampledTelemetryHelper<void, ProcessTelemetryProperties>(\n\t\t\t{\n\t\t\t\teventName: \"ddsOpProcessing\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.OpProcessingTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t\tnew Map<string, ITelemetryBaseProperties>([\n\t\t\t\t[\"local\", { localOp: true }],\n\t\t\t\t[\"remote\", { localOp: false }],\n\t\t\t]),\n\t\t);\n\t\tconst callbacksHelper = new SampledTelemetryHelper<boolean>(\n\t\t\t{\n\t\t\t\teventName: \"ddsEventCallbacks\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.DdsCallbacksTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t);\n\n\t\tthis.runtime.once(\"dispose\", () => {\n\t\t\tthis.callbacksHelper.dispose();\n\t\t\tthis.opProcessingHelper.dispose();\n\t\t});\n\n\t\treturn { opProcessingHelper, callbacksHelper };\n\t}\n\n\t/**\n\t * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n\t * would result in same error thrown. If called multiple times, only first error is remembered.\n\t * @param error - error object that is thrown whenever an attempt is made to modify this object\n\t */\n\tprivate closeWithError(error: IFluidErrorBase | undefined): void {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n\t * It wraps error with DataProcessingError, closes this object and throws resulting error.\n\t * See closeWithError() for more details\n\t * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n\t * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n\t * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n\t * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n\t * allow processing of ops or local changes, which very quickly results in container closure.\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(\n\t\t\te,\n\t\t\t\"SharedObjectEventListenerException\",\n\t\t);\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\tprivate setBoundAndHandleAttach(): void {\n\t\t// Ensure didAttach is only called once, and we only register a single event\n\t\t// but we still call setConnectionState as our existing mocks don't\n\t\t// always propagate connection state\n\t\tthis.setBoundAndHandleAttach = () => this.setConnectionState(this.runtime.connected);\n\t\tthis._isBoundToContext = true;\n\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\tconst runDidAttach: () => void = () => {\n\t\t\t// Allows objects to do any custom processing if it is attached.\n\t\t\tthis.didAttach();\n\t\t\tthis.setConnectionState(this.runtime.connected);\n\t\t};\n\t\tif (this.isAttached()) {\n\t\t\trunDidAttach();\n\t\t} else {\n\t\t\tthis.runtime.once(\"attaching\", runDidAttach);\n\t\t}\n\t}\n\n\t/**\n\t * A shared object, after construction, can either be loaded in the case that it is already part of\n\t * a shared document. Or later attached if it is being newly added.\n\t * @param services - Services used by the shared object\n\t */\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tthis.services = services;\n\t\t// set this before load so that isAttached is true\n\t\t// for attached runtimes when load core is running\n\t\tthis._isBoundToContext = true;\n\t\tawait this.loadCore(services.objectStorage);\n\t\tthis.attachDeltaHandler();\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * Initializes the object as a local, non-shared object. This object can become shared after\n\t * it is attached to the document.\n\t */\n\tpublic initializeLocal(): void {\n\t\tthis.initializeLocalCore();\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).bindToContext}\n\t */\n\tpublic bindToContext(): void {\n\t\t// ensure the method only runs once by removing the implementation\n\t\t// without this the method suffers from re-entrancy issues\n\t\tthis.bindToContext = () => {};\n\t\tif (!this._isBoundToContext) {\n\t\t\tthis.runtime.bindChannel(this);\n\t\t\t// must set after bind channel so isAttached doesn't report true\n\t\t\t// before binding is complete\n\t\t\tthis.setBoundAndHandleAttach();\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n\t */\n\tpublic connect(services: IChannelServices): void {\n\t\t// handle the case where load is called\n\t\t// before connect; loading detached data stores\n\t\tif (this.services === undefined) {\n\t\t\tthis.services = services;\n\t\t\tthis.attachDeltaHandler();\n\t\t}\n\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n\t */\n\tpublic isAttached(): boolean {\n\t\treturn this._isBoundToContext && this.runtime.attachState !== AttachState.Detached;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic abstract getAttachSummary(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic abstract summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}\n\t */\n\tpublic abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the distributed data type to perform custom loading\n\t * @param services - Storage used by the shared object\n\t */\n\tprotected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n\t/**\n\t * Allows the distributed data type to perform custom local loading.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n\t * Also called after non-local data type get loaded.\n\t */\n\tprotected didAttach(): void {\n\t\treturn;\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Derived classes must override this to do custom processing on a 'bunch' of remote messages.\n\t * @remarks\n\t * A 'bunch' is a group of messages that have the following properties:\n\t * - They are all part of the same grouped batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t * - They are not interleaved with messages from other DDS in the container.\n\t * Derived classes should override this if they need to do custom processing on a 'bunch' of remote messages.\n\t * @param messageCollection - The collection of messages to process.\n\t *\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tprotected abstract processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\n\tprotected abstract onDisconnect(): void;\n\n\t/**\n\t * The serializer to serialize / parse handles.\n\t */\n\tprotected abstract get serializer(): IFluidSerializer;\n\n\t/**\n\t * Submits a message by the local client to the runtime.\n\t * @param content - Content of the message. Note: handles contained in the\n\t * message object should not be encoded in any way\n\t * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t */\n\tprotected submitLocalMessage(content: unknown, localOpMetadata: unknown = undefined): void {\n\t\tthis.verifyNotClosed();\n\t\tif (this.isAttached()) {\n\t\t\t// NOTE: We may also be encoding in the ContainerRuntime layer.\n\t\t\t// Once the layer-compat window passes we can remove the encoding codepath here altogether\n\t\t\tconst onlyBind =\n\t\t\t\t(this.runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t\t.submitMessagesWithoutEncodingHandles === true;\n\t\t\tconst contentToSubmit = onlyBind\n\t\t\t\t? bindHandles(content, this.handle)\n\t\t\t\t: makeHandlesSerializable(content, this.serializer, this.handle);\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(contentToSubmit, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n\t * that want to be part of summary but does not generate ops.\n\t */\n\tprotected dirty(): void {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.services!.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Called when the object has fully connected to the delta stream\n\t * Default implementation for DDS, override if different behavior is required.\n\t */\n\tprotected onConnect(): void {}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n\t * The default implementation here is to resubmit the same message. The client can override if different behavior\n\t * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n\t * anything at all.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.submitLocalMessage(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted but its content should be \"squashed\" if any subsequent pending changes\n\t * override the content in the fashion described on {@link @fluidframework/datastore-definitions#IDeltaHandler.reSubmit}.\n\t *\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitSquashed(content: unknown, localOpMetadata: unknown): void {\n\t\tconst allowStagingModeWithoutSquashing =\n\t\t\tloggerToMonitoringContext(this.logger).config.getBoolean(\n\t\t\t\t\"Fluid.SharedObject.AllowStagingModeWithoutSquashing\",\n\t\t\t) ??\n\t\t\t(this.runtime.options.allowStagingModeWithoutSquashing as boolean | undefined) ??\n\t\t\ttrue;\n\t\tif (allowStagingModeWithoutSquashing) {\n\t\t\tthis.reSubmitCore(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.throwUnsupported(\"reSubmitSquashed\");\n\t\t}\n\t}\n\n\t/**\n\t * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n\t * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n\t * the Promise will reject.\n\t * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n\t */\n\tprotected async newAckBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: unknown) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.runtime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.runtime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\t// Note: rejectBecauseDispose will never be undefined here\n\t\t\tthis.runtime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n\n\tprivate attachDeltaHandler(): void {\n\t\t// Services should already be there in case we are attaching delta handler.\n\t\tassert(\n\t\t\tthis.services !== undefined,\n\t\t\t0x07a /* \"Services should be there to attach delta handler\" */,\n\t\t);\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.services.deltaConnection.attach({\n\t\t\tprocessMessages: (messagesCollection: IRuntimeMessageCollection) => {\n\t\t\t\tthis.processMessages(messagesCollection);\n\t\t\t},\n\t\t\tsetConnectionState: (connected: boolean) => {\n\t\t\t\tthis.setConnectionState(connected);\n\t\t\t},\n\t\t\treSubmit: (content: unknown, localOpMetadata: unknown, squash: boolean) => {\n\t\t\t\tthis.reSubmit(content, localOpMetadata, squash);\n\t\t\t},\n\t\t\tapplyStashedOp: (content: unknown): void => {\n\t\t\t\tthis.applyStashedOp(parseHandles(content, this.serializer));\n\t\t\t},\n\t\t\trollback: (content: unknown, localOpMetadata: unknown) => {\n\t\t\t\tthis.rollback(content, localOpMetadata);\n\t\t\t},\n\t\t} satisfies IDeltaHandler);\n\t}\n\n\t/**\n\t * Set the state of connection to services.\n\t * @param connected - true if connected, false otherwise.\n\t */\n\tprivate setConnectionState(connected: boolean): void {\n\t\t// only an attached shared object can transition its\n\t\t// connected state. This is defensive, as some\n\t\t// of our test harnesses don't handle this correctly\n\t\tif (!this.isAttached() || this._connected === connected) {\n\t\t\t// Not changing state, nothing the same.\n\t\t\treturn;\n\t\t}\n\n\t\t// Should I change the state at the end? So that we *can't* send new stuff before we send old?\n\t\tthis._connected = connected;\n\n\t\tif (connected) {\n\t\t\t// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending\n\t\t\t// messages will work.\n\t\t\tthis.onConnect();\n\t\t} else {\n\t\t\t// Things that are true now...\n\t\t\t// - if we had a connection we can no longer send messages over it\n\t\t\t// - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n\t\t\t//\n\t\t\t// - nack could get a new msn - but might as well do it in the join?\n\t\t\tthis.onDisconnect();\n\t\t}\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Process a bunch of messages for this shared object. A bunch is group of messages that have the following properties:\n\t * - They are all part of the same grouped batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t * - They are not interleaved with messages from other DDS in the container.\n\t * @param messageCollection - The collection of messages to process.\n\t *\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tprivate processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.verifyNotClosed(); // This will result in container closure.\n\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\n\t\t// Decode any handles in the contents before processing the messages.\n\t\tconst decodedMessagesContent: IRuntimeMessagesContent[] = [];\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tconst decodedMessageContent: IRuntimeMessagesContent = {\n\t\t\t\tcontents: parseHandles(contents, this.serializer),\n\t\t\t\tlocalOpMetadata,\n\t\t\t\tclientSequenceNumber,\n\t\t\t};\n\t\t\tdecodedMessagesContent.push(decodedMessageContent);\n\t\t}\n\n\t\tconst emitEvents = (event: \"pre-op\" | \"op\"): void => {\n\t\t\tfor (const { contents, clientSequenceNumber } of decodedMessagesContent) {\n\t\t\t\tconst message: ISequencedDocumentMessage = {\n\t\t\t\t\t...envelope,\n\t\t\t\t\tcontents,\n\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t};\n\t\t\t\tthis.emitInternal(event, message, local);\n\t\t\t}\n\t\t};\n\n\t\temitEvents(\"pre-op\");\n\t\tthis.opProcessingHelper.measure(\n\t\t\t(): ICustomData<ProcessTelemetryProperties> => {\n\t\t\t\tconst decodedMessagesCollection: IRuntimeMessageCollection = {\n\t\t\t\t\tenvelope,\n\t\t\t\t\tlocal,\n\t\t\t\t\tmessagesContent: decodedMessagesContent,\n\t\t\t\t};\n\t\t\t\tthis.processMessagesCore(decodedMessagesCollection);\n\t\t\t\tconst telemetryProperties: ProcessTelemetryProperties = {\n\t\t\t\t\tsequenceDifference: envelope.sequenceNumber - envelope.referenceSequenceNumber,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tcustomData: telemetryProperties,\n\t\t\t\t};\n\t\t\t},\n\t\t\tlocal ? \"local\" : \"remote\",\n\t\t);\n\t\temitEvents(\"op\");\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n\t * reconnection.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t * @param squash - If `true`, the message will be resubmitted in a squashed form. If `false`,\n\t * the legacy behavior (no squashing) will be used.\n\t */\n\tprivate reSubmit(content: unknown, localOpMetadata: unknown, squash: boolean): void {\n\t\tif (squash) {\n\t\t\tthis.reSubmitSquashed(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.reSubmitCore(content, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.throwUnsupported(\"rollback\");\n\t}\n\n\t/**\n\t * Apply changes from the provided op content just as if a local client has made the change,\n\t * including submitting the op. Used when rehydrating an attached container\n\t * with pending changes. The rehydration process replays all remote ops\n\t * and applies stashed ops after the remote op with a sequence number\n\t * that matches that of the stashed op is applied. This ensures\n\t * stashed ops are applied at the same state they were originally created.\n\t *\n\t * It is possible that stashed ops have been sent in the past, and will be found when\n\t * the shared object catches up with remotes ops.\n\t * So this prepares the SharedObject for seeing potentially seeing the ACK.\n\t * If no matching remote op is found, all the applied stashed ops will go\n\t * through the normal resubmit flow upon reconnection, which allows the dds\n\t * to rebase them to the latest state, and then resubmit them.\n\t *\n\t * @param content - Contents of a stashed op.\n\t */\n\tprotected abstract applyStashedOp(content: unknown): void;\n\n\t/**\n\t * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,\n\t * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners\n\t * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events\n\t * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the\n\t * future.\n\t * @param event - The event to emit.\n\t * @param args - Arguments to pass to the event listeners.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t */\n\tpublic emit(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn this.callbacksHelper.measure(() => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn super.emit(event, ...args);\n\t\t});\n\t}\n\n\t/**\n\t * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement\n\t * done on the duration of the callbacks. Simply calls `super.emit()`.\n\t * @param event - Event to emit\n\t * @param args - Arguments for the event\n\t * @returns Whatever `super.emit()` returns.\n\t */\n\tprivate emitInternal(event: EventEmitterEventType, ...args: unknown[]): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n\n\tprivate throwUnsupported(featureName: string): never {\n\t\tthrow new LoggingError(\"Unsupported DDS feature\", {\n\t\t\tfeatureName,\n\t\t\t...tagCodeArtifacts({ ddsType: this.attributes.type }),\n\t\t});\n\t}\n}\n\n/**\n * Helper for implementing {@link ISharedObject} with simplified, synchronous summarization and garbage collection.\n * @remarks\n * DDS implementations with async and incremental summarization should extend {@link SharedObjectCore} directly instead.\n * @privateRemarks\n * TODO:\n * This class is badly named.\n * Once it becomes `@internal` \"SharedObjectCore\" should probably become \"SharedObject\"\n * and this class should be renamed to something like \"SharedObjectSynchronous\".\n * @legacy @beta\n */\nexport abstract class SharedObject<\n\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n> extends SharedObjectCore<TEvent> {\n\t/**\n\t * True while we are garbage collecting this object's data.\n\t */\n\tprivate _isGCing: boolean = false;\n\n\t/**\n\t * The serializer to use to serialize / parse handles, if any.\n\t */\n\tprivate readonly _serializer: IFluidSerializer;\n\n\tprotected get serializer(): IFluidSerializer {\n\t\t/**\n\t\t * During garbage collection, the GCHandleVisitor \"serializer\" keeps track of IFluidHandles that are serialized. These\n\t\t * handles represent references to other Fluid objects.\n\t\t *\n\t\t * This is fine for now. However, if we implement delay loading in DDSes, they may load and de-serialize content\n\t\t * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n\t\t */\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */,\n\t\t);\n\t\treturn this._serializer;\n\t}\n\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\t/**\n\t\t * The prefix to use for telemetry events emitted by this object.\n\t\t */\n\t\tprivate readonly telemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes);\n\n\t\tthis._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic getAttachSummary(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tundefined /* incrementalSummaryContext */,\n\t\t\tfullTree,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\t// Set _isGCing to true. This flag is used to ensure that we only use GCHandleVisitor in this codepath and not when trying to truly serialize.\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */,\n\t\t);\n\t\tthis._isGCing = true;\n\n\t\tlet gcData: IGarbageCollectionData;\n\t\ttry {\n\t\t\tconst handleVisitor = new GCHandleVisitor(this.runtime.channelsRoutingContext);\n\t\t\tthis.processGCDataCore(handleVisitor);\n\t\t\t// The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n\t\t\t// routes of handles serialized during summarization.\n\t\t\tgcData = { gcNodes: { \"/\": handleVisitor.getVisitedHandlePaths() } };\n\t\t\tassert(\n\t\t\t\tthis._isGCing,\n\t\t\t\t0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis._isGCing = false;\n\t\t}\n\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Calls the serializer over all data in this object that reference other GC nodes.\n\t * Derived classes must override this to provide custom list of references to other GC nodes.\n\t *\n\t * @remarks Serialization itself doesn't matter (the result is ignored). We're tapping into the serialization infrastructure\n\t * as a way to visit all the content in this content that may reference other objects via handle.\n\t *\n\t * @param serializer - The \"serializer\" (more like handle visitor) to use.\n\t * Implementations should ensure that serialize is called on all handles, as the way to visit them.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\t// We run the full summarize logic to get the list of outbound routes from this object. This is a little\n\t\t// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n\t\t// See: https://github.com/microsoft/FluidFramework/issues/4547\n\t\tthis.summarizeCore(serializer);\n\t}\n\n\t/**\n\t * Gets a form of the object that can be serialized.\n\t * @returns A tree representing the snapshot of the shared object.\n\t */\n\tprotected abstract summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\tprivate incrementTelemetryMetric(\n\t\tpropertyName: string,\n\t\tincrementBy: number,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): void {\n\t\tif (telemetryContext !== undefined) {\n\t\t\t// TelemetryContext needs to implment a get function\n\t\t\tassert(\n\t\t\t\t\"get\" in telemetryContext && typeof telemetryContext.get === \"function\",\n\t\t\t\t0x97e /* received context must have a get function */,\n\t\t\t);\n\n\t\t\tconst prevTotal = ((telemetryContext as TelemetryContext).get(\n\t\t\t\tthis.telemetryContextPrefix,\n\t\t\t\tpropertyName,\n\t\t\t) ?? 0) as number;\n\t\t\ttelemetryContext.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n\t\t}\n\t}\n}\n\n/**\n * Defines a kind of shared object.\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n *\n * @remarks\n * For use internally and in the \"encapsulated API\".\n * See {@link SharedObjectKind} for the type erased version for use in the public declarative API.\n *\n * @privateRemarks\n * This does not extend {@link SharedObjectKind} since doing so would prevent implementing this interface in type safe code.\n * Any implementation of this can safely be used as a {@link SharedObjectKind} with an explicit type conversion,\n * but doing so is typically not needed as {@link createSharedObjectKind} is used to produce values that are both types simultaneously.\n * @legacy @beta\n */\nexport interface ISharedObjectKind<TSharedObject> {\n\t/**\n\t * Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.\n\t * @remarks\n\t * The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels.\n\t * To create new shared objects use:\n\t *\n\t * - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.\n\t *\n\t * - {@link ISharedObjectKind.create} if using a custom container definitions (and thus not using {@link @fluidframework/fluid-static#IFluidContainer}).\n\t */\n\tgetFactory(): IChannelFactory<TSharedObject>;\n\n\t/**\n\t * Create a shared object.\n\t * @param runtime - The data store runtime that the new shared object belongs to.\n\t * @param id - Optional name of the shared object.\n\t * @returns Newly created shared object.\n\t *\n\t * @example\n\t * To create a `SharedTree`, call the static create method:\n\t *\n\t * ```typescript\n\t * const myTree = SharedTree.create(this.runtime, id);\n\t * ```\n\t * @remarks\n\t * The created object is local (detached): insert a handle to it into an attached object to share (attach) it.\n\t * If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.\n\t *\n\t * @privateRemarks\n\t * This can only be used with a `MockFluidDataStoreRuntime` when that mock is created with a `registry` containing a factory for this shared object.\n\t */\n\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;\n}\n\n/**\n * Defines a kind of shared object.\n * @remarks\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n * See {@link @fluidframework/fluid-static#IFluidContainer.create} and {@link @fluidframework/fluid-static#ContainerSchema} for details.\n * @privateRemarks\n * Part of the \"declarative API\".\n * Type erased reference to an {@link ISharedObjectKind} or a DataObject class in for use in\n * `fluid-static`'s `IFluidContainer` and `ContainerSchema`.\n * Use {@link createSharedObjectKind} to creating an instance of this type.\n * @sealed\n * @public\n */\nexport interface SharedObjectKind<out TSharedObject = unknown>\n\textends ErasedType<readonly [\"SharedObjectKind\", TSharedObject]> {\n\t/**\n\t * Check whether an {@link @fluidframework/core-interfaces#IFluidLoadable} is an instance of this shared object kind.\n\t * @remarks This should be used in place of `instanceof` checks for shared objects, as their actual classes are not exported in Fluid's public API.\n\t */\n\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject;\n}\n\n/**\n * Utility for creating ISharedObjectKind instances.\n * @remarks\n * This takes in a class which implements IChannelFactory,\n * and uses it to return a a single value which is intended to be used as the API entry point for the corresponding shared object type.\n * The returned value implements {@link ISharedObjectKind} for use in the encapsulated API, as well as the type erased {@link SharedObjectKind} used by the declarative API.\n * See {@link @fluidframework/fluid-static#ContainerSchema} for how this is used in the declarative API.\n * @internal\n */\nexport function createSharedObjectKind<TSharedObject>(\n\tfactory: (new () => IChannelFactory<TSharedObject>) & { readonly Type: string },\n): ISharedObjectKind<TSharedObject> & SharedObjectKind<TSharedObject> {\n\tconst result: ISharedObjectKind<TSharedObject> &\n\t\tOmit<SharedObjectKind<TSharedObject>, \"brand\"> = {\n\t\tgetFactory(): IChannelFactory<TSharedObject> {\n\t\t\treturn new factory();\n\t\t},\n\n\t\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject {\n\t\t\treturn runtime.createChannel(id, factory.Type) as TSharedObject;\n\t\t},\n\n\t\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject {\n\t\t\treturn isChannel(value) && value.attributes.type === factory.Type;\n\t\t},\n\t};\n\n\treturn result as typeof result & SharedObjectKind<TSharedObject>;\n}\n\nfunction isChannel(loadable: IFluidLoadable): loadable is IChannel {\n\t// This assumes no other IFluidLoadable has an `attributes` field, and thus may not be fully robust.\n\treturn (loadable as IChannel).attributes !== undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAOpE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAe7D,OAAO,EAKN,qBAAqB,EACrB,yBAAyB,GAGzB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,sBAAsB,GAEtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAEN,mBAAmB,EACnB,6BAA6B,EAE7B,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAGhB,YAAY,GACZ,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAyB,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAWhF;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAgB,gBAGrB,SAAQ,6BAAqC;IAG7C,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAuCD;;;OAGG;IACH,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED;IACC;;OAEG;IACI,EAAU;IACjB;;OAEG;IACO,OAA+B;IACzC;;OAEG;IACa,UAA8B;QAE9C,KAAK,CAAC,CAA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C,IAAI,CAAC;QACnE,CAAC;KACD,CAAC;IAEF,OAAO,MAAyD,CAAC;AAClE,CAAC;AAED,SAAS,SAAS,CAAC,QAAwB;IAC1C,oGAAoG;IACpG,OAAQ,QAAqB,CAAC,UAAU,KAAK,SAAS,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport type { ITelemetryBaseProperties, ErasedType } from \"@fluidframework/core-interfaces\";\nimport type {\n\tIFluidHandleInternal,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelServices,\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIDeltaHandler,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype IGarbageCollectionData,\n\tblobCountPropertyName,\n\ttotalBlobSizePropertyName,\n\ttype IRuntimeMessageCollection,\n\ttype IRuntimeMessagesContent,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttoDeltaManagerInternal,\n\ttype TelemetryContext,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tDataProcessingError,\n\tEventEmitterWithErrorHandling,\n\ttype MonitoringContext,\n\tSampledTelemetryHelper,\n\tcreateChildLogger,\n\tloggerToMonitoringContext,\n\ttagCodeArtifacts,\n\ttype ICustomData,\n\ttype IFluidErrorBase,\n\tLoggingError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { GCHandleVisitor } from \"./gcHandleVisitor.js\";\nimport { SharedObjectHandle } from \"./handle.js\";\nimport { FluidSerializer, type IFluidSerializer } from \"./serializer.js\";\nimport type { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nimport { bindHandles, makeHandlesSerializable, parseHandles } from \"./utils.js\";\n\n/**\n * Custom telemetry properties used in {@link SharedObjectCore} to instantiate {@link TelemetryEventBatcher} class.\n * This interface is used to define the properties that will be passed to the {@link TelemetryEventBatcher.measure} function\n * which is called in the {@link SharedObjectCore.process} method.\n */\ninterface ProcessTelemetryProperties {\n\tsequenceDifference: number;\n}\n\n/**\n * Base class from which all {@link ISharedObject|shared objects} derive.\n * @remarks\n * This class implements common behaviors that implementations of {@link ISharedObject} may want to reuse.\n * Even more such behaviors are implemented in the {@link SharedObject} class.\n * @privateRemarks\n * Currently some documentation (like the above) implies that this is supposed to be the only implementation of ISharedObject, which is both package-exported and not `@sealed`.\n * This situation should be clarified to indicate if other implementations of ISharedObject are allowed and just currently don't exist,\n * or if the intention is that no other implementations should exist and creating some might break things.\n * As part of this, any existing implementations of ISharedObject (via SharedObjectCore or otherwise) in use by legacy API users will need to be considered.\n *\n * TODO:\n * This class should eventually be made internal, as custom subclasses of it outside this repository are intended to be made unsupported in the future.\n * @legacy @beta\n */\nexport abstract class SharedObjectCore<\n\t\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n\t>\n\textends EventEmitterWithErrorHandling<TEvent>\n\timplements ISharedObject<TEvent>\n{\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly opProcessingHelper: SampledTelemetryHelper<\n\t\tvoid,\n\t\tProcessTelemetryProperties\n\t>;\n\tprivate readonly callbacksHelper: SampledTelemetryHelper<boolean>;\n\n\t/**\n\t * The handle referring to this SharedObject\n\t */\n\tpublic readonly handle: IFluidHandleInternal;\n\n\t/**\n\t * Telemetry logger for the shared object\n\t */\n\tprotected readonly logger: ITelemetryLoggerExt;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Connection state\n\t */\n\tprivate _connected = false;\n\n\t/**\n\t * Services used by the shared object\n\t */\n\tprivate services: IChannelServices | undefined;\n\n\t/**\n\t * True if the dds is bound to its parent.\n\t */\n\tprivate _isBoundToContext: boolean = false;\n\n\t/**\n\t * Tracks error that closed this object.\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * Gets the connection state\n\t * @returns The state of the connection\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\tconstructor(\n\t\t/**\n\t\t * The ID of the shared object.\n\t\t */\n\t\tpublic id: string,\n\t\t/**\n\t\t * The runtime instance that contains the Shared Object.\n\t\t */\n\t\tprotected runtime: IFluidDataStoreRuntime,\n\t\t/**\n\t\t * The attributes of the Shared Object.\n\t\t */\n\t\tpublic readonly attributes: IChannelAttributes,\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) =>\n\t\t\tthis.eventListenerErrorHandler(event, e),\n\t\t);\n\n\t\tassert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n\t\tthis.handle = new SharedObjectHandle(this, id, runtime);\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: runtime.logger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\tsharedObjectId: uuid(),\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tddsType: this.attributes.type,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.mc = loggerToMonitoringContext(this.logger);\n\n\t\tconst { opProcessingHelper, callbacksHelper } = this.setUpSampledTelemetryHelpers();\n\t\tthis.opProcessingHelper = opProcessingHelper;\n\t\tthis.callbacksHelper = callbacksHelper;\n\t}\n\n\t/**\n\t * Accessor for `this.runtime`'s {@link @fluidframework/datastore-definitions#IFluidDataStoreRuntime.deltaManager} as a {@link @fluidframework/container-definitions/internal#IDeltaManager}\n\t */\n\tprotected get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n\t\treturn toDeltaManagerInternal(this.runtime.deltaManager);\n\t}\n\n\t/**\n\t * This function is only supposed to be called from SharedObjectCore's constructor and\n\t * depends on a few things being set already. assert() calls make sure of it.\n\t * @returns The telemetry sampling helpers, so the constructor can be the one to assign them\n\t * to variables to avoid complaints from TypeScript.\n\t */\n\tprivate setUpSampledTelemetryHelpers(): {\n\t\topProcessingHelper: SampledTelemetryHelper<void, ProcessTelemetryProperties>;\n\t\tcallbacksHelper: SampledTelemetryHelper<boolean>;\n\t} {\n\t\tassert(\n\t\t\tthis.mc !== undefined && this.logger !== undefined,\n\t\t\t0x349 /* this.mc and/or this.logger has not been set */,\n\t\t);\n\t\tconst opProcessingHelper = new SampledTelemetryHelper<void, ProcessTelemetryProperties>(\n\t\t\t{\n\t\t\t\teventName: \"ddsOpProcessing\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.OpProcessingTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t\tnew Map<string, ITelemetryBaseProperties>([\n\t\t\t\t[\"local\", { localOp: true }],\n\t\t\t\t[\"remote\", { localOp: false }],\n\t\t\t]),\n\t\t);\n\t\tconst callbacksHelper = new SampledTelemetryHelper<boolean>(\n\t\t\t{\n\t\t\t\teventName: \"ddsEventCallbacks\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.DdsCallbacksTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t);\n\n\t\tthis.runtime.once(\"dispose\", () => {\n\t\t\tthis.callbacksHelper.dispose();\n\t\t\tthis.opProcessingHelper.dispose();\n\t\t});\n\n\t\treturn { opProcessingHelper, callbacksHelper };\n\t}\n\n\t/**\n\t * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n\t * would result in same error thrown. If called multiple times, only first error is remembered.\n\t * @param error - error object that is thrown whenever an attempt is made to modify this object\n\t */\n\tprivate closeWithError(error: IFluidErrorBase | undefined): void {\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n\t * It wraps error with DataProcessingError, closes this object and throws resulting error.\n\t * See closeWithError() for more details\n\t * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n\t * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n\t * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n\t * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n\t * allow processing of ops or local changes, which very quickly results in container closure.\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(\n\t\t\te,\n\t\t\t\"SharedObjectEventListenerException\",\n\t\t);\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\tprivate setBoundAndHandleAttach(): void {\n\t\t// Ensure didAttach is only called once, and we only register a single event\n\t\t// but we still call setConnectionState as our existing mocks don't\n\t\t// always propagate connection state\n\t\tthis.setBoundAndHandleAttach = () => this.setConnectionState(this.runtime.connected);\n\t\tthis._isBoundToContext = true;\n\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\tconst runDidAttach: () => void = () => {\n\t\t\t// Allows objects to do any custom processing if it is attached.\n\t\t\tthis.didAttach();\n\t\t\tthis.setConnectionState(this.runtime.connected);\n\t\t};\n\t\tif (this.isAttached()) {\n\t\t\trunDidAttach();\n\t\t} else {\n\t\t\tthis.runtime.once(\"attaching\", runDidAttach);\n\t\t}\n\t}\n\n\t/**\n\t * A shared object, after construction, can either be loaded in the case that it is already part of\n\t * a shared document. Or later attached if it is being newly added.\n\t * @param services - Services used by the shared object\n\t */\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tthis.services = services;\n\t\t// set this before load so that isAttached is true\n\t\t// for attached runtimes when load core is running\n\t\tthis._isBoundToContext = true;\n\t\tawait this.loadCore(services.objectStorage);\n\t\tthis.attachDeltaHandler();\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * Initializes the object as a local, non-shared object. This object can become shared after\n\t * it is attached to the document.\n\t */\n\tpublic initializeLocal(): void {\n\t\tthis.initializeLocalCore();\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).bindToContext}\n\t */\n\tpublic bindToContext(): void {\n\t\t// ensure the method only runs once by removing the implementation\n\t\t// without this the method suffers from re-entrancy issues\n\t\tthis.bindToContext = () => {};\n\t\tif (!this._isBoundToContext) {\n\t\t\tthis.runtime.bindChannel(this);\n\t\t\t// must set after bind channel so isAttached doesn't report true\n\t\t\t// before binding is complete\n\t\t\tthis.setBoundAndHandleAttach();\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n\t */\n\tpublic connect(services: IChannelServices): void {\n\t\t// handle the case where load is called\n\t\t// before connect; loading detached data stores\n\t\tif (this.services === undefined) {\n\t\t\tthis.services = services;\n\t\t\tthis.attachDeltaHandler();\n\t\t}\n\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n\t */\n\tpublic isAttached(): boolean {\n\t\treturn this._isBoundToContext && this.runtime.attachState !== AttachState.Detached;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic abstract getAttachSummary(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic abstract summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}\n\t */\n\tpublic abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the distributed data type to perform custom loading\n\t * @param services - Storage used by the shared object\n\t */\n\tprotected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n\t/**\n\t * Allows the distributed data type to perform custom local loading.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n\t * Also called after non-local data type get loaded.\n\t */\n\tprotected didAttach(): void {\n\t\treturn;\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Derived classes must override this to do custom processing on a 'bunch' of remote messages.\n\t * @remarks\n\t * A 'bunch' is a group of messages that have the following properties:\n\t * - They are all part of the same grouped batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t * - They are not interleaved with messages from other DDS in the container.\n\t * Derived classes should override this if they need to do custom processing on a 'bunch' of remote messages.\n\t * @param messageCollection - The collection of messages to process.\n\t *\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tprotected abstract processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\n\tprotected abstract onDisconnect(): void;\n\n\t/**\n\t * The serializer to serialize / parse handles.\n\t */\n\tprotected abstract get serializer(): IFluidSerializer;\n\n\t/**\n\t * Submits a message by the local client to the runtime.\n\t * @param content - Content of the message. Note: handles contained in the\n\t * message object should not be encoded in any way\n\t * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t */\n\tprotected submitLocalMessage(content: unknown, localOpMetadata: unknown = undefined): void {\n\t\tthis.verifyNotClosed();\n\t\tif (this.isAttached()) {\n\t\t\t// NOTE: We may also be encoding in the ContainerRuntime layer.\n\t\t\t// Once the layer-compat window passes we can remove the encoding codepath here altogether\n\t\t\tconst onlyBind =\n\t\t\t\t(this.runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t\t.submitMessagesWithoutEncodingHandles === true;\n\t\t\tconst contentToSubmit = onlyBind\n\t\t\t\t? bindHandles(content, this.handle)\n\t\t\t\t: makeHandlesSerializable(content, this.serializer, this.handle);\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(contentToSubmit, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n\t * that want to be part of summary but does not generate ops.\n\t */\n\tprotected dirty(): void {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.services!.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Called when the object has fully connected to the delta stream\n\t * Default implementation for DDS, override if different behavior is required.\n\t */\n\tprotected onConnect(): void {}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n\t * The default implementation here is to resubmit the same message. The client can override if different behavior\n\t * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n\t * anything at all.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.submitLocalMessage(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted but its content should be \"squashed\" if any subsequent pending changes\n\t * override the content in the fashion described on {@link @fluidframework/datastore-definitions#IDeltaHandler.reSubmit}.\n\t *\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitSquashed(content: unknown, localOpMetadata: unknown): void {\n\t\tconst allowStagingModeWithoutSquashing =\n\t\t\tloggerToMonitoringContext(this.logger).config.getBoolean(\n\t\t\t\t\"Fluid.SharedObject.AllowStagingModeWithoutSquashing\",\n\t\t\t) ??\n\t\t\t(this.runtime.options.allowStagingModeWithoutSquashing as boolean | undefined) ??\n\t\t\ttrue;\n\t\tif (allowStagingModeWithoutSquashing) {\n\t\t\tthis.reSubmitCore(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.throwUnsupported(\"reSubmitSquashed\");\n\t\t}\n\t}\n\n\t/**\n\t * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n\t * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n\t * the Promise will reject.\n\t * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n\t */\n\tprotected async newAckBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: unknown) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.runtime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.runtime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\t// Note: rejectBecauseDispose will never be undefined here\n\t\t\tthis.runtime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n\n\tprivate attachDeltaHandler(): void {\n\t\t// Services should already be there in case we are attaching delta handler.\n\t\tassert(\n\t\t\tthis.services !== undefined,\n\t\t\t0x07a /* \"Services should be there to attach delta handler\" */,\n\t\t);\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.services.deltaConnection.attach({\n\t\t\tprocessMessages: (messagesCollection: IRuntimeMessageCollection) => {\n\t\t\t\tthis.processMessages(messagesCollection);\n\t\t\t},\n\t\t\tsetConnectionState: (connected: boolean) => {\n\t\t\t\tthis.setConnectionState(connected);\n\t\t\t},\n\t\t\treSubmit: (content: unknown, localOpMetadata: unknown, squash: boolean) => {\n\t\t\t\tthis.reSubmit(content, localOpMetadata, squash);\n\t\t\t},\n\t\t\tapplyStashedOp: (content: unknown): void => {\n\t\t\t\tthis.applyStashedOp(parseHandles(content, this.serializer));\n\t\t\t},\n\t\t\trollback: (content: unknown, localOpMetadata: unknown) => {\n\t\t\t\tthis.rollback(content, localOpMetadata);\n\t\t\t},\n\t\t} satisfies IDeltaHandler);\n\t}\n\n\t/**\n\t * Set the state of connection to services.\n\t * @param connected - true if connected, false otherwise.\n\t */\n\tprivate setConnectionState(connected: boolean): void {\n\t\t// only an attached shared object can transition its\n\t\t// connected state. This is defensive, as some\n\t\t// of our test harnesses don't handle this correctly\n\t\tif (!this.isAttached() || this._connected === connected) {\n\t\t\t// Not changing state, nothing the same.\n\t\t\treturn;\n\t\t}\n\n\t\t// Should I change the state at the end? So that we *can't* send new stuff before we send old?\n\t\tthis._connected = connected;\n\n\t\tif (connected) {\n\t\t\t// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending\n\t\t\t// messages will work.\n\t\t\tthis.onConnect();\n\t\t} else {\n\t\t\t// Things that are true now...\n\t\t\t// - if we had a connection we can no longer send messages over it\n\t\t\t// - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n\t\t\t//\n\t\t\t// - nack could get a new msn - but might as well do it in the join?\n\t\t\tthis.onDisconnect();\n\t\t}\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Process a bunch of messages for this shared object. A bunch is group of messages that have the following properties:\n\t * - They are all part of the same grouped batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t * - They are not interleaved with messages from other DDS in the container.\n\t * @param messageCollection - The collection of messages to process.\n\t *\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tprivate processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.verifyNotClosed(); // This will result in container closure.\n\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\n\t\t// Decode any handles in the contents before processing the messages.\n\t\tconst decodedMessagesContent: IRuntimeMessagesContent[] = [];\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tconst decodedMessageContent: IRuntimeMessagesContent = {\n\t\t\t\tcontents: parseHandles(contents, this.serializer),\n\t\t\t\tlocalOpMetadata,\n\t\t\t\tclientSequenceNumber,\n\t\t\t};\n\t\t\tdecodedMessagesContent.push(decodedMessageContent);\n\t\t}\n\n\t\tconst emitEvents = (event: \"pre-op\" | \"op\"): void => {\n\t\t\tfor (const { contents, clientSequenceNumber } of decodedMessagesContent) {\n\t\t\t\tconst message: ISequencedDocumentMessage = {\n\t\t\t\t\t...envelope,\n\t\t\t\t\tcontents,\n\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t};\n\t\t\t\tthis.emitInternal(event, message, local);\n\t\t\t}\n\t\t};\n\n\t\temitEvents(\"pre-op\");\n\t\tthis.opProcessingHelper.measure(\n\t\t\t(): ICustomData<ProcessTelemetryProperties> => {\n\t\t\t\tconst decodedMessagesCollection: IRuntimeMessageCollection = {\n\t\t\t\t\tenvelope,\n\t\t\t\t\tlocal,\n\t\t\t\t\tmessagesContent: decodedMessagesContent,\n\t\t\t\t};\n\t\t\t\tthis.processMessagesCore(decodedMessagesCollection);\n\t\t\t\tconst telemetryProperties: ProcessTelemetryProperties = {\n\t\t\t\t\tsequenceDifference: envelope.sequenceNumber - envelope.referenceSequenceNumber,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tcustomData: telemetryProperties,\n\t\t\t\t};\n\t\t\t},\n\t\t\tlocal ? \"local\" : \"remote\",\n\t\t);\n\t\temitEvents(\"op\");\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n\t * reconnection.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t * @param squash - If `true`, the message will be resubmitted in a squashed form. If `false`,\n\t * the legacy behavior (no squashing) will be used.\n\t */\n\tprivate reSubmit(content: unknown, localOpMetadata: unknown, squash: boolean): void {\n\t\tif (squash) {\n\t\t\tthis.reSubmitSquashed(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.reSubmitCore(content, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.throwUnsupported(\"rollback\");\n\t}\n\n\t/**\n\t * Apply changes from the provided op content just as if a local client has made the change,\n\t * including submitting the op. Used when rehydrating an attached container\n\t * with pending changes. The rehydration process replays all remote ops\n\t * and applies stashed ops after the remote op with a sequence number\n\t * that matches that of the stashed op is applied. This ensures\n\t * stashed ops are applied at the same state they were originally created.\n\t *\n\t * It is possible that stashed ops have been sent in the past, and will be found when\n\t * the shared object catches up with remotes ops.\n\t * So this prepares the SharedObject for seeing potentially seeing the ACK.\n\t * If no matching remote op is found, all the applied stashed ops will go\n\t * through the normal resubmit flow upon reconnection, which allows the dds\n\t * to rebase them to the latest state, and then resubmit them.\n\t *\n\t * @param content - Contents of a stashed op.\n\t */\n\tprotected abstract applyStashedOp(content: unknown): void;\n\n\t/**\n\t * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,\n\t * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners\n\t * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events\n\t * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the\n\t * future.\n\t * @param event - The event to emit.\n\t * @param args - Arguments to pass to the event listeners.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t */\n\tpublic emit(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn this.callbacksHelper.measure(() => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn super.emit(event, ...args);\n\t\t});\n\t}\n\n\t/**\n\t * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement\n\t * done on the duration of the callbacks. Simply calls `super.emit()`.\n\t * @param event - Event to emit\n\t * @param args - Arguments for the event\n\t * @returns Whatever `super.emit()` returns.\n\t */\n\tprivate emitInternal(event: EventEmitterEventType, ...args: unknown[]): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n\n\tprivate throwUnsupported(featureName: string): never {\n\t\tthrow new LoggingError(\"Unsupported DDS feature\", {\n\t\t\tfeatureName,\n\t\t\t...tagCodeArtifacts({ ddsType: this.attributes.type }),\n\t\t});\n\t}\n}\n\n/**\n * Helper for implementing {@link ISharedObject} with simplified, synchronous summarization and garbage collection.\n * @remarks\n * DDS implementations with async and incremental summarization should extend {@link SharedObjectCore} directly instead.\n * @privateRemarks\n * TODO:\n * This class is badly named.\n * Once it becomes `@internal` \"SharedObjectCore\" should probably become \"SharedObject\"\n * and this class should be renamed to something like \"SharedObjectSynchronous\".\n * @legacy @beta\n */\nexport abstract class SharedObject<\n\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n> extends SharedObjectCore<TEvent> {\n\t/**\n\t * True while we are garbage collecting this object's data.\n\t */\n\tprivate _isGCing: boolean = false;\n\n\t/**\n\t * The serializer to use to serialize / parse handles, if any.\n\t */\n\tprivate readonly _serializer: IFluidSerializer;\n\n\tprotected get serializer(): IFluidSerializer {\n\t\t/**\n\t\t * During garbage collection, the GCHandleVisitor \"serializer\" keeps track of IFluidHandles that are serialized. These\n\t\t * handles represent references to other Fluid objects.\n\t\t *\n\t\t * This is fine for now. However, if we implement delay loading in DDSes, they may load and de-serialize content\n\t\t * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n\t\t */\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */,\n\t\t);\n\t\treturn this._serializer;\n\t}\n\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\t/**\n\t\t * The prefix to use for telemetry events emitted by this object.\n\t\t */\n\t\tprivate readonly telemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes);\n\n\t\tthis._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic getAttachSummary(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tundefined /* incrementalSummaryContext */,\n\t\t\tfullTree,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\t// Set _isGCing to true. This flag is used to ensure that we only use GCHandleVisitor in this codepath and not when trying to truly serialize.\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */,\n\t\t);\n\t\tthis._isGCing = true;\n\n\t\tlet gcData: IGarbageCollectionData;\n\t\ttry {\n\t\t\tconst handleVisitor = new GCHandleVisitor(this.runtime.channelsRoutingContext);\n\t\t\tthis.processGCDataCore(handleVisitor);\n\t\t\t// The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n\t\t\t// routes of handles serialized during summarization.\n\t\t\tgcData = { gcNodes: { \"/\": handleVisitor.getVisitedHandlePaths() } };\n\t\t\tassert(\n\t\t\t\tthis._isGCing,\n\t\t\t\t0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis._isGCing = false;\n\t\t}\n\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Calls the serializer over all data in this object that reference other GC nodes.\n\t * Derived classes must override this to provide custom list of references to other GC nodes.\n\t *\n\t * @remarks Serialization itself doesn't matter (the result is ignored). We're tapping into the serialization infrastructure\n\t * as a way to visit all the content in this content that may reference other objects via handle.\n\t *\n\t * @param serializer - The \"serializer\" (more like handle visitor) to use.\n\t * Implementations should ensure that serialize is called on all handles, as the way to visit them.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\t// We run the full summarize logic to get the list of outbound routes from this object. This is a little\n\t\t// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n\t\t// See: https://github.com/microsoft/FluidFramework/issues/4547\n\t\tthis.summarizeCore(serializer);\n\t}\n\n\t/**\n\t * Gets a form of the object that can be serialized.\n\t * @returns A tree representing the snapshot of the shared object.\n\t */\n\tprotected abstract summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\tprivate incrementTelemetryMetric(\n\t\tpropertyName: string,\n\t\tincrementBy: number,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): void {\n\t\tif (telemetryContext !== undefined) {\n\t\t\t// TelemetryContext needs to implment a get function\n\t\t\tassert(\n\t\t\t\t\"get\" in telemetryContext && typeof telemetryContext.get === \"function\",\n\t\t\t\t0x97e /* received context must have a get function */,\n\t\t\t);\n\n\t\t\tconst prevTotal = ((telemetryContext as TelemetryContext).get(\n\t\t\t\tthis.telemetryContextPrefix,\n\t\t\t\tpropertyName,\n\t\t\t) ?? 0) as number;\n\t\t\ttelemetryContext.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n\t\t}\n\t}\n}\n\n/**\n * Defines a kind of shared object.\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n *\n * @remarks\n * For use internally and in the \"encapsulated API\".\n * See {@link SharedObjectKind} for the type erased version for use in the public declarative API.\n *\n * @privateRemarks\n * This does not extend {@link SharedObjectKind} since doing so would prevent implementing this interface in type safe code.\n * Any implementation of this can safely be used as a {@link SharedObjectKind} with an explicit type conversion,\n * but doing so is typically not needed as {@link createSharedObjectKind} is used to produce values that are both types simultaneously.\n * @legacy @beta\n */\nexport interface ISharedObjectKind<TSharedObject> {\n\t/**\n\t * Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.\n\t * @remarks\n\t * The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels.\n\t * To create new shared objects use:\n\t *\n\t * - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.\n\t *\n\t * - {@link ISharedObjectKind.create} if using a custom container definitions (and thus not using {@link @fluidframework/fluid-static#IFluidContainer}).\n\t */\n\tgetFactory(): IChannelFactory<TSharedObject>;\n\n\t/**\n\t * Create a shared object.\n\t * @param runtime - The data store runtime that the new shared object belongs to.\n\t * @param id - Optional name of the shared object.\n\t * @returns Newly created shared object.\n\t *\n\t * @example\n\t * To create a `SharedTree`, call the static create method:\n\t *\n\t * ```typescript\n\t * const myTree = SharedTree.create(this.runtime, id);\n\t * ```\n\t * @remarks\n\t * The created object is local (detached): insert a handle to it into an attached object to share (attach) it.\n\t * If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.\n\t *\n\t * @privateRemarks\n\t * This can only be used with a `MockFluidDataStoreRuntime` when that mock is created with a `registry` containing a factory for this shared object.\n\t */\n\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;\n}\n\n/**\n * Defines a kind of shared object.\n * @remarks\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n * See {@link @fluidframework/fluid-static#IFluidContainer.create} and {@link @fluidframework/fluid-static#ContainerSchema} for details.\n * @privateRemarks\n * Part of the \"declarative API\".\n * Type erased reference to an {@link ISharedObjectKind} or a DataObject class in for use in\n * `fluid-static`'s `IFluidContainer` and `ContainerSchema`.\n * Use {@link createSharedObjectKind} to creating an instance of this type.\n * @sealed\n * @public\n */\nexport interface SharedObjectKind<out TSharedObject = unknown>\n\textends ErasedType<readonly [\"SharedObjectKind\", TSharedObject]> {\n\t/**\n\t * Check whether an {@link @fluidframework/core-interfaces#IFluidLoadable} is an instance of this shared object kind.\n\t * @remarks This should be used in place of `instanceof` checks for shared objects, as their actual classes are not exported in Fluid's public API.\n\t */\n\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject;\n}\n\n/**\n * Utility for creating ISharedObjectKind instances.\n * @remarks\n * This takes in a class which implements IChannelFactory,\n * and uses it to return a a single value which is intended to be used as the API entry point for the corresponding shared object type.\n * The returned value implements {@link ISharedObjectKind} for use in the encapsulated API, as well as the type erased {@link SharedObjectKind} used by the declarative API.\n * See {@link @fluidframework/fluid-static#ContainerSchema} for how this is used in the declarative API.\n * @internal\n */\nexport function createSharedObjectKind<TSharedObject>(\n\tfactory: (new () => IChannelFactory<TSharedObject>) & { readonly Type: string },\n): ISharedObjectKind<TSharedObject> & SharedObjectKind<TSharedObject> {\n\tconst result: ISharedObjectKind<TSharedObject> &\n\t\tOmit<SharedObjectKind<TSharedObject>, \"brand\"> = {\n\t\tgetFactory(): IChannelFactory<TSharedObject> {\n\t\t\treturn new factory();\n\t\t},\n\n\t\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject {\n\t\t\treturn runtime.createChannel(id, factory.Type) as TSharedObject;\n\t\t},\n\n\t\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject {\n\t\t\treturn isChannel(value) && value.attributes.type === factory.Type;\n\t\t},\n\t};\n\n\treturn result as typeof result & SharedObjectKind<TSharedObject>;\n}\n\nfunction isChannel(loadable: IFluidLoadable): loadable is IChannel {\n\t// This assumes no other IFluidLoadable has an `attributes` field, and thus may not be fully robust.\n\treturn (loadable as IChannel).attributes !== undefined;\n}\n"]}
|
|
@@ -98,7 +98,7 @@ _SharedObjectFromKernel_lazyData = new WeakMap(), _SharedObjectFromKernel_kernel
|
|
|
98
98
|
// Make `this` implement TOut.
|
|
99
99
|
mergeAPIs(this, data.view);
|
|
100
100
|
}, _SharedObjectFromKernel_kernel_get = function _SharedObjectFromKernel_kernel_get() {
|
|
101
|
-
return (__classPrivateFieldGet(this, _SharedObjectFromKernel_lazyData, "f") ?? fail(
|
|
101
|
+
return (__classPrivateFieldGet(this, _SharedObjectFromKernel_lazyData, "f") ?? fail(0xcb0 /* must initializeData first */)).kernel;
|
|
102
102
|
};
|
|
103
103
|
/**
|
|
104
104
|
* When present on a method, it indicates the methods return value should be replaced with `this` (the wrapper)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObjectKernel.js","sourceRoot":"","sources":["../src/sharedObjectKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAIH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAqBnE,OAAO,EACN,sBAAsB,EACtB,YAAY,GAGZ,MAAM,mBAAmB,CAAC;AAmE3B;;;;;;;;;;;GAWG;AACH,MAAM,sBAGJ,SAAQ,YAAoB;IAW7B,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EACd,OAAkC,EAClD,sBAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC;;QAHvC,YAAO,GAAP,OAAO,CAA2B;QAdnD;;;;;WAKG;QACH,2CAA0C,SAAS,EAAC;QAE3C,qDAAwB;QAWhC,uBAAA,IAAI,sCAAe;YAClB,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,kBAAkB,EAAE,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,CAC3C,IAAI,CAAC,kBAAkB,CAAC,EAAE,EA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B,CAAC;AACF,CAAC;AAiCD;;;;;GAKG;AACH,4EAA4E;AAC5E,SAAS,kBAAkB,CAAmB,OAA+B;IAC5E,MAAM,cAAc;QAWnB;;WAEG;QACH,IAAW,IAAI;YACd,OAAO,cAAc,CAAC,IAAI,CAAC;QAC5B,CAAC;QAED;;WAEG;QACH,IAAW,UAAU;YACpB,OAAO,cAAc,CAAC,UAAU,CAAC;QAClC,CAAC;QAED;;WAEG;QACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;YAE9B,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,UAAU,EACV,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YACF,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,MAAiC,CAAC;QAC1C,CAAC;QAED;;WAEG;QACI,MAAM,CAAC,OAA+B,EAAE,EAAU;YACxD,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,cAAc,CAAC,UAAU,EACzB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YAEF,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,OAAO,MAAiC,CAAC;QAC1C,CAAC;;IA3DD;;OAEG;IACoB,mBAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;OAEG;IACoB,yBAAU,GAAuB,OAAO,CAAC,UAAU,CAAC;IAsD5E,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAA+B;IAE/B,OAAO,sBAAsB,CAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIChannelServices,\n\tIFluidDataStoreRuntime,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n\tIRuntimeMessageCollection,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { IFluidSerializer } from \"./serializer.js\";\nimport {\n\tcreateSharedObjectKind,\n\tSharedObject,\n\ttype ISharedObjectKind,\n\ttype SharedObjectKind,\n} from \"./sharedObject.js\";\nimport type { ISharedObjectEvents, ISharedObject } from \"./types.js\";\nimport type { IChannelView } from \"./utils.js\";\n\n/**\n * Functionality specific to a particular kind of {@link ISharedObject}.\n * @remarks\n * Shared objects expose APIs for two consumers:\n *\n * 1. The runtime, which uses {@link @fluidframework/datastore-definitions#IChannel} to summarize and apply ops and {@link @fluidframework/datastore-definitions#IChannelFactory} to create the load summaries.\n *\n * 2. The app, which uses shared object kind specific APIs to read and write data.\n *\n * There is some common functionality all shared objects use, provided by {@link SharedObject} and {@link SharedObjectCore}.\n * SharedKernel describes the portion of the behavior required by the runtime which\n * differs between different kinds of shared objects.\n *\n * {@link makeSharedObjectKind} is then used to wrap up the kernel into a full {@link ISharedObject} implementation.\n * The runtime specific APIs are then type erased into a {@link SharedObjectKind}.\n * @privateRemarks\n * Unlike the `SharedObject` class, this interface is internal, and thus can be adjusted more easily.\n * Therefore this interface is not intended to address all needs, and will likely need small changes as it gets more adoption.\n *\n * @internal\n */\nexport interface SharedKernel {\n\t/**\n\t * {@inheritDoc SharedObject.summarizeCore}\n\t */\n\tsummarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.onDisconnect}\n\t */\n\tonDisconnect(): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.reSubmitCore}\n\t */\n\treSubmitCore(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.applyStashedOp}\n\t */\n\tapplyStashedOp(content: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.processMessagesCore}\n\t */\n\tprocessMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.rollback}\n\t */\n\trollback?(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.didAttach}\n\t */\n\tdidAttach?(): void;\n}\n\n/**\n * SharedObject implementation that delegates to a SharedKernel.\n * @typeParam TOut - The type of the object exposed to the app.\n * Once initialized, instances of this class forward properties to the `TOut` value provided by the factory.\n * See {@link mergeAPIs} for more limitations.\n *\n * @remarks\n * The App facing API (TOut) needs to be implemented by this object which also has to implement the runtime facing API (ISharedObject).\n *\n * Requiring both of these to be implemented by the same object adds some otherwise unnecessary coupling.\n * This class is a workaround for that, which takes separate implementations of the two APIs and merges them into one using {@link mergeAPIs}.\n */\nclass SharedObjectFromKernel<\n\tTOut extends object,\n\tTEvent extends ISharedObjectEvents,\n> extends SharedObject<TEvent> {\n\t/**\n\t * Lazy init here so kernel can be constructed in loadCore when loading from existing data.\n\t *\n\t * Explicit initialization to undefined is done so Proxy knows this property is from this class (via `Reflect.has`),\n\t * not from the grafted APIs.\n\t */\n\t#lazyData: FactoryOut<TOut> | undefined = undefined;\n\n\treadonly #kernelArgs: KernelArgs;\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tpublic readonly factory: SharedKernelFactory<TOut>,\n\t\ttelemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.#kernelArgs = {\n\t\t\tsharedObject: this,\n\t\t\tserializer: this.serializer,\n\t\t\tsubmitLocalMessage: (op, localOpMetadata) =>\n\t\t\t\tthis.submitLocalMessage(op, localOpMetadata),\n\t\t\teventEmitter: this,\n\t\t\tlogger: this.logger,\n\t\t\tidCompressor: runtime.idCompressor,\n\t\t\tlastSequenceNumber: () => this.deltaManager.lastSequenceNumber,\n\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\n\t\t\t// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern\n\t\t\t// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes\n\t\t\t// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the\n\t\t\t// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler\n\t\t\t// would emit an error.\n\t\t\tminVersionForCollab: (runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t.minVersionForCollab,\n\t\t};\n\t}\n\n\tprotected override summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats {\n\t\treturn this.#kernel.summarizeCore(\n\t\t\tserializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t}\n\n\tprotected override initializeLocalCore(): void {\n\t\tthis.#initializeData(this.factory.create(this.#kernelArgs));\n\t}\n\n\t#initializeData(data: FactoryOut<TOut>): void {\n\t\tassert(\n\t\t\tthis.#lazyData === undefined,\n\t\t\t0xb99 /* initializeData must be called first and only once */,\n\t\t);\n\t\tthis.#lazyData = data;\n\n\t\t// Make `this` implement TOut.\n\t\tmergeAPIs(this, data.view);\n\t}\n\n\tget #kernel(): SharedKernel {\n\t\treturn (this.#lazyData ?? fail(\"must initializeData first\")).kernel;\n\t}\n\n\tprotected override async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tthis.#initializeData(await this.factory.loadCore(this.#kernelArgs, storage));\n\t}\n\n\tprotected override onDisconnect(): void {\n\t\tthis.#kernel.onDisconnect();\n\t}\n\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.#kernel.reSubmitCore(content, localOpMetadata);\n\t}\n\n\tprotected override applyStashedOp(content: unknown): void {\n\t\tthis.#kernel.applyStashedOp(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.#kernel.processMessagesCore(messagesCollection);\n\t}\n\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tif (this.#kernel.rollback === undefined) {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.#kernel.rollback(content, localOpMetadata);\n\t\t}\n\t}\n\n\tprotected override didAttach(): void {\n\t\tthis.#kernel.didAttach?.();\n\t}\n}\n\n/**\n * When present on a method, it indicates the methods return value should be replaced with `this` (the wrapper)\n * when wrapping the object with the method.\n * @remarks\n * This is useful when using {@link mergeAPIs} with methods where the return type is `this`, like `Map.set`.\n * @internal\n */\nexport const thisWrap: unique symbol = Symbol(\"selfWrap\");\n\n/**\n * A {@link SharedKernel} providing the implementation of some distributed data structure (DDS) and the needed runtime facing APIs,\n * and a separate view object which exposes the app facing APIs (`T`)\n * for reading and writing data which are specific to this particular data structure.\n * @remarks\n * Output from {@link SharedKernelFactory}.\n * This is an alternative to defining DDSs by sub-classing {@link SharedObject}.\n * @internal\n */\nexport interface FactoryOut<T extends object> {\n\treadonly kernel: SharedKernel;\n\treadonly view: T;\n}\n\n/**\n * A factory for creating DDSs.\n * @remarks\n * Outputs {@link FactoryOut}.\n * This is an alternative to directly implementing {@link @fluidframework/datastore-definitions#IChannelFactory}.\n * Use with {@link makeSharedObjectKind} to create a {@link SharedObjectKind}.\n * @internal\n */\nexport interface SharedKernelFactory<T extends object> {\n\tcreate(args: KernelArgs): FactoryOut<T>;\n\n\t/**\n\t * Create combined with {@link SharedObjectCore.loadCore}.\n\t */\n\tloadCore(args: KernelArgs, storage: IChannelStorageService): Promise<FactoryOut<T>>;\n}\n\n/**\n * Inputs for building a {@link SharedKernel} via {@link SharedKernelFactory}.\n * @internal\n */\nexport interface KernelArgs {\n\t/**\n\t * The shared object whose behavior is being implemented.\n\t */\n\treadonly sharedObject: IChannelView & IFluidLoadable;\n\t/**\n\t * {@inheritdoc SharedObject.serializer}\n\t */\n\treadonly serializer: IFluidSerializer;\n\t/**\n\t * {@inheritdoc SharedObjectCore.submitLocalMessage}\n\t */\n\treadonly submitLocalMessage: (op: unknown, localOpMetadata: unknown) => void;\n\t/**\n\t * Top level emitter for events for this object.\n\t * @remarks\n\t * This is needed since the separate kernel and view from {@link FactoryOut} currently have to be recombined,\n\t * and having this as its own thing helps accomplish that.\n\t */\n\treadonly eventEmitter: TypedEventEmitter<ISharedObjectEvents>;\n\t/**\n\t * {@inheritdoc SharedObjectCore.logger}\n\t */\n\treadonly logger: ITelemetryLoggerExt;\n\t/**\n\t * {@inheritdoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.idCompressor}\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.lastSequenceNumber}\n\t */\n\treadonly lastSequenceNumber: () => number;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.initialSequenceNumber}\n\t */\n\treadonly initialSequenceNumber: number;\n\t/**\n\t * Minimum version of the FF runtime that is required to collaborate on new documents. Used so that a\n\t * compatible set of feature flags and formats can be enabled in the SharedObject implementation.\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.minVersionForCollab} for more details.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab | undefined;\n}\n\n/**\n * Add getters to `base` which forward own properties from `extra`.\n * @remarks\n * This only handles use of \"get\" and \"has\".\n * Therefore, APIs involving setting properties should not be used as `Extra`.\n *\n * Functions from `extra` are bound to the `extra` object and support {@link thisWrap}.\n *\n * Asserts when properties collide.\n * @internal\n */\nexport function mergeAPIs<const Base extends object, const Extra extends object>(\n\tbase: Base,\n\textra: Extra,\n): asserts base is Base & Extra {\n\tfor (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(extra))) {\n\t\tassert(!Reflect.has(base, key), 0xb9a /* colliding properties */);\n\n\t\t// Detect and special case functions.\n\t\t// Currently this is done eagerly (when mergeAPIs is called) rather than lazily (when the property is read):\n\t\t// this eager approach should result in slightly better performance,\n\t\t// but if functions on `extra` are reassigned over time it will produce incorrect behavior.\n\t\t// If this functionality is required, the design can be changed.\n\t\tlet getter: () => unknown;\n\t\t// Bind functions to the extra object and handle thisWrap.\n\t\tif (typeof descriptor.value === \"function\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst fromExtra: () => Extra | Base = descriptor.value;\n\t\t\tgetter = () => forwardMethod(fromExtra, extra, base);\n\t\t\t// To catch (and error on) cases where the function is reassigned and this eager binding approach is not appropriate, make it non-writable.\n\t\t\tObject.defineProperty(extra, key, { ...descriptor, writable: false });\n\t\t} else {\n\t\t\tgetter = () => extra[key];\n\t\t}\n\n\t\tObject.defineProperty(base, key, {\n\t\t\tconfigurable: false,\n\t\t\tenumerable: descriptor.enumerable,\n\t\t\tget: getter,\n\t\t\t// If setters become required, support them here.\n\t\t});\n\t}\n}\n\n/**\n * Wrap a method `f` of `oldThis` to be a method of `newThis`.\n * @remarks\n * The wrapped function will be called with `oldThis` as the `this` parameter.\n * It also accounts for when `f` is marked with {@link thisWrap}.\n */\nfunction forwardMethod<TArgs extends [], TReturn>(\n\tf: (...args: TArgs) => TReturn,\n\toldThis: TReturn,\n\tnewThis: TReturn,\n): (...args: TArgs) => TReturn {\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (thisWrap in f) {\n\t\treturn (...args: TArgs) => {\n\t\t\tconst result = f.call(oldThis, ...args);\n\t\t\tassert(result === oldThis, 0xb9b /* methods returning thisWrap should return this */);\n\t\t\treturn newThis;\n\t\t};\n\t} else {\n\t\treturn f.bind(oldThis);\n\t}\n}\n\n/**\n * Options for creating a {@link SharedObjectKind} via {@link makeSharedObjectKind}.\n * @typeParam T - The type of the object exposed to the app.\n * This can optionally include members from {@link ISharedObject} which will be provided automatically.\n * @internal\n */\nexport interface SharedObjectOptions<T extends object> {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\treadonly type: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\treadonly attributes: IChannelAttributes;\n\n\t/**\n\t * The factory used to create the kernel and its view.\n\t * @remarks\n\t * The view produced by this factory will be grafted onto the {@link SharedObject} using {@link mergeAPIs}.\n\t * See {@link mergeAPIs} for more information on limitations that apply.\n\t */\n\treadonly factory: SharedKernelFactory<Omit<T, keyof ISharedObject>>;\n\n\t/**\n\t * {@inheritDoc SharedObject.telemetryContextPrefix}\n\t */\n\treadonly telemetryContextPrefix: string;\n}\n\n/**\n * Utility to create a {@link @fluidframework/datastore-definitions#IChannelFactory} classes.\n * @remarks\n * Use {@link makeSharedObjectKind} instead unless exposing the factory is required for legacy API compatibility.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction makeChannelFactory<T extends object>(options: SharedObjectOptions<T>) {\n\tclass ChannelFactory implements IChannelFactory<T> {\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic static readonly Type = options.type;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic static readonly Attributes: IChannelAttributes = options.attributes;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic get type(): string {\n\t\t\treturn ChannelFactory.Type;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic get attributes(): IChannelAttributes {\n\t\t\treturn ChannelFactory.Attributes;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t\t */\n\t\tpublic async load(\n\t\t\truntime: IFluidDataStoreRuntime,\n\t\t\tid: string,\n\t\t\tservices: IChannelServices,\n\t\t\tattributes: IChannelAttributes,\n\t\t): Promise<T & IChannel> {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tattributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\t\t\tawait shared.load(services);\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t\t */\n\t\tpublic create(runtime: IFluidDataStoreRuntime, id: string): T & IChannel {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tChannelFactory.Attributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\n\t\t\tshared.initializeLocal();\n\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\t}\n\n\treturn ChannelFactory;\n}\n\n/**\n * Utility to create a {@link SharedObjectKind}.\n * @privateRemarks\n * Using this API avoids having to subclasses any Fluid Framework types,\n * reducing the coupling between the framework and the SharedObject implementation.\n * @internal\n */\nexport function makeSharedObjectKind<T extends object>(\n\toptions: SharedObjectOptions<T>,\n): ISharedObjectKind<T> & SharedObjectKind<T> {\n\treturn createSharedObjectKind<T>(makeChannelFactory(options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedObjectKernel.js","sourceRoot":"","sources":["../src/sharedObjectKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAIH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAqBnE,OAAO,EACN,sBAAsB,EACtB,YAAY,GAGZ,MAAM,mBAAmB,CAAC;AAmE3B;;;;;;;;;;;GAWG;AACH,MAAM,sBAGJ,SAAQ,YAAoB;IAW7B,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EACd,OAAkC,EAClD,sBAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC;;QAHvC,YAAO,GAAP,OAAO,CAA2B;QAdnD;;;;;WAKG;QACH,2CAA0C,SAAS,EAAC;QAE3C,qDAAwB;QAWhC,uBAAA,IAAI,sCAAe;YAClB,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,kBAAkB,EAAE,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,CAC3C,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,eAAe,CAAC;YAC7C,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB;YAC9D,qBAAqB,EAAE,IAAI,CAAC,YAAY,CAAC,qBAAqB;YAE9D,+HAA+H;YAC/H,8HAA8H;YAC9H,4HAA4H;YAC5H,4HAA4H;YAC5H,uBAAuB;YACvB,mBAAmB,EAAG,OA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V,QAA0B,EAC1B,UAA8B;YAE9B,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,UAAU,EACV,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YACF,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,MAAiC,CAAC;QAC1C,CAAC;QAED;;WAEG;QACI,MAAM,CAAC,OAA+B,EAAE,EAAU;YACxD,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,cAAc,CAAC,UAAU,EACzB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YAEF,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,OAAO,MAAiC,CAAC;QAC1C,CAAC;;IA3DD;;OAEG;IACoB,mBAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;OAEG;IACoB,yBAAU,GAAuB,OAAO,CAAC,UAAU,CAAC;IAsD5E,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAA+B;IAE/B,OAAO,sBAAsB,CAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIChannelServices,\n\tIFluidDataStoreRuntime,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n\tIRuntimeMessageCollection,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { IFluidSerializer } from \"./serializer.js\";\nimport {\n\tcreateSharedObjectKind,\n\tSharedObject,\n\ttype ISharedObjectKind,\n\ttype SharedObjectKind,\n} from \"./sharedObject.js\";\nimport type { ISharedObjectEvents, ISharedObject } from \"./types.js\";\nimport type { IChannelView } from \"./utils.js\";\n\n/**\n * Functionality specific to a particular kind of {@link ISharedObject}.\n * @remarks\n * Shared objects expose APIs for two consumers:\n *\n * 1. The runtime, which uses {@link @fluidframework/datastore-definitions#IChannel} to summarize and apply ops and {@link @fluidframework/datastore-definitions#IChannelFactory} to create the load summaries.\n *\n * 2. The app, which uses shared object kind specific APIs to read and write data.\n *\n * There is some common functionality all shared objects use, provided by {@link SharedObject} and {@link SharedObjectCore}.\n * SharedKernel describes the portion of the behavior required by the runtime which\n * differs between different kinds of shared objects.\n *\n * {@link makeSharedObjectKind} is then used to wrap up the kernel into a full {@link ISharedObject} implementation.\n * The runtime specific APIs are then type erased into a {@link SharedObjectKind}.\n * @privateRemarks\n * Unlike the `SharedObject` class, this interface is internal, and thus can be adjusted more easily.\n * Therefore this interface is not intended to address all needs, and will likely need small changes as it gets more adoption.\n *\n * @internal\n */\nexport interface SharedKernel {\n\t/**\n\t * {@inheritDoc SharedObject.summarizeCore}\n\t */\n\tsummarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.onDisconnect}\n\t */\n\tonDisconnect(): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.reSubmitCore}\n\t */\n\treSubmitCore(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.applyStashedOp}\n\t */\n\tapplyStashedOp(content: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.processMessagesCore}\n\t */\n\tprocessMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.rollback}\n\t */\n\trollback?(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.didAttach}\n\t */\n\tdidAttach?(): void;\n}\n\n/**\n * SharedObject implementation that delegates to a SharedKernel.\n * @typeParam TOut - The type of the object exposed to the app.\n * Once initialized, instances of this class forward properties to the `TOut` value provided by the factory.\n * See {@link mergeAPIs} for more limitations.\n *\n * @remarks\n * The App facing API (TOut) needs to be implemented by this object which also has to implement the runtime facing API (ISharedObject).\n *\n * Requiring both of these to be implemented by the same object adds some otherwise unnecessary coupling.\n * This class is a workaround for that, which takes separate implementations of the two APIs and merges them into one using {@link mergeAPIs}.\n */\nclass SharedObjectFromKernel<\n\tTOut extends object,\n\tTEvent extends ISharedObjectEvents,\n> extends SharedObject<TEvent> {\n\t/**\n\t * Lazy init here so kernel can be constructed in loadCore when loading from existing data.\n\t *\n\t * Explicit initialization to undefined is done so Proxy knows this property is from this class (via `Reflect.has`),\n\t * not from the grafted APIs.\n\t */\n\t#lazyData: FactoryOut<TOut> | undefined = undefined;\n\n\treadonly #kernelArgs: KernelArgs;\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tpublic readonly factory: SharedKernelFactory<TOut>,\n\t\ttelemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.#kernelArgs = {\n\t\t\tsharedObject: this,\n\t\t\tserializer: this.serializer,\n\t\t\tsubmitLocalMessage: (op, localOpMetadata) =>\n\t\t\t\tthis.submitLocalMessage(op, localOpMetadata),\n\t\t\teventEmitter: this,\n\t\t\tlogger: this.logger,\n\t\t\tidCompressor: runtime.idCompressor,\n\t\t\tlastSequenceNumber: () => this.deltaManager.lastSequenceNumber,\n\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\n\t\t\t// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern\n\t\t\t// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes\n\t\t\t// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the\n\t\t\t// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler\n\t\t\t// would emit an error.\n\t\t\tminVersionForCollab: (runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t.minVersionForCollab,\n\t\t};\n\t}\n\n\tprotected override summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats {\n\t\treturn this.#kernel.summarizeCore(\n\t\t\tserializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t}\n\n\tprotected override initializeLocalCore(): void {\n\t\tthis.#initializeData(this.factory.create(this.#kernelArgs));\n\t}\n\n\t#initializeData(data: FactoryOut<TOut>): void {\n\t\tassert(\n\t\t\tthis.#lazyData === undefined,\n\t\t\t0xb99 /* initializeData must be called first and only once */,\n\t\t);\n\t\tthis.#lazyData = data;\n\n\t\t// Make `this` implement TOut.\n\t\tmergeAPIs(this, data.view);\n\t}\n\n\tget #kernel(): SharedKernel {\n\t\treturn (this.#lazyData ?? fail(0xcb0 /* must initializeData first */)).kernel;\n\t}\n\n\tprotected override async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tthis.#initializeData(await this.factory.loadCore(this.#kernelArgs, storage));\n\t}\n\n\tprotected override onDisconnect(): void {\n\t\tthis.#kernel.onDisconnect();\n\t}\n\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.#kernel.reSubmitCore(content, localOpMetadata);\n\t}\n\n\tprotected override applyStashedOp(content: unknown): void {\n\t\tthis.#kernel.applyStashedOp(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.#kernel.processMessagesCore(messagesCollection);\n\t}\n\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tif (this.#kernel.rollback === undefined) {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.#kernel.rollback(content, localOpMetadata);\n\t\t}\n\t}\n\n\tprotected override didAttach(): void {\n\t\tthis.#kernel.didAttach?.();\n\t}\n}\n\n/**\n * When present on a method, it indicates the methods return value should be replaced with `this` (the wrapper)\n * when wrapping the object with the method.\n * @remarks\n * This is useful when using {@link mergeAPIs} with methods where the return type is `this`, like `Map.set`.\n * @internal\n */\nexport const thisWrap: unique symbol = Symbol(\"selfWrap\");\n\n/**\n * A {@link SharedKernel} providing the implementation of some distributed data structure (DDS) and the needed runtime facing APIs,\n * and a separate view object which exposes the app facing APIs (`T`)\n * for reading and writing data which are specific to this particular data structure.\n * @remarks\n * Output from {@link SharedKernelFactory}.\n * This is an alternative to defining DDSs by sub-classing {@link SharedObject}.\n * @internal\n */\nexport interface FactoryOut<T extends object> {\n\treadonly kernel: SharedKernel;\n\treadonly view: T;\n}\n\n/**\n * A factory for creating DDSs.\n * @remarks\n * Outputs {@link FactoryOut}.\n * This is an alternative to directly implementing {@link @fluidframework/datastore-definitions#IChannelFactory}.\n * Use with {@link makeSharedObjectKind} to create a {@link SharedObjectKind}.\n * @internal\n */\nexport interface SharedKernelFactory<T extends object> {\n\tcreate(args: KernelArgs): FactoryOut<T>;\n\n\t/**\n\t * Create combined with {@link SharedObjectCore.loadCore}.\n\t */\n\tloadCore(args: KernelArgs, storage: IChannelStorageService): Promise<FactoryOut<T>>;\n}\n\n/**\n * Inputs for building a {@link SharedKernel} via {@link SharedKernelFactory}.\n * @internal\n */\nexport interface KernelArgs {\n\t/**\n\t * The shared object whose behavior is being implemented.\n\t */\n\treadonly sharedObject: IChannelView & IFluidLoadable;\n\t/**\n\t * {@inheritdoc SharedObject.serializer}\n\t */\n\treadonly serializer: IFluidSerializer;\n\t/**\n\t * {@inheritdoc SharedObjectCore.submitLocalMessage}\n\t */\n\treadonly submitLocalMessage: (op: unknown, localOpMetadata: unknown) => void;\n\t/**\n\t * Top level emitter for events for this object.\n\t * @remarks\n\t * This is needed since the separate kernel and view from {@link FactoryOut} currently have to be recombined,\n\t * and having this as its own thing helps accomplish that.\n\t */\n\treadonly eventEmitter: TypedEventEmitter<ISharedObjectEvents>;\n\t/**\n\t * {@inheritdoc SharedObjectCore.logger}\n\t */\n\treadonly logger: ITelemetryLoggerExt;\n\t/**\n\t * {@inheritdoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.idCompressor}\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.lastSequenceNumber}\n\t */\n\treadonly lastSequenceNumber: () => number;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.initialSequenceNumber}\n\t */\n\treadonly initialSequenceNumber: number;\n\t/**\n\t * Minimum version of the FF runtime that is required to collaborate on new documents. Used so that a\n\t * compatible set of feature flags and formats can be enabled in the SharedObject implementation.\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.minVersionForCollab} for more details.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab | undefined;\n}\n\n/**\n * Add getters to `base` which forward own properties from `extra`.\n * @remarks\n * This only handles use of \"get\" and \"has\".\n * Therefore, APIs involving setting properties should not be used as `Extra`.\n *\n * Functions from `extra` are bound to the `extra` object and support {@link thisWrap}.\n *\n * Asserts when properties collide.\n * @internal\n */\nexport function mergeAPIs<const Base extends object, const Extra extends object>(\n\tbase: Base,\n\textra: Extra,\n): asserts base is Base & Extra {\n\tfor (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(extra))) {\n\t\tassert(!Reflect.has(base, key), 0xb9a /* colliding properties */);\n\n\t\t// Detect and special case functions.\n\t\t// Currently this is done eagerly (when mergeAPIs is called) rather than lazily (when the property is read):\n\t\t// this eager approach should result in slightly better performance,\n\t\t// but if functions on `extra` are reassigned over time it will produce incorrect behavior.\n\t\t// If this functionality is required, the design can be changed.\n\t\tlet getter: () => unknown;\n\t\t// Bind functions to the extra object and handle thisWrap.\n\t\tif (typeof descriptor.value === \"function\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst fromExtra: () => Extra | Base = descriptor.value;\n\t\t\tgetter = () => forwardMethod(fromExtra, extra, base);\n\t\t\t// To catch (and error on) cases where the function is reassigned and this eager binding approach is not appropriate, make it non-writable.\n\t\t\tObject.defineProperty(extra, key, { ...descriptor, writable: false });\n\t\t} else {\n\t\t\tgetter = () => extra[key];\n\t\t}\n\n\t\tObject.defineProperty(base, key, {\n\t\t\tconfigurable: false,\n\t\t\tenumerable: descriptor.enumerable,\n\t\t\tget: getter,\n\t\t\t// If setters become required, support them here.\n\t\t});\n\t}\n}\n\n/**\n * Wrap a method `f` of `oldThis` to be a method of `newThis`.\n * @remarks\n * The wrapped function will be called with `oldThis` as the `this` parameter.\n * It also accounts for when `f` is marked with {@link thisWrap}.\n */\nfunction forwardMethod<TArgs extends [], TReturn>(\n\tf: (...args: TArgs) => TReturn,\n\toldThis: TReturn,\n\tnewThis: TReturn,\n): (...args: TArgs) => TReturn {\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (thisWrap in f) {\n\t\treturn (...args: TArgs) => {\n\t\t\tconst result = f.call(oldThis, ...args);\n\t\t\tassert(result === oldThis, 0xb9b /* methods returning thisWrap should return this */);\n\t\t\treturn newThis;\n\t\t};\n\t} else {\n\t\treturn f.bind(oldThis);\n\t}\n}\n\n/**\n * Options for creating a {@link SharedObjectKind} via {@link makeSharedObjectKind}.\n * @typeParam T - The type of the object exposed to the app.\n * This can optionally include members from {@link ISharedObject} which will be provided automatically.\n * @internal\n */\nexport interface SharedObjectOptions<T extends object> {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\treadonly type: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\treadonly attributes: IChannelAttributes;\n\n\t/**\n\t * The factory used to create the kernel and its view.\n\t * @remarks\n\t * The view produced by this factory will be grafted onto the {@link SharedObject} using {@link mergeAPIs}.\n\t * See {@link mergeAPIs} for more information on limitations that apply.\n\t */\n\treadonly factory: SharedKernelFactory<Omit<T, keyof ISharedObject>>;\n\n\t/**\n\t * {@inheritDoc SharedObject.telemetryContextPrefix}\n\t */\n\treadonly telemetryContextPrefix: string;\n}\n\n/**\n * Utility to create a {@link @fluidframework/datastore-definitions#IChannelFactory} classes.\n * @remarks\n * Use {@link makeSharedObjectKind} instead unless exposing the factory is required for legacy API compatibility.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction makeChannelFactory<T extends object>(options: SharedObjectOptions<T>) {\n\tclass ChannelFactory implements IChannelFactory<T> {\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic static readonly Type = options.type;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic static readonly Attributes: IChannelAttributes = options.attributes;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic get type(): string {\n\t\t\treturn ChannelFactory.Type;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic get attributes(): IChannelAttributes {\n\t\t\treturn ChannelFactory.Attributes;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t\t */\n\t\tpublic async load(\n\t\t\truntime: IFluidDataStoreRuntime,\n\t\t\tid: string,\n\t\t\tservices: IChannelServices,\n\t\t\tattributes: IChannelAttributes,\n\t\t): Promise<T & IChannel> {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tattributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\t\t\tawait shared.load(services);\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t\t */\n\t\tpublic create(runtime: IFluidDataStoreRuntime, id: string): T & IChannel {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tChannelFactory.Attributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\n\t\t\tshared.initializeLocal();\n\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\t}\n\n\treturn ChannelFactory;\n}\n\n/**\n * Utility to create a {@link SharedObjectKind}.\n * @privateRemarks\n * Using this API avoids having to subclasses any Fluid Framework types,\n * reducing the coupling between the framework and the SharedObject implementation.\n * @internal\n */\nexport function makeSharedObjectKind<T extends object>(\n\toptions: SharedObjectOptions<T>,\n): ISharedObjectKind<T> & SharedObjectKind<T> {\n\treturn createSharedObjectKind<T>(makeChannelFactory(options));\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/shared-object-base",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.81.0",
|
|
4
4
|
"description": "Fluid base class for shared distributed data structures",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,30 +69,30 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/container-definitions": "~2.
|
|
74
|
-
"@fluidframework/core-interfaces": "~2.
|
|
75
|
-
"@fluidframework/core-utils": "~2.
|
|
76
|
-
"@fluidframework/datastore": "~2.
|
|
77
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
78
|
-
"@fluidframework/driver-definitions": "~2.
|
|
79
|
-
"@fluidframework/id-compressor": "~2.
|
|
80
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
81
|
-
"@fluidframework/runtime-utils": "~2.
|
|
82
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
72
|
+
"@fluid-internal/client-utils": "~2.81.0",
|
|
73
|
+
"@fluidframework/container-definitions": "~2.81.0",
|
|
74
|
+
"@fluidframework/core-interfaces": "~2.81.0",
|
|
75
|
+
"@fluidframework/core-utils": "~2.81.0",
|
|
76
|
+
"@fluidframework/datastore": "~2.81.0",
|
|
77
|
+
"@fluidframework/datastore-definitions": "~2.81.0",
|
|
78
|
+
"@fluidframework/driver-definitions": "~2.81.0",
|
|
79
|
+
"@fluidframework/id-compressor": "~2.81.0",
|
|
80
|
+
"@fluidframework/runtime-definitions": "~2.81.0",
|
|
81
|
+
"@fluidframework/runtime-utils": "~2.81.0",
|
|
82
|
+
"@fluidframework/telemetry-utils": "~2.81.0",
|
|
83
83
|
"uuid": "^11.1.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
87
87
|
"@biomejs/biome": "~1.9.3",
|
|
88
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
89
|
-
"@fluid-private/test-pairwise-generator": "~2.
|
|
90
|
-
"@fluid-tools/build-cli": "^0.
|
|
88
|
+
"@fluid-internal/mocha-test-setup": "~2.81.0",
|
|
89
|
+
"@fluid-private/test-pairwise-generator": "~2.81.0",
|
|
90
|
+
"@fluid-tools/build-cli": "^0.63.0",
|
|
91
91
|
"@fluidframework/build-common": "^2.0.3",
|
|
92
|
-
"@fluidframework/build-tools": "^0.
|
|
93
|
-
"@fluidframework/eslint-config-fluid": "~2.
|
|
94
|
-
"@fluidframework/shared-object-base-previous": "npm:@fluidframework/shared-object-base@2.
|
|
95
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
92
|
+
"@fluidframework/build-tools": "^0.63.0",
|
|
93
|
+
"@fluidframework/eslint-config-fluid": "~2.81.0",
|
|
94
|
+
"@fluidframework/shared-object-base-previous": "npm:@fluidframework/shared-object-base@2.80.0",
|
|
95
|
+
"@fluidframework/test-runtime-utils": "~2.81.0",
|
|
96
96
|
"@microsoft/api-extractor": "7.52.11",
|
|
97
97
|
"@types/benchmark": "^2.1.0",
|
|
98
98
|
"@types/mocha": "^10.0.10",
|
package/src/packageVersion.ts
CHANGED
package/src/sharedObject.ts
CHANGED
|
@@ -238,6 +238,7 @@ export abstract class SharedObjectCore<
|
|
|
238
238
|
* @param error - error object that is thrown whenever an attempt is made to modify this object
|
|
239
239
|
*/
|
|
240
240
|
private closeWithError(error: IFluidErrorBase | undefined): void {
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy
|
|
241
242
|
if (this.closeError === undefined) {
|
|
242
243
|
this.closeError = error;
|
|
243
244
|
}
|
|
@@ -184,7 +184,7 @@ class SharedObjectFromKernel<
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
get #kernel(): SharedKernel {
|
|
187
|
-
return (this.#lazyData ?? fail(
|
|
187
|
+
return (this.#lazyData ?? fail(0xcb0 /* must initializeData first */)).kernel;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
protected override async loadCore(storage: IChannelStorageService): Promise<void> {
|
package/.eslintrc.cjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
extends: [require.resolve("@fluidframework/eslint-config-fluid/recommended"), "prettier"],
|
|
8
|
-
parserOptions: {
|
|
9
|
-
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
-
},
|
|
11
|
-
rules: {
|
|
12
|
-
// #region TODO: remove these once eslint-config-fluid has been updated to 5.8.0
|
|
13
|
-
"@typescript-eslint/consistent-type-exports": [
|
|
14
|
-
"error",
|
|
15
|
-
{ fixMixedExportsWithInlineTypeSpecifier: true },
|
|
16
|
-
],
|
|
17
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
18
|
-
"error",
|
|
19
|
-
{ fixStyle: "inline-type-imports" },
|
|
20
|
-
],
|
|
21
|
-
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
22
|
-
// #endregion
|
|
23
|
-
},
|
|
24
|
-
};
|