@fluidframework/shared-object-base 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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/.eslintrc.js +5 -8
- package/.mocharc.js +2 -2
- package/README.md +1 -1
- package/api-extractor.json +2 -2
- package/bench/src/index.ts +37 -33
- package/bench/src/util.ts +26 -26
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/remoteObjectHandle.d.ts.map +1 -1
- package/dist/remoteObjectHandle.js +16 -8
- package/dist/remoteObjectHandle.js.map +1 -1
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +5 -7
- package/dist/serializer.js.map +1 -1
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +7 -4
- package/dist/sharedObject.js.map +1 -1
- package/dist/summarySerializer.d.ts.map +1 -1
- package/dist/summarySerializer.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -3
- package/dist/utils.js.map +1 -1
- package/dist/valueType.d.ts.map +1 -1
- package/dist/valueType.js.map +1 -1
- package/lib/handle.d.ts.map +1 -1
- package/lib/handle.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/remoteObjectHandle.d.ts.map +1 -1
- package/lib/remoteObjectHandle.js +17 -9
- package/lib/remoteObjectHandle.js.map +1 -1
- package/lib/serializer.d.ts.map +1 -1
- package/lib/serializer.js +5 -7
- package/lib/serializer.js.map +1 -1
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +7 -4
- package/lib/sharedObject.js.map +1 -1
- package/lib/summarySerializer.d.ts.map +1 -1
- package/lib/summarySerializer.js.map +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -3
- package/lib/utils.js.map +1 -1
- package/lib/valueType.d.ts.map +1 -1
- package/lib/valueType.js.map +1 -1
- package/package.json +49 -48
- package/prettier.config.cjs +1 -1
- package/src/handle.ts +28 -28
- package/src/index.ts +12 -2
- package/src/packageVersion.ts +1 -1
- package/src/remoteObjectHandle.ts +70 -55
- package/src/serializer.ts +182 -187
- package/src/sharedObject.ts +702 -650
- package/src/summarySerializer.ts +8 -8
- package/src/types.ts +50 -31
- package/src/utils.ts +20 -26
- package/src/valueType.ts +9 -9
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/dist/sharedObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAElC,+DAA6E;AAC7E,iFAAoE;AASpE,6EAM6C;AAC7C,qEAOyC;AACzC,qEAAsE;AACtE,6CAAiE;AACjE,qCAA8C;AAC9C,2DAAwD;AAGxD;;GAEG;AACH,MAAsB,gBAClB,SAAQ,+CAAqC;IA6C7C;;;;OAIG;IACH,YACW,EAAU,EACP,OAA+B,EACzB,UAA8B;QAC9C,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAM,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAHnF,OAAE,GAAF,EAAE,CAAQ;QACP,YAAO,GAAP,OAAO,CAAwB;QACzB,eAAU,GAAV,UAAU,CAAoB;QApClD;;WAEG;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,GAAG,IAAI,CAAC;QAErB,IAAI,MAA8B,CAAC;QACnC,IAAI;YACA,MAAM,UAAU,GAAG,IAAI,qCAAiB,CACpC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EACnC,CAAC,MAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CACvD,CAAC;YACF,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACnC,yGAAyG;YACzG,qDAAqD;YACrD,MAAM,GAAG,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,mBAAmB,EAAE,EAAE,EAAE,CAAC;YAChE,IAAA,qBAAM,EAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,mEAAmE,CAAC,CAAC;SACpG;gBAAS;YACN,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACzB;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;OAGG;IACO,iBAAiB,CAAC,UAA6B;QACrD,wGAAwG;QACxG,2GAA2G;QAC3G,+DAA+D;QAC/D,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAWO,wBAAwB,CAAC,YAAoB,EAAE,WAAmB,EAAE,gBAAoC;;QAC5G,MAAM,SAAS,GAAG,CAAC,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,CAAC,mCAAI,CAAC,CAAW,CAAC;QACpG,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;IAC9F,CAAC;CACJ;AA3HD,oCA2HC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert, EventEmitterEventType } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n IGarbageCollectionData,\n ISummaryTreeWithStats,\n ITelemetryContext,\n blobCountPropertyName,\n totalBlobSizePropertyName,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n ChildLogger,\n EventEmitterWithErrorHandling,\n loggerToMonitoringContext,\n MonitoringContext,\n SampledTelemetryHelper,\n TelemetryDataTag,\n} from \"@fluidframework/telemetry-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { FluidSerializer, IFluidSerializer } from \"./serializer\";\nimport { SharedObjectHandle } from \"./handle\";\nimport { SummarySerializer } from \"./summarySerializer\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types\";\n\n/**\n * Base class from which all shared objects derive.\n */\nexport abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {\n public get IFluidLoadable() { return this; }\n\n private readonly opProcessingHelper: SampledTelemetryHelper;\n private readonly callbacksHelper: SampledTelemetryHelper;\n\n /**\n * The handle referring to this SharedObject\n */\n public readonly handle: IFluidHandle;\n\n /**\n * Telemetry logger for the shared object\n */\n protected readonly logger: ITelemetryLogger;\n private readonly mc: MonitoringContext;\n\n /**\n * Connection state\n */\n private _connected = false;\n\n /**\n * Services used by the shared object\n */\n private services: IChannelServices | undefined;\n\n /**\n * True if the dds is bound to its parent.\n */\n private _isBoundToContext: boolean = false;\n\n /**\n * Tracks error that closed this object.\n */\n private closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n /**\n * Gets the connection state\n * @returns The state of the connection\n */\n public get connected(): boolean {\n return this._connected;\n }\n\n /**\n * @param id - The id of the shared object\n * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n * @param attributes - Attributes of the shared object\n */\n constructor(\n public id: string,\n protected runtime: IFluidDataStoreRuntime,\n public readonly attributes: IChannelAttributes) {\n super((event: EventEmitterEventType, e: any) => this.eventListenerErrorHandler(event, e));\n\n assert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n this.handle = new SharedObjectHandle(\n this,\n id,\n runtime.IFluidHandleContext);\n\n this.logger = ChildLogger.create(\n runtime.logger,\n undefined,\n {\n all: {\n sharedObjectId: uuid(),\n ddsType: {\n value: this.attributes.type,\n tag: TelemetryDataTag.CodeArtifact,\n },\n },\n },\n );\n this.mc = loggerToMonitoringContext(this.logger);\n\n [this.opProcessingHelper, this.callbacksHelper] = this.setUpSampledTelemetryHelpers();\n\n this.attachListeners();\n }\n\n /**\n * This function is only supposed to be called from SharedObjectCore's constructor and\n * depends on a few things being set already. assert() calls make sure of it.\n * @returns The telemetry sampling helpers, so the constructor can be the one to assign them\n * to variables to avoid complaints from TypeScript.\n */\n private setUpSampledTelemetryHelpers(): SampledTelemetryHelper[] {\n assert(this.mc !== undefined && this.logger !== undefined,\n 0x349 /* this.mc and/or this.logger has not been set */);\n const opProcessingHelper = new SampledTelemetryHelper(\n {\n eventName: \"ddsOpProcessing\",\n category: \"performance\",\n },\n this.logger,\n this.mc.config.getNumber(\"Fluid.SharedObject.OpProcessingTelemetrySampling\") ?? 100,\n true,\n new Map<string, ITelemetryProperties>([\n [\"local\", { localOp: true }],\n [\"remote\", { localOp: false }],\n ]));\n const callbacksHelper = new SampledTelemetryHelper(\n {\n eventName: \"ddsEventCallbacks\",\n category: \"performance\",\n },\n this.logger,\n this.mc.config.getNumber(\"Fluid.SharedObject.DdsCallbacksTelemetrySampling\") ?? 100,\n true);\n\n this.runtime.once(\"dispose\", () => {\n this.callbacksHelper.dispose();\n this.opProcessingHelper.dispose();\n });\n\n return [opProcessingHelper, callbacksHelper];\n }\n\n /**\n * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n * would result in same error thrown. If called multiple times, only first error is remembered.\n * @param error - error object that is thrown whenever an attempt is made to modify this object\n */\n private closeWithError(error: any) {\n if (this.closeError === undefined) {\n this.closeError = error;\n }\n }\n\n /**\n * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n */\n private verifyNotClosed() {\n if (this.closeError !== undefined) {\n throw this.closeError;\n }\n }\n\n /**\n * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n * It wraps error with DataProcessingError, closes this object and throws resulting error.\n * See closeWithError() for more details\n * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n * allow processing of ops or local changes, which very quickly results in container closure.\n */\n private eventListenerErrorHandler(event: EventEmitterEventType, e: any) {\n const error = DataProcessingError.wrapIfUnrecognized(\n e,\n \"SharedObjectEventListenerException\");\n error.addTelemetryProperties({ emittedEventName: String(event) });\n\n this.closeWithError(error);\n throw error;\n }\n\n private attachListeners() {\n // Only listen to these events if not attached.\n if (!this.isAttached()) {\n this.runtime.once(\"attaching\", () => {\n // Calling this will let the dds to do any custom processing based on attached\n // like starting generating ops.\n this.didAttach();\n });\n }\n }\n\n /**\n * A shared object, after construction, can either be loaded in the case that it is already part of\n * a shared document. Or later attached if it is being newly added.\n * @param services - Services used by the shared object\n */\n public async load(services: IChannelServices): Promise<void> {\n if (this.runtime.attachState !== AttachState.Detached) {\n this.services = services;\n }\n await this.loadCore(services.objectStorage);\n if (this.runtime.attachState !== AttachState.Detached) {\n this.attachDeltaHandler();\n }\n }\n\n /**\n * Initializes the object as a local, non-shared object. This object can become shared after\n * it is attached to the document.\n */\n public initializeLocal(): void {\n this.initializeLocalCore();\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).bindToContext}\n */\n public bindToContext(): void {\n if (this._isBoundToContext) {\n return;\n }\n\n this._isBoundToContext = true;\n\n this.runtime.bindChannel(this);\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n */\n public connect(services: IChannelServices) {\n this.services = services;\n this.attachDeltaHandler();\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n */\n public isAttached(): boolean {\n return this.services !== undefined && this.runtime.attachState !== AttachState.Detached;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n */\n public abstract getAttachSummary(\n fullTree?: boolean,\n trackState?: boolean,\n telemetryContext?: ITelemetryContext,\n ): ISummaryTreeWithStats;\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n */\n public abstract summarize(\n fullTree?: boolean,\n trackState?: boolean,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummaryTreeWithStats>;\n\n /**\n * {@inheritDoc (ISharedObject:interface).getGCData}\n */\n public abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n /**\n * Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference\n * to another object in the container.\n * @param decodedHandle - The handle of the Fluid object that is decoded.\n */\n protected handleDecoded(decodedHandle: IFluidHandle) {\n if (this.isAttached()) {\n // This represents an outbound reference from this object to the node represented by decodedHandle.\n this.services?.deltaConnection.addedGCOutboundReference?.(this.handle, decodedHandle);\n }\n }\n\n /**\n * Allows the distributed data type to perform custom loading\n * @param services - Storage used by the shared object\n */\n protected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n /**\n * Allows the distributed data type to perform custom local loading.\n */\n protected initializeLocalCore() {\n return;\n }\n\n /**\n * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n * Also called after non-local data type get loaded.\n */\n protected didAttach() {\n return;\n }\n\n /**\n * Derived classes must override this to do custom processing on a remote message.\n * @param message - The message to process\n * @param local - True if the shared object is local\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n protected abstract processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown);\n\n /**\n * Called when the object has disconnected from the delta stream.\n */\n protected abstract onDisconnect();\n\n /**\n * Submits a message by the local client to the runtime.\n * @param content - Content of the message\n * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n */\n protected submitLocalMessage(content: any, localOpMetadata: unknown = undefined): void {\n this.verifyNotClosed();\n if (this.isAttached()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.submit(content, localOpMetadata);\n }\n }\n\n /**\n * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n * that want to be part of summary but does not generate ops.\n */\n protected dirty(): void {\n if (!this.isAttached()) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.services!.deltaConnection.dirty();\n }\n\n /**\n * Called when the object has fully connected to the delta stream\n * Default implementation for DDS, override if different behavior is required.\n */\n protected onConnect() { }\n\n /**\n * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n * The default implementation here is to resubmit the same message. The client can override if different behavior\n * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n * anything at all.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n this.submitLocalMessage(content, localOpMetadata);\n }\n\n /**\n * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n * the Promise will reject.\n * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n */\n protected async newAckBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n // Note: rejectBecauseDispose will never be undefined here\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n\n private attachDeltaHandler() {\n // Services should already be there in case we are attaching delta handler.\n assert(this.services !== undefined, 0x07a /* \"Services should be there to attach delta handler\" */);\n this._isBoundToContext = true;\n // Allows objects to do any custom processing if it is attached.\n this.didAttach();\n\n // attachDeltaHandler is only called after services is assigned\n this.services.deltaConnection.attach({\n process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => {\n this.process(message, local, localOpMetadata);\n },\n setConnectionState: (connected: boolean) => {\n this.setConnectionState(connected);\n },\n reSubmit: (content: any, localOpMetadata: unknown) => {\n this.reSubmit(content, localOpMetadata);\n },\n applyStashedOp: (content: any): unknown => {\n return this.applyStashedOp(content);\n },\n rollback: (content: any, localOpMetadata: unknown) => {\n this.rollback(content, localOpMetadata);\n },\n });\n\n // Trigger initial state\n // attachDeltaHandler is only called after services is assigned\n this.setConnectionState(this.services.deltaConnection.connected);\n }\n\n /**\n * Set the state of connection to services.\n * @param connected - true if connected, false otherwise.\n */\n private setConnectionState(connected: boolean) {\n if (this._connected === connected) {\n // Not changing state, nothing the same.\n return;\n }\n\n // Should I change the state at the end? So that we *can't* send new stuff before we send old?\n this._connected = connected;\n\n if (!connected) {\n // Things that are true now...\n // - if we had a connection we can no longer send messages over it\n // - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n //\n // - nack could get a new msn - but might as well do it in the join?\n this.onDisconnect();\n } else {\n // Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending\n // messages will work.\n this.onConnect();\n }\n }\n\n /**\n * Handles a message being received from the remote delta server.\n * @param message - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n private process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n this.verifyNotClosed(); // This will result in container closure.\n this.emitInternal(\"pre-op\", message, local, this);\n\n this.opProcessingHelper.measure(\n () => { this.processCore(message, local, localOpMetadata); },\n local ? \"local\" : \"remote\");\n\n this.emitInternal(\"op\", message, local, this);\n }\n\n /**\n * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n * reconnection.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n private reSubmit(content: any, localOpMetadata: unknown) {\n this.reSubmitCore(content, localOpMetadata);\n }\n\n /**\n * Revert an op\n */\n protected rollback(content: any, localOpMetadata: unknown) {\n throw new Error(\"rollback not supported\");\n }\n\n /**\n * Apply changes from an op. Used when rehydrating an attached container\n * with pending changes. This prepares the SharedObject for seeing an ACK\n * for the op or resubmitting the op upon reconnection.\n * @param content - Contents of a stashed op.\n * @returns localMetadata of the op, to be passed to process() or resubmit()\n * when the op is ACKed or resubmitted, respectively\n */\n protected abstract applyStashedOp(content: any): unknown;\n\n /**\n * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,\n * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners\n * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events\n * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the\n * future.\n *\n * @internal\n *\n * @param event - The event to emit.\n * @param args - Arguments to pass to the event listeners.\n * @returns `true` if the event had listeners, `false` otherwise.\n */\n public emit(event: EventEmitterEventType, ...args: any[]): boolean {\n return this.callbacksHelper.measure(() => {\n // Creating ops while handling a DDS event can lead\n // to undefined behavior and events observed in the wrong order.\n // For example, we have two callbacks registered for a DDS, A and B.\n // Then if on change #1 callback A creates change #2, the invocation flow will be:\n //\n // A because of #1\n // A because of #2\n // B because of #2\n // B because of #1\n //\n // The runtime must enforce op coherence by not allowing any ops to be created during\n // the event handler\n return this.runtime.ensureNoDataModelChanges(() => super.emit(event, ...args));\n });\n }\n\n /**\n * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement\n * done on the duration of the callbacks. Simply calls `super.emit()`.\n * @param event - Event to emit\n * @param args - Arguments for the event\n * @returns Whatever `super.emit()` returns.\n */\n private emitInternal(\n event: EventEmitterEventType,\n ...args: any[]): boolean {\n return super.emit(event, ...args);\n }\n}\n\n/**\n * SharedObject with simplified, synchronous summarization and GC.\n * DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.\n */\nexport abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n extends SharedObjectCore<TEvent> {\n /**\n * True while we are garbage collecting this object's data.\n */\n private _isGCing: boolean = false;\n\n /**\n * The serializer to use to serialize / parse handles, if any.\n */\n private readonly _serializer: IFluidSerializer;\n\n protected get serializer(): IFluidSerializer {\n /**\n * During garbage collection, the SummarySerializer keeps track of IFluidHandles that are serialized. These\n * handles represent references to other Fluid objects.\n *\n * This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content\n * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n */\n assert(!this._isGCing,\n 0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */);\n return this._serializer;\n }\n\n /**\n * @param id - The id of the shared object\n * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n * @param attributes - Attributes of the shared object\n */\n constructor(\n id: string,\n runtime: IFluidDataStoreRuntime,\n attributes: IChannelAttributes,\n private readonly telemetryContextPrefix: string,\n ) {\n super(id, runtime, attributes);\n\n this._serializer = new FluidSerializer(\n this.runtime.channelsRoutingContext,\n (handle: IFluidHandle) => this.handleDecoded(handle),\n );\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n */\n public getAttachSummary(\n fullTree: boolean = false,\n trackState: boolean = false,\n telemetryContext?: ITelemetryContext,\n ): ISummaryTreeWithStats {\n const result = this.summarizeCore(this.serializer, telemetryContext);\n this.incrementTelemetryMetric(blobCountPropertyName, result.stats.blobNodeCount, telemetryContext);\n this.incrementTelemetryMetric(totalBlobSizePropertyName, result.stats.totalBlobSize, telemetryContext);\n return result;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n */\n public async summarize(\n fullTree: boolean = false,\n trackState: boolean = false,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummaryTreeWithStats> {\n const result = this.summarizeCore(this.serializer, telemetryContext);\n this.incrementTelemetryMetric(blobCountPropertyName, result.stats.blobNodeCount, telemetryContext);\n this.incrementTelemetryMetric(totalBlobSizePropertyName, result.stats.totalBlobSize, telemetryContext);\n return result;\n }\n\n /**\n * {@inheritDoc (ISharedObject:interface).getGCData}\n */\n public getGCData(fullGC: boolean = false): IGarbageCollectionData {\n // Set _isGCing to true. This flag is used to ensure that we only use SummarySerializer to serialize handles\n // in this object's data.\n assert(!this._isGCing, 0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */);\n this._isGCing = true;\n\n let gcData: IGarbageCollectionData;\n try {\n const serializer = new SummarySerializer(\n this.runtime.channelsRoutingContext,\n (handle: IFluidHandle) => this.handleDecoded(handle),\n );\n this.processGCDataCore(serializer);\n // The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n // routes of handles serialized during summarization.\n gcData = { gcNodes: { \"/\": serializer.getSerializedRoutes() } };\n assert(this._isGCing, 0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */);\n } finally {\n this._isGCing = false;\n }\n\n return gcData;\n }\n\n /**\n * Calls the serializer over all data in this object that reference other GC nodes.\n * Derived classes must override this to provide custom list of references to other GC nodes.\n */\n protected processGCDataCore(serializer: SummarySerializer) {\n // We run the full summarize logic to get the list of outbound routes from this object. This is a little\n // expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n // See: https://github.com/microsoft/FluidFramework/issues/4547\n this.summarizeCore(serializer);\n }\n\n /**\n * Gets a form of the object that can be serialized.\n * @returns A tree representing the snapshot of the shared object.\n */\n protected abstract summarizeCore(\n serializer: IFluidSerializer,\n telemetryContext?: ITelemetryContext,\n ): ISummaryTreeWithStats;\n\n private incrementTelemetryMetric(propertyName: string, incrementBy: number, telemetryContext?: ITelemetryContext) {\n const prevTotal = (telemetryContext?.get(this.telemetryContextPrefix, propertyName) ?? 0) as number;\n telemetryContext?.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAElC,+DAA6E;AAC7E,iFAAoE;AASpE,6EAM6C;AAC7C,qEAOyC;AACzC,qEAAsE;AACtE,6CAAiE;AACjE,qCAA8C;AAC9C,2DAAwD;AAGxD;;GAEG;AACH,MAAsB,gBACrB,SAAQ,+CAAqC;IAiD7C;;;;OAIG;IACH,YACQ,EAAU,EACP,OAA+B,EACzB,UAA8B;QAE9C,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAM,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAJnF,OAAE,GAAF,EAAE,CAAQ;QACP,YAAO,GAAP,OAAO,CAAwB;QACzB,eAAU,GAAV,UAAU,CAAoB;QApC/C;;WAEG;QACK,eAAU,GAAG,KAAK,CAAC;QAO3B;;WAEG;QACK,sBAAiB,GAAY,KAAK,CAAC;QA2B1C,IAAA,qBAAM,EAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAEjE,IAAI,CAAC,MAAM,GAAG,IAAI,2BAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAE5E,IAAI,CAAC,MAAM,GAAG,6BAAW,C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AAmB,EAAE,EAAE,EAAE,CAAC;YAChE,IAAA,qBAAM,EACL,IAAI,CAAC,QAAQ,EACb,KAAK,CAAC,mEAAmE,CACzE,CAAC;SACF;gBAAS;YACT,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACtB;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;OAGG;IACO,iBAAiB,CAAC,UAA6B;QACxD,wGAAwG;QACxG,2GAA2G;QAC3G,+DAA+D;QAC/D,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAWO,wBAAwB,CAC/B,YAAoB,EACpB,WAAmB,EACnB,gBAAoC;;QAEpC,MAAM,SAAS,GAAG,CAAC,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,CAAC,mCAClF,CAAC,CAAW,CAAC;QACd,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;IAC3F,CAAC;CACD;AAzJD,oCAyJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert, EventEmitterEventType } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tblobCountPropertyName,\n\ttotalBlobSizePropertyName,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tChildLogger,\n\tEventEmitterWithErrorHandling,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n\tSampledTelemetryHelper,\n\tTelemetryDataTag,\n} from \"@fluidframework/telemetry-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { FluidSerializer, IFluidSerializer } from \"./serializer\";\nimport { SharedObjectHandle } from \"./handle\";\nimport { SummarySerializer } from \"./summarySerializer\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types\";\n\n/**\n * Base class from which all shared objects derive.\n */\nexport abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n\textends EventEmitterWithErrorHandling<TEvent>\n\timplements ISharedObject<TEvent>\n{\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\tprivate readonly opProcessingHelper: SampledTelemetryHelper;\n\tprivate readonly callbacksHelper: SampledTelemetryHelper;\n\n\t/**\n\t * The handle referring to this SharedObject\n\t */\n\tpublic readonly handle: IFluidHandle;\n\n\t/**\n\t * Telemetry logger for the shared object\n\t */\n\tprotected readonly logger: ITelemetryLogger;\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\t/**\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t */\n\tconstructor(\n\t\tpublic id: string,\n\t\tprotected runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly attributes: IChannelAttributes,\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: any) => this.eventListenerErrorHandler(event, e));\n\n\t\tassert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n\t\tthis.handle = new SharedObjectHandle(this, id, runtime.IFluidHandleContext);\n\n\t\tthis.logger = ChildLogger.create(runtime.logger, undefined, {\n\t\t\tall: {\n\t\t\t\tsharedObjectId: uuid(),\n\t\t\t\tddsType: {\n\t\t\t\t\tvalue: this.attributes.type,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.mc = loggerToMonitoringContext(this.logger);\n\n\t\t[this.opProcessingHelper, this.callbacksHelper] = this.setUpSampledTelemetryHelpers();\n\n\t\tthis.attachListeners();\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(): SampledTelemetryHelper[] {\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(\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\") ?? 100,\n\t\t\ttrue,\n\t\t\tnew Map<string, ITelemetryProperties>([\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(\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\") ?? 100,\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: any) {\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() {\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: any) {\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 attachListeners() {\n\t\t// Only listen to these events if not attached.\n\t\tif (!this.isAttached()) {\n\t\t\tthis.runtime.once(\"attaching\", () => {\n\t\t\t\t// Calling this will let the dds to do any custom processing based on attached\n\t\t\t\t// like starting generating ops.\n\t\t\t\tthis.didAttach();\n\t\t\t});\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\tif (this.runtime.attachState !== AttachState.Detached) {\n\t\t\tthis.services = services;\n\t\t}\n\t\tawait this.loadCore(services.objectStorage);\n\t\tif (this.runtime.attachState !== AttachState.Detached) {\n\t\t\tthis.attachDeltaHandler();\n\t\t}\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\tif (this._isBoundToContext) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._isBoundToContext = true;\n\n\t\tthis.runtime.bindChannel(this);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n\t */\n\tpublic connect(services: IChannelServices) {\n\t\tthis.services = services;\n\t\tthis.attachDeltaHandler();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n\t */\n\tpublic isAttached(): boolean {\n\t\treturn this.services !== undefined && 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 (ISharedObject:interface).getGCData}\n\t */\n\tpublic abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference\n\t * to another object in the container.\n\t * @param decodedHandle - The handle of the Fluid object that is decoded.\n\t */\n\tprotected handleDecoded(decodedHandle: IFluidHandle) {\n\t\tif (this.isAttached()) {\n\t\t\t// This represents an outbound reference from this object to the node represented by decodedHandle.\n\t\t\tthis.services?.deltaConnection.addedGCOutboundReference?.(this.handle, decodedHandle);\n\t\t}\n\t}\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() {\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() {\n\t\treturn;\n\t}\n\n\t/**\n\t * Derived classes must override this to do custom processing on a remote message.\n\t * @param message - The message to process\n\t * @param local - True if the shared object is local\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprotected abstract processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t);\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\tprotected abstract onDisconnect();\n\n\t/**\n\t * Submits a message by the local client to the runtime.\n\t * @param content - Content of the message\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: any, localOpMetadata: unknown = undefined): void {\n\t\tthis.verifyNotClosed();\n\t\tif (this.isAttached()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(content, 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() {}\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: any, localOpMetadata: unknown) {\n\t\tthis.submitLocalMessage(content, localOpMetadata);\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?: any) => 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(\n\t\t\t\t\t\t\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\",\n\t\t\t\t\t),\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() {\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\tthis._isBoundToContext = true;\n\t\t// Allows objects to do any custom processing if it is attached.\n\t\tthis.didAttach();\n\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.services.deltaConnection.attach({\n\t\t\tprocess: (\n\t\t\t\tmessage: ISequencedDocumentMessage,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: unknown,\n\t\t\t) => {\n\t\t\t\tthis.process(message, local, localOpMetadata);\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: any, localOpMetadata: unknown) => {\n\t\t\t\tthis.reSubmit(content, localOpMetadata);\n\t\t\t},\n\t\t\tapplyStashedOp: (content: any): unknown => {\n\t\t\t\treturn this.applyStashedOp(content);\n\t\t\t},\n\t\t\trollback: (content: any, localOpMetadata: unknown) => {\n\t\t\t\tthis.rollback(content, localOpMetadata);\n\t\t\t},\n\t\t});\n\n\t\t// Trigger initial state\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.setConnectionState(this.services.deltaConnection.connected);\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) {\n\t\tif (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// 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} else {\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}\n\t}\n\n\t/**\n\t * Handles a message being received from the remote delta server.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprivate process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n\t\tthis.verifyNotClosed(); // This will result in container closure.\n\t\tthis.emitInternal(\"pre-op\", message, local, this);\n\n\t\tthis.opProcessingHelper.measure(\n\t\t\t() => {\n\t\t\t\tthis.processCore(message, local, localOpMetadata);\n\t\t\t},\n\t\t\tlocal ? \"local\" : \"remote\",\n\t\t);\n\n\t\tthis.emitInternal(\"op\", message, local, this);\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 */\n\tprivate reSubmit(content: any, localOpMetadata: unknown) {\n\t\tthis.reSubmitCore(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown) {\n\t\tthrow new Error(\"rollback not supported\");\n\t}\n\n\t/**\n\t * Apply changes from an op. Used when rehydrating an attached container\n\t * with pending changes. This prepares the SharedObject for seeing an ACK\n\t * for the op or resubmitting the op upon reconnection.\n\t * @param content - Contents of a stashed op.\n\t * @returns localMetadata of the op, to be passed to process() or resubmit()\n\t * when the op is ACKed or resubmitted, respectively\n\t */\n\tprotected abstract applyStashedOp(content: any): unknown;\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 *\n\t * @internal\n\t *\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// Creating ops while handling a DDS event can lead\n\t\t\t// to undefined behavior and events observed in the wrong order.\n\t\t\t// For example, we have two callbacks registered for a DDS, A and B.\n\t\t\t// Then if on change #1 callback A creates change #2, the invocation flow will be:\n\t\t\t//\n\t\t\t// A because of #1\n\t\t\t// A because of #2\n\t\t\t// B because of #2\n\t\t\t// B because of #1\n\t\t\t//\n\t\t\t// The runtime must enforce op coherence by not allowing any ops to be created during\n\t\t\t// the event handler\n\t\t\treturn this.runtime.ensureNoDataModelChanges(() => 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: any[]): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n}\n\n/**\n * SharedObject with simplified, synchronous summarization and GC.\n * DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.\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 SummarySerializer 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 DDss, 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\t/**\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t */\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly telemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes);\n\n\t\tthis._serializer = new FluidSerializer(\n\t\t\tthis.runtime.channelsRoutingContext,\n\t\t\t(handle: IFluidHandle) => this.handleDecoded(handle),\n\t\t);\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(this.serializer, telemetryContext);\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): Promise<ISummaryTreeWithStats> {\n\t\tconst result = this.summarizeCore(this.serializer, telemetryContext);\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 (ISharedObject: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 SummarySerializer to serialize handles\n\t\t// in this object's data.\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 serializer = new SummarySerializer(\n\t\t\t\tthis.runtime.channelsRoutingContext,\n\t\t\t\t(handle: IFluidHandle) => this.handleDecoded(handle),\n\t\t\t);\n\t\t\tthis.processGCDataCore(serializer);\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: { \"/\": serializer.getSerializedRoutes() } };\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\tprotected processGCDataCore(serializer: SummarySerializer) {\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): ISummaryTreeWithStats;\n\n\tprivate incrementTelemetryMetric(\n\t\tpropertyName: string,\n\t\tincrementBy: number,\n\t\ttelemetryContext?: ITelemetryContext,\n\t) {\n\t\tconst prevTotal = (telemetryContext?.get(this.telemetryContextPrefix, propertyName) ??\n\t\t\t0) as number;\n\t\ttelemetryContext?.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarySerializer.d.ts","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"summarySerializer.d.ts","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA0B;IACpD,mBAAmB,IAAI,MAAM,EAAE;IAItC,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY;;;;CAIlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarySerializer.js","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6CAA+C;AAE/C;;GAEG;AACH,MAAa,iBAAkB,SAAQ,4BAAe;IAAtD;;
|
|
1
|
+
{"version":3,"file":"summarySerializer.js","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6CAA+C;AAE/C;;GAEG;AACH,MAAa,iBAAkB,SAAQ,4BAAe;IAAtD;;QACkB,qBAAgB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAS5D,CAAC;IARO,mBAAmB;QACzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC1C,CAAC;IAES,eAAe,CAAC,MAAoB,EAAE,IAAkB;QACjE,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;CACD;AAVD,8CAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { FluidSerializer } from \"./serializer\";\n\n/**\n * Serializer implementation for serializing handles during summary.\n */\nexport class SummarySerializer extends FluidSerializer {\n\tprivate readonly serializedRoutes: Set<string> = new Set();\n\tpublic getSerializedRoutes(): string[] {\n\t\treturn Array.from(this.serializedRoutes);\n\t}\n\n\tprotected serializeHandle(handle: IFluidHandle, bind: IFluidHandle) {\n\t\tthis.serializedRoutes.add(handle.absolutePath);\n\t\treturn super.serializeHandle(handle, bind);\n\t}\n}\n"]}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACvD;;;;;;;OAOG;IACH,CACC,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CACT,EAAE,EAAE,yBAAyB,EAC7B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,qBAAqB,KACzB,IAAI,OACR;IAEF;;;;;;;OAOG;IACH,CACC,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,CACT,EAAE,EAAE,yBAAyB,EAC7B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,qBAAqB,KACzB,IAAI,OACR;CACF;AAED;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB,CACtF,SAAQ,QAAQ,EACf,cAAc,CAAC,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;OAIG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,sBAAsB,CAAC;CACpD"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIErrorEvent,\n\tIEventProvider,\n\tIEventThisPlaceHolder,\n} from \"@fluidframework/common-definitions\";\nimport { IChannel } from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions\";\n\n/**\n * Events emitted by {@link ISharedObject}.\n */\nexport interface ISharedObjectEvents extends IErrorEvent {\n\t/**\n\t * Fires before an incoming operation (op) is applied to the shared object.\n\t *\n\t * @remarks Note: this should be considered an internal implementation detail. It is not recommended for external\n\t * use.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"pre-op\",\n\t\tlistener: (\n\t\t\top: ISequencedDocumentMessage,\n\t\t\tlocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t);\n\n\t/**\n\t * Fires after an incoming op is applied to the shared object.\n\t *\n\t * @remarks Note: this should be considered an internal implementation detail. It is not recommended for external\n\t * use.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"op\",\n\t\tlistener: (\n\t\t\top: ISequencedDocumentMessage,\n\t\t\tlocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t);\n}\n\n/**\n * Base interface for shared objects from which other interfaces derive. Implemented by SharedObject\n */\nexport interface ISharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n\textends IChannel,\n\t\tIEventProvider<TEvent> {\n\t/**\n\t * Binds the given shared object to its containing data store runtime, causing it to attach once\n\t * the runtime attaches.\n\t */\n\tbindToContext(): void;\n\n\t/**\n\t * Returns the GC data for this shared object. It contains a list of GC nodes that contains references to\n\t * other GC nodes.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tgetGCData(fullGC?: boolean): IGarbageCollectionData;\n}\n"]}
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,GAAG,EACV,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAChB,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,GAAG,EACV,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,OAIlB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,gBAAgB,OAGpE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,UAAU,GAC1B,qBAAqB,CAIvB"}
|
package/dist/utils.js
CHANGED
|
@@ -17,9 +17,7 @@ const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
|
17
17
|
*/
|
|
18
18
|
function serializeHandles(value, serializer, bind) {
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
20
|
-
return value !== undefined
|
|
21
|
-
? serializer.stringify(value, bind)
|
|
22
|
-
: value;
|
|
20
|
+
return value !== undefined ? serializer.stringify(value, bind) : value;
|
|
23
21
|
}
|
|
24
22
|
exports.serializeHandles = serializeHandles;
|
|
25
23
|
/**
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,iEAAmE;AAGnE;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,iEAAmE;AAGnE;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAC/B,KAAU,EACV,UAA4B,EAC5B,IAAkB;IAElB,+DAA+D;IAC/D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACxE,CAAC;AAPD,4CAOC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,uBAAuB,CACtC,KAAU,EACV,UAA4B,EAC5B,IAAkB;IAElB,+DAA+D;IAC/D,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAPD,0DAOC;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,KAAU,EAAE,UAA4B;IACpE,+DAA+D;IAC/D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9E,CAAC;AAHD,oCAGC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACtC,GAAW,EACX,OAA4B;IAE5B,MAAM,OAAO,GAAG,IAAI,kCAAkB,EAAE,CAAC;IACzC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;AACjC,CAAC;AAPD,0DAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { IFluidSerializer } from \"./serializer\";\n\n/**\n * Given a mostly-plain object that may have handle objects embedded within, return a string representation of an object\n * where the handle objects have been replaced with a serializable form.\n * @param value - The mostly-plain object\n * @param serializer - The serializer that knows how to convert handles into serializable format\n * @param context - The handle context for the container\n * @param bind - Bind any other handles we find in the object against this given handle.\n * @returns Result of strigifying an object\n */\nexport function serializeHandles(\n\tvalue: any,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): string | undefined {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn value !== undefined ? serializer.stringify(value, bind) : value;\n}\n\n/**\n * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n * where any embedded IFluidHandles have been replaced with a serializable form.\n *\n * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n * the root to any replaced handles. (If no handles are found, returns the original object.)\n *\n * @param input - The mostly-plain object\n * @param context - The handle context for the container\n * @param bind - Bind any other handles we find in the object against this given handle.\n * @returns The fully-plain object\n */\nexport function makeHandlesSerializable(\n\tvalue: any,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n) {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn serializer.encode(value, bind);\n}\n\n/**\n * Given a fully-plain object that may have serializable-form handles within, will return the mostly-plain object\n * with handle objects created instead.\n * @param value - The fully-plain object\n * @param serializer - The serializer that knows how to convert serializable-form handles into handle objects\n * @param context - The handle context for the container\n * @returns The mostly-plain object with handle objects within\n */\nexport function parseHandles(value: any, serializer: IFluidSerializer) {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn value !== undefined ? serializer.parse(JSON.stringify(value)) : value;\n}\n\n/**\n * Create a new summary containing one blob\n * @param key - the key for the blob in the summary\n * @param content - blob content\n * @returns The summary containing the blob\n */\nexport function createSingleBlobSummary(\n\tkey: string,\n\tcontent: string | Uint8Array,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tbuilder.addBlob(key, content);\n\treturn builder.getSummaryTree();\n}\n"]}
|
package/dist/valueType.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueType.d.ts","sourceRoot":"","sources":["../src/valueType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,SAAS;
|
|
1
|
+
{"version":3,"file":"valueType.d.ts","sourceRoot":"","sources":["../src/valueType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,SAAS;IACpB;;;OAGG;IACH,MAAM,IAAA;IAEN;;OAEG;IACH,KAAK,IAAA;CACL"}
|
package/dist/valueType.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueType.js","sourceRoot":"","sources":["../src/valueType.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,IAAY,SAWX;AAXD,WAAY,SAAS;
|
|
1
|
+
{"version":3,"file":"valueType.js","sourceRoot":"","sources":["../src/valueType.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,IAAY,SAWX;AAXD,WAAY,SAAS;IACpB;;;OAGG;IACH,6CAAM,CAAA;IAEN;;OAEG;IACH,2CAAK,CAAA;AACN,CAAC,EAXW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAWpB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * enum representing the possible types of a shared object\n */\nexport enum ValueType {\n\t/**\n\t * The value is a shared object\n\t * @deprecated Instead store the handle of the shared object, rather than the shared object itself.\n\t */\n\tShared,\n\n\t/**\n\t * The value is a plain JavaScript object or handle. If a plain object, it may contain handles deeper within.\n\t */\n\tPlain,\n}\n"]}
|
package/lib/handle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB,CAAC,aAAa,CAAC;IAgBtE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa;IAfxC;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;;;;;OAMG;gBAEiB,KAAK,EAAE,aAAa,EACvC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,mBAAmB;IAKlC;;;OAGG;IACI,WAAW,IAAI,IAAI;CAI1B"}
|
package/lib/handle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAgC;
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAgC;IAQvE;;;;;;OAMG;IACH,YACoB,KAAoB,EACvC,IAAY,EACZ,YAAiC;QAEjC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAJd,UAAK,GAAL,KAAK,CAAe;IAKxC,CAAC;IApBD;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;IAiBD;;;OAGG;IACI,WAAW;QACjB,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC3B,KAAK,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandleContext } from \"@fluidframework/core-interfaces\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { ISharedObject } from \"./types\";\n\n/**\n * Handle for a shared object.\n *\n * @remarks\n *\n * This object is used for already loaded (in-memory) shared objects and is used only for serialization purposes.\n *\n * De-serialization process goes through {@link @fluidframework/datastore#FluidObjectHandle}, and request flow:\n * {@link @fluidframework/datastore#FluidDataStoreRuntime.request} recognizes requests in the form of\n * '/\\<shared object id\\>' and loads shared object.\n */\nexport class SharedObjectHandle extends FluidObjectHandle<ISharedObject> {\n\t/**\n\t * Whether services have been attached for the associated shared object.\n\t */\n\tpublic get isAttached(): boolean {\n\t\treturn this.value.isAttached();\n\t}\n\n\t/**\n\t * Creates a new SharedObjectHandle.\n\t * @param value - The shared object this handle is for.\n\t * @param path - The id of the shared object. It is also the path to this object relative to the routeContext.\n\t * @param routeContext - The parent {@link @fluidframework/core-interfaces#IFluidHandleContext} that has a route\n\t * to this handle.\n\t */\n\tconstructor(\n\t\tprotected readonly value: ISharedObject,\n\t\tpath: string,\n\t\trouteContext: IFluidHandleContext,\n\t) {\n\t\tsuper(value, path, routeContext);\n\t}\n\n\t/**\n\t * Attaches all bound handles first (which may in turn attach further handles), then attaches this handle.\n\t * When attaching the handle, it registers the associated shared object.\n\t */\n\tpublic attachGraph(): void {\n\t\tthis.value.bindToContext();\n\t\tsuper.attachGraph();\n\t}\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { FluidSerializer, IFluidSerializer, ISerializedHandle, isSerializedHandle } from "./serializer";
|
|
5
|
+
export { FluidSerializer, IFluidSerializer, ISerializedHandle, isSerializedHandle, } from "./serializer";
|
|
6
6
|
export { SharedObject, SharedObjectCore } from "./sharedObject";
|
|
7
7
|
export { SummarySerializer } from "./summarySerializer";
|
|
8
8
|
export { ISharedObject, ISharedObjectEvents } from "./types";
|
|
9
|
-
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles } from "./utils";
|
|
9
|
+
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles, } from "./utils";
|
|
10
10
|
export { ValueType } from "./valueType";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { FluidSerializer, isSerializedHandle } from "./serializer";
|
|
5
|
+
export { FluidSerializer, isSerializedHandle, } from "./serializer";
|
|
6
6
|
export { SharedObject, SharedObjectCore } from "./sharedObject";
|
|
7
7
|
export { SummarySerializer } from "./summarySerializer";
|
|
8
|
-
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles } from "./utils";
|
|
8
|
+
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles, } from "./utils";
|
|
9
9
|
export { ValueType } from "./valueType";
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EAGf,kBAAkB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tFluidSerializer,\n\tIFluidSerializer,\n\tISerializedHandle,\n\tisSerializedHandle,\n} from \"./serializer\";\nexport { SharedObject, SharedObjectCore } from \"./sharedObject\";\nexport { SummarySerializer } from \"./summarySerializer\";\nexport { ISharedObject, ISharedObjectEvents } from \"./types\";\nexport {\n\tcreateSingleBlobSummary,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tserializeHandles,\n} from \"./utils\";\nexport { ValueType } from \"./valueType\";\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/shared-object-base";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.3.0
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.3.2.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/shared-object-base";
|
|
8
|
-
export const pkgVersion = "2.0.0-internal.3.0
|
|
8
|
+
export const pkgVersion = "2.0.0-internal.3.2.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -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,sBAAsB,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.0.0-internal.3.0
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,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.0.0-internal.3.2.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,SAAS,EAGT,MAAM,iCAAiC,CAAC;AAOzC;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,YAAY;aAoB1C,YAAY,EAAE,MAAM;aACpB,YAAY,EAAE,mBAAmB;IApBlD,IAAW,YAAY,SAEtB;IACD,IAAW,mBAAmB,SAE7B;IACD,IAAW,YAAY,SAEtB;IAED,SAAgB,UAAU,QAAQ;IAClC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;gBAEc,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB;IAQrC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAoBzB,WAAW,IAAI,IAAI;IAInB,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAI1B,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;CAU3D"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { assert } from "@fluidframework/common-utils";
|
|
6
6
|
import { RuntimeHeaders } from "@fluidframework/container-runtime";
|
|
7
|
-
import { create404Response, exceptionToResponse, responseToException } from "@fluidframework/runtime-utils";
|
|
7
|
+
import { create404Response, exceptionToResponse, responseToException, } from "@fluidframework/runtime-utils";
|
|
8
8
|
/**
|
|
9
9
|
* This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized
|
|
10
10
|
* FluidObjectHandle.
|
|
@@ -24,14 +24,24 @@ export class RemoteFluidObjectHandle {
|
|
|
24
24
|
this.isAttached = true;
|
|
25
25
|
assert(absolutePath.startsWith("/"), 0x19d /* "Handles should always have absolute paths" */);
|
|
26
26
|
}
|
|
27
|
-
get IFluidRouter() {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
get IFluidRouter() {
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
get IFluidHandleContext() {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
get IFluidHandle() {
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
30
36
|
async get() {
|
|
31
37
|
if (this.objectP === undefined) {
|
|
32
38
|
// Add `viaHandle` header to distinguish from requests from non-handle paths.
|
|
33
|
-
const request = {
|
|
34
|
-
|
|
39
|
+
const request = {
|
|
40
|
+
url: this.absolutePath,
|
|
41
|
+
headers: { [RuntimeHeaders.viaHandle]: true },
|
|
42
|
+
};
|
|
43
|
+
this.objectP = this.routeContext
|
|
44
|
+
.resolveHandle(request)
|
|
35
45
|
.then((response) => {
|
|
36
46
|
if (response.mimeType === "fluid/object") {
|
|
37
47
|
const fluidObject = response.value;
|
|
@@ -52,9 +62,7 @@ export class RemoteFluidObjectHandle {
|
|
|
52
62
|
try {
|
|
53
63
|
const object = await this.get();
|
|
54
64
|
const router = object.IFluidRouter;
|
|
55
|
-
return router !== undefined
|
|
56
|
-
? router.request(request)
|
|
57
|
-
: create404Response(request);
|
|
65
|
+
return router !== undefined ? router.request(request) : create404Response(request);
|
|
58
66
|
}
|
|
59
67
|
catch (error) {
|
|
60
68
|
return exceptionToResponse(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AASnE,OAAO,
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AASnE,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,+BAA+B,CAAC;AAEvC;;;;;;GAMG;AAC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,MAAM,MAAM,GAA8B,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;YAEnC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;SACnF;QAAC,OAAO,KAAK,EAAE;YACf,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;SAClC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { RuntimeHeaders } from \"@fluidframework/container-runtime\";\nimport {\n\tIFluidHandle,\n\tIFluidHandleContext,\n\tIRequest,\n\tIResponse,\n\tFluidObject,\n\tIFluidRouter,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tcreate404Response,\n\texceptionToResponse,\n\tresponseToException,\n} from \"@fluidframework/runtime-utils\";\n\n/**\n * This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized\n * FluidObjectHandle.\n * This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,\n * custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the\n * IFluidHandle can be retrieved by calling `get` on it.\n */\nexport class RemoteFluidObjectHandle implements IFluidHandle {\n\tpublic get IFluidRouter() {\n\t\treturn this;\n\t}\n\tpublic get IFluidHandleContext() {\n\t\treturn this;\n\t}\n\tpublic get IFluidHandle() {\n\t\treturn this;\n\t}\n\n\tpublic readonly isAttached = true;\n\tprivate objectP: Promise<FluidObject> | undefined;\n\n\t/**\n\t * Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.\n\t * @param absolutePath - The absolute path to the handle from the container runtime.\n\t * @param routeContext - The root IFluidHandleContext that has a route to this handle.\n\t */\n\tconstructor(\n\t\tpublic readonly absolutePath: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t) {\n\t\tassert(\n\t\t\tabsolutePath.startsWith(\"/\"),\n\t\t\t0x19d /* \"Handles should always have absolute paths\" */,\n\t\t);\n\t}\n\n\tpublic async get(): Promise<any> {\n\t\tif (this.objectP === undefined) {\n\t\t\t// Add `viaHandle` header to distinguish from requests from non-handle paths.\n\t\t\tconst request: IRequest = {\n\t\t\t\turl: this.absolutePath,\n\t\t\t\theaders: { [RuntimeHeaders.viaHandle]: true },\n\t\t\t};\n\t\t\tthis.objectP = this.routeContext\n\t\t\t\t.resolveHandle(request)\n\t\t\t\t.then<FluidObject>((response) => {\n\t\t\t\t\tif (response.mimeType === \"fluid/object\") {\n\t\t\t\t\t\tconst fluidObject: FluidObject = response.value;\n\t\t\t\t\t\treturn fluidObject;\n\t\t\t\t\t}\n\t\t\t\t\tthrow responseToException(response, request);\n\t\t\t\t});\n\t\t}\n\t\treturn this.objectP;\n\t}\n\n\tpublic attachGraph(): void {\n\t\treturn;\n\t}\n\n\tpublic bind(handle: IFluidHandle): void {\n\t\thandle.attachGraph();\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\ttry {\n\t\t\tconst object: FluidObject<IFluidRouter> = await this.get();\n\t\t\tconst router = object.IFluidRouter;\n\n\t\t\treturn router !== undefined ? router.request(request) : create404Response(request);\n\t\t} catch (error) {\n\t\t\treturn exceptionToResponse(error);\n\t\t}\n\t}\n}\n"]}
|
package/lib/serializer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGpF;;GAEG;
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,YAAY,EAAE,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Y,EAAE,IAAI,EAAE,YAAY;;;;CAOlE"}
|
package/lib/serializer.js
CHANGED
|
@@ -22,9 +22,7 @@ export class FluidSerializer {
|
|
|
22
22
|
// Detect if 'value' is an IFluidHandle.
|
|
23
23
|
const handle = value === null || value === void 0 ? void 0 : value.IFluidHandle;
|
|
24
24
|
// If 'value' is an IFluidHandle return its encoded form.
|
|
25
|
-
return handle !== undefined
|
|
26
|
-
? this.serializeHandle(handle, bind)
|
|
27
|
-
: value;
|
|
25
|
+
return handle !== undefined ? this.serializeHandle(handle, bind) : value;
|
|
28
26
|
};
|
|
29
27
|
// If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
30
28
|
// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
@@ -49,7 +47,9 @@ export class FluidSerializer {
|
|
|
49
47
|
this.root = this.root.routeContext;
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
|
-
get IFluidSerializer() {
|
|
50
|
+
get IFluidSerializer() {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
53
|
/**
|
|
54
54
|
* Given a mostly-jsonable object tree that may have handle objects embedded within, will return a
|
|
55
55
|
* fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.
|
|
@@ -120,9 +120,7 @@ export class FluidSerializer {
|
|
|
120
120
|
// current property is replaced by the `replaced` value.
|
|
121
121
|
if (replaced !== value) {
|
|
122
122
|
// Lazily create a shallow clone of the `input` object if we haven't done so already.
|
|
123
|
-
clone = clone !== null && clone !== void 0 ? clone : (Array.isArray(input)
|
|
124
|
-
? [...input]
|
|
125
|
-
: Object.assign({}, input));
|
|
123
|
+
clone = clone !== null && clone !== void 0 ? clone : (Array.isArray(input) ? [...input] : Object.assign({}, input));
|
|
126
124
|
// Overwrite the current property `key` in the clone with the `replaced` value.
|
|
127
125
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
128
126
|
clone[key] = replaced;
|
package/lib/serializer.js.map
CHANGED
|
@@ -1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oBAC/E,oEAAoE;oBACpE,KAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;iBAC1B;aACJ;SACJ;QACD,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC;IAC1B,CAAC;IAES,eAAe,CAAC,MAAoB,EAAE,IAAkB;QAC9D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACH,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SAC3B,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// RATIONALE: Many methods consume and return 'any' by necessity.\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n\nimport { generateHandleContextPath } from \"@fluidframework/runtime-utils\";\nimport { IFluidHandle, IFluidHandleContext } from \"@fluidframework/core-interfaces\";\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle\";\n\n/**\n * JSON serialized form of an IFluidHandle\n */\n export interface ISerializedHandle {\n // Marker to indicate to JSON.parse that the object is a Fluid handle\n type: \"__fluid_handle__\";\n\n // URL to the object. Relative URLs are relative to the handle context passed to the stringify.\n url: string;\n}\n\nexport const isSerializedHandle = (value: any): value is ISerializedHandle =>\n value?.type === \"__fluid_handle__\";\n\nexport interface IFluidSerializer {\n /**\n * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n * where any embedded IFluidHandles have been replaced with a serializable form.\n *\n * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n * the root to any replaced handles. (If no handles are found, returns the original object.)\n */\n encode(value: any, bind: IFluidHandle): any;\n\n /**\n * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n *\n * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n * the root to any replaced handles. (If no handles are found, returns the original object.)\n *\n * The decoded handles are implicitly bound to the handle context of this serializer.\n */\n decode(input: any): any;\n\n /**\n * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n */\n stringify(value: any, bind: IFluidHandle): string;\n\n /**\n * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n * handles will be realized as part of the parse\n */\n parse(value: string): any;\n}\n\n/**\n * Data Store serializer implementation\n */\nexport class FluidSerializer implements IFluidSerializer {\n private readonly root: IFluidHandleContext;\n\n public constructor(\n private readonly context: IFluidHandleContext,\n // To be called whenever a handle is parsed by this serializer.\n private readonly handleParsedCb: (handle: IFluidHandle) => void,\n ) {\n this.root = this.context;\n while (this.root.routeContext !== undefined) {\n this.root = this.root.routeContext;\n }\n }\n\n public get IFluidSerializer() { return this; }\n\n /**\n * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n *\n * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n * the root to any replaced handles. (If no handles are found, returns the original object.)\n *\n * Any unbound handles encountered are bound to the provided IFluidHandle.\n */\n public encode(\n input: any,\n bind: IFluidHandle,\n ) {\n // If the given 'input' cannot contain handles, return it immediately. Otherwise,\n // return the result of 'recursivelyReplace()'.\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n return !!input && typeof input === \"object\"\n ? this.recursivelyReplace(input, this.encodeValue, bind)\n : input;\n }\n\n /**\n * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n *\n * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n * the root to any replaced handles. (If no handles are found, returns the original object.)\n *\n * The decoded handles are implicitly bound to the handle context of this serializer.\n */\n public decode(input: any) {\n // If the given 'input' cannot contain handles, return it immediately. Otherwise,\n // return the result of 'recursivelyReplace()'.\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n return !!input && typeof input === \"object\"\n ? this.recursivelyReplace(input, this.decodeValue)\n : input;\n }\n\n public stringify(input: any, bind: IFluidHandle) {\n return JSON.stringify(input, (key, value) => this.encodeValue(value, bind));\n }\n\n // Parses the serialized data - context must match the context with which the JSON was stringified\n public parse(input: string) {\n return JSON.parse(input, (key, value) => this.decodeValue(value));\n }\n\n // If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n // Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n private readonly encodeValue = (value: any, bind: IFluidHandle) => {\n // Detect if 'value' is an IFluidHandle.\n const handle = value?.IFluidHandle;\n\n // If 'value' is an IFluidHandle return its encoded form.\n return handle !== undefined\n ? this.serializeHandle(handle, bind)\n : value;\n };\n\n // If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n // Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n private readonly decodeValue = (value: any) => {\n // If 'value' is a serialized IFluidHandle return the deserialized result.\n if (isSerializedHandle(value)) {\n // Old documents may have handles with relative path in their summaries. Convert these to absolute\n // paths. This will ensure that future summaries will have absolute paths for these handles.\n const absolutePath = value.url.startsWith(\"/\")\n ? value.url\n : generateHandleContextPath(value.url, this.context);\n\n const parsedHandle = new RemoteFluidObjectHandle(absolutePath, this.root);\n this.handleParsedCb(parsedHandle);\n return parsedHandle;\n } else {\n return value;\n }\n };\n\n // Invoked for non-null objects to recursively replace references to IFluidHandles.\n // Clones as-needed to avoid mutating the `input` object. If no IFluidHandes are present,\n // returns the original `input`.\n private recursivelyReplace(\n input: any,\n replacer: (input: any, context: any) => any,\n context?: any,\n ) {\n // Note: Caller is responsible for ensuring that `input` is defined / non-null.\n // (Required for Object.keys() below.)\n\n // Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n // is a non-null object.\n const maybeReplaced = replacer(input, context);\n\n // If the replacer made a substitution there is no need to decscend further. IFluidHandles are always\n // leaves in the object graph.\n if (maybeReplaced !== input) {\n return maybeReplaced;\n }\n\n // Otherwise descend into the object graph looking for IFluidHandle instances.\n let clone: object | undefined;\n for (const key of Object.keys(input)) {\n const value = input[key];\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!!value && typeof value === \"object\") {\n // Note: Except for IFluidHandle, `input` must not contain circular references (as object must\n // be JSON serializable.) Therefore, guarding against infinite recursion here would only\n // lead to a later error when attempting to stringify().\n const replaced = this.recursivelyReplace(value, replacer, context);\n\n // If the `replaced` object is different than the original `value` then the subgraph contained one\n // or more handles. If this happens, we need to return a clone of the `input` object where the\n // current property is replaced by the `replaced` value.\n if (replaced !== value) {\n // Lazily create a shallow clone of the `input` object if we haven't done so already.\n clone = clone ?? (Array.isArray(input)\n ? [...input]\n : { ...input });\n\n // Overwrite the current property `key` in the clone with the `replaced` value.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n clone![key] = replaced;\n }\n }\n }\n return clone ?? input;\n }\n\n protected serializeHandle(handle: IFluidHandle, bind: IFluidHandle) {\n bind.bind(handle);\n return {\n type: \"__fluid_handle__\",\n url: handle.absolutePath,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iEAAiE;AACjE,wDAAwD;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAa/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAU,EAA8B,EAAE,CAC5E,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,kBAAkB,CAAC;AAmCpC;;GAEG;AACH,MAAM,OAAO,eAAe;IAG3B,YACkB,OAA4B;IAC7C,+DAA+D;IAC9C,cAA8C;QAF9C,YAAO,GAAP,OAAO,CAAqB;QAE5B,mBAAc,GAAd,cAAc,CAAgC;QAyDhE,6EAA6E;QAC7E,iFAAiF;QAChE,gBAAW,GAAG,CAAC,KAAU,EAAE,IAAkB,EAAE,EAAE;YACj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AAC,KAAK,CAAC,EAAE;YACrC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,yEAAyE;YACzE,IAAI,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBACzC,8FAA8F;gBAC9F,+FAA+F;gBAC/F,8DAA8D;gBAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAEnE,kGAAkG;gBAClG,+FAA+F;gBAC/F,wDAAwD;gBACxD,IAAI,QAAQ,KAAK,KAAK,EAAE;oBACvB,qFAAqF;oBACrF,KAAK,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,mBAAM,KAAK,CAAE,CAAC,CAAC;oBAEpE,+EAA+E;oBAC/E,oEAAoE;oBACpE,KAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;iBACvB;aACD;SACD;QACD,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC;IACvB,CAAC;IAES,eAAe,CAAC,MAAoB,EAAE,IAAkB;QACjE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SACxB,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// RATIONALE: Many methods consume and return 'any' by necessity.\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n\nimport { generateHandleContextPath } from \"@fluidframework/runtime-utils\";\nimport { IFluidHandle, IFluidHandleContext } from \"@fluidframework/core-interfaces\";\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle\";\n\n/**\n * JSON serialized form of an IFluidHandle\n */\nexport interface ISerializedHandle {\n\t// Marker to indicate to JSON.parse that the object is a Fluid handle\n\ttype: \"__fluid_handle__\";\n\n\t// URL to the object. Relative URLs are relative to the handle context passed to the stringify.\n\turl: string;\n}\n\nexport const isSerializedHandle = (value: any): value is ISerializedHandle =>\n\tvalue?.type === \"__fluid_handle__\";\n\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\tencode(value: any, bind: IFluidHandle): any;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tdecode(input: any): any;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: any, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\tparse(value: string): any;\n}\n\n/**\n * Data Store serializer implementation\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(\n\t\tprivate readonly context: IFluidHandleContext,\n\t\t// To be called whenever a handle is parsed by this serializer.\n\t\tprivate readonly handleParsedCb: (handle: IFluidHandle) => void,\n\t) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\tpublic encode(input: any, bind: IFluidHandle) {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.encodeValue, bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tpublic decode(input: any) {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue)\n\t\t\t: input;\n\t}\n\n\tpublic stringify(input: any, bind: IFluidHandle) {\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bind));\n\t}\n\n\t// Parses the serialized data - context must match the context with which the JSON was stringified\n\tpublic parse(input: string) {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\n\t// If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n\t// Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n\tprivate readonly encodeValue = (value: any, bind: IFluidHandle) => {\n\t\t// Detect if 'value' is an IFluidHandle.\n\t\tconst handle = value?.IFluidHandle;\n\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\treturn handle !== undefined ? this.serializeHandle(handle, bind) : value;\n\t};\n\n\t// If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n\t// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n\tprivate readonly decodeValue = (value: any) => {\n\t\t// If 'value' is a serialized IFluidHandle return the deserialized result.\n\t\tif (isSerializedHandle(value)) {\n\t\t\t// Old documents may have handles with relative path in their summaries. Convert these to absolute\n\t\t\t// paths. This will ensure that future summaries will have absolute paths for these handles.\n\t\t\tconst absolutePath = value.url.startsWith(\"/\")\n\t\t\t\t? value.url\n\t\t\t\t: generateHandleContextPath(value.url, this.context);\n\n\t\t\tconst parsedHandle = new RemoteFluidObjectHandle(absolutePath, this.root);\n\t\t\tthis.handleParsedCb(parsedHandle);\n\t\t\treturn parsedHandle;\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t};\n\n\t// Invoked for non-null objects to recursively replace references to IFluidHandles.\n\t// Clones as-needed to avoid mutating the `input` object. If no IFluidHandes are present,\n\t// returns the original `input`.\n\tprivate recursivelyReplace(\n\t\tinput: any,\n\t\treplacer: (input: any, context: any) => any,\n\t\tcontext?: any,\n\t) {\n\t\t// Note: Caller is responsible for ensuring that `input` is defined / non-null.\n\t\t// (Required for Object.keys() below.)\n\n\t\t// Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n\t\t// is a non-null object.\n\t\tconst maybeReplaced = replacer(input, context);\n\n\t\t// If the replacer made a substitution there is no need to decscend further. IFluidHandles are always\n\t\t// leaves in the object graph.\n\t\tif (maybeReplaced !== input) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\n\t\t// Otherwise descend into the object graph looking for IFluidHandle instances.\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value = input[key];\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\tif (!!value && typeof value === \"object\") {\n\t\t\t\t// Note: Except for IFluidHandle, `input` must not contain circular references (as object must\n\t\t\t\t// be JSON serializable.) Therefore, guarding against infinite recursion here would only\n\t\t\t\t// lead to a later error when attempting to stringify().\n\t\t\t\tconst replaced = this.recursivelyReplace(value, replacer, context);\n\n\t\t\t\t// If the `replaced` object is different than the original `value` then the subgraph contained one\n\t\t\t\t// or more handles. If this happens, we need to return a clone of the `input` object where the\n\t\t\t\t// current property is replaced by the `replaced` value.\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\t// Lazily create a shallow clone of the `input` object if we haven't done so already.\n\t\t\t\t\tclone = clone ?? (Array.isArray(input) ? [...input] : { ...input });\n\n\t\t\t\t\t// Overwrite the current property `key` in the clone with the `replaced` value.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tclone![key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clone ?? input;\n\t}\n\n\tprotected serializeHandle(handle: IFluidHandle, bind: IFluidHandle) {\n\t\tbind.bind(handle);\n\t\treturn {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: handle.absolutePath,\n\t\t};\n\t}\n}\n"]}
|