@fluidframework/container-loader 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -2
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +3 -3
- package/api-report/container-loader.api.md +18 -18
- package/dist/{audience.js → audience.cjs} +1 -1
- package/dist/audience.cjs.map +1 -0
- package/dist/audience.d.ts +1 -0
- package/dist/audience.d.ts.map +1 -1
- package/dist/{catchUpMonitor.js → catchUpMonitor.cjs} +1 -1
- package/dist/catchUpMonitor.cjs.map +1 -0
- package/dist/{connectionManager.js → connectionManager.cjs} +23 -20
- package/dist/connectionManager.cjs.map +1 -0
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/{connectionState.js → connectionState.cjs} +4 -1
- package/dist/connectionState.cjs.map +1 -0
- package/dist/connectionState.d.ts +3 -0
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/{connectionStateHandler.js → connectionStateHandler.cjs} +6 -6
- package/dist/connectionStateHandler.cjs.map +1 -0
- package/dist/connectionStateHandler.d.ts +10 -0
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/container-loader-alpha.d.ts +240 -0
- package/dist/container-loader-beta.d.ts +96 -0
- package/dist/container-loader-public.d.ts +96 -0
- package/dist/container-loader-untrimmed.d.ts +351 -0
- package/dist/{container.js → container.cjs} +36 -29
- package/dist/container.cjs.map +1 -0
- package/dist/container.d.ts +4 -6
- package/dist/container.d.ts.map +1 -1
- package/dist/{containerContext.js → containerContext.cjs} +1 -1
- package/dist/containerContext.cjs.map +1 -0
- package/dist/{containerStorageAdapter.js → containerStorageAdapter.cjs} +6 -6
- package/dist/containerStorageAdapter.cjs.map +1 -0
- package/dist/{contracts.js → contracts.cjs} +1 -1
- package/dist/contracts.cjs.map +1 -0
- package/dist/{debugLogger.js → debugLogger.cjs} +10 -5
- package/dist/debugLogger.cjs.map +1 -0
- package/dist/debugLogger.d.ts.map +1 -1
- package/dist/{deltaManager.js → deltaManager.cjs} +21 -4
- package/dist/deltaManager.cjs.map +1 -0
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/{deltaQueue.js → deltaQueue.cjs} +1 -1
- package/dist/deltaQueue.cjs.map +1 -0
- package/dist/{disposal.js → disposal.cjs} +1 -1
- package/dist/disposal.cjs.map +1 -0
- package/dist/{error.js → error.cjs} +1 -1
- package/dist/error.cjs.map +1 -0
- package/dist/{index.js → index.cjs} +6 -6
- package/dist/index.cjs.map +1 -0
- package/dist/{loader.js → loader.cjs} +7 -5
- package/dist/loader.cjs.map +1 -0
- package/dist/loader.d.ts +12 -2
- package/dist/loader.d.ts.map +1 -1
- package/dist/location-redirection-utilities/{index.js → index.cjs} +2 -2
- package/dist/location-redirection-utilities/index.cjs.map +1 -0
- package/dist/location-redirection-utilities/{resolveWithLocationRedirection.js → resolveWithLocationRedirection.cjs} +3 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.cjs.map +1 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/dist/{noopHeuristic.js → noopHeuristic.cjs} +1 -1
- package/dist/noopHeuristic.cjs.map +1 -0
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/{protocol.js → protocol.cjs} +1 -1
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.ts +4 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/{protocolTreeDocumentStorageService.js → protocolTreeDocumentStorageService.cjs} +1 -1
- package/dist/protocolTreeDocumentStorageService.cjs.map +1 -0
- package/dist/{quorum.js → quorum.cjs} +1 -1
- package/dist/quorum.cjs.map +1 -0
- package/dist/{retriableDocumentStorageService.js → retriableDocumentStorageService.cjs} +1 -1
- package/dist/retriableDocumentStorageService.cjs.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{utils.js → utils.cjs} +2 -1
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/lib/audience.d.ts +1 -4
- package/lib/audience.d.ts.map +1 -1
- package/lib/{audience.js → audience.mjs} +1 -5
- package/lib/audience.mjs.map +1 -0
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/{catchUpMonitor.js → catchUpMonitor.mjs} +1 -1
- package/lib/catchUpMonitor.mjs.map +1 -0
- package/lib/connectionManager.d.ts +1 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/{connectionManager.js → connectionManager.mjs} +23 -20
- package/lib/connectionManager.mjs.map +1 -0
- package/lib/connectionState.d.ts +3 -0
- package/lib/connectionState.d.ts.map +1 -1
- package/lib/{connectionState.js → connectionState.mjs} +4 -1
- package/lib/connectionState.mjs.map +1 -0
- package/lib/connectionStateHandler.d.ts +13 -3
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/{connectionStateHandler.js → connectionStateHandler.mjs} +6 -6
- package/lib/connectionStateHandler.mjs.map +1 -0
- package/lib/container-loader-alpha.d.ts +240 -0
- package/lib/container-loader-beta.d.ts +96 -0
- package/lib/container-loader-public.d.ts +96 -0
- package/lib/container-loader-untrimmed.d.ts +351 -0
- package/lib/container.d.ts +8 -10
- package/lib/container.d.ts.map +1 -1
- package/lib/{container.js → container.mjs} +36 -26
- package/lib/container.mjs.map +1 -0
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/{containerContext.js → containerContext.mjs} +1 -1
- package/lib/containerContext.mjs.map +1 -0
- package/lib/containerStorageAdapter.d.ts +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/{containerStorageAdapter.js → containerStorageAdapter.mjs} +6 -6
- package/lib/containerStorageAdapter.mjs.map +1 -0
- package/lib/contracts.d.ts.map +1 -1
- package/lib/{contracts.js → contracts.mjs} +1 -1
- package/lib/contracts.mjs.map +1 -0
- package/lib/debugLogger.d.ts.map +1 -1
- package/lib/{debugLogger.js → debugLogger.mjs} +3 -2
- package/lib/debugLogger.mjs.map +1 -0
- package/lib/deltaManager.d.ts +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/{deltaManager.js → deltaManager.mjs} +21 -4
- package/lib/deltaManager.mjs.map +1 -0
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/{deltaQueue.js → deltaQueue.mjs} +1 -1
- package/lib/deltaQueue.mjs.map +1 -0
- package/lib/disposal.d.ts.map +1 -1
- package/lib/{disposal.js → disposal.mjs} +1 -1
- package/lib/disposal.mjs.map +1 -0
- package/lib/error.d.ts.map +1 -1
- package/lib/{error.js → error.mjs} +1 -1
- package/lib/error.mjs.map +1 -0
- package/lib/index.d.ts +6 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.mjs +10 -0
- package/lib/index.mjs.map +1 -0
- package/lib/loader.d.ts +14 -4
- package/lib/loader.d.ts.map +1 -1
- package/lib/{loader.js → loader.mjs} +7 -5
- package/lib/loader.mjs.map +1 -0
- package/lib/location-redirection-utilities/index.d.ts +1 -1
- package/lib/location-redirection-utilities/index.d.ts.map +1 -1
- package/lib/location-redirection-utilities/{index.js → index.mjs} +2 -2
- package/lib/location-redirection-utilities/index.mjs.map +1 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/lib/location-redirection-utilities/{resolveWithLocationRedirection.js → resolveWithLocationRedirection.mjs} +3 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +1 -0
- package/lib/noopHeuristic.d.ts.map +1 -1
- package/lib/{noopHeuristic.js → noopHeuristic.mjs} +1 -1
- package/lib/noopHeuristic.mjs.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/protocol.d.ts +4 -0
- package/lib/protocol.d.ts.map +1 -1
- package/lib/{protocol.js → protocol.mjs} +1 -1
- package/lib/protocol.mjs.map +1 -0
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/{protocolTreeDocumentStorageService.js → protocolTreeDocumentStorageService.mjs} +1 -1
- package/lib/protocolTreeDocumentStorageService.mjs.map +1 -0
- package/lib/quorum.d.ts +0 -4
- package/lib/quorum.d.ts.map +1 -1
- package/lib/{quorum.js → quorum.mjs} +1 -1
- package/lib/quorum.mjs.map +1 -0
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/{retriableDocumentStorageService.js → retriableDocumentStorageService.mjs} +1 -1
- package/lib/retriableDocumentStorageService.mjs.map +1 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.d.ts.map +1 -1
- package/lib/{utils.js → utils.mjs} +2 -1
- package/lib/utils.mjs.map +1 -0
- package/package.json +48 -29
- package/src/connectionManager.ts +22 -14
- package/src/connectionState.ts +3 -0
- package/src/connectionStateHandler.ts +16 -3
- package/src/container.ts +34 -17
- package/src/containerStorageAdapter.ts +3 -3
- package/src/debugLogger.ts +7 -1
- package/src/deltaManager.ts +25 -1
- package/src/loader.ts +11 -1
- package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +2 -0
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +4 -0
- package/src/utils.ts +2 -0
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +5 -3
- package/dist/audience.js.map +0 -1
- package/dist/catchUpMonitor.js.map +0 -1
- package/dist/connectionManager.js.map +0 -1
- package/dist/connectionState.js.map +0 -1
- package/dist/connectionStateHandler.js.map +0 -1
- package/dist/container.js.map +0 -1
- package/dist/containerContext.js.map +0 -1
- package/dist/containerStorageAdapter.js.map +0 -1
- package/dist/contracts.js.map +0 -1
- package/dist/debugLogger.js.map +0 -1
- package/dist/deltaManager.js.map +0 -1
- package/dist/deltaQueue.js.map +0 -1
- package/dist/disposal.js.map +0 -1
- package/dist/error.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/loader.js.map +0 -1
- package/dist/location-redirection-utilities/index.js.map +0 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +0 -1
- package/dist/noopHeuristic.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/protocol.js.map +0 -1
- package/dist/protocolTreeDocumentStorageService.js.map +0 -1
- package/dist/quorum.js.map +0 -1
- package/dist/retriableDocumentStorageService.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/lib/audience.js.map +0 -1
- package/lib/catchUpMonitor.js.map +0 -1
- package/lib/connectionManager.js.map +0 -1
- package/lib/connectionState.js.map +0 -1
- package/lib/connectionStateHandler.js.map +0 -1
- package/lib/container.js.map +0 -1
- package/lib/containerContext.js.map +0 -1
- package/lib/containerStorageAdapter.js.map +0 -1
- package/lib/contracts.js.map +0 -1
- package/lib/debugLogger.js.map +0 -1
- package/lib/deltaManager.js.map +0 -1
- package/lib/deltaQueue.js.map +0 -1
- package/lib/disposal.js.map +0 -1
- package/lib/error.js.map +0 -1
- package/lib/index.js +0 -10
- package/lib/index.js.map +0 -1
- package/lib/loader.js.map +0 -1
- package/lib/location-redirection-utilities/index.js.map +0 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +0 -1
- package/lib/noopHeuristic.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/protocol.js.map +0 -1
- package/lib/protocolTreeDocumentStorageService.js.map +0 -1
- package/lib/quorum.js.map +0 -1
- package/lib/retriableDocumentStorageService.js.map +0 -1
- package/lib/utils.js.map +0 -1
- package/tsconfig.esnext.json +0 -7
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectionStateHandler.js","sourceRoot":"","sources":["../src/connectionStateHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAA2D;AAG3D,qEAIyC;AAEzC,q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AAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACjE,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;SACnC;IACF,CAAC;IAES,SAAS,CAAC,QAAiB;QACpC,OAAO,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC;IACjE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties, TelemetryEventCategory } from \"@fluidframework/core-interfaces\";\nimport { assert, Timer } from \"@fluidframework/core-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { ISequencedClient, IClient } from \"@fluidframework/protocol-definitions\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tloggerToMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { IAnyDriverError } from \"@fluidframework/driver-definitions\";\nimport { CatchUpMonitor, ICatchUpMonitor } from \"./catchUpMonitor\";\nimport { ConnectionState } from \"./connectionState\";\nimport { IConnectionDetailsInternal, IConnectionStateChangeReason } from \"./contracts\";\nimport { IProtocolHandler } from \"./protocol\";\n\n// Based on recent data, it looks like majority of cases where we get stuck are due to really slow or\n// timing out ops fetches. So attempt recovery infrequently. Also fetch uses 30 second timeout, so\n// if retrying fixes the problem, we should not see these events.\nconst JoinOpTimeoutMs = 45000;\n\n// Timeout waiting for \"self\" join signal, before giving up\nconst JoinSignalTimeoutMs = 5000;\n\n/** Constructor parameter type for passing in dependencies needed by the ConnectionStateHandler */\nexport interface IConnectionStateHandlerInputs {\n\tlogger: ITelemetryLoggerExt;\n\t/** Log to telemetry any change in state, included to Connecting */\n\tconnectionStateChanged: (\n\t\tvalue: ConnectionState,\n\t\toldState: ConnectionState,\n\t\treason?: IConnectionStateChangeReason,\n\t) => void;\n\t/** Whether to expect the client to join in write mode on next connection */\n\tshouldClientJoinWrite: () => boolean;\n\t/** (Optional) How long should we wait on our previous client's Leave op before transitioning to Connected again */\n\tmaxClientLeaveWaitTime: number | undefined;\n\t/** Log an issue encountered while in the Connecting state. details will be logged as a JSON string */\n\tlogConnectionIssue: (\n\t\teventName: string,\n\t\tcategory: TelemetryEventCategory,\n\t\tdetails?: ITelemetryProperties,\n\t) => void;\n\t/** Callback to note that an old local client ID is still present in the Quorum that should have left and should now be considered invalid */\n\tclientShouldHaveLeft: (clientId: string) => void;\n}\n\n/**\n * interface that connection state handler implements\n */\nexport interface IConnectionStateHandler {\n\treadonly connectionState: ConnectionState;\n\treadonly pendingClientId: string | undefined;\n\n\tcontainerSaved(): void;\n\tdispose(): void;\n\tinitProtocol(protocol: IProtocolHandler): void;\n\treceivedConnectEvent(details: IConnectionDetailsInternal): void;\n\treceivedDisconnectEvent(reason: IConnectionStateChangeReason): void;\n\testablishingConnection(reason: IConnectionStateChangeReason): void;\n\t/**\n\t * Switches state to disconnected when we are still establishing connection during container.load(),\n\t * container connect() or reconnect and the container gets closed or disposed or disconnect happens.\n\t * @param reason - reason for cancelling the connection.\n\t */\n\tcancelEstablishingConnection(reason: IConnectionStateChangeReason): void;\n}\n\nexport function createConnectionStateHandler(\n\tinputs: IConnectionStateHandlerInputs,\n\tdeltaManager: IDeltaManager<any, any>,\n\tclientId?: string,\n) {\n\tconst mc = loggerToMonitoringContext(inputs.logger);\n\treturn createConnectionStateHandlerCore(\n\t\tmc.config.getBoolean(\"Fluid.Container.CatchUpBeforeDeclaringConnected\") === true, // connectedRaisedWhenCaughtUp\n\t\tmc.config.getBoolean(\"Fluid.Container.EnableJoinSignalWait\") === true, // readClientsWaitForJoinSignal\n\t\tinputs,\n\t\tdeltaManager,\n\t\tclientId,\n\t);\n}\n\nexport function createConnectionStateHandlerCore(\n\tconnectedRaisedWhenCaughtUp: boolean,\n\treadClientsWaitForJoinSignal: boolean,\n\tinputs: IConnectionStateHandlerInputs,\n\tdeltaManager: IDeltaManager<any, any>,\n\tclientId?: string,\n) {\n\tif (!connectedRaisedWhenCaughtUp) {\n\t\treturn new ConnectionStateHandler(inputs, readClientsWaitForJoinSignal, clientId);\n\t}\n\treturn new ConnectionStateCatchup(\n\t\tinputs,\n\t\t(handler: IConnectionStateHandlerInputs) =>\n\t\t\tnew ConnectionStateHandler(handler, readClientsWaitForJoinSignal, clientId),\n\t\tdeltaManager,\n\t);\n}\n\n/**\n * Helper internal interface to abstract away Audience & Quorum\n */\ninterface IMembership {\n\ton(\n\t\teventName: \"addMember\" | \"removeMember\",\n\t\tlistener: (clientId: string, details: IClient | ISequencedClient) => void,\n\t);\n\tgetMember(clientId: string): undefined | unknown;\n}\n\n/**\n * Class that can be used as a base class for building IConnectionStateHandler adapters / pipeline.\n * It implements both ends of communication interfaces and passes data back and forward\n */\nclass ConnectionStateHandlerPassThrough\n\timplements IConnectionStateHandler, IConnectionStateHandlerInputs\n{\n\tprotected readonly pimpl: IConnectionStateHandler;\n\n\tconstructor(\n\t\tprotected readonly inputs: IConnectionStateHandlerInputs,\n\t\tpimplFactory: (handler: IConnectionStateHandlerInputs) => IConnectionStateHandler,\n\t) {\n\t\tthis.pimpl = pimplFactory(this);\n\t}\n\n\t/**\n\t * IConnectionStateHandler\n\t */\n\tpublic get connectionState() {\n\t\treturn this.pimpl.connectionState;\n\t}\n\tpublic get pendingClientId() {\n\t\treturn this.pimpl.pendingClientId;\n\t}\n\n\tpublic containerSaved() {\n\t\treturn this.pimpl.containerSaved();\n\t}\n\tpublic dispose() {\n\t\treturn this.pimpl.dispose();\n\t}\n\tpublic initProtocol(protocol: IProtocolHandler) {\n\t\treturn this.pimpl.initProtocol(protocol);\n\t}\n\tpublic receivedDisconnectEvent(reason: IConnectionStateChangeReason<IAnyDriverError>) {\n\t\treturn this.pimpl.receivedDisconnectEvent(reason);\n\t}\n\n\tpublic establishingConnection(reason: IConnectionStateChangeReason) {\n\t\treturn this.pimpl.establishingConnection(reason);\n\t}\n\n\tpublic cancelEstablishingConnection(reason: IConnectionStateChangeReason) {\n\t\treturn this.pimpl.cancelEstablishingConnection(reason);\n\t}\n\n\tpublic receivedConnectEvent(details: IConnectionDetailsInternal) {\n\t\treturn this.pimpl.receivedConnectEvent(details);\n\t}\n\n\t/**\n\t * IConnectionStateHandlerInputs\n\t */\n\n\tpublic get logger() {\n\t\treturn this.inputs.logger;\n\t}\n\tpublic connectionStateChanged(\n\t\tvalue: ConnectionState,\n\t\toldState: ConnectionState,\n\t\treason?: IConnectionStateChangeReason,\n\t) {\n\t\treturn this.inputs.connectionStateChanged(value, oldState, reason);\n\t}\n\tpublic shouldClientJoinWrite() {\n\t\treturn this.inputs.shouldClientJoinWrite();\n\t}\n\tpublic get maxClientLeaveWaitTime() {\n\t\treturn this.inputs.maxClientLeaveWaitTime;\n\t}\n\tpublic logConnectionIssue(\n\t\teventName: string,\n\t\tcategory: TelemetryEventCategory,\n\t\tdetails?: ITelemetryProperties,\n\t) {\n\t\treturn this.inputs.logConnectionIssue(eventName, category, details);\n\t}\n\tpublic clientShouldHaveLeft(clientId: string) {\n\t\treturn this.inputs.clientShouldHaveLeft(clientId);\n\t}\n}\n\n/**\n * Implementation of IConnectionStateHandler pass-through adapter that waits for specific sequence number\n * before raising connected event\n */\nclass ConnectionStateCatchup extends ConnectionStateHandlerPassThrough {\n\tprivate catchUpMonitor: ICatchUpMonitor | undefined;\n\n\tconstructor(\n\t\tinputs: IConnectionStateHandlerInputs,\n\t\tpimplFactory: (handler: IConnectionStateHandlerInputs) => IConnectionStateHandler,\n\t\tprivate readonly deltaManager: IDeltaManager<any, any>,\n\t) {\n\t\tsuper(inputs, pimplFactory);\n\t\tthis._connectionState = this.pimpl.connectionState;\n\t}\n\n\tprivate _connectionState: ConnectionState;\n\tpublic get connectionState() {\n\t\treturn this._connectionState;\n\t}\n\n\tpublic connectionStateChanged(\n\t\tvalue: ConnectionState,\n\t\toldState: ConnectionState,\n\t\treason?: IConnectionStateChangeReason<IAnyDriverError>,\n\t) {\n\t\tswitch (value) {\n\t\t\tcase ConnectionState.Connected:\n\t\t\t\tassert(\n\t\t\t\t\tthis._connectionState === ConnectionState.CatchingUp,\n\t\t\t\t\t0x3e1 /* connectivity transitions */,\n\t\t\t\t);\n\t\t\t\t// Create catch-up monitor here (not earlier), as we might get more exact info by now about how far\n\t\t\t\t// client is behind through join signal. This is only true if base layer uses signals (i.e. audience,\n\t\t\t\t// not quorum, including for \"rea\" connections) to make decisions about moving to \"connected\" state.\n\t\t\t\t// In addition to that, in its current form, doing this in ConnectionState.CatchingUp is dangerous as\n\t\t\t\t// we might get callback right away, and it will screw up state transition (as code outside of switch\n\t\t\t\t// statement will overwrite current state).\n\t\t\t\tassert(\n\t\t\t\t\tthis.catchUpMonitor === undefined,\n\t\t\t\t\t0x3eb /* catchUpMonitor should be gone */,\n\t\t\t\t);\n\t\t\t\tthis.catchUpMonitor = new CatchUpMonitor(\n\t\t\t\t\tthis.deltaManager,\n\t\t\t\t\tthis.transitionToConnectedState,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase ConnectionState.Disconnected:\n\t\t\t\tthis.catchUpMonitor?.dispose();\n\t\t\t\tthis.catchUpMonitor = undefined;\n\t\t\t\tbreak;\n\t\t\t// ConnectionState.EstablishingConnection state would be set when we start establishing connection\n\t\t\t// during container.connect() or reconnect because of an error.\n\t\t\tcase ConnectionState.EstablishingConnection:\n\t\t\t\tassert(\n\t\t\t\t\tthis._connectionState === ConnectionState.Disconnected,\n\t\t\t\t\t0x6d2 /* connectivity transition to establishing connection */,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase ConnectionState.CatchingUp:\n\t\t\t\tassert(\n\t\t\t\t\tthis._connectionState === ConnectionState.EstablishingConnection,\n\t\t\t\t\t0x3e3 /* connectivity transitions */,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t}\n\t\tthis._connectionState = value;\n\t\tthis.inputs.connectionStateChanged(value, oldState, reason);\n\t}\n\n\tprivate readonly transitionToConnectedState = () => {\n\t\t// Defensive measure, we should always be in Connecting state when this is called.\n\t\tconst state = this.pimpl.connectionState;\n\t\tassert(state === ConnectionState.Connected, 0x3e5 /* invariant broken */);\n\t\tassert(this._connectionState === ConnectionState.CatchingUp, 0x3e6 /* invariant broken */);\n\t\tthis._connectionState = ConnectionState.Connected;\n\t\tthis.inputs.connectionStateChanged(ConnectionState.Connected, ConnectionState.CatchingUp, {\n\t\t\ttext: \"caught up\",\n\t\t});\n\t};\n}\n\n/**\n * In the lifetime of a container, the connection will likely disconnect and reconnect periodically.\n * This class ensures that any ops sent by this container instance on previous connection are either\n * sequenced or blocked by the server before emitting the new \"connected\" event and allowing runtime to resubmit ops.\n *\n * Each connection is assigned a clientId by the service, and the connection is book-ended by a Join and a Leave op\n * generated by the service. Due to the distributed nature of the Relay Service, in the case of reconnect we cannot\n * make any assumptions about ordering of operations between the old and new connections - i.e. new Join op could\n * be sequenced before old Leave op (and some acks from pending ops that were in flight when we disconnected).\n *\n * The job of this class is to encapsulate the transition period during reconnect, which is identified by\n * ConnectionState.CatchingUp. Specifically, before moving to Connected state with the new clientId, it ensures that:\n *\n * a. We process the Leave op for the previous clientId. This allows us to properly handle any acks from in-flight ops\n * that got sequenced with the old clientId (we'll recognize them as local ops). After the Leave op, any other\n * pending ops can safely be submitted with the new clientId without fear of duplication in the sequenced op stream.\n *\n * b. We process the Join op for the new clientId (identified when the underlying connection was first established),\n * indicating the service is ready to sequence ops sent with the new clientId.\n *\n * c. We process all ops known at the time the underlying connection was established (so we are \"caught up\")\n *\n * For (a) we give up waiting after some time (same timeout as server uses), and go ahead and transition to Connected.\n *\n * For (b) we log telemetry if it takes too long, but still only transition to Connected when the Join op/signal is\n * processed.\n *\n * For (c) this is optional behavior, controlled by the parameters of receivedConnectEvent\n */\nclass ConnectionStateHandler implements IConnectionStateHandler {\n\tprivate _connectionState = ConnectionState.Disconnected;\n\tprivate _pendingClientId: string | undefined;\n\tprivate readonly prevClientLeftTimer: Timer;\n\tprivate readonly joinOpTimer: Timer;\n\tprivate protocol?: IProtocolHandler;\n\tprivate connection?: IConnectionDetailsInternal;\n\tprivate _clientId?: string;\n\n\tprivate waitEvent: PerformanceEvent | undefined;\n\n\tpublic get connectionState(): ConnectionState {\n\t\treturn this._connectionState;\n\t}\n\n\tprivate get clientId(): string | undefined {\n\t\treturn this._clientId;\n\t}\n\n\tpublic get pendingClientId(): string | undefined {\n\t\treturn this._pendingClientId;\n\t}\n\n\tconstructor(\n\t\tprivate readonly handler: IConnectionStateHandlerInputs,\n\t\tprivate readonly readClientsWaitForJoinSignal: boolean,\n\t\tclientIdFromPausedSession?: string,\n\t) {\n\t\tthis._clientId = clientIdFromPausedSession;\n\t\tthis.prevClientLeftTimer = new Timer(\n\t\t\t// Default is 5 min for which we are going to wait for its own \"leave\" message. This is same as\n\t\t\t// the max time on server after which leave op is sent.\n\t\t\tthis.handler.maxClientLeaveWaitTime ?? 300000,\n\t\t\t() => {\n\t\t\t\tassert(\n\t\t\t\t\tthis.connectionState !== ConnectionState.Connected,\n\t\t\t\t\t0x2ac /* \"Connected when timeout waiting for leave from previous session fired!\" */,\n\t\t\t\t);\n\t\t\t\tthis.applyForConnectedState(\"timeout\");\n\t\t\t},\n\t\t);\n\n\t\tthis.joinOpTimer = new Timer(\n\t\t\t0, // default value is not used - startJoinOpTimer() explicitly provides timeout\n\t\t\t() => {\n\t\t\t\t// I've observed timer firing within couple ms from disconnect event, looks like\n\t\t\t\t// queued timer callback is not cancelled if timer is cancelled while callback sits in the queue.\n\t\t\t\tif (this.connectionState !== ConnectionState.CatchingUp) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst details = {\n\t\t\t\t\tprotocolInitialized: this.protocol !== undefined,\n\t\t\t\t\tpendingClientId: this.pendingClientId,\n\t\t\t\t\tclientJoined: this.hasMember(this.pendingClientId),\n\t\t\t\t\twaitingForLeaveOp: this.waitingForLeaveOp,\n\t\t\t\t};\n\t\t\t\tthis.handler.logConnectionIssue(\"NoJoinOp\", \"error\", details);\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate startJoinOpTimer() {\n\t\tassert(!this.joinOpTimer.hasTimer, 0x234 /* \"has joinOpTimer\" */);\n\t\tassert(this.connection !== undefined, 0x4b3 /* have connection */);\n\t\tthis.joinOpTimer.start(\n\t\t\tthis.connection.mode === \"write\" ? JoinOpTimeoutMs : JoinSignalTimeoutMs,\n\t\t);\n\t}\n\n\tprivate stopJoinOpTimer() {\n\t\tassert(this.joinOpTimer.hasTimer, 0x235 /* \"no joinOpTimer\" */);\n\t\tthis.joinOpTimer.clear();\n\t}\n\n\tprivate get waitingForLeaveOp() {\n\t\treturn this.prevClientLeftTimer.hasTimer;\n\t}\n\n\tpublic dispose() {\n\t\tassert(!this.joinOpTimer.hasTimer, 0x2a5 /* \"join timer\" */);\n\t\tthis.prevClientLeftTimer.clear();\n\t}\n\n\tpublic containerSaved() {\n\t\t// If we were waiting for moving to Connected state, then only apply for state change. Since the container\n\t\t// is now saved and we don't have any ops to roundtrip, we can clear the timer and apply for connected state.\n\t\tif (this.waitingForLeaveOp) {\n\t\t\tthis.prevClientLeftTimer.clear();\n\t\t\tthis.applyForConnectedState(\"containerSaved\");\n\t\t}\n\t}\n\n\tprivate receivedAddMemberEvent(clientId: string) {\n\t\t// This is the only one that requires the pending client ID\n\t\tif (clientId === this.pendingClientId) {\n\t\t\tif (this.joinOpTimer.hasTimer) {\n\t\t\t\tthis.stopJoinOpTimer();\n\t\t\t} else if (this.shouldWaitForJoinSignal()) {\n\t\t\t\t// timer has already fired, meaning it took too long to get join op/signal.\n\t\t\t\t// Record how long it actually took to recover.\n\t\t\t\t// This is generic event, as it by itself is not an error.\n\t\t\t\t// We also have a case where NoJoinOp happens during container boot (we do not report it as error in such case),\n\t\t\t\t// if this log statement happens after boot - we do not want to consider it error case.\n\t\t\t\tthis.handler.logConnectionIssue(\"ReceivedJoinOp\", \"generic\");\n\t\t\t}\n\t\t\t// Start the event in case we are waiting for leave or timeout.\n\t\t\tif (this.waitingForLeaveOp) {\n\t\t\t\tthis.waitEvent = PerformanceEvent.start(this.handler.logger, {\n\t\t\t\t\teventName: \"WaitBeforeClientLeave\",\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\twaitOnClientId: this._clientId,\n\t\t\t\t\t\thadOutstandingOps: this.handler.shouldClientJoinWrite(),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis.applyForConnectedState(\"addMemberEvent\");\n\t\t} else if (clientId === this.clientId) {\n\t\t\t// If we see our clientId and it's not also our pending ID, it's our own join op\n\t\t\t// being replayed, so start the timer in case our previous client is still in quorum\n\t\t\tassert(\n\t\t\t\t!this.waitingForLeaveOp,\n\t\t\t\t0x5d2 /* Unexpected join op with current clientId while waiting */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis.connectionState !== ConnectionState.Connected,\n\t\t\t\t0x5d3 /* Unexpected join op with current clientId while connected */,\n\t\t\t);\n\t\t\tthis.prevClientLeftTimer.restart();\n\t\t}\n\t}\n\n\tprivate applyForConnectedState(\n\t\tsource: \"removeMemberEvent\" | \"addMemberEvent\" | \"timeout\" | \"containerSaved\",\n\t) {\n\t\tassert(\n\t\t\tthis.protocol !== undefined,\n\t\t\t0x236 /* \"In all cases it should be already installed\" */,\n\t\t);\n\n\t\tassert(\n\t\t\t!this.waitingForLeaveOp || this.hasMember(this.clientId),\n\t\t\t0x2e2 /* \"Must only wait for leave message when clientId in quorum\" */,\n\t\t);\n\n\t\t// Move to connected state only if we are in Connecting state, we have seen our join op\n\t\t// and there is no timer running which means we are not waiting for previous client to leave\n\t\t// or timeout has occurred while doing so.\n\t\tif (\n\t\t\tthis.pendingClientId !== this.clientId &&\n\t\t\tthis.hasMember(this.pendingClientId) &&\n\t\t\t!this.waitingForLeaveOp\n\t\t) {\n\t\t\tthis.waitEvent?.end({ source });\n\t\t\tthis.setConnectionState(ConnectionState.Connected);\n\t\t} else {\n\t\t\t// Adding this event temporarily so that we can get help debugging if something goes wrong.\n\t\t\t// We may not see any ops due to being disconnected all that time - that's not an error!\n\t\t\tconst error =\n\t\t\t\tsource === \"timeout\" && this.connectionState !== ConnectionState.Disconnected;\n\t\t\tthis.handler.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"connectedStateRejected\",\n\t\t\t\tcategory: error ? \"error\" : \"generic\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tsource,\n\t\t\t\t\tpendingClientId: this.pendingClientId,\n\t\t\t\t\tclientId: this.clientId,\n\t\t\t\t\twaitingForLeaveOp: this.waitingForLeaveOp,\n\t\t\t\t\tclientJoined: this.hasMember(this.pendingClientId),\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate receivedRemoveMemberEvent(clientId: string) {\n\t\t// If the client which has left was us, then finish the timer.\n\t\tif (this.clientId === clientId) {\n\t\t\tthis.prevClientLeftTimer.clear();\n\t\t\tthis.applyForConnectedState(\"removeMemberEvent\");\n\t\t}\n\t}\n\n\tpublic receivedDisconnectEvent(reason: IConnectionStateChangeReason<IAnyDriverError>) {\n\t\tthis.connection = undefined;\n\t\tthis.setConnectionState(ConnectionState.Disconnected, reason);\n\t}\n\n\tpublic cancelEstablishingConnection(reason: IConnectionStateChangeReason) {\n\t\tassert(\n\t\t\tthis._connectionState === ConnectionState.EstablishingConnection,\n\t\t\t0x6d3 /* Connection state should be EstablishingConnection */,\n\t\t);\n\t\tassert(this.connection === undefined, 0x6d4 /* No connetion should be present */);\n\t\tconst oldState = this._connectionState;\n\t\tthis._connectionState = ConnectionState.Disconnected;\n\t\tthis.handler.connectionStateChanged(ConnectionState.Disconnected, oldState, reason);\n\t}\n\n\tpublic establishingConnection(reason: IConnectionStateChangeReason) {\n\t\tconst oldState = this._connectionState;\n\t\tthis._connectionState = ConnectionState.EstablishingConnection;\n\t\tthis.handler.connectionStateChanged(ConnectionState.EstablishingConnection, oldState, {\n\t\t\ttext: `Establishing Connection due to ${reason.text}`,\n\t\t\terror: reason.error,\n\t\t});\n\t}\n\n\tprivate shouldWaitForJoinSignal() {\n\t\tassert(\n\t\t\tthis.connection !== undefined,\n\t\t\t0x4b4 /* all callers call here with active connection */,\n\t\t);\n\t\treturn this.connection.mode === \"write\" || this.readClientsWaitForJoinSignal;\n\t}\n\n\t/**\n\t * The \"connect\" event indicates the connection to the Relay Service is live.\n\t * However, some additional conditions must be met before we can fully transition to\n\t * \"Connected\" state. This function handles that interim period, known as \"Connecting\" state.\n\t * @param details - Connection details returned from the Relay Service\n\t * @param deltaManager - DeltaManager to be used for delaying Connected transition until caught up.\n\t * If it's undefined, then don't delay and transition to Connected as soon as Leave/Join op are accounted for\n\t */\n\tpublic receivedConnectEvent(details: IConnectionDetailsInternal) {\n\t\tthis.connection = details;\n\n\t\tconst oldState = this._connectionState;\n\t\tthis._connectionState = ConnectionState.CatchingUp;\n\n\t\t// The following checks are wrong. They are only valid if user has write access to a file.\n\t\t// If user lost such access mid-session, user will not be able to get \"write\" connection.\n\t\t//\n\t\t// const writeConnection = details.mode === \"write\";\n\t\t// assert(!this.handler.shouldClientJoinWrite() || writeConnection,\n\t\t// 0x30a /* shouldClientJoinWrite should imply this is a writeConnection */);\n\t\t// assert(!this.waitingForLeaveOp || writeConnection,\n\t\t// 0x2a6 /* \"waitingForLeaveOp should imply writeConnection (we need to be ready to flush pending ops)\" */);\n\n\t\t// Stash the clientID to detect when transitioning from connecting (socket.io channel open) to connected\n\t\t// (have received the join message for the client ID)\n\t\t// This is especially important in the reconnect case. It's possible there could be outstanding\n\t\t// ops sent by this client, so we should keep the old client id until we see our own client's\n\t\t// join message. after we see the join message for our new connection with our new client id,\n\t\t// we know there can no longer be outstanding ops that we sent with the previous client id.\n\t\tthis._pendingClientId = details.clientId;\n\n\t\t// IMPORTANT: Report telemetry after we set _pendingClientId, but before transitioning to Connected state\n\t\tthis.handler.connectionStateChanged(ConnectionState.CatchingUp, oldState, details.reason);\n\n\t\t// Check if we need to wait for join op/signal, and if we need to wait for leave op from previous connection.\n\t\t// Pending clientId could have joined already (i.e. join op/signal already processed):\n\t\t// We are fetching ops from storage in parallel to connecting to Relay Service,\n\t\t// and given async processes, it's possible that we have already processed our own join message before\n\t\t// connection was fully established.\n\t\tif (!this.hasMember(this._pendingClientId) && this.shouldWaitForJoinSignal()) {\n\t\t\t// We are waiting for our own join op / signal. When it is processed\n\t\t\t// we'll attempt to transition to Connected state via receivedAddMemberEvent() flow.\n\t\t\tthis.startJoinOpTimer();\n\t\t} else if (!this.waitingForLeaveOp) {\n\t\t\t// We're not waiting for Join or Leave op (if read-only connection those don't even apply),\n\t\t\t// go ahead and declare the state to be Connected!\n\t\t\t// If we are waiting for Leave op still, do nothing for now, we will transition to Connected later.\n\t\t\tthis.setConnectionState(ConnectionState.Connected);\n\t\t}\n\t\t// else - We are waiting for Leave op still, do nothing for now, we will transition to Connected later\n\t}\n\n\tprivate setConnectionState(\n\t\tvalue: ConnectionState.Disconnected,\n\t\treason: IConnectionStateChangeReason,\n\t): void;\n\tprivate setConnectionState(value: ConnectionState.Connected): void;\n\tprivate setConnectionState(\n\t\tvalue: ConnectionState.Disconnected | ConnectionState.Connected,\n\t\treason?: IConnectionStateChangeReason,\n\t): void {\n\t\tif (this.connectionState === value) {\n\t\t\t// Already in the desired state - exit early\n\t\t\tthis.handler.logger.sendErrorEvent({ eventName: \"setConnectionStateSame\", value });\n\t\t\treturn;\n\t\t}\n\n\t\tconst oldState = this._connectionState;\n\t\tthis._connectionState = value;\n\n\t\t// This is the only place in code that deals with quorum. The rest works with audience\n\t\t// The code below ensures that we do not send ops until we know that old \"write\" client's disconnect\n\t\t// produced (and sequenced) leave op\n\t\tconst currentClientInQuorum =\n\t\t\tthis._clientId !== undefined &&\n\t\t\tthis.protocol?.quorum?.getMember(this._clientId) !== undefined;\n\t\tif (value === ConnectionState.Connected) {\n\t\t\tassert(\n\t\t\t\toldState === ConnectionState.CatchingUp,\n\t\t\t\t0x1d8 /* \"Should only transition from Connecting state\" */,\n\t\t\t);\n\t\t\t// Mark our old client should have left in the quorum if it's still there\n\t\t\tif (currentClientInQuorum) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.handler.clientShouldHaveLeft(this._clientId!);\n\t\t\t}\n\t\t\tthis._clientId = this.pendingClientId;\n\t\t} else if (value === ConnectionState.Disconnected) {\n\t\t\t// Clear pending state immediately to prepare for reconnect\n\t\t\tthis._pendingClientId = undefined;\n\n\t\t\tif (this.joinOpTimer.hasTimer) {\n\t\t\t\tthis.stopJoinOpTimer();\n\t\t\t}\n\n\t\t\t// Only wait for \"leave\" message if the connected client exists in the quorum and had some non-acked ops\n\t\t\t// Also check if the timer is not already running as\n\t\t\t// we could receive \"Disconnected\" event multiple times without getting connected and in that case we\n\t\t\t// don't want to reset the timer as we still want to wait on original client which started this timer.\n\t\t\tif (\n\t\t\t\tcurrentClientInQuorum &&\n\t\t\t\tthis.handler.shouldClientJoinWrite() &&\n\t\t\t\t!this.waitingForLeaveOp // same as !this.prevClientLeftTimer.hasTimer\n\t\t\t) {\n\t\t\t\tthis.prevClientLeftTimer.restart();\n\t\t\t} else {\n\t\t\t\t// Adding this event temporarily so that we can get help debugging if something goes wrong.\n\t\t\t\tthis.handler.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"noWaitOnDisconnected\",\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tclientId: this._clientId,\n\t\t\t\t\t\tinQuorum: currentClientInQuorum,\n\t\t\t\t\t\twaitingForLeaveOp: this.waitingForLeaveOp,\n\t\t\t\t\t\thadOutstandingOps: this.handler.shouldClientJoinWrite(),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Report transition before we propagate event across layers\n\t\tthis.handler.connectionStateChanged(this._connectionState, oldState, reason);\n\t}\n\n\t// Helper method to switch between quorum and audience.\n\t// Old design was checking only quorum for \"write\" clients.\n\t// Latest change checks audience for all types of connections.\n\tprotected get membership(): IMembership | undefined {\n\t\t// We could always use audience here, and in practice it will probably be correct.\n\t\t// (including case when this.readClientsWaitForJoinSignal === false).\n\t\t// But only if it's superset of quorum, i.e. when filtered to \"write\" clients, they are always identical!\n\t\t// It's safer to assume that we have bugs and engaging kill-bit switch should bring us back to well-known\n\t\t// and tested state!\n\t\treturn this.readClientsWaitForJoinSignal ? this.protocol?.audience : this.protocol?.quorum;\n\t}\n\n\tpublic initProtocol(protocol: IProtocolHandler) {\n\t\tthis.protocol = protocol;\n\n\t\tthis.membership?.on(\"addMember\", (clientId, details) => {\n\t\t\tassert(\n\t\t\t\t(details as IClient).mode === \"read\" ||\n\t\t\t\t\tprotocol.quorum.getMember(clientId) !== undefined,\n\t\t\t\t0x4b5 /* Audience is subset of quorum */,\n\t\t\t);\n\t\t\tthis.receivedAddMemberEvent(clientId);\n\t\t});\n\n\t\tthis.membership?.on(\"removeMember\", (clientId) => {\n\t\t\tassert(\n\t\t\t\tprotocol.quorum.getMember(clientId) === undefined,\n\t\t\t\t0x4b6 /* Audience is subset of quorum */,\n\t\t\t);\n\t\t\tthis.receivedRemoveMemberEvent(clientId);\n\t\t});\n\n\t\t/* There is a tiny tiny race possible, where these events happen in this order:\n 1. A connection is established (no \"cached\" mode is used, so it happens in parallel / faster than other steps)\n 2. Some other client produces a summary\n 3. We get \"lucky\" and load from that summary as our initial snapshot\n 4. ConnectionStateHandler.initProtocol is called, \"self\" is already in the quorum.\n We could avoid this sequence (and delete test case for it) if we move connection lower in Container.load()\n */\n\t\tif (this.hasMember(this.pendingClientId)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.receivedAddMemberEvent(this.pendingClientId!);\n\t\t}\n\n\t\t// if we have a clientId from a previous container we need to wait for its leave message\n\t\tif (this.clientId !== undefined && this.hasMember(this.clientId)) {\n\t\t\tthis.prevClientLeftTimer.restart();\n\t\t}\n\t}\n\n\tprotected hasMember(clientId?: string) {\n\t\treturn this.membership?.getMember(clientId ?? \"\") !== undefined;\n\t}\n}\n"]}
|
package/dist/container.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,sDAAsD;AACtD,yDAAiC;AAEjC,+BAAkC;AAClC,2DAAqE;AACrE,+DAA8E;AAC9E,qEAUyC;AACzC,iFAqB+C;AAS/C,+DAOsC;AAEtC,+EAkB8C;AAC9C,qEAcyC;AACzC,yCAAsC;AACtC,yDAAsD;AACtD,2CAMqB;AACrB,iDAA+D;AAC/D,qCAAgF;AAChF,qDAA8C;AAC9C,uEAKmC;AACnC,qEAAiG;AACjG,mCAIiB;AACjB,qCAA2D;AAC3D,mDAAgD;AAChD,2DAAwD;AACxD,uDAAoD;AACpD,yCAKoB;AAEpB,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAExC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AACpC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAEpC,MAAM,sBAAsB,GAAG,iDAAiD,CAAC;AAEjF,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AA0FlD;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,sBAAsB,CAAC,SAAqB;IACjE,oDAAoD;IACpD,IAAI,SAAS,CAAC,MAAM,EAAE;QACrB,MAAM,IAAI,4BAAU,CAAC,0CAA0C,CAAC,CAAC;KACjE;IAED,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;QAE5C,MAAM,cAAc,GAAG,CAAC,GAAyC,EAAE,EAAE;YACpE,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YACxC,MAAM,WAAW,GAAG,4CAA4C,CAAC;YACjE,MAAM,CACL,GAAG,KAAK,SAAS;gBAChB,C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CAAC,QAAQ,EAAE,QAAQ,KAAK,KAAK,EAAE;YACtC;;;;;eAKG;YACH,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;SACnE;IACF,CAAC;IAEO,wBAAwB,CAC/B,cAA+B,EAC/B,kBAAuC,EACvC,aAAsB,IAAI;QAE1B,QAAQ,kBAAkB,EAAE;YAC3B,KAAK,SAAS;gBACb,IAAI,UAAU,EAAE;oBACf,sDAAsD;oBACtD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;iBAC1C;YACF,0BAA0B;YAC1B,KAAK,SAAS;gBACb,IAAA,mBAAM,EACL,IAAI,CAAC,0BAA0B,EAC/B,KAAK,CAAC,+CAA+C,CACrD,CAAC;gBACF,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAC;gBACxC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;gBACpC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;gBAC1C,MAAM;YACP,KAAK,MAAM;gBACV,MAAM;YACP;gBACC,IAAA,4BAAe,EAAC,kBAAkB,CAAC,CAAC;SACrC;IACF,CAAC;CACD;AAnmED,8BAmmEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-internal-modules\nimport merge from \"lodash/merge\";\n\nimport { v4 as uuid } from \"uuid\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { TypedEventEmitter, performance } from \"@fluid-internal/client-utils\";\nimport {\n\tIEvent,\n\tITelemetryProperties,\n\tTelemetryEventCategory,\n\tIRequest,\n\tIResponse,\n\t// eslint-disable-next-line import/no-deprecated\n\tIFluidRouter,\n\tFluidObject,\n\tLogLevel,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tAttachState,\n\tContainerWarning,\n\tIAudience,\n\tIBatchMessage,\n\tICodeDetailsLoader,\n\tIContainer,\n\tIContainerEvents,\n\tIContainerLoadMode,\n\tICriticalContainerError,\n\tIDeltaManager,\n\tIFluidCodeDetails,\n\tIHostLoader,\n\tIFluidModuleWithDetails,\n\tIProvideRuntimeFactory,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetailsComparer,\n\tIRuntime,\n\tReadOnlyInfo,\n\tisFluidCodeDetails,\n\tIGetPendingLocalStateProps,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tIThrottlingWarning,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\treadAndParse,\n\tOnlineStatus,\n\tisOnline,\n\trunWithRetry,\n\tisCombinedAppAndProtocolSummary,\n\tMessageType2,\n} from \"@fluidframework/driver-utils\";\nimport { IQuorumSnapshot } from \"@fluidframework/protocol-base\";\nimport {\n\tIClient,\n\tIClientDetails,\n\tICommittedProposal,\n\tIDocumentAttributes,\n\tIDocumentMessage,\n\tIQuorumClients,\n\tIQuorumProposals,\n\tISequencedClient,\n\tISequencedDocumentMessage,\n\tISequencedProposal,\n\tISignalMessage,\n\tISnapshotTree,\n\tISummaryContent,\n\tISummaryTree,\n\tIVersion,\n\tMessageType,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tcreateChildLogger,\n\tEventEmitterWithErrorHandling,\n\tPerformanceEvent,\n\traiseConnectedEvent,\n\tconnectedEventName,\n\tnormalizeError,\n\tMonitoringContext,\n\tcreateChildMonitoringContext,\n\twrapError,\n\tITelemetryLoggerExt,\n\tformatTick,\n\tGenericError,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils\";\nimport { Audience } from \"./audience\";\nimport { ContainerContext } from \"./containerContext\";\nimport {\n\tReconnectMode,\n\tIConnectionManagerFactoryArgs,\n\tgetPackageName,\n\tIConnectionDetailsInternal,\n\tIConnectionStateChangeReason,\n} from \"./contracts\";\nimport { DeltaManager, IConnectionArgs } from \"./deltaManager\";\nimport { IDetachedBlobStorage, ILoaderOptions, RelativeLoader } from \"./loader\";\nimport { pkgVersion } from \"./packageVersion\";\nimport {\n\tContainerStorageAdapter,\n\tgetBlobContentsFromTree,\n\tgetBlobContentsFromTreeWithBlobContents,\n\tISerializableBlobContents,\n} from \"./containerStorageAdapter\";\nimport { IConnectionStateHandler, createConnectionStateHandler } from \"./connectionStateHandler\";\nimport {\n\tcombineAppAndProtocolSummary,\n\tgetProtocolSnapshotTree,\n\tgetSnapshotTreeFromSerializedContainer,\n} from \"./utils\";\nimport { initQuorumValuesFromCodeDetails } from \"./quorum\";\nimport { NoopHeuristic } from \"./noopHeuristic\";\nimport { ConnectionManager } from \"./connectionManager\";\nimport { ConnectionState } from \"./connectionState\";\nimport {\n\tIProtocolHandler,\n\tProtocolHandler,\n\tProtocolHandlerBuilder,\n\tprotocolHandlerShouldProcessSignal,\n} from \"./protocol\";\n\nconst detachedContainerRefSeqNumber = 0;\n\nconst dirtyContainerEvent = \"dirty\";\nconst savedContainerEvent = \"saved\";\n\nconst packageNotFactoryError = \"Code package does not implement IRuntimeFactory\";\n\nconst hasBlobsSummaryTree = \".hasAttachmentBlobs\";\n\n/**\n * @internal\n */\nexport interface IContainerLoadProps {\n\t/**\n\t * The resolved url of the container being loaded\n\t */\n\treadonly resolvedUrl: IResolvedUrl;\n\t/**\n\t * Control which snapshot version to load from. See IParsedUrl for detailed information.\n\t */\n\treadonly version: string | undefined;\n\t/**\n\t * Loads the Container in paused state if true, unpaused otherwise.\n\t */\n\treadonly loadMode?: IContainerLoadMode;\n\n\t/**\n\t * The pending state serialized from a pervious container instance\n\t */\n\treadonly pendingLocalState?: IPendingContainerState;\n\n\t/**\n\t * Load the container to at least this sequence number.\n\t */\n\treadonly loadToSequenceNumber?: number;\n}\n\n/**\n * @internal\n */\nexport interface IContainerCreateProps {\n\t/**\n\t * Disables the Container from reconnecting if false, allows reconnect otherwise.\n\t */\n\treadonly canReconnect?: boolean;\n\t/**\n\t * Client details provided in the override will be merged over the default client.\n\t */\n\treadonly clientDetailsOverride?: IClientDetails;\n\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope: FluidObject;\n\n\t/**\n\t * The logger downstream consumers should construct their loggers from\n\t */\n\treadonly subLogger: ITelemetryLoggerExt;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Waits until container connects to delta storage and gets up-to-date.\n *\n * Useful when resolving URIs and hitting 404, due to container being loaded from (stale) snapshot and not being\n * up to date. Host may chose to wait in such case and retry resolving URI.\n *\n * Warning: Will wait infinitely for connection to establish if there is no connection.\n * May result in deadlock if Container.disconnect() is called and never followed by a call to Container.connect().\n *\n * @returns `true`: container is up to date, it processed all the ops that were know at the time of first connection.\n *\n * `false`: storage does not provide indication of how far the client is. Container processed all the ops known to it,\n * but it maybe still behind.\n *\n * @throws an error beginning with `\"Container closed\"` if the container is closed before it catches up.\n */\nexport async function waitContainerToCatchUp(container: IContainer) {\n\t// Make sure we stop waiting if container is closed.\n\tif (container.closed) {\n\t\tthrow new UsageError(\"waitContainerToCatchUp: Container closed\");\n\t}\n\n\treturn new Promise<boolean>((resolve, reject) => {\n\t\tconst deltaManager = container.deltaManager;\n\n\t\tconst closedCallback = (err?: ICriticalContainerError | undefined) => {\n\t\t\tcontainer.off(\"closed\", closedCallback);\n\t\t\tconst baseMessage = \"Container closed while waiting to catch up\";\n\t\t\treject(\n\t\t\t\terr !== undefined\n\t\t\t\t\t? wrapError(\n\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t\t(innerMessage) => new GenericError(`${baseMessage}: ${innerMessage}`),\n\t\t\t\t\t )\n\t\t\t\t\t: new GenericError(baseMessage),\n\t\t\t);\n\t\t};\n\t\tcontainer.on(\"closed\", closedCallback);\n\n\t\t// Depending on config, transition to \"connected\" state may include the guarantee\n\t\t// that all known ops have been processed. If so, we may introduce additional wait here.\n\t\t// Waiting for \"connected\" state in either case gets us at least to our own Join op\n\t\t// which is a reasonable approximation of \"caught up\"\n\t\tconst waitForOps = () => {\n\t\t\tassert(\n\t\t\t\tcontainer.connectionState === ConnectionState.CatchingUp ||\n\t\t\t\t\tcontainer.connectionState === ConnectionState.Connected,\n\t\t\t\t0x0cd /* \"Container disconnected while waiting for ops!\" */,\n\t\t\t);\n\t\t\tconst hasCheckpointSequenceNumber = deltaManager.hasCheckpointSequenceNumber;\n\n\t\t\tconst connectionOpSeqNumber = deltaManager.lastKnownSeqNumber;\n\t\t\tassert(\n\t\t\t\tdeltaManager.lastSequenceNumber <= connectionOpSeqNumber,\n\t\t\t\t0x266 /* \"lastKnownSeqNumber should never be below last processed sequence number\" */,\n\t\t\t);\n\t\t\tif (deltaManager.lastSequenceNumber === connectionOpSeqNumber) {\n\t\t\t\tcontainer.off(\"closed\", closedCallback);\n\t\t\t\tresolve(hasCheckpointSequenceNumber);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst callbackOps = (message: ISequencedDocumentMessage) => {\n\t\t\t\tif (connectionOpSeqNumber <= message.sequenceNumber) {\n\t\t\t\t\tcontainer.off(\"closed\", closedCallback);\n\t\t\t\t\tresolve(hasCheckpointSequenceNumber);\n\t\t\t\t\tdeltaManager.off(\"op\", callbackOps);\n\t\t\t\t}\n\t\t\t};\n\t\t\tdeltaManager.on(\"op\", callbackOps);\n\t\t};\n\n\t\t// We can leverage DeltaManager's \"connect\" event here and test for ConnectionState.Disconnected\n\t\t// But that works only if service provides us checkPointSequenceNumber\n\t\t// Our internal testing is based on R11S that does not, but almost all tests connect as \"write\" and\n\t\t// use this function to catch up, so leveraging our own join op as a fence/barrier\n\t\tif (container.connectionState === ConnectionState.Connected) {\n\t\t\twaitForOps();\n\t\t\treturn;\n\t\t}\n\n\t\tconst callback = () => {\n\t\t\tcontainer.off(connectedEventName, callback);\n\t\t\twaitForOps();\n\t\t};\n\t\tcontainer.on(connectedEventName, callback);\n\n\t\tif (container.connectionState === ConnectionState.Disconnected) {\n\t\t\tcontainer.connect();\n\t\t}\n\t});\n}\n\nconst getCodeProposal =\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t(quorum: IQuorumProposals) => quorum.get(\"code\") ?? quorum.get(\"code2\");\n\n/**\n * Helper function to report to telemetry cases where operation takes longer than expected (200ms)\n * @param logger - logger to use\n * @param eventName - event name\n * @param action - functor to call and measure\n */\nexport async function ReportIfTooLong(\n\tlogger: ITelemetryLoggerExt,\n\teventName: string,\n\taction: () => Promise<ITelemetryProperties>,\n) {\n\tconst event = PerformanceEvent.start(logger, { eventName });\n\tconst props = await action();\n\tif (event.duration > 200) {\n\t\tevent.end(props);\n\t}\n}\n\n/**\n * State saved by a container at close time, to be used to load a new instance\n * of the container to the same state\n * @internal\n */\nexport interface IPendingContainerState {\n\tpendingRuntimeState: unknown;\n\t/**\n\t * Snapshot from which container initially loaded.\n\t */\n\tbaseSnapshot: ISnapshotTree;\n\t/**\n\t * Serializable blobs from the base snapshot. Used to load offline since\n\t * storage is not available.\n\t */\n\tsnapshotBlobs: ISerializableBlobContents;\n\t/**\n\t * All ops since base snapshot sequence number up to the latest op\n\t * seen when the container was closed. Used to apply stashed (saved pending)\n\t * ops at the same sequence number at which they were made.\n\t */\n\tsavedOps: ISequencedDocumentMessage[];\n\turl: string;\n\tclientId?: string;\n}\n\nconst summarizerClientType = \"summarizer\";\n\ninterface IContainerLifecycleEvents extends IEvent {\n\t(event: \"runtimeInstantiated\", listener: () => void): void;\n\t(event: \"disposed\", listener: () => void): void;\n}\n\nexport class Container\n\textends EventEmitterWithErrorHandling<IContainerEvents>\n\timplements IContainer, IContainerExperimental\n{\n\t/**\n\t * Load an existing container.\n\t * @internal\n\t */\n\tpublic static async load(\n\t\tloadProps: IContainerLoadProps,\n\t\tcreateProps: IContainerCreateProps,\n\t): Promise<Container> {\n\t\tconst { version, pendingLocalState, loadMode, resolvedUrl, loadToSequenceNumber } =\n\t\t\tloadProps;\n\n\t\tconst container = new Container(createProps, loadProps);\n\n\t\tconst disableRecordHeapSize = container.mc.config.getBoolean(\n\t\t\t\"Fluid.Loader.DisableRecordHeapSize\",\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tcontainer.mc.logger,\n\t\t\t{ eventName: \"Load\" },\n\t\t\tasync (event) =>\n\t\t\t\tnew Promise<Container>((resolve, reject) => {\n\t\t\t\t\tconst defaultMode: IContainerLoadMode = { opsBeforeReturn: \"cached\" };\n\t\t\t\t\t// if we have pendingLocalState, anything we cached is not useful and we shouldn't wait for connection\n\t\t\t\t\t// to return container, so ignore this value and use undefined for opsBeforeReturn\n\t\t\t\t\tconst mode: IContainerLoadMode = pendingLocalState\n\t\t\t\t\t\t? { ...(loadMode ?? defaultMode), opsBeforeReturn: undefined }\n\t\t\t\t\t\t: loadMode ?? defaultMode;\n\n\t\t\t\t\tconst onClosed = (err?: ICriticalContainerError) => {\n\t\t\t\t\t\t// pre-0.58 error message: containerClosedWithoutErrorDuringLoad\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\terr ?? new GenericError(\"Container closed without error during load\"),\n\t\t\t\t\t\t);\n\t\t\t\t\t};\n\t\t\t\t\tcontainer.on(\"closed\", onClosed);\n\n\t\t\t\t\tcontainer\n\t\t\t\t\t\t.load(version, mode, resolvedUrl, pendingLocalState, loadToSequenceNumber)\n\t\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\t\tcontainer.removeListener(\"closed\", onClosed);\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\t(props) => {\n\t\t\t\t\t\t\t\tevent.end({ ...props, ...loadMode });\n\t\t\t\t\t\t\t\tresolve(container);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\tconst err = normalizeError(error);\n\t\t\t\t\t\t\t\t// Depending where error happens, we can be attempting to connect to web socket\n\t\t\t\t\t\t\t\t// and continuously retrying (consider offline mode)\n\t\t\t\t\t\t\t\t// Host has no container to close, so it's prudent to do it here\n\t\t\t\t\t\t\t\t// Note: We could only dispose the container instead of just close but that would\n\t\t\t\t\t\t\t\t// the telemetry where users sometimes search for ContainerClose event to look\n\t\t\t\t\t\t\t\t// for load failures. So not removing this at this time.\n\t\t\t\t\t\t\t\tcontainer.close(err);\n\t\t\t\t\t\t\t\tcontainer.dispose(err);\n\t\t\t\t\t\t\t\tonClosed(err);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\tdisableRecordHeapSize !== true /* recordHeapSize */,\n\t\t);\n\t}\n\n\t/**\n\t * Create a new container in a detached state.\n\t */\n\tpublic static async createDetached(\n\t\tcreateProps: IContainerCreateProps,\n\t\tcodeDetails: IFluidCodeDetails,\n\t): Promise<Container> {\n\t\tconst container = new Container(createProps);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tcontainer.mc.logger,\n\t\t\t{ eventName: \"CreateDetached\" },\n\t\t\tasync (_event) => {\n\t\t\t\tawait container.createDetached(codeDetails);\n\t\t\t\treturn container;\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t}\n\n\t/**\n\t * Create a new container in a detached state that is initialized with a\n\t * snapshot from a previous detached container.\n\t */\n\tpublic static async rehydrateDetachedFromSnapshot(\n\t\tcreateProps: IContainerCreateProps,\n\t\tsnapshot: string,\n\t): Promise<Container> {\n\t\tconst container = new Container(createProps);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tcontainer.mc.logger,\n\t\t\t{ eventName: \"RehydrateDetachedFromSnapshot\" },\n\t\t\tasync (_event) => {\n\t\t\t\tconst deserializedSummary = JSON.parse(snapshot);\n\t\t\t\tif (!isCombinedAppAndProtocolSummary(deserializedSummary, hasBlobsSummaryTree)) {\n\t\t\t\t\tthrow new UsageError(\"Cannot rehydrate detached container. Incorrect format\");\n\t\t\t\t}\n\n\t\t\t\tawait container.rehydrateDetachedFromSnapshot(deserializedSummary);\n\t\t\t\treturn container;\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t}\n\n\t// Tells if container can reconnect on losing fist connection\n\t// If false, container gets closed on loss of connection.\n\tprivate readonly _canReconnect: boolean;\n\tprivate readonly clientDetailsOverride: IClientDetails | undefined;\n\tprivate readonly urlResolver: IUrlResolver;\n\tprivate readonly serviceFactory: IDocumentServiceFactory;\n\tprivate readonly codeLoader: ICodeDetailsLoader;\n\tprivate readonly options: ILoaderOptions;\n\tprivate readonly scope: FluidObject;\n\tprivate readonly subLogger: ITelemetryLoggerExt;\n\tprivate readonly detachedBlobStorage: IDetachedBlobStorage | undefined;\n\tprivate readonly protocolHandlerBuilder: ProtocolHandlerBuilder;\n\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Used by the RelativeLoader to spawn a new Container for the same document. Used to create the summarizing client.\n\t * @internal\n\t */\n\tpublic readonly clone: (\n\t\tloadProps: IContainerLoadProps,\n\t\tcreateParamOverrides: Partial<IContainerCreateProps>,\n\t) => Promise<Container>;\n\n\t/**\n\t * Lifecycle state of the container, used mainly to prevent re-entrancy and telemetry\n\t *\n\t * States are allowed to progress to further states:\n\t * \"loading\" - \"loaded\" - \"closing\" - \"disposing\" - \"closed\" - \"disposed\"\n\t *\n\t * For example, moving from \"closed\" to \"disposing\" is not allowed since it is an earlier state.\n\t *\n\t * loading: Container has been created, but is not yet in normal/loaded state\n\t * loaded: Container is in normal/loaded state\n\t * closing: Container has started closing process (for re-entrancy prevention)\n\t * disposing: Container has started disposing process (for re-entrancy prevention)\n\t * closed: Container has closed\n\t * disposed: Container has been disposed\n\t */\n\tprivate _lifecycleState:\n\t\t| \"loading\"\n\t\t| \"loaded\"\n\t\t| \"closing\"\n\t\t| \"disposing\"\n\t\t| \"closed\"\n\t\t| \"disposed\" = \"loading\";\n\n\tprivate setLoaded() {\n\t\t// It's conceivable the container could be closed when this is called\n\t\t// Only transition states if currently loading\n\t\tif (this._lifecycleState === \"loading\") {\n\t\t\t// Propagate current connection state through the system.\n\t\t\tthis.propagateConnectionState(true /* initial transition */);\n\t\t\tthis._lifecycleState = \"loaded\";\n\t\t}\n\t}\n\n\tpublic get closed(): boolean {\n\t\treturn (\n\t\t\tthis._lifecycleState === \"closing\" || this._lifecycleState === \"closed\" || this.disposed\n\t\t);\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this._lifecycleState === \"disposing\" || this._lifecycleState === \"disposed\";\n\t}\n\n\tprivate _attachState = AttachState.Detached;\n\n\tprivate readonly storageAdapter: ContainerStorageAdapter;\n\n\tprivate readonly _deltaManager: DeltaManager<ConnectionManager>;\n\tprivate service: IDocumentService | undefined;\n\n\tprivate _runtime: IRuntime | undefined;\n\tprivate get runtime() {\n\t\tif (this._runtime === undefined) {\n\t\t\tthrow new Error(\"Attempted to access runtime before it was defined\");\n\t\t}\n\t\treturn this._runtime;\n\t}\n\tprivate _protocolHandler: IProtocolHandler | undefined;\n\tprivate get protocolHandler() {\n\t\tif (this._protocolHandler === undefined) {\n\t\t\tthrow new Error(\"Attempted to access protocolHandler before it was defined\");\n\t\t}\n\t\treturn this._protocolHandler;\n\t}\n\n\t/** During initialization we pause the inbound queues. We track this state to ensure we only call resume once */\n\tprivate inboundQueuePausedFromInit = true;\n\tprivate firstConnection = true;\n\tprivate readonly connectionTransitionTimes: number[] = [];\n\tprivate _loadedFromVersion: IVersion | undefined;\n\tprivate attachStarted = false;\n\tprivate _dirtyContainer = false;\n\tprivate readonly savedOps: ISequencedDocumentMessage[] = [];\n\tprivate baseSnapshot?: ISnapshotTree;\n\tprivate baseSnapshotBlobs?: ISerializableBlobContents;\n\tprivate readonly _containerId: string;\n\n\tprivate lastVisible: number | undefined;\n\tprivate readonly visibilityEventHandler: (() => void) | undefined;\n\tprivate readonly connectionStateHandler: IConnectionStateHandler;\n\tprivate readonly clientsWhoShouldHaveLeft = new Set<string>();\n\n\tprivate setAutoReconnectTime = performance.now();\n\n\tprivate noopHeuristic: NoopHeuristic | undefined;\n\n\tprivate get connectionMode() {\n\t\treturn this._deltaManager.connectionManager.connectionMode;\n\t}\n\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl | undefined {\n\t\t/**\n\t\t * All attached containers will have a document service,\n\t\t * this is required, as attached containers are attached to\n\t\t * a service. Detached containers will neither have a document\n\t\t * service or a resolved url as they only exist locally.\n\t\t * in order to create a document service a resolved url must\n\t\t * first be obtained, this is how the container is identified.\n\t\t * Because of this, the document service's resolved url\n\t\t * is always the same as the containers, as we had to\n\t\t * obtain the resolved url, and then create the service from it.\n\t\t */\n\t\treturn this.service?.resolvedUrl;\n\t}\n\n\tpublic get readOnlyInfo(): ReadOnlyInfo {\n\t\treturn this._deltaManager.readOnlyInfo;\n\t}\n\n\t/**\n\t * Sends signal to runtime (and data stores) to be read-only.\n\t * Hosts may have read only views, indicating to data stores that no edits are allowed.\n\t * This is independent from this._readonlyPermissions (permissions) and this.connectionMode\n\t * (server can return \"write\" mode even when asked for \"read\")\n\t * Leveraging same \"readonly\" event as runtime & data stores should behave the same in such case\n\t * as in read-only permissions.\n\t * But this.active can be used by some DDSes to figure out if ops can be sent\n\t * (for example, read-only view still participates in code proposals / upgrades decisions)\n\t *\n\t * Forcing Readonly does not prevent DDS from generating ops. It is up to user code to honour\n\t * the readonly flag. If ops are generated, they will accumulate locally and not be sent. If\n\t * there are pending in the outbound queue, it will stop sending until force readonly is\n\t * cleared.\n\t *\n\t * @param readonly - set or clear force readonly.\n\t */\n\tpublic forceReadonly(readonly: boolean) {\n\t\tthis._deltaManager.connectionManager.forceReadonly(readonly);\n\t}\n\n\tpublic get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n\t\treturn this._deltaManager;\n\t}\n\n\tpublic get connectionState(): ConnectionState {\n\t\treturn this.connectionStateHandler.connectionState;\n\t}\n\n\tprivate get connected(): boolean {\n\t\treturn this.connectionStateHandler.connectionState === ConnectionState.Connected;\n\t}\n\n\tprivate _clientId: string | undefined;\n\n\t/**\n\t * The server provided id of the client.\n\t * Set once this.connected is true, otherwise undefined\n\t */\n\tpublic get clientId(): string | undefined {\n\t\treturn this._clientId;\n\t}\n\n\tprivate get offlineLoadEnabled(): boolean {\n\t\tconst enabled =\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Container.enableOfflineLoad\") ??\n\t\t\tthis.options?.enableOfflineLoad === true;\n\t\t// summarizer will not have any pending state we want to save\n\t\treturn enabled && this.deltaManager.clientDetails.capabilities.interactive;\n\t}\n\n\t/**\n\t * Get the code details that are currently specified for the container.\n\t * @returns The current code details if any are specified, undefined if none are specified.\n\t */\n\tpublic getSpecifiedCodeDetails(): IFluidCodeDetails | undefined {\n\t\treturn this.getCodeDetailsFromQuorum();\n\t}\n\n\tprivate _loadedCodeDetails: IFluidCodeDetails | undefined;\n\t/**\n\t * Get the code details that were used to load the container.\n\t * @returns The code details that were used to load the container if it is loaded, undefined if it is not yet\n\t * loaded.\n\t */\n\tpublic getLoadedCodeDetails(): IFluidCodeDetails | undefined {\n\t\treturn this._loadedCodeDetails;\n\t}\n\n\tprivate _loadedModule: IFluidModuleWithDetails | undefined;\n\n\t/**\n\t * Retrieves the audience associated with the document\n\t */\n\tpublic get audience(): IAudience {\n\t\treturn this.protocolHandler.audience;\n\t}\n\n\t/**\n\t * Returns true if container is dirty.\n\t * Which means data loss if container is closed at that same moment\n\t * Most likely that happens when there is no network connection to Relay Service\n\t */\n\tpublic get isDirty() {\n\t\treturn this._dirtyContainer;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/container-definitions#IContainer.entryPoint}\n\t */\n\tpublic async getEntryPoint(): Promise<FluidObject | undefined> {\n\t\tif (this._disposed) {\n\t\t\tthrow new UsageError(\"The context is already disposed\");\n\t\t}\n\t\tif (this._runtime !== undefined) {\n\t\t\treturn this._runtime.getEntryPoint?.();\n\t\t}\n\t\treturn new Promise<FluidObject | undefined>((resolve, reject) => {\n\t\t\tconst runtimeInstantiatedHandler = () => {\n\t\t\t\tassert(\n\t\t\t\t\tthis._runtime !== undefined,\n\t\t\t\t\t0x5a3 /* runtimeInstantiated fired but runtime is still undefined */,\n\t\t\t\t);\n\t\t\t\tresolve(this._runtime.getEntryPoint?.());\n\t\t\t\tthis._lifecycleEvents.off(\"disposed\", disposedHandler);\n\t\t\t};\n\t\t\tconst disposedHandler = () => {\n\t\t\t\treject(new Error(\"ContainerContext was disposed\"));\n\t\t\t\tthis._lifecycleEvents.off(\"runtimeInstantiated\", runtimeInstantiatedHandler);\n\t\t\t};\n\t\t\tthis._lifecycleEvents.once(\"runtimeInstantiated\", runtimeInstantiatedHandler);\n\t\t\tthis._lifecycleEvents.once(\"disposed\", disposedHandler);\n\t\t});\n\t}\n\n\tprivate readonly _lifecycleEvents = new TypedEventEmitter<IContainerLifecycleEvents>();\n\n\t/**\n\t * @internal\n\t */\n\tconstructor(\n\t\tcreateProps: IContainerCreateProps,\n\t\tloadProps?: Pick<IContainerLoadProps, \"pendingLocalState\">,\n\t) {\n\t\tsuper((name, error) => {\n\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"ContainerEventHandlerException\",\n\t\t\t\t\tname: typeof name === \"string\" ? name : undefined,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\tconst {\n\t\t\tcanReconnect,\n\t\t\tclientDetailsOverride,\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions,\n\t\t\tscope,\n\t\t\tsubLogger,\n\t\t\tdetachedBlobStorage,\n\t\t\tprotocolHandlerBuilder,\n\t\t} = createProps;\n\n\t\tthis.connectionTransitionTimes[ConnectionState.Disconnected] = performance.now();\n\t\tconst pendingLocalState = loadProps?.pendingLocalState;\n\t\tthis._clientId = pendingLocalState?.clientId;\n\n\t\tthis._canReconnect = canReconnect ?? true;\n\t\tthis.clientDetailsOverride = clientDetailsOverride;\n\t\tthis.urlResolver = urlResolver;\n\t\tthis.serviceFactory = documentServiceFactory;\n\t\tthis.codeLoader = codeLoader;\n\t\t// Warning: this is only a shallow clone. Mutation of any individual loader option will mutate it for\n\t\t// all clients that were loaded from the same loader (including summarizer clients).\n\t\t// Tracking alternative ways to handle this in AB#4129.\n\t\tthis.options = { ...options };\n\t\tthis.scope = scope;\n\t\tthis.detachedBlobStorage = detachedBlobStorage;\n\t\tthis.protocolHandlerBuilder =\n\t\t\tprotocolHandlerBuilder ??\n\t\t\t((\n\t\t\t\tattributes: IDocumentAttributes,\n\t\t\t\tquorumSnapshot: IQuorumSnapshot,\n\t\t\t\tsendProposal: (key: string, value: any) => number,\n\t\t\t) =>\n\t\t\t\tnew ProtocolHandler(\n\t\t\t\t\tattributes,\n\t\t\t\t\tquorumSnapshot,\n\t\t\t\t\tsendProposal,\n\t\t\t\t\tnew Audience(),\n\t\t\t\t\t(clientId: string) => this.clientsWhoShouldHaveLeft.has(clientId),\n\t\t\t\t));\n\n\t\t// Note that we capture the createProps here so we can replicate the creation call when we want to clone.\n\t\tthis.clone = async (\n\t\t\t_loadProps: IContainerLoadProps,\n\t\t\tcreateParamOverrides: Partial<IContainerCreateProps>,\n\t\t) => {\n\t\t\treturn Container.load(_loadProps, {\n\t\t\t\t...createProps,\n\t\t\t\t...createParamOverrides,\n\t\t\t});\n\t\t};\n\n\t\t// Create logger for data stores to use\n\t\tconst type = this.client.details.type;\n\t\tconst interactive = this.client.details.capabilities.interactive;\n\t\tconst clientType = `${interactive ? \"interactive\" : \"noninteractive\"}${\n\t\t\ttype !== undefined && type !== \"\" ? `/${type}` : \"\"\n\t\t}`;\n\n\t\tthis._containerId = uuid();\n\t\t// Need to use the property getter for docId because for detached flow we don't have the docId initially.\n\t\t// We assign the id later so property getter is used.\n\t\tthis.subLogger = createChildLogger({\n\t\t\tlogger: subLogger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\tclientType, // Differentiating summarizer container from main container\n\t\t\t\t\tcontainerId: this._containerId,\n\t\t\t\t\tdocId: () => this.resolvedUrl?.id,\n\t\t\t\t\tcontainerAttachState: () => this._attachState,\n\t\t\t\t\tcontainerLifecycleState: () => this._lifecycleState,\n\t\t\t\t\tcontainerConnectionState: () => ConnectionState[this.connectionState],\n\t\t\t\t\tserializedContainer: pendingLocalState !== undefined,\n\t\t\t\t},\n\t\t\t\t// we need to be judicious with our logging here to avoid generating too much data\n\t\t\t\t// all data logged here should be broadly applicable, and not specific to a\n\t\t\t\t// specific error or class of errors\n\t\t\t\terror: {\n\t\t\t\t\t// load information to associate errors with the specific load point\n\t\t\t\t\tdmInitialSeqNumber: () => this._deltaManager?.initialSequenceNumber,\n\t\t\t\t\tdmLastProcessedSeqNumber: () => this._deltaManager?.lastSequenceNumber,\n\t\t\t\t\tdmLastKnownSeqNumber: () => this._deltaManager?.lastKnownSeqNumber,\n\t\t\t\t\tcontainerLoadedFromVersionId: () => this._loadedFromVersion?.id,\n\t\t\t\t\tcontainerLoadedFromVersionDate: () => this._loadedFromVersion?.date,\n\t\t\t\t\t// message information to associate errors with the specific execution state\n\t\t\t\t\t// dmLastMsqSeqNumber: if present, same as dmLastProcessedSeqNumber\n\t\t\t\t\tdmLastMsqSeqNumber: () => this.deltaManager?.lastMessage?.sequenceNumber,\n\t\t\t\t\tdmLastMsqSeqTimestamp: () => this.deltaManager?.lastMessage?.timestamp,\n\t\t\t\t\tdmLastMsqSeqClientId: () =>\n\t\t\t\t\t\tthis.deltaManager?.lastMessage?.clientId === null\n\t\t\t\t\t\t\t? \"null\"\n\t\t\t\t\t\t\t: this.deltaManager?.lastMessage?.clientId,\n\t\t\t\t\tdmLastMsgClientSeq: () => this.deltaManager?.lastMessage?.clientSequenceNumber,\n\t\t\t\t\tconnectionStateDuration: () =>\n\t\t\t\t\t\tperformance.now() - this.connectionTransitionTimes[this.connectionState],\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\t// Prefix all events in this file with container-loader\n\t\tthis.mc = createChildMonitoringContext({ logger: this.subLogger, namespace: \"Container\" });\n\n\t\tthis._deltaManager = this.createDeltaManager();\n\n\t\tthis.connectionStateHandler = createConnectionStateHandler(\n\t\t\t{\n\t\t\t\tlogger: this.mc.logger,\n\t\t\t\tconnectionStateChanged: (value, oldState, reason) => {\n\t\t\t\t\tif (value === ConnectionState.Connected) {\n\t\t\t\t\t\tthis._clientId = this.connectionStateHandler.pendingClientId;\n\t\t\t\t\t}\n\t\t\t\t\tthis.logConnectionStateChangeTelemetry(value, oldState, reason);\n\t\t\t\t\tif (this._lifecycleState === \"loaded\") {\n\t\t\t\t\t\tthis.propagateConnectionState(\n\t\t\t\t\t\t\tfalse /* initial transition */,\n\t\t\t\t\t\t\tvalue === ConnectionState.Disconnected\n\t\t\t\t\t\t\t\t? reason\n\t\t\t\t\t\t\t\t: undefined /* disconnectedReason */,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldClientJoinWrite: () => this._deltaManager.connectionManager.shouldJoinWrite(),\n\t\t\t\tmaxClientLeaveWaitTime: options.maxClientLeaveWaitTime,\n\t\t\t\tlogConnectionIssue: (\n\t\t\t\t\teventName: string,\n\t\t\t\t\tcategory: TelemetryEventCategory,\n\t\t\t\t\tdetails?: ITelemetryProperties,\n\t\t\t\t) => {\n\t\t\t\t\tconst mode = this.connectionMode;\n\t\t\t\t\t// We get here when socket does not receive any ops on \"write\" connection, including\n\t\t\t\t\t// its own join op.\n\t\t\t\t\t// Report issues only if we already loaded container - op processing is paused while container is loading,\n\t\t\t\t\t// so we always time-out processing of join op in cases where fetching snapshot takes a minute.\n\t\t\t\t\t// It's not a problem with op processing itself - such issues should be tracked as part of boot perf monitoring instead.\n\t\t\t\t\tthis._deltaManager.logConnectionIssue({\n\t\t\t\t\t\teventName,\n\t\t\t\t\t\tmode,\n\t\t\t\t\t\tcategory: this._lifecycleState === \"loading\" ? \"generic\" : category,\n\t\t\t\t\t\tduration:\n\t\t\t\t\t\t\tperformance.now() -\n\t\t\t\t\t\t\tthis.connectionTransitionTimes[ConnectionState.CatchingUp],\n\t\t\t\t\t\t...(details === undefined ? {} : { details: JSON.stringify(details) }),\n\t\t\t\t\t});\n\n\t\t\t\t\t// If this is \"write\" connection, it took too long to receive join op. But in most cases that's due\n\t\t\t\t\t// to very slow op fetches and we will eventually get there.\n\t\t\t\t\t// For \"read\" connections, we get here due to self join signal not arriving on time. We will need to\n\t\t\t\t\t// better understand when and why it may happen.\n\t\t\t\t\t// For now, attempt to recover by reconnecting. In future, maybe we can query relay service for\n\t\t\t\t\t// current state of audience.\n\t\t\t\t\t// Other possible recovery path - move to connected state (i.e. ConnectionStateHandler.joinOpTimer\n\t\t\t\t\t// to call this.applyForConnectedState(\"addMemberEvent\") for \"read\" connections)\n\t\t\t\t\tif (mode === \"read\") {\n\t\t\t\t\t\tconst reason = { text: \"NoJoinSignal\" };\n\t\t\t\t\t\tthis.disconnectInternal(reason);\n\t\t\t\t\t\tthis.connectInternal({ reason, fetchOpsFromStorage: false });\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tclientShouldHaveLeft: (clientId: string) => {\n\t\t\t\t\tthis.clientsWhoShouldHaveLeft.add(clientId);\n\t\t\t\t},\n\t\t\t},\n\t\t\tthis.deltaManager,\n\t\t\tpendingLocalState?.clientId,\n\t\t);\n\n\t\tthis.on(savedContainerEvent, () => {\n\t\t\tthis.connectionStateHandler.containerSaved();\n\t\t});\n\n\t\t// We expose our storage publicly, so it's possible others may call uploadSummaryWithContext() with a\n\t\t// non-combined summary tree (in particular, ContainerRuntime.submitSummary). We'll intercept those calls\n\t\t// using this callback and fix them up.\n\t\tconst addProtocolSummaryIfMissing = (summaryTree: ISummaryTree) =>\n\t\t\tisCombinedAppAndProtocolSummary(summaryTree) === true\n\t\t\t\t? summaryTree\n\t\t\t\t: combineAppAndProtocolSummary(summaryTree, this.captureProtocolSummary());\n\n\t\t// Whether the combined summary tree has been forced on by either the loader option or the monitoring context.\n\t\t// Even if not forced on via this flag, combined summaries may still be enabled by service policy.\n\t\tconst forceEnableSummarizeProtocolTree =\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Container.summarizeProtocolTree2\") ??\n\t\t\toptions.summarizeProtocolTree;\n\n\t\tthis.storageAdapter = new ContainerStorageAdapter(\n\t\t\tdetachedBlobStorage,\n\t\t\tthis.mc.logger,\n\t\t\tpendingLocalState?.snapshotBlobs,\n\t\t\taddProtocolSummaryIfMissing,\n\t\t\tforceEnableSummarizeProtocolTree,\n\t\t);\n\n\t\tconst isDomAvailable =\n\t\t\ttypeof document === \"object\" &&\n\t\t\tdocument !== null &&\n\t\t\ttypeof document.addEventListener === \"function\" &&\n\t\t\tdocument.addEventListener !== null;\n\t\t// keep track of last time page was visible for telemetry (on interactive clients only)\n\t\tif (isDomAvailable && interactive) {\n\t\t\tthis.lastVisible = document.hidden ? performance.now() : undefined;\n\t\t\tthis.visibilityEventHandler = () => {\n\t\t\t\tif (document.hidden) {\n\t\t\t\t\tthis.lastVisible = performance.now();\n\t\t\t\t} else {\n\t\t\t\t\t// settimeout so this will hopefully fire after disconnect event if being hidden caused it\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis.lastVisible = undefined;\n\t\t\t\t\t}, 0);\n\t\t\t\t}\n\t\t\t};\n\t\t\tdocument.addEventListener(\"visibilitychange\", this.visibilityEventHandler);\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the quorum associated with the document\n\t */\n\tpublic getQuorum(): IQuorumClients {\n\t\treturn this.protocolHandler.quorum;\n\t}\n\n\tpublic dispose(error?: ICriticalContainerError) {\n\t\tthis._deltaManager.dispose(error);\n\t\tthis.verifyClosed();\n\t}\n\n\tpublic close(error?: ICriticalContainerError) {\n\t\t// 1. Ensure that close sequence is exactly the same no matter if it's initiated by host or by DeltaManager\n\t\t// 2. We need to ensure that we deliver disconnect event to runtime properly. See connectionStateChanged\n\t\t// handler. We only deliver events if container fully loaded. Transitioning from \"loading\" ->\n\t\t// \"closing\" will lose that info (can also solve by tracking extra state).\n\t\tthis._deltaManager.close(error);\n\t\tthis.verifyClosed();\n\t}\n\n\tprivate verifyClosed(): void {\n\t\tassert(\n\t\t\tthis.connectionState === ConnectionState.Disconnected,\n\t\t\t0x0cf /* \"disconnect event was not raised!\" */,\n\t\t);\n\n\t\tassert(\n\t\t\tthis._lifecycleState === \"closed\" || this._lifecycleState === \"disposed\",\n\t\t\t0x314 /* Container properly closed */,\n\t\t);\n\t}\n\n\tprivate closeCore(error?: ICriticalContainerError) {\n\t\tassert(!this.closed, 0x315 /* re-entrancy */);\n\n\t\ttry {\n\t\t\t// Ensure that we raise all key events even if one of these throws\n\t\t\ttry {\n\t\t\t\t// Raise event first, to ensure we capture _lifecycleState before transition.\n\t\t\t\t// This gives us a chance to know what errors happened on open vs. on fully loaded container.\n\t\t\t\t// Log generic events instead of error events if container is in loading state, as most errors are not really FF errors\n\t\t\t\t// which can pollute telemetry for real bugs\n\t\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"ContainerClose\",\n\t\t\t\t\t\tcategory:\n\t\t\t\t\t\t\tthis._lifecycleState !== \"loading\" && error !== undefined\n\t\t\t\t\t\t\t\t? \"error\"\n\t\t\t\t\t\t\t\t: \"generic\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\tthis._lifecycleState = \"closing\";\n\n\t\t\t\tthis._protocolHandler?.close();\n\n\t\t\t\tthis.connectionStateHandler.dispose();\n\t\t\t} catch (exception) {\n\t\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"ContainerCloseException\" }, exception);\n\t\t\t}\n\n\t\t\tthis.emit(\"closed\", error);\n\n\t\t\tif (this.visibilityEventHandler !== undefined) {\n\t\t\t\tdocument.removeEventListener(\"visibilitychange\", this.visibilityEventHandler);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._lifecycleState = \"closed\";\n\n\t\t\t// There is no user for summarizer, so we need to ensure dispose is called\n\t\t\tif (this.client.details.type === summarizerClientType) {\n\t\t\t\tthis.dispose(error);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _disposed = false;\n\tprivate disposeCore(error?: ICriticalContainerError) {\n\t\tassert(!this._disposed, 0x54c /* Container already disposed */);\n\t\tthis._disposed = true;\n\n\t\ttry {\n\t\t\t// Ensure that we raise all key events even if one of these throws\n\t\t\ttry {\n\t\t\t\t// Raise event first, to ensure we capture _lifecycleState before transition.\n\t\t\t\t// This gives us a chance to know what errors happened on open vs. on fully loaded container.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"ContainerDispose\",\n\t\t\t\t\t\t// Only log error if container isn't closed\n\t\t\t\t\t\tcategory: !this.closed && error !== undefined ? \"error\" : \"generic\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\t// ! Progressing from \"closed\" to \"disposing\" is not allowed\n\t\t\t\tif (this._lifecycleState !== \"closed\") {\n\t\t\t\t\tthis._lifecycleState = \"disposing\";\n\t\t\t\t}\n\n\t\t\t\tthis._protocolHandler?.close();\n\n\t\t\t\tthis.connectionStateHandler.dispose();\n\n\t\t\t\tconst maybeError = error !== undefined ? new Error(error.message) : undefined;\n\t\t\t\tthis._runtime?.dispose(maybeError);\n\n\t\t\t\tthis.storageAdapter.dispose();\n\n\t\t\t\t// Notify storage about critical errors. They may be due to disconnect between client & server knowledge\n\t\t\t\t// about file, like file being overwritten in storage, but client having stale local cache.\n\t\t\t\t// Driver need to ensure all caches are cleared on critical errors\n\t\t\t\tthis.service?.dispose(error);\n\t\t\t} catch (exception) {\n\t\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t\t{ eventName: \"ContainerDisposeException\" },\n\t\t\t\t\texception,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.emit(\"disposed\", error);\n\n\t\t\tthis.removeAllListeners();\n\t\t\tif (this.visibilityEventHandler !== undefined) {\n\t\t\t\tdocument.removeEventListener(\"visibilitychange\", this.visibilityEventHandler);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._lifecycleState = \"disposed\";\n\t\t\tthis._lifecycleEvents.emit(\"disposed\");\n\t\t}\n\t}\n\n\tpublic async closeAndGetPendingLocalState(\n\t\tstopBlobAttachingSignal?: AbortSignal,\n\t): Promise<string> {\n\t\t// runtime matches pending ops to successful ones by clientId and client seq num, so we need to close the\n\t\t// container at the same time we get pending state, otherwise this container could reconnect and resubmit with\n\t\t// a new clientId and a future container using stale pending state without the new clientId would resubmit them\n\t\tthis.disconnectInternal({ text: \"closeAndGetPendingLocalState\" }); // TODO https://dev.azure.com/fluidframework/internal/_workitems/edit/5127\n\t\tconst pendingState = await this.getPendingLocalStateCore({\n\t\t\tnotifyImminentClosure: true,\n\t\t\tstopBlobAttachingSignal,\n\t\t});\n\t\tthis.close();\n\t\treturn pendingState;\n\t}\n\n\tpublic async getPendingLocalState(): Promise<string> {\n\t\treturn this.getPendingLocalStateCore({ notifyImminentClosure: false });\n\t}\n\n\tprivate async getPendingLocalStateCore(props: IGetPendingLocalStateProps) {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{\n\t\t\t\teventName: \"getPendingLocalState\",\n\t\t\t\tnotifyImminentClosure: props.notifyImminentClosure,\n\t\t\t\tsavedOpsSize: this.savedOps.length,\n\t\t\t\tclientId: this.clientId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tif (!this.offlineLoadEnabled) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Can't get pending local state unless offline load is enabled\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (this.closed || this._disposed) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Pending state cannot be retried if the container is closed or disposed\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tthis.attachState === AttachState.Attached,\n\t\t\t\t\t0x0d1 /* \"Container should be attached before close\" */,\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tthis.resolvedUrl !== undefined && this.resolvedUrl.type === \"fluid\",\n\t\t\t\t\t0x0d2 /* \"resolved url should be valid Fluid url\" */,\n\t\t\t\t);\n\t\t\t\tassert(!!this.baseSnapshot, 0x5d4 /* no base snapshot */);\n\t\t\t\tassert(!!this.baseSnapshotBlobs, 0x5d5 /* no snapshot blobs */);\n\t\t\t\tconst pendingRuntimeState = await this.runtime.getPendingLocalState(props);\n\t\t\t\tconst pendingState: IPendingContainerState = {\n\t\t\t\t\tpendingRuntimeState,\n\t\t\t\t\tbaseSnapshot: this.baseSnapshot,\n\t\t\t\t\tsnapshotBlobs: this.baseSnapshotBlobs,\n\t\t\t\t\tsavedOps: this.savedOps,\n\t\t\t\t\turl: this.resolvedUrl.url,\n\t\t\t\t\t// no need to save this if there is no pending runtime state\n\t\t\t\t\tclientId: pendingRuntimeState !== undefined ? this.clientId : undefined,\n\t\t\t\t};\n\n\t\t\t\treturn JSON.stringify(pendingState);\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic get attachState(): AttachState {\n\t\treturn this._attachState;\n\t}\n\n\tpublic serialize(): string {\n\t\tassert(\n\t\t\tthis.attachState === AttachState.Detached,\n\t\t\t0x0d3 /* \"Should only be called in detached container\" */,\n\t\t);\n\n\t\tconst appSummary: ISummaryTree = this.runtime.createSummary();\n\t\tconst protocolSummary = this.captureProtocolSummary();\n\t\tconst combinedSummary = combineAppAndProtocolSummary(appSummary, protocolSummary);\n\n\t\tif (this.detachedBlobStorage && this.detachedBlobStorage.size > 0) {\n\t\t\tcombinedSummary.tree[hasBlobsSummaryTree] = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: \"true\",\n\t\t\t};\n\t\t}\n\t\treturn JSON.stringify(combinedSummary);\n\t}\n\n\tpublic async attach(\n\t\trequest: IRequest,\n\t\tattachProps?: { deltaConnection?: \"none\" | \"delayed\" },\n\t): Promise<void> {\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"Attach\" },\n\t\t\tasync () => {\n\t\t\t\tif (this._lifecycleState !== \"loaded\") {\n\t\t\t\t\t// pre-0.58 error message: containerNotValidForAttach\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`The Container is not in a valid state for attach [${this._lifecycleState}]`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// If container is already attached or attach is in progress, throw an error.\n\t\t\t\tassert(\n\t\t\t\t\tthis._attachState === AttachState.Detached && !this.attachStarted,\n\t\t\t\t\t0x205 /* \"attach() called more than once\" */,\n\t\t\t\t);\n\t\t\t\tthis.attachStarted = true;\n\n\t\t\t\t// If attachment blobs were uploaded in detached state we will go through a different attach flow\n\t\t\t\tconst hasAttachmentBlobs =\n\t\t\t\t\tthis.detachedBlobStorage !== undefined && this.detachedBlobStorage.size > 0;\n\n\t\t\t\ttry {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tthis.deltaManager.inbound.length === 0,\n\t\t\t\t\t\t0x0d6 /* \"Inbound queue should be empty when attaching\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tlet summary: ISummaryTree;\n\t\t\t\t\tif (!hasAttachmentBlobs) {\n\t\t\t\t\t\t// Get the document state post attach - possibly can just call attach but we need to change the\n\t\t\t\t\t\t// semantics around what the attach means as far as async code goes.\n\t\t\t\t\t\tconst appSummary: ISummaryTree = this.runtime.createSummary();\n\t\t\t\t\t\tconst protocolSummary = this.captureProtocolSummary();\n\t\t\t\t\t\tsummary = combineAppAndProtocolSummary(appSummary, protocolSummary);\n\n\t\t\t\t\t\t// Set the state as attaching as we are starting the process of attaching container.\n\t\t\t\t\t\t// This should be fired after taking the summary because it is the place where we are\n\t\t\t\t\t\t// starting to attach the container to storage.\n\t\t\t\t\t\t// Also, this should only be fired in detached container.\n\t\t\t\t\t\tthis._attachState = AttachState.Attaching;\n\t\t\t\t\t\tthis.runtime.setAttachState(AttachState.Attaching);\n\t\t\t\t\t\tthis.emit(\"attaching\");\n\t\t\t\t\t\tif (this.offlineLoadEnabled) {\n\t\t\t\t\t\t\tconst snapshot = getSnapshotTreeFromSerializedContainer(summary);\n\t\t\t\t\t\t\tthis.baseSnapshot = snapshot;\n\t\t\t\t\t\t\tthis.baseSnapshotBlobs =\n\t\t\t\t\t\t\t\tgetBlobContentsFromTreeWithBlobContents(snapshot);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Actually go and create the resolved document\n\t\t\t\t\tif (this.service === undefined) {\n\t\t\t\t\t\tconst createNewResolvedUrl = await this.urlResolver.resolve(request);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tthis.client.details.type !== summarizerClientType &&\n\t\t\t\t\t\t\t\tcreateNewResolvedUrl !== undefined,\n\t\t\t\t\t\t\t0x2c4 /* \"client should not be summarizer before container is created\" */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.service = await runWithRetry(\n\t\t\t\t\t\t\tasync () =>\n\t\t\t\t\t\t\t\tthis.serviceFactory.createContainer(\n\t\t\t\t\t\t\t\t\tsummary,\n\t\t\t\t\t\t\t\t\tcreateNewResolvedUrl,\n\t\t\t\t\t\t\t\t\tthis.subLogger,\n\t\t\t\t\t\t\t\t\tfalse, // clientIsSummarizer\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\"containerAttach\",\n\t\t\t\t\t\t\tthis.mc.logger,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcancel: this._deltaManager.closeAbortController.signal,\n\t\t\t\t\t\t\t}, // progress\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthis.storageAdapter.connectToService(this.service);\n\n\t\t\t\t\tif (hasAttachmentBlobs) {\n\t\t\t\t\t\t// upload blobs to storage\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t!!this.detachedBlobStorage,\n\t\t\t\t\t\t\t0x24e /* \"assertion for type narrowing\" */,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// build a table mapping IDs assigned locally to IDs assigned by storage and pass it to runtime to\n\t\t\t\t\t\t// support blob handles that only know about the local IDs\n\t\t\t\t\t\tconst redirectTable = new Map<string, string>();\n\t\t\t\t\t\t// if new blobs are added while uploading, upload them too\n\t\t\t\t\t\twhile (redirectTable.size < this.detachedBlobStorage.size) {\n\t\t\t\t\t\t\tconst newIds = this.detachedBlobStorage\n\t\t\t\t\t\t\t\t.getBlobIds()\n\t\t\t\t\t\t\t\t.filter((id) => !redirectTable.has(id));\n\t\t\t\t\t\t\tfor (const id of newIds) {\n\t\t\t\t\t\t\t\tconst blob = await this.detachedBlobStorage.readBlob(id);\n\t\t\t\t\t\t\t\tconst response = await this.storageAdapter.createBlob(blob);\n\t\t\t\t\t\t\t\tredirectTable.set(id, response.id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// take summary and upload\n\t\t\t\t\t\tconst appSummary: ISummaryTree = this.runtime.createSummary(redirectTable);\n\t\t\t\t\t\tconst protocolSummary = this.captureProtocolSummary();\n\t\t\t\t\t\tsummary = combineAppAndProtocolSummary(appSummary, protocolSummary);\n\n\t\t\t\t\t\tthis._attachState = AttachState.Attaching;\n\t\t\t\t\t\tthis.runtime.setAttachState(AttachState.Attaching);\n\t\t\t\t\t\tthis.emit(\"attaching\");\n\t\t\t\t\t\tif (this.offlineLoadEnabled) {\n\t\t\t\t\t\t\tconst snapshot = getSnapshotTreeFromSerializedContainer(summary);\n\t\t\t\t\t\t\tthis.baseSnapshot = snapshot;\n\t\t\t\t\t\t\tthis.baseSnapshotBlobs =\n\t\t\t\t\t\t\t\tgetBlobContentsFromTreeWithBlobContents(snapshot);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait this.storageAdapter.uploadSummaryWithContext(summary, {\n\t\t\t\t\t\t\treferenceSequenceNumber: 0,\n\t\t\t\t\t\t\tackHandle: undefined,\n\t\t\t\t\t\t\tproposalHandle: undefined,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._attachState = AttachState.Attached;\n\t\t\t\t\tthis.runtime.setAttachState(AttachState.Attached);\n\t\t\t\t\tthis.emit(\"attached\");\n\n\t\t\t\t\tif (!this.closed) {\n\t\t\t\t\t\tthis.handleDeltaConnectionArg(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfetchOpsFromStorage: false,\n\t\t\t\t\t\t\t\treason: { text: \"createDetached\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattachProps?.deltaConnection,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// add resolved URL on error object so that host has the ability to find this document and delete it\n\t\t\t\t\tconst newError = normalizeError(error);\n\t\t\t\t\tnewError.addTelemetryProperties({ resolvedUrl: this.resolvedUrl?.url });\n\t\t\t\t\tthis.close(newError);\n\t\t\t\t\tthrow newError;\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t}\n\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic async request(path: IRequest): Promise<IResponse> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"Request\" },\n\t\t\tasync () => this.runtime.request(path),\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate setAutoReconnectInternal(mode: ReconnectMode, reason: IConnectionStateChangeReason) {\n\t\tconst currentMode = this._deltaManager.connectionManager.reconnectMode;\n\n\t\tif (currentMode === mode) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst now = performance.now();\n\t\tconst duration = now - this.setAutoReconnectTime;\n\t\tthis.setAutoReconnectTime = now;\n\n\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\teventName:\n\t\t\t\tmode === ReconnectMode.Enabled ? \"AutoReconnectEnabled\" : \"AutoReconnectDisabled\",\n\t\t\tconnectionMode: this.connectionMode,\n\t\t\tconnectionState: ConnectionState[this.connectionState],\n\t\t\tduration,\n\t\t});\n\n\t\tthis._deltaManager.connectionManager.setAutoReconnect(mode, reason);\n\t}\n\n\tpublic connect() {\n\t\tif (this.closed) {\n\t\t\tthrow new UsageError(`The Container is closed and cannot be connected`);\n\t\t} else if (this._attachState !== AttachState.Attached) {\n\t\t\tthrow new UsageError(`The Container is not attached and cannot be connected`);\n\t\t} else if (!this.connected) {\n\t\t\t// Note: no need to fetch ops as we do it preemptively as part of DeltaManager.attachOpHandler().\n\t\t\t// If there is gap, we will learn about it once connected, but the gap should be small (if any),\n\t\t\t// assuming that connect() is called quickly after initial container boot.\n\t\t\tthis.connectInternal({\n\t\t\t\treason: { text: \"DocumentConnect\" },\n\t\t\t\tfetchOpsFromStorage: false,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate connectInternal(args: IConnectionArgs) {\n\t\tassert(!this.closed, 0x2c5 /* \"Attempting to connect() a closed Container\" */);\n\t\tassert(\n\t\t\tthis._attachState === AttachState.Attached,\n\t\t\t0x2c6 /* \"Attempting to connect() a container that is not attached\" */,\n\t\t);\n\n\t\t// Resume processing ops and connect to delta stream\n\t\tthis.resumeInternal(args);\n\n\t\t// Set Auto Reconnect Mode\n\t\tconst mode = ReconnectMode.Enabled;\n\t\tthis.setAutoReconnectInternal(mode, args.reason);\n\t}\n\n\tpublic disconnect() {\n\t\tif (this.closed) {\n\t\t\tthrow new UsageError(`The Container is closed and cannot be disconnected`);\n\t\t} else {\n\t\t\tthis.disconnectInternal({ text: \"DocumentDisconnect\" });\n\t\t}\n\t}\n\n\tprivate disconnectInternal(reason: IConnectionStateChangeReason) {\n\t\tassert(!this.closed, 0x2c7 /* \"Attempting to disconnect() a closed Container\" */);\n\n\t\t// Set Auto Reconnect Mode\n\t\tconst mode = ReconnectMode.Disabled;\n\t\tthis.setAutoReconnectInternal(mode, reason);\n\t}\n\n\tprivate resumeInternal(args: IConnectionArgs) {\n\t\tassert(!this.closed, 0x0d9 /* \"Attempting to connect() a closed DeltaManager\" */);\n\n\t\t// Resume processing ops\n\t\tif (this.inboundQueuePausedFromInit) {\n\t\t\tthis.inboundQueuePausedFromInit = false;\n\t\t\tthis._deltaManager.inbound.resume();\n\t\t\tthis._deltaManager.inboundSignal.resume();\n\t\t}\n\n\t\t// Ensure connection to web socket\n\t\tthis.connectToDeltaStream(args);\n\t}\n\n\tpublic readonly getAbsoluteUrl = async (relativeUrl: string): Promise<string | undefined> => {\n\t\tif (this.resolvedUrl === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn this.urlResolver.getAbsoluteUrl(\n\t\t\tthis.resolvedUrl,\n\t\t\trelativeUrl,\n\t\t\tgetPackageName(this._loadedCodeDetails),\n\t\t);\n\t};\n\n\tpublic async proposeCodeDetails(codeDetails: IFluidCodeDetails) {\n\t\tif (!isFluidCodeDetails(codeDetails)) {\n\t\t\tthrow new Error(\"Provided codeDetails are not IFluidCodeDetails\");\n\t\t}\n\n\t\tif (this.codeLoader.IFluidCodeDetailsComparer) {\n\t\t\tconst comparison = await this.codeLoader.IFluidCodeDetailsComparer.compare(\n\t\t\t\tcodeDetails,\n\t\t\t\tthis.getCodeDetailsFromQuorum(),\n\t\t\t);\n\t\t\tif (comparison !== undefined && comparison <= 0) {\n\t\t\t\tthrow new Error(\"Proposed code details should be greater than the current\");\n\t\t\t}\n\t\t}\n\n\t\treturn this.protocolHandler.quorum\n\t\t\t.propose(\"code\", codeDetails)\n\t\t\t.then(() => true)\n\t\t\t.catch(() => false);\n\t}\n\n\tprivate async processCodeProposal(): Promise<void> {\n\t\tconst codeDetails = this.getCodeDetailsFromQuorum();\n\n\t\tawait Promise.all([\n\t\t\tthis.deltaManager.inbound.pause(),\n\t\t\tthis.deltaManager.inboundSignal.pause(),\n\t\t]);\n\n\t\tif ((await this.satisfies(codeDetails)) === true) {\n\t\t\tthis.deltaManager.inbound.resume();\n\t\t\tthis.deltaManager.inboundSignal.resume();\n\t\t\treturn;\n\t\t}\n\n\t\t// pre-0.58 error message: existingContextDoesNotSatisfyIncomingProposal\n\t\tconst error = new GenericError(\"Existing context does not satisfy incoming proposal\");\n\t\tthis.close(error);\n\t}\n\n\t/**\n\t * Determines if the currently loaded module satisfies the incoming constraint code details\n\t */\n\tprivate async satisfies(constraintCodeDetails: IFluidCodeDetails) {\n\t\t// If we have no module, it can't satisfy anything.\n\t\tif (this._loadedModule === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst comparers: IFluidCodeDetailsComparer[] = [];\n\n\t\tconst maybeCompareCodeLoader = this.codeLoader;\n\t\tif (maybeCompareCodeLoader.IFluidCodeDetailsComparer !== undefined) {\n\t\t\tcomparers.push(maybeCompareCodeLoader.IFluidCodeDetailsComparer);\n\t\t}\n\n\t\tconst maybeCompareExport: Partial<IProvideFluidCodeDetailsComparer> | undefined =\n\t\t\tthis._loadedModule?.module.fluidExport;\n\t\tif (maybeCompareExport?.IFluidCodeDetailsComparer !== undefined) {\n\t\t\tcomparers.push(maybeCompareExport.IFluidCodeDetailsComparer);\n\t\t}\n\n\t\t// If there are no comparers, then it's impossible to know if the currently loaded package satisfies\n\t\t// the incoming constraint, so we return false. Assuming it does not satisfy is safer, to force a reload\n\t\t// rather than potentially running with incompatible code.\n\t\tif (comparers.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const comparer of comparers) {\n\t\t\tconst satisfies = await comparer.satisfies(\n\t\t\t\tthis._loadedModule?.details,\n\t\t\t\tconstraintCodeDetails,\n\t\t\t);\n\t\t\tif (satisfies === false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate async getVersion(version: string | null): Promise<IVersion | undefined> {\n\t\tconst versions = await this.storageAdapter.getVersions(version, 1);\n\t\treturn versions[0];\n\t}\n\n\tprivate connectToDeltaStream(args: IConnectionArgs) {\n\t\t// All agents need \"write\" access, including summarizer.\n\t\tif (!this._canReconnect || !this.client.details.capabilities.interactive) {\n\t\t\targs.mode = \"write\";\n\t\t}\n\n\t\tthis._deltaManager.connect(args);\n\t}\n\n\t/**\n\t * Load container.\n\t *\n\t * @param specifiedVersion - Version SHA to load snapshot. If not specified, will fetch the latest snapshot.\n\t */\n\tprivate async load(\n\t\tspecifiedVersion: string | undefined,\n\t\tloadMode: IContainerLoadMode,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tpendingLocalState: IPendingContainerState | undefined,\n\t\tloadToSequenceNumber: number | undefined,\n\t) {\n\t\tconst timings: Record<string, number> = { phase1: performance.now() };\n\t\tthis.service = await this.serviceFactory.createDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tthis.subLogger,\n\t\t\tthis.client.details.type === summarizerClientType,\n\t\t);\n\n\t\t// Except in cases where it has stashed ops or requested by feature gate, the container will connect in \"read\" mode\n\t\tconst mode =\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Container.ForceWriteConnection\") === true ||\n\t\t\t(pendingLocalState?.savedOps.length ?? 0) > 0\n\t\t\t\t? \"write\"\n\t\t\t\t: \"read\";\n\t\tconst connectionArgs: IConnectionArgs = {\n\t\t\treason: { text: \"DocumentOpen\" },\n\t\t\tmode,\n\t\t\tfetchOpsFromStorage: false,\n\t\t};\n\n\t\t// Start websocket connection as soon as possible. Note that there is no op handler attached yet, but the\n\t\t// DeltaManager is resilient to this and will wait to start processing ops until after it is attached.\n\t\tif (loadMode.deltaConnection === undefined && !pendingLocalState) {\n\t\t\tthis.connectToDeltaStream(connectionArgs);\n\t\t}\n\n\t\tthis.storageAdapter.connectToService(this.service);\n\n\t\tthis._attachState = AttachState.Attached;\n\n\t\ttimings.phase2 = performance.now();\n\t\t// Fetch specified snapshot.\n\t\tconst { snapshot, versionId } =\n\t\t\tpendingLocalState === undefined\n\t\t\t\t? await this.fetchSnapshotTree(specifiedVersion)\n\t\t\t\t: { snapshot: pendingLocalState.baseSnapshot, versionId: undefined };\n\n\t\tif (pendingLocalState) {\n\t\t\tthis.baseSnapshot = pendingLocalState.baseSnapshot;\n\t\t\tthis.baseSnapshotBlobs = pendingLocalState.snapshotBlobs;\n\t\t} else {\n\t\t\tassert(snapshot !== undefined, 0x237 /* \"Snapshot should exist\" */);\n\t\t\tif (this.offlineLoadEnabled) {\n\t\t\t\tthis.baseSnapshot = snapshot;\n\t\t\t\t// Save contents of snapshot now, otherwise closeAndGetPendingLocalState() must be async\n\t\t\t\tthis.baseSnapshotBlobs = await getBlobContentsFromTree(\n\t\t\t\t\tsnapshot,\n\t\t\t\t\tthis.storageAdapter,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst attributes: IDocumentAttributes = await this.getDocumentAttributes(\n\t\t\tthis.storageAdapter,\n\t\t\tsnapshot,\n\t\t);\n\n\t\t// If we saved ops, we will replay them and don't need DeltaManager to fetch them\n\t\tconst sequenceNumber =\n\t\t\tpendingLocalState?.savedOps[pendingLocalState.savedOps.length - 1]?.sequenceNumber;\n\t\tconst dmAttributes =\n\t\t\tsequenceNumber !== undefined ? { ...attributes, sequenceNumber } : attributes;\n\n\t\tlet opsBeforeReturnP: Promise<void> | undefined;\n\n\t\tif (loadMode.pauseAfterLoad === true) {\n\t\t\t// If we are trying to pause at a specific sequence number, ensure the latest snapshot is not newer than the desired sequence number.\n\t\t\tif (loadMode.opsBeforeReturn === \"sequenceNumber\") {\n\t\t\t\tassert(\n\t\t\t\t\tloadToSequenceNumber !== undefined,\n\t\t\t\t\t0x727 /* sequenceNumber should be defined */,\n\t\t\t\t);\n\t\t\t\t// Note: It is possible that we think the latest snapshot is newer than the specified sequence number\n\t\t\t\t// due to saved ops that may be replayed after the snapshot.\n\t\t\t\t// https://dev.azure.com/fluidframework/internal/_workitems/edit/5055\n\t\t\t\tif (dmAttributes.sequenceNumber > loadToSequenceNumber) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Cannot satisfy request to pause the container at the specified sequence number. Most recent snapshot is newer than the specified sequence number.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Force readonly mode - this will ensure we don't receive an error for the lack of join op\n\t\t\tthis.forceReadonly(true);\n\n\t\t\t// We need to setup a listener to stop op processing once we reach the desired sequence number (if specified).\n\t\t\tconst opHandler = () => {\n\t\t\t\tif (loadToSequenceNumber === undefined) {\n\t\t\t\t\t// If there is no specified sequence number, pause after the inbound queue is empty.\n\t\t\t\t\tif (this.deltaManager.inbound.length !== 0) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// If there is a specified sequence number, keep processing until we reach it.\n\t\t\t\t\tif (this.deltaManager.lastSequenceNumber < loadToSequenceNumber) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Pause op processing once we have processed the desired number of ops.\n\t\t\t\tvoid this.deltaManager.inbound.pause();\n\t\t\t\tvoid this.deltaManager.outbound.pause();\n\t\t\t\tthis.off(\"op\", opHandler);\n\t\t\t};\n\t\t\tif (\n\t\t\t\t(loadToSequenceNumber === undefined && this.deltaManager.inbound.length === 0) ||\n\t\t\t\tthis.deltaManager.lastSequenceNumber === loadToSequenceNumber\n\t\t\t) {\n\t\t\t\t// If we have already reached the desired sequence number, call opHandler() to pause immediately.\n\t\t\t\topHandler();\n\t\t\t} else {\n\t\t\t\t// If we have not yet reached the desired sequence number, setup a listener to pause once we reach it.\n\t\t\t\tthis.on(\"op\", opHandler);\n\t\t\t}\n\t\t}\n\n\t\t// Attach op handlers to finish initialization and be able to start processing ops\n\t\t// Kick off any ops fetching if required.\n\t\tswitch (loadMode.opsBeforeReturn) {\n\t\t\tcase undefined:\n\t\t\t\t// Start prefetch, but not set opsBeforeReturnP - boot is not blocked by it!\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tthis.attachDeltaManagerOpHandler(\n\t\t\t\t\tdmAttributes,\n\t\t\t\t\tloadMode.deltaConnection !== \"none\" ? \"all\" : \"none\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"sequenceNumber\":\n\t\t\tcase \"cached\":\n\t\t\tcase \"all\":\n\t\t\t\topsBeforeReturnP = this.attachDeltaManagerOpHandler(\n\t\t\t\t\tdmAttributes,\n\t\t\t\t\tloadMode.opsBeforeReturn,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tunreachableCase(loadMode.opsBeforeReturn);\n\t\t}\n\n\t\t// ...load in the existing quorum\n\t\t// Initialize the protocol handler\n\t\tawait this.initializeProtocolStateFromSnapshot(attributes, this.storageAdapter, snapshot);\n\n\t\ttimings.phase3 = performance.now();\n\t\tconst codeDetails = this.getCodeDetailsFromQuorum();\n\t\tawait this.instantiateRuntime(\n\t\t\tcodeDetails,\n\t\t\tsnapshot,\n\t\t\t// give runtime a dummy value so it knows we're loading from a stash blob\n\t\t\tpendingLocalState ? pendingLocalState?.pendingRuntimeState ?? {} : undefined,\n\t\t);\n\n\t\t// replay saved ops\n\t\tif (pendingLocalState) {\n\t\t\tfor (const message of pendingLocalState.savedOps) {\n\t\t\t\tthis.processRemoteMessage(message);\n\n\t\t\t\t// allow runtime to apply stashed ops at this op's sequence number\n\t\t\t\tawait this.runtime.notifyOpReplay?.(message);\n\t\t\t}\n\t\t\tpendingLocalState.savedOps = [];\n\t\t}\n\n\t\t// We might have hit some failure that did not manifest itself in exception in this flow,\n\t\t// do not start op processing in such case - static version of Container.load() will handle it correctly.\n\t\tif (!this.closed) {\n\t\t\tif (opsBeforeReturnP !== undefined) {\n\t\t\t\tthis._deltaManager.inbound.resume();\n\n\t\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.mc.logger,\n\t\t\t\t\t{ eventName: \"WaitOps\" },\n\t\t\t\t\tasync () => opsBeforeReturnP,\n\t\t\t\t);\n\t\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.mc.logger,\n\t\t\t\t\t{ eventName: \"WaitOpProcessing\" },\n\t\t\t\t\tasync () => this._deltaManager.inbound.waitTillProcessingDone(),\n\t\t\t\t);\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tthis._deltaManager.inbound.pause();\n\t\t\t}\n\n\t\t\tthis.handleDeltaConnectionArg(\n\t\t\t\tconnectionArgs,\n\t\t\t\tloadMode.deltaConnection,\n\t\t\t\tpendingLocalState !== undefined,\n\t\t\t);\n\t\t}\n\n\t\t// If we have not yet reached `loadToSequenceNumber`, we will wait for ops to arrive until we reach it\n\t\tif (\n\t\t\tloadToSequenceNumber !== undefined &&\n\t\t\tthis.deltaManager.lastSequenceNumber < loadToSequenceNumber\n\t\t) {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tconst opHandler = (message: ISequencedDocumentMessage) => {\n\t\t\t\t\tif (message.sequenceNumber >= loadToSequenceNumber) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tthis.off(\"op\", opHandler);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tthis.on(\"op\", opHandler);\n\t\t\t});\n\t\t}\n\n\t\t// Safety net: static version of Container.load() should have learned about it through \"closed\" handler.\n\t\t// But if that did not happen for some reason, fail load for sure.\n\t\t// Otherwise we can get into situations where container is closed and does not try to connect to ordering\n\t\t// service, but caller does not know that (callers do expect container to be not closed on successful path\n\t\t// and listen only on \"closed\" event)\n\t\tif (this.closed) {\n\t\t\tthrow new Error(\"Container was closed while load()\");\n\t\t}\n\n\t\t// Internal context is fully loaded at this point\n\t\tthis.setLoaded();\n\t\ttimings.end = performance.now();\n\t\tthis.subLogger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: \"LoadStagesTimings\",\n\t\t\t\tdetails: JSON.stringify(timings),\n\t\t\t},\n\t\t\tundefined,\n\t\t\tLogLevel.verbose,\n\t\t);\n\t\treturn {\n\t\t\tsequenceNumber: attributes.sequenceNumber,\n\t\t\tversion: versionId,\n\t\t\tdmLastProcessedSeqNumber: this._deltaManager.lastSequenceNumber,\n\t\t\tdmLastKnownSeqNumber: this._deltaManager.lastKnownSeqNumber,\n\t\t};\n\t}\n\n\tprivate async createDetached(codeDetails: IFluidCodeDetails) {\n\t\tconst attributes: IDocumentAttributes = {\n\t\t\tsequenceNumber: detachedContainerRefSeqNumber,\n\t\t\tminimumSequenceNumber: 0,\n\t\t};\n\n\t\tawait this.attachDeltaManagerOpHandler(attributes);\n\n\t\t// Need to just seed the source data in the code quorum. Quorum itself is empty\n\t\tconst qValues = initQuorumValuesFromCodeDetails(codeDetails);\n\t\tthis.initializeProtocolState(\n\t\t\tattributes,\n\t\t\t{\n\t\t\t\tmembers: [],\n\t\t\t\tproposals: [],\n\t\t\t\tvalues: qValues,\n\t\t\t}, // IQuorumSnapShot\n\t\t);\n\n\t\tawait this.instantiateRuntime(codeDetails, undefined);\n\n\t\tthis.setLoaded();\n\t}\n\n\tprivate async rehydrateDetachedFromSnapshot(detachedContainerSnapshot: ISummaryTree) {\n\t\tif (detachedContainerSnapshot.tree[hasBlobsSummaryTree] !== undefined) {\n\t\t\tassert(\n\t\t\t\t!!this.detachedBlobStorage && this.detachedBlobStorage.size > 0,\n\t\t\t\t0x250 /* \"serialized container with attachment blobs must be rehydrated with detached blob storage\" */,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\tdelete detachedContainerSnapshot.tree[hasBlobsSummaryTree];\n\t\t}\n\n\t\tconst snapshotTree = getSnapshotTreeFromSerializedContainer(detachedContainerSnapshot);\n\t\tthis.storageAdapter.loadSnapshotForRehydratingContainer(snapshotTree);\n\t\tconst attributes = await this.getDocumentAttributes(this.storageAdapter, snapshotTree);\n\n\t\tawait this.attachDeltaManagerOpHandler(attributes);\n\n\t\t// Initialize the protocol handler\n\t\tconst baseTree = getProtocolSnapshotTree(snapshotTree);\n\t\tconst qValues = await readAndParse<[string, ICommittedProposal][]>(\n\t\t\tthis.storageAdapter,\n\t\t\tbaseTree.blobs.quorumValues,\n\t\t);\n\t\tthis.initializeProtocolState(\n\t\t\tattributes,\n\t\t\t{\n\t\t\t\tmembers: [],\n\t\t\t\tproposals: [],\n\t\t\t\tvalues: qValues,\n\t\t\t}, // IQuorumSnapShot\n\t\t);\n\t\tconst codeDetails = this.getCodeDetailsFromQuorum();\n\n\t\tawait this.instantiateRuntime(codeDetails, snapshotTree);\n\n\t\tthis.setLoaded();\n\t}\n\n\tprivate async getDocumentAttributes(\n\t\tstorage: IDocumentStorageService,\n\t\ttree: ISnapshotTree | undefined,\n\t): Promise<IDocumentAttributes> {\n\t\tif (tree === undefined) {\n\t\t\treturn {\n\t\t\t\tminimumSequenceNumber: 0,\n\t\t\t\tsequenceNumber: 0,\n\t\t\t};\n\t\t}\n\n\t\t// Backward compatibility: old docs would have \".attributes\" instead of \"attributes\"\n\t\tconst attributesHash =\n\t\t\t\".protocol\" in tree.trees\n\t\t\t\t? tree.trees[\".protocol\"].blobs.attributes\n\t\t\t\t: tree.blobs[\".attributes\"];\n\n\t\tconst attributes = await readAndParse<IDocumentAttributes>(storage, attributesHash);\n\n\t\treturn attributes;\n\t}\n\n\tprivate async initializeProtocolStateFromSnapshot(\n\t\tattributes: IDocumentAttributes,\n\t\tstorage: IDocumentStorageService,\n\t\tsnapshot: ISnapshotTree | undefined,\n\t): Promise<void> {\n\t\tconst quorumSnapshot: IQuorumSnapshot = {\n\t\t\tmembers: [],\n\t\t\tproposals: [],\n\t\t\tvalues: [],\n\t\t};\n\n\t\tif (snapshot !== undefined) {\n\t\t\tconst baseTree = getProtocolSnapshotTree(snapshot);\n\t\t\t[quorumSnapshot.members, quorumSnapshot.proposals, quorumSnapshot.values] =\n\t\t\t\tawait Promise.all([\n\t\t\t\t\treadAndParse<[string, ISequencedClient][]>(\n\t\t\t\t\t\tstorage,\n\t\t\t\t\t\tbaseTree.blobs.quorumMembers,\n\t\t\t\t\t),\n\t\t\t\t\treadAndParse<[number, ISequencedProposal, string[]][]>(\n\t\t\t\t\t\tstorage,\n\t\t\t\t\t\tbaseTree.blobs.quorumProposals,\n\t\t\t\t\t),\n\t\t\t\t\treadAndParse<[string, ICommittedProposal][]>(\n\t\t\t\t\t\tstorage,\n\t\t\t\t\t\tbaseTree.blobs.quorumValues,\n\t\t\t\t\t),\n\t\t\t\t]);\n\t\t}\n\n\t\tthis.initializeProtocolState(attributes, quorumSnapshot);\n\t}\n\n\tprivate initializeProtocolState(\n\t\tattributes: IDocumentAttributes,\n\t\tquorumSnapshot: IQuorumSnapshot,\n\t): void {\n\t\tconst protocol = this.protocolHandlerBuilder(attributes, quorumSnapshot, (key, value) =>\n\t\t\tthis.submitMessage(MessageType.Propose, JSON.stringify({ key, value })),\n\t\t);\n\n\t\tconst protocolLogger = createChildLogger({\n\t\t\tlogger: this.subLogger,\n\t\t\tnamespace: \"ProtocolHandler\",\n\t\t});\n\n\t\tprotocol.quorum.on(\"error\", (error) => {\n\t\t\tprotocolLogger.sendErrorEvent(error);\n\t\t});\n\n\t\t// Track membership changes and update connection state accordingly\n\t\tthis.connectionStateHandler.initProtocol(protocol);\n\n\t\tprotocol.quorum.on(\"addProposal\", (proposal: ISequencedProposal) => {\n\t\t\tif (proposal.key === \"code\" || proposal.key === \"code2\") {\n\t\t\t\tthis.emit(\"codeDetailsProposed\", proposal.value, proposal);\n\t\t\t}\n\t\t});\n\n\t\tprotocol.quorum.on(\"approveProposal\", (sequenceNumber, key, value) => {\n\t\t\tif (key === \"code\" || key === \"code2\") {\n\t\t\t\tif (!isFluidCodeDetails(value)) {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"CodeProposalNotIFluidCodeDetails\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.processCodeProposal().catch((error) => {\n\t\t\t\t\tconst normalizedError = normalizeError(error);\n\t\t\t\t\tthis.close(normalizedError);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\t// we need to make sure this member get set in a synchronous context,\n\t\t// or other things can happen after the object that will be set is created, but not yet set\n\t\t// this was breaking this._initialClients handling\n\t\t//\n\t\tthis._protocolHandler = protocol;\n\t}\n\n\tprivate captureProtocolSummary(): ISummaryTree {\n\t\tconst quorumSnapshot = this.protocolHandler.snapshot();\n\t\tconst summary: ISummaryTree = {\n\t\t\ttree: {\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: JSON.stringify(this.protocolHandler.attributes),\n\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t},\n\t\t\t\tquorumMembers: {\n\t\t\t\t\tcontent: JSON.stringify(quorumSnapshot.members),\n\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t},\n\t\t\t\tquorumProposals: {\n\t\t\t\t\tcontent: JSON.stringify(quorumSnapshot.proposals),\n\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t},\n\t\t\t\tquorumValues: {\n\t\t\t\t\tcontent: JSON.stringify(quorumSnapshot.values),\n\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t},\n\t\t\t},\n\t\t\ttype: SummaryType.Tree,\n\t\t};\n\n\t\treturn summary;\n\t}\n\n\tprivate getCodeDetailsFromQuorum(): IFluidCodeDetails {\n\t\tconst quorum = this.protocolHandler.quorum;\n\n\t\tconst pkg = getCodeProposal(quorum);\n\n\t\treturn pkg as IFluidCodeDetails;\n\t}\n\n\tprivate get client(): IClient {\n\t\tconst client: IClient =\n\t\t\tthis.options?.client !== undefined\n\t\t\t\t? (this.options.client as IClient)\n\t\t\t\t: {\n\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\tcapabilities: { interactive: true },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmode: \"read\", // default reconnection mode on lost connection / connection error\n\t\t\t\t\t\tpermission: [],\n\t\t\t\t\t\tscopes: [],\n\t\t\t\t\t\tuser: { id: \"\" },\n\t\t\t\t };\n\n\t\tif (this.clientDetailsOverride !== undefined) {\n\t\t\tmerge(client.details, this.clientDetailsOverride);\n\t\t}\n\t\tclient.details.environment = [\n\t\t\tclient.details.environment,\n\t\t\t` loaderVersion:${pkgVersion}`,\n\t\t\t` containerId:${this._containerId}`,\n\t\t].join(\";\");\n\t\treturn client;\n\t}\n\n\t/**\n\t * Returns true if connection is active, i.e. it's \"write\" connection and\n\t * container runtime was notified about this connection (i.e. we are up-to-date and could send ops).\n\t * This happens after client received its own joinOp and thus is in the quorum.\n\t * If it's not true, runtime is not in position to send ops.\n\t */\n\tprivate activeConnection() {\n\t\treturn (\n\t\t\tthis.connectionState === ConnectionState.Connected && this.connectionMode === \"write\"\n\t\t);\n\t}\n\n\tprivate createDeltaManager() {\n\t\tconst serviceProvider = () => this.service;\n\t\tconst deltaManager = new DeltaManager<ConnectionManager>(\n\t\t\tserviceProvider,\n\t\t\tcreateChildLogger({ logger: this.subLogger, namespace: \"DeltaManager\" }),\n\t\t\t() => this.activeConnection(),\n\t\t\t(props: IConnectionManagerFactoryArgs) =>\n\t\t\t\tnew ConnectionManager(\n\t\t\t\t\tserviceProvider,\n\t\t\t\t\t() => this.isDirty,\n\t\t\t\t\tthis.client,\n\t\t\t\t\tthis._canReconnect,\n\t\t\t\t\tcreateChildLogger({ logger: this.subLogger, namespace: \"ConnectionManager\" }),\n\t\t\t\t\tprops,\n\t\t\t\t),\n\t\t);\n\n\t\t// Disable inbound queues as Container is not ready to accept any ops until we are fully loaded!\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tdeltaManager.inbound.pause();\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tdeltaManager.inboundSignal.pause();\n\n\t\tdeltaManager.on(\"connect\", (details: IConnectionDetailsInternal, _opsBehind?: number) => {\n\t\t\tassert(this.connectionMode === details.mode, 0x4b7 /* mismatch */);\n\t\t\tthis.connectionStateHandler.receivedConnectEvent(details);\n\t\t});\n\n\t\tdeltaManager.on(\"establishingConnection\", (reason: IConnectionStateChangeReason) => {\n\t\t\tthis.connectionStateHandler.establishingConnection(reason);\n\t\t});\n\n\t\tdeltaManager.on(\"cancelEstablishingConnection\", (reason: IConnectionStateChangeReason) => {\n\t\t\tthis.connectionStateHandler.cancelEstablishingConnection(reason);\n\t\t});\n\n\t\tdeltaManager.on(\"disconnect\", (reason: IConnectionStateChangeReason) => {\n\t\t\tthis.noopHeuristic?.notifyDisconnect();\n\t\t\tif (!this.closed) {\n\t\t\t\tthis.connectionStateHandler.receivedDisconnectEvent(reason);\n\t\t\t}\n\t\t});\n\n\t\tdeltaManager.on(\"throttled\", (warning: IThrottlingWarning) => {\n\t\t\tconst warn = warning as ContainerWarning;\n\t\t\t// Some \"warning\" events come from outside the container and are logged\n\t\t\t// elsewhere (e.g. summarizing container). We shouldn't log these here.\n\t\t\tif (warn.logged !== true) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"ContainerWarning\" }, warn);\n\t\t\t}\n\t\t\tthis.emit(\"warning\", warn);\n\t\t});\n\n\t\tdeltaManager.on(\"readonly\", (readonly) => {\n\t\t\tthis.setContextConnectedState(\n\t\t\t\tthis.connectionState === ConnectionState.Connected,\n\t\t\t\treadonly,\n\t\t\t);\n\t\t\tthis.emit(\"readonly\", readonly);\n\t\t});\n\n\t\tdeltaManager.on(\"closed\", (error?: ICriticalContainerError) => {\n\t\t\tthis.closeCore(error);\n\t\t});\n\n\t\tdeltaManager.on(\"disposed\", (error?: ICriticalContainerError) => {\n\t\t\tthis.disposeCore(error);\n\t\t});\n\n\t\treturn deltaManager;\n\t}\n\n\tprivate async attachDeltaManagerOpHandler(\n\t\tattributes: IDocumentAttributes,\n\t\tprefetchType?: \"sequenceNumber\" | \"cached\" | \"all\" | \"none\",\n\t) {\n\t\treturn this._deltaManager.attachOpHandler(\n\t\t\tattributes.minimumSequenceNumber,\n\t\t\tattributes.sequenceNumber,\n\t\t\t{\n\t\t\t\tprocess: (message) => this.processRemoteMessage(message),\n\t\t\t\tprocessSignal: (message) => {\n\t\t\t\t\tthis.processSignal(message);\n\t\t\t\t},\n\t\t\t},\n\t\t\tprefetchType,\n\t\t);\n\t}\n\n\tprivate logConnectionStateChangeTelemetry(\n\t\tvalue: ConnectionState,\n\t\toldState: ConnectionState,\n\t\treason?: IConnectionStateChangeReason,\n\t) {\n\t\t// Log actual event\n\t\tconst time = performance.now();\n\t\tthis.connectionTransitionTimes[value] = time;\n\t\tconst duration = time - this.connectionTransitionTimes[oldState];\n\n\t\tlet durationFromDisconnected: number | undefined;\n\t\tlet connectionInitiationReason: string | undefined;\n\t\tlet autoReconnect: ReconnectMode | undefined;\n\t\tlet checkpointSequenceNumber: number | undefined;\n\t\tlet opsBehind: number | undefined;\n\t\tif (value === ConnectionState.Disconnected) {\n\t\t\tautoReconnect = this._deltaManager.connectionManager.reconnectMode;\n\t\t} else {\n\t\t\tif (value === ConnectionState.Connected) {\n\t\t\t\tdurationFromDisconnected =\n\t\t\t\t\ttime - this.connectionTransitionTimes[ConnectionState.Disconnected];\n\t\t\t\tdurationFromDisconnected = formatTick(durationFromDisconnected);\n\t\t\t} else if (value === ConnectionState.CatchingUp) {\n\t\t\t\t// This info is of most interesting while Catching Up.\n\t\t\t\tcheckpointSequenceNumber = this.deltaManager.lastKnownSeqNumber;\n\t\t\t\t// Need to check that we have already loaded and fetched the snapshot.\n\t\t\t\tif (\n\t\t\t\t\tthis.deltaManager.hasCheckpointSequenceNumber &&\n\t\t\t\t\tthis._lifecycleState === \"loaded\"\n\t\t\t\t) {\n\t\t\t\t\topsBehind = checkpointSequenceNumber - this.deltaManager.lastSequenceNumber;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconnectionInitiationReason = this.firstConnection ? \"InitialConnect\" : \"AutoReconnect\";\n\t\t}\n\n\t\tthis.mc.logger.sendPerformanceEvent(\n\t\t\t{\n\t\t\t\teventName: `ConnectionStateChange_${ConnectionState[value]}`,\n\t\t\t\tfrom: ConnectionState[oldState],\n\t\t\t\tduration,\n\t\t\t\tdurationFromDisconnected,\n\t\t\t\treason: reason?.text,\n\t\t\t\tconnectionInitiationReason,\n\t\t\t\tpendingClientId: this.connectionStateHandler.pendingClientId,\n\t\t\t\tclientId: this.clientId,\n\t\t\t\tautoReconnect,\n\t\t\t\topsBehind,\n\t\t\t\tonline: OnlineStatus[isOnline()],\n\t\t\t\tlastVisible:\n\t\t\t\t\tthis.lastVisible !== undefined\n\t\t\t\t\t\t? performance.now() - this.lastVisible\n\t\t\t\t\t\t: undefined,\n\t\t\t\tcheckpointSequenceNumber,\n\t\t\t\tquorumSize: this._protocolHandler?.quorum.getMembers().size,\n\t\t\t\tisDirty: this.isDirty,\n\t\t\t\t...this._deltaManager.connectionProps,\n\t\t\t},\n\t\t\treason?.error,\n\t\t);\n\n\t\tif (value === ConnectionState.Connected) {\n\t\t\tthis.firstConnection = false;\n\t\t}\n\t}\n\n\tprivate propagateConnectionState(\n\t\tinitialTransition: boolean,\n\t\tdisconnectedReason?: IConnectionStateChangeReason,\n\t) {\n\t\t// When container loaded, we want to propagate initial connection state.\n\t\t// After that, we communicate only transitions to Connected & Disconnected states, skipping all other states.\n\t\t// This can be changed in the future, for example we likely should add \"CatchingUp\" event on Container.\n\t\tif (\n\t\t\t!initialTransition &&\n\t\t\tthis.connectionState !== ConnectionState.Connected &&\n\t\t\tthis.connectionState !== ConnectionState.Disconnected\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst state = this.connectionState === ConnectionState.Connected;\n\n\t\t// Both protocol and context should not be undefined if we got so far.\n\n\t\tthis.setContextConnectedState(state, this.readOnlyInfo.readonly ?? false);\n\t\tthis.protocolHandler.setConnectionState(state, this.clientId);\n\t\traiseConnectedEvent(this.mc.logger, this, state, this.clientId, disconnectedReason?.text);\n\t}\n\n\t// back-compat: ADO #1385: Remove in the future, summary op should come through submitSummaryMessage()\n\tprivate submitContainerMessage(\n\t\ttype: MessageType,\n\t\tcontents: any,\n\t\tbatch?: boolean,\n\t\tmetadata?: any,\n\t): number {\n\t\tswitch (type) {\n\t\t\tcase MessageType.Operation:\n\t\t\t\treturn this.submitMessage(type, JSON.stringify(contents), batch, metadata);\n\t\t\tcase MessageType.Summarize:\n\t\t\t\treturn this.submitSummaryMessage(contents as unknown as ISummaryContent);\n\t\t\tdefault: {\n\t\t\t\tconst newError = new GenericError(\n\t\t\t\t\t\"invalidContainerSubmitOpType\",\n\t\t\t\t\tundefined /* error */,\n\t\t\t\t\t{ messageType: type },\n\t\t\t\t);\n\t\t\t\tthis.close(newError);\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @returns clientSequenceNumber of last message in a batch */\n\tprivate submitBatch(batch: IBatchMessage[], referenceSequenceNumber?: number): number {\n\t\tlet clientSequenceNumber = -1;\n\t\tfor (const message of batch) {\n\t\t\tclientSequenceNumber = this.submitMessage(\n\t\t\t\tMessageType.Operation,\n\t\t\t\tmessage.contents,\n\t\t\t\ttrue, // batch\n\t\t\t\tmessage.metadata,\n\t\t\t\tmessage.compression,\n\t\t\t\treferenceSequenceNumber,\n\t\t\t);\n\t\t}\n\t\tthis._deltaManager.flush();\n\t\treturn clientSequenceNumber;\n\t}\n\n\tprivate submitSummaryMessage(summary: ISummaryContent, referenceSequenceNumber?: number) {\n\t\t// github #6451: this is only needed for staging so the server\n\t\t// know when the protocol tree is included\n\t\t// this can be removed once all clients send\n\t\t// protocol tree by default\n\t\tif (summary.details === undefined) {\n\t\t\tsummary.details = {};\n\t\t}\n\t\tsummary.details.includesProtocolTree = this.storageAdapter.summarizeProtocolTree;\n\t\treturn this.submitMessage(\n\t\t\tMessageType.Summarize,\n\t\t\tJSON.stringify(summary),\n\t\t\tfalse /* batch */,\n\t\t\tundefined /* metadata */,\n\t\t\tundefined /* compression */,\n\t\t\treferenceSequenceNumber,\n\t\t);\n\t}\n\n\tprivate submitMessage(\n\t\ttype: MessageType,\n\t\tcontents?: string,\n\t\tbatch?: boolean,\n\t\tmetadata?: any,\n\t\tcompression?: string,\n\t\treferenceSequenceNumber?: number,\n\t): number {\n\t\tif (this.connectionState !== ConnectionState.Connected) {\n\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"SubmitMessageWithNoConnection\", type });\n\t\t\treturn -1;\n\t\t}\n\n\t\tthis.noopHeuristic?.notifyMessageSent();\n\t\treturn this._deltaManager.submit(\n\t\t\ttype,\n\t\t\tcontents,\n\t\t\tbatch,\n\t\t\tmetadata,\n\t\t\tcompression,\n\t\t\treferenceSequenceNumber,\n\t\t);\n\t}\n\n\tprivate processRemoteMessage(message: ISequencedDocumentMessage) {\n\t\tif (this.offlineLoadEnabled) {\n\t\t\tthis.savedOps.push(message);\n\t\t}\n\t\tconst local = this.clientId === message.clientId;\n\n\t\t// Allow the protocol handler to process the message\n\t\tconst result = this.protocolHandler.processMessage(message, local);\n\n\t\t// Forward messages to the loaded runtime for processing\n\t\tthis.runtime.process(message, local);\n\n\t\t// Inactive (not in quorum or not writers) clients don't take part in the minimum sequence number calculation.\n\t\tif (this.activeConnection()) {\n\t\t\tif (this.noopHeuristic === undefined) {\n\t\t\t\tconst serviceConfiguration = this.deltaManager.serviceConfiguration;\n\t\t\t\t// Note that config from first connection will be used for this container's lifetime.\n\t\t\t\t// That means that if relay service changes settings, such changes will impact only newly booted\n\t\t\t\t// clients.\n\t\t\t\t// All existing will continue to use settings they got earlier.\n\t\t\t\tassert(\n\t\t\t\t\tserviceConfiguration !== undefined,\n\t\t\t\t\t0x2e4 /* \"there should be service config for active connection\" */,\n\t\t\t\t);\n\t\t\t\tthis.noopHeuristic = new NoopHeuristic(\n\t\t\t\t\tserviceConfiguration.noopTimeFrequency,\n\t\t\t\t\tserviceConfiguration.noopCountFrequency,\n\t\t\t\t);\n\t\t\t\tthis.noopHeuristic.on(\"wantsNoop\", () => {\n\t\t\t\t\t// On disconnect we notify the heuristic which should prevent it from wanting a noop.\n\t\t\t\t\t// Hitting this assert would imply we lost activeConnection between notifying the heuristic of a processed message and\n\t\t\t\t\t// running the microtask that the heuristic queued in response.\n\t\t\t\t\tassert(\n\t\t\t\t\t\tthis.activeConnection(),\n\t\t\t\t\t\t0x241 /* \"Trying to send noop without active connection\" */,\n\t\t\t\t\t);\n\t\t\t\t\tthis.submitMessage(MessageType.NoOp);\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis.noopHeuristic.notifyMessageProcessed(message);\n\t\t\t// The contract with the protocolHandler is that returning \"immediateNoOp\" is equivalent to \"please immediately accept the proposal I just processed\".\n\t\t\tif (result.immediateNoOp === true) {\n\t\t\t\t// ADO:1385: Remove cast and use MessageType once definition changes propagate\n\t\t\t\tthis.submitMessage(MessageType2.Accept as unknown as MessageType);\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"op\", message);\n\t}\n\n\tprivate submitSignal(content: any, targetClientId?: string) {\n\t\tthis._deltaManager.submitSignal(JSON.stringify(content), targetClientId);\n\t}\n\n\tprivate processSignal(message: ISignalMessage) {\n\t\t// No clientId indicates a system signal message.\n\t\tif (protocolHandlerShouldProcessSignal(message)) {\n\t\t\tthis.protocolHandler.processSignal(message);\n\t\t} else {\n\t\t\tconst local = this.clientId === message.clientId;\n\t\t\tthis.runtime.processSignal(message, local);\n\t\t}\n\t}\n\n\t/**\n\t * Get the most recent snapshot, or a specific version.\n\t * @param specifiedVersion - The specific version of the snapshot to retrieve\n\t * @returns The snapshot requested, or the latest snapshot if no version was specified, plus version ID\n\t */\n\tprivate async fetchSnapshotTree(\n\t\tspecifiedVersion: string | undefined,\n\t): Promise<{ snapshot?: ISnapshotTree; versionId?: string }> {\n\t\tconst version = await this.getVersion(specifiedVersion ?? null);\n\n\t\tif (version === undefined && specifiedVersion !== undefined) {\n\t\t\t// We should have a defined version to load from if specified version requested\n\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\teventName: \"NoVersionFoundWhenSpecified\",\n\t\t\t\tid: specifiedVersion,\n\t\t\t});\n\t\t}\n\t\tthis._loadedFromVersion = version;\n\t\tconst snapshot = (await this.storageAdapter.getSnapshotTree(version)) ?? undefined;\n\n\t\tif (snapshot === undefined && version !== undefined) {\n\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"getSnapshotTreeFailed\", id: version.id });\n\t\t}\n\t\treturn { snapshot, versionId: version?.id };\n\t}\n\n\tprivate async instantiateRuntime(\n\t\tcodeDetails: IFluidCodeDetails,\n\t\tsnapshot: ISnapshotTree | undefined,\n\t\tpendingLocalState?: unknown,\n\t) {\n\t\tassert(this._runtime?.disposed !== false, 0x0dd /* \"Existing runtime not disposed\" */);\n\n\t\t// The relative loader will proxy requests to '/' to the loader itself assuming no non-cache flags\n\t\t// are set. Global requests will still go directly to the loader\n\t\tconst maybeLoader: FluidObject<IHostLoader> = this.scope;\n\t\tconst loader = new RelativeLoader(this, maybeLoader.ILoader);\n\n\t\tconst loadCodeResult = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.subLogger,\n\t\t\t{ eventName: \"CodeLoad\" },\n\t\t\tasync () => this.codeLoader.load(codeDetails),\n\t\t);\n\n\t\tthis._loadedModule = {\n\t\t\tmodule: loadCodeResult.module,\n\t\t\t// An older interface ICodeLoader could return an IFluidModule which didn't have details.\n\t\t\t// If we're using one of those older ICodeLoaders, then we fix up the module with the specified details here.\n\t\t\t// TODO: Determine if this is still a realistic scenario or if this fixup could be removed.\n\t\t\tdetails: loadCodeResult.details ?? codeDetails,\n\t\t};\n\n\t\tconst fluidExport: FluidObject<IProvideRuntimeFactory> | undefined =\n\t\t\tthis._loadedModule.module.fluidExport;\n\t\tconst runtimeFactory = fluidExport?.IRuntimeFactory;\n\t\tif (runtimeFactory === undefined) {\n\t\t\tthrow new Error(packageNotFactoryError);\n\t\t}\n\n\t\tconst getSpecifiedCodeDetails = () =>\n\t\t\t(this.protocolHandler.quorum.get(\"code\") ??\n\t\t\t\tthis.protocolHandler.quorum.get(\"code2\")) as IFluidCodeDetails | undefined;\n\n\t\tconst existing = snapshot !== undefined;\n\n\t\tconst context = new ContainerContext(\n\t\t\tthis.options,\n\t\t\tthis.scope,\n\t\t\tsnapshot,\n\t\t\tthis._loadedFromVersion,\n\t\t\tthis._deltaManager,\n\t\t\tthis.storageAdapter,\n\t\t\tthis.protocolHandler.quorum,\n\t\t\tthis.protocolHandler.audience,\n\t\t\tloader,\n\t\t\t(type, contents, batch, metadata) =>\n\t\t\t\tthis.submitContainerMessage(type, contents, batch, metadata),\n\t\t\t(summaryOp: ISummaryContent, referenceSequenceNumber?: number) =>\n\t\t\t\tthis.submitSummaryMessage(summaryOp, referenceSequenceNumber),\n\t\t\t(batch: IBatchMessage[], referenceSequenceNumber?: number) =>\n\t\t\t\tthis.submitBatch(batch, referenceSequenceNumber),\n\t\t\t(content, targetClientId) => this.submitSignal(content, targetClientId),\n\t\t\t(error?: ICriticalContainerError) => this.dispose(error),\n\t\t\t(error?: ICriticalContainerError) => this.close(error),\n\t\t\tthis.updateDirtyContainerState,\n\t\t\tthis.getAbsoluteUrl,\n\t\t\t() => this.resolvedUrl?.id,\n\t\t\t() => this.clientId,\n\t\t\t() => this.attachState,\n\t\t\t() => this.connected,\n\t\t\tgetSpecifiedCodeDetails,\n\t\t\tthis._deltaManager.clientDetails,\n\t\t\texisting,\n\t\t\tthis.subLogger,\n\t\t\tpendingLocalState,\n\t\t);\n\n\t\tthis._runtime = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.subLogger,\n\t\t\t{ eventName: \"InstantiateRuntime\" },\n\t\t\tasync () => runtimeFactory.instantiateRuntime(context, existing),\n\t\t);\n\t\tthis._lifecycleEvents.emit(\"runtimeInstantiated\");\n\n\t\tthis._loadedCodeDetails = codeDetails;\n\t}\n\n\tprivate readonly updateDirtyContainerState = (dirty: boolean) => {\n\t\tif (this._dirtyContainer === dirty) {\n\t\t\treturn;\n\t\t}\n\t\tthis._dirtyContainer = dirty;\n\t\tthis.emit(dirty ? dirtyContainerEvent : savedContainerEvent);\n\t};\n\n\t/**\n\t * Set the connected state of the ContainerContext\n\t * This controls the \"connected\" state of the ContainerRuntime as well\n\t * @param state - Is the container currently connected?\n\t * @param readonly - Is the container in readonly mode?\n\t */\n\tprivate setContextConnectedState(state: boolean, readonly: boolean): void {\n\t\tif (this._runtime?.disposed === false) {\n\t\t\t/**\n\t\t\t * We want to lie to the ContainerRuntime when we are in readonly mode to prevent issues with pending\n\t\t\t * ops getting through to the DeltaManager.\n\t\t\t * The ContainerRuntime's \"connected\" state simply means it is ok to send ops\n\t\t\t * See https://dev.azure.com/fluidframework/internal/_workitems/edit/1246\n\t\t\t */\n\t\t\tthis.runtime.setConnectionState(state && !readonly, this.clientId);\n\t\t}\n\t}\n\n\tprivate handleDeltaConnectionArg(\n\t\tconnectionArgs: IConnectionArgs,\n\t\tdeltaConnectionArg?: \"none\" | \"delayed\",\n\t\tcanConnect: boolean = true,\n\t) {\n\t\tswitch (deltaConnectionArg) {\n\t\t\tcase undefined:\n\t\t\t\tif (canConnect) {\n\t\t\t\t\t// connect to delta stream now since we did not before\n\t\t\t\t\tthis.connectToDeltaStream(connectionArgs);\n\t\t\t\t}\n\t\t\t// intentional fallthrough\n\t\t\tcase \"delayed\":\n\t\t\t\tassert(\n\t\t\t\t\tthis.inboundQueuePausedFromInit,\n\t\t\t\t\t0x346 /* inboundQueuePausedFromInit should be true */,\n\t\t\t\t);\n\t\t\t\tthis.inboundQueuePausedFromInit = false;\n\t\t\t\tthis._deltaManager.inbound.resume();\n\t\t\t\tthis._deltaManager.inboundSignal.resume();\n\t\t\t\tbreak;\n\t\t\tcase \"none\":\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tunreachableCase(deltaConnectionArg);\n\t\t}\n\t}\n}\n\n/**\n * IContainer interface that includes experimental features still under development.\n * @alpha\n */\nexport interface IContainerExperimental extends IContainer {\n\t/**\n\t * Get pending state from container. WARNING: misuse of this API can result in duplicate op\n\t * submission and potential document corruption. The blob returned MUST be deleted if and when this\n\t * container emits a \"connected\" event.\n\t * @returns serialized blob that can be passed to Loader.resolve()\n\t * @alpha misuse of this API can result in duplicate op submission and potential document corruption\n\t * {@link https://github.com/microsoft/FluidFramework/blob/main/packages/loader/container-loader/closeAndGetPendingLocalState.md}\n\t */\n\tgetPendingLocalState?(): Promise<string>;\n\n\t/**\n\t * Closes the container and returns serialized local state intended to be\n\t * given to a newly loaded container.\n\t * @alpha\n\t * {@link https://github.com/microsoft/FluidFramework/blob/main/packages/loader/container-loader/closeAndGetPendingLocalState.md}\n\t */\n\tcloseAndGetPendingLocalState?(stopBlobAttachingSignal?: AbortSignal): Promise<string>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2BH;;GAEG;AACH,MAAa,gBAAgB;IAU5B,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,YAAY,EAA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BAAa,GAAb,aAAa,CAAe;QAC7B,4BAAuB,GAAvB,uBAAuB,CAAqC;QAC5D,kBAAa,GAAb,aAAa,CAAgB;QAC7B,aAAQ,GAAR,QAAQ,CAAS;QACjB,iBAAY,GAAZ,YAAY,CAAqB;QACjC,sBAAiB,GAAjB,iBAAiB,CAAU;QAlE5B,sBAAiB,GAAiC,IAAI,GAAG,CAAC;YACzE;;;;eAIG;YACH,CAAC,0BAA0B,EAAE,IAAI,CAAC;SAClC,CAAC,CAAC;IA4DA,CAAC;IAEG,oBAAoB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAC/B,CAAC;CACD;AA7ED,4CA6EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIAudience,\n\tIContainerContext,\n\tIDeltaManager,\n\tILoader,\n\tICriticalContainerError,\n\tAttachState,\n\tILoaderOptions,\n\tIFluidCodeDetails,\n\tIBatchMessage,\n} from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n\tIClientDetails,\n\tIDocumentMessage,\n\tIQuorumClients,\n\tISequencedDocumentMessage,\n\tISnapshotTree,\n\tIVersion,\n\tMessageType,\n\tISummaryContent,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * {@inheritDoc @fluidframework/container-definitions#IContainerContext}\n */\nexport class ContainerContext implements IContainerContext {\n\tpublic readonly supportedFeatures: ReadonlyMap<string, unknown> = new Map([\n\t\t/**\n\t\t * This version of the loader accepts `referenceSequenceNumber`, provided by the container runtime,\n\t\t * as a parameter to the `submitBatchFn` and `submitSummaryFn` functions.\n\t\t * This is then used to set the reference sequence numbers of the submitted ops in the DeltaManager.\n\t\t */\n\t\t[\"referenceSequenceNumbers\", true],\n\t]);\n\n\tpublic get clientId(): string | undefined {\n\t\treturn this._getClientId();\n\t}\n\n\t/**\n\t * DISCLAIMER: this id is only for telemetry purposes. Not suitable for any other usages.\n\t */\n\tpublic get id(): string {\n\t\treturn this._getContainerDiagnosticId() ?? \"\";\n\t}\n\n\t/**\n\t * When true, ops are free to flow\n\t * When false, ops should be kept as pending or rejected\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._getConnected();\n\t}\n\n\tconstructor(\n\t\tpublic readonly options: ILoaderOptions,\n\t\tpublic readonly scope: FluidObject,\n\t\tpublic readonly baseSnapshot: ISnapshotTree | undefined,\n\t\tprivate readonly _version: IVersion | undefined,\n\t\tpublic readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tpublic readonly storage: IDocumentStorageService,\n\t\tpublic readonly quorum: IQuorumClients,\n\t\tpublic readonly audience: IAudience,\n\t\tpublic readonly loader: ILoader,\n\t\tpublic readonly submitFn: (\n\t\t\ttype: MessageType,\n\t\t\tcontents: any,\n\t\t\tbatch: boolean,\n\t\t\tappData: any,\n\t\t) => number,\n\t\tpublic readonly submitSummaryFn: (\n\t\t\tsummaryOp: ISummaryContent,\n\t\t\treferenceSequenceNumber?: number,\n\t\t) => number,\n\t\t/** @returns clientSequenceNumber of last message in a batch */\n\t\tpublic readonly submitBatchFn: (\n\t\t\tbatch: IBatchMessage[],\n\t\t\treferenceSequenceNumber?: number,\n\t\t) => number,\n\t\tpublic readonly submitSignalFn: (content: any, targetClientId?: string) => void,\n\t\tpublic readonly disposeFn: (error?: ICriticalContainerError) => void,\n\t\tpublic readonly closeFn: (error?: ICriticalContainerError) => void,\n\t\tpublic readonly updateDirtyContainerState: (dirty: boolean) => void,\n\t\tpublic readonly getAbsoluteUrl: (relativeUrl: string) => Promise<string | undefined>,\n\t\tprivate readonly _getContainerDiagnosticId: () => string | undefined,\n\t\tprivate readonly _getClientId: () => string | undefined,\n\t\tprivate readonly _getAttachState: () => AttachState,\n\t\tprivate readonly _getConnected: () => boolean,\n\t\tpublic readonly getSpecifiedCodeDetails: () => IFluidCodeDetails | undefined,\n\t\tpublic readonly clientDetails: IClientDetails,\n\t\tpublic readonly existing: boolean,\n\t\tpublic readonly taggedLogger: ITelemetryLoggerExt,\n\t\tpublic readonly pendingLocalState?: unknown,\n\t) {}\n\n\tpublic getLoadedFromVersion(): IVersion | undefined {\n\t\treturn this._version;\n\t}\n\n\tpublic get attachState(): AttachState {\n\t\treturn this._getAttachState();\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"containerStorageAdapter.js","sourceRoot":"","sources":["../src/containerStorageAdapter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAA8E;AAC9E,2DAAoD;AASpD,+DAA0D;AAS1D,6FAAkF;AAClF,uFAAoF;AAUpF;;;GAGG;AACH,MAAa,uBAAuB;IAInC;;OAEG;IACH,IAAW,qBAAqB;QAC/B,OAAO,IAAI,CAAC,sBAAsB,KAAK,IAAI,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACH,YACC,mBAAqD,EACpC,MAA2B;IAC5C;;OAEG;IACc,eAA2D,EAAE,EAC7D,2BAAwE,EACzF,gCAAqD;QANpC,WAAM,GAAN,MAAM,CAAqB;QAI3B,iBAAY,GAAZ,YAAY,CAAiD;QAC7D,gCAA2B,GAA3B,2BAA2B,CAA6C;QAO1F,aAAQ,GAAY,KAAK,CAAC;QAJzB,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;QACxE,IAAI,CAAC,sBAAsB,GAAG,gCAAgC,CAAC;IAChE,CAAC;IAGD,OAAO,CAAC,KAAa;QACpB,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,CAAC;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KACzC;AACF,CAAC;AAED,wDAAwD;AACxD,SAAS,0CAA0C,CAClD,IAAmC,EACnC,KAAgC;IAEhC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACpC,IAAA,mBAAM,EAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC9E,oDAAoD;IACpD,KAAK,CAAC,EAAE,CAAC,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\nimport {\n\tFetchSource,\n\tIDocumentService,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDetachedBlobStorage } from \"./loader\";\nimport { ProtocolTreeStorageService } from \"./protocolTreeDocumentStorageService\";\nimport { RetriableDocumentStorageService } from \"./retriableDocumentStorageService\";\n\n/**\n * Stringified blobs from a summary/snapshot tree.\n * @internal\n */\nexport interface ISerializableBlobContents {\n\t[id: string]: string;\n}\n\n/**\n * This class wraps the actual storage and make sure no wrong apis are called according to\n * container attach state.\n */\nexport class ContainerStorageAdapter implements IDocumentStorageService, IDisposable {\n\tprivate _storageService: IDocumentStorageService & Partial<IDisposable>;\n\n\tprivate _summarizeProtocolTree: boolean | undefined;\n\t/**\n\t * Whether the adapter will enforce sending combined summary trees.\n\t */\n\tpublic get summarizeProtocolTree() {\n\t\treturn this._summarizeProtocolTree === true;\n\t}\n\n\t/**\n\t * An adapter that ensures we're using detachedBlobStorage up until we connect to a real service, and then\n\t * after connecting to a real service augments it with retry and combined summary tree enforcement.\n\t * @param detachedBlobStorage - The detached blob storage to use up until we connect to a real service\n\t * @param logger - Telemetry logger\n\t * @param addProtocolSummaryIfMissing - a callback to permit the container to inspect the summary we're about to\n\t * upload, and fix it up with a protocol tree if needed\n\t * @param forceEnableSummarizeProtocolTree - Enforce uploading a protocol summary regardless of the service's policy\n\t */\n\tpublic constructor(\n\t\tdetachedBlobStorage: IDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\t/**\n\t\t * ArrayBufferLikes or utf8 encoded strings, containing blobs from a snapshot\n\t\t */\n\t\tprivate readonly blobContents: { [id: string]: ArrayBufferLike | string } = {},\n\t\tprivate readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,\n\t\tforceEnableSummarizeProtocolTree: boolean | undefined,\n\t) {\n\t\tthis._storageService = new BlobOnlyStorage(detachedBlobStorage, logger);\n\t\tthis._summarizeProtocolTree = forceEnableSummarizeProtocolTree;\n\t}\n\n\tdisposed: boolean = false;\n\tdispose(error?: Error): void {\n\t\tthis._storageService?.dispose?.(error);\n\t\tthis.disposed = true;\n\t}\n\n\tpublic connectToService(service: IDocumentService): void {\n\t\tif (!(this._storageService instanceof BlobOnlyStorage)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst storageServiceP = service.connectToStorage();\n\t\tconst retriableStorage = (this._storageService = new RetriableDocumentStorageService(\n\t\t\tstorageServiceP,\n\t\t\tthis.logger,\n\t\t));\n\n\t\tthis._summarizeProtocolTree =\n\t\t\tthis._summarizeProtocolTree ?? service.policies?.summarizeProtocolTree;\n\t\tif (this.summarizeProtocolTree) {\n\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"summarizeProtocolTreeEnabled\" });\n\t\t\tthis._storageService = new ProtocolTreeStorageService(\n\t\t\t\tretriableStorage,\n\t\t\t\tthis.addProtocolSummaryIfMissing,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic loadSnapshotForRehydratingContainer(snapshotTree: ISnapshotTreeWithBlobContents) {\n\t\tthis.getBlobContents(snapshotTree);\n\t}\n\n\tprivate getBlobContents(snapshotTree: ISnapshotTreeWithBlobContents) {\n\t\tfor (const [id, value] of Object.entries(snapshotTree.blobsContents)) {\n\t\t\tthis.blobContents[id] = value;\n\t\t}\n\t\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\t\tthis.getBlobContents(tree);\n\t\t}\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\t// back-compat 0.40 containerRuntime requests policies even in detached container if storage is present\n\t\t// and storage is always present in >=0.41.\n\t\ttry {\n\t\t\treturn this._storageService.policies;\n\t\t} catch (e) {}\n\t\treturn undefined;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this._storageService.repositoryUrl;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this._storageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst maybeBlob = this.blobContents[id];\n\t\tif (maybeBlob !== undefined) {\n\t\t\tif (typeof maybeBlob === \"string\") {\n\t\t\t\tconst blob = stringToBuffer(maybeBlob, \"utf8\");\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t\treturn maybeBlob;\n\t\t}\n\t\treturn this._storageService.readBlob(id);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this._storageService.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this._storageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this._storageService.downloadSummary(handle);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this._storageService.createBlob(file);\n\t}\n}\n\n/**\n * Storage which only supports createBlob() and readBlob(). This is used with IDetachedBlobStorage to support\n * blobs in detached containers.\n */\nclass BlobOnlyStorage implements IDocumentStorageService {\n\tconstructor(\n\t\tprivate readonly detachedStorage: IDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tpublic async createBlob(content: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.verifyStorage().createBlob(content);\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.verifyStorage().readBlob(blobId);\n\t}\n\n\tprivate verifyStorage(): IDetachedBlobStorage {\n\t\tif (this.detachedStorage === undefined) {\n\t\t\tthrow new UsageError(\"Real storage calls not allowed in Unattached container\");\n\t\t}\n\t\treturn this.detachedStorage;\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.notCalled();\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.notCalled();\n\t}\n\n\t/* eslint-disable @typescript-eslint/unbound-method */\n\tpublic getSnapshotTree: () => Promise<ISnapshotTree | null> = this.notCalled;\n\tpublic getVersions: () => Promise<IVersion[]> = this.notCalled;\n\tpublic write: () => Promise<IVersion> = this.notCalled;\n\tpublic uploadSummaryWithContext: () => Promise<string> = this.notCalled;\n\tpublic downloadSummary: () => Promise<ISummaryTree> = this.notCalled;\n\t/* eslint-enable @typescript-eslint/unbound-method */\n\n\tprivate notCalled(): never {\n\t\tthis.verifyStorage();\n\t\ttry {\n\t\t\t// some browsers may not populate stack unless exception is thrown\n\t\t\tthrow new Error(\"BlobOnlyStorage not implemented method used\");\n\t\t} catch (err) {\n\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"BlobOnlyStorageWrongCall\" }, err);\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\n// runtime will write a tree to the summary containing \"attachment\" type entries\n// which reference attachment blobs by ID, along with a blob containing the blob redirect table.\n// However, some drivers do not support the \"attachment\" type and will convert them to \"blob\" type\n// entries. We want to avoid saving these to reduce the size of stashed change blobs, but we\n// need to make sure the blob redirect table is saved.\nconst blobsTreeName = \".blobs\";\nconst redirectTableBlobName = \".redirectTable\";\n\n/**\n * Get blob contents of a snapshot tree from storage (or, ideally, cache)\n */\nexport async function getBlobContentsFromTree(\n\tsnapshot: ISnapshotTree,\n\tstorage: IDocumentStorageService,\n): Promise<ISerializableBlobContents> {\n\tconst blobs = {};\n\tawait getBlobContentsFromTreeCore(snapshot, blobs, storage);\n\treturn blobs;\n}\n\nasync function getBlobContentsFromTreeCore(\n\ttree: ISnapshotTree,\n\tblobs: ISerializableBlobContents,\n\tstorage: IDocumentStorageService,\n\troot = true,\n) {\n\tconst treePs: Promise<any>[] = [];\n\tfor (const [key, subTree] of Object.entries(tree.trees)) {\n\t\tif (root && key === blobsTreeName) {\n\t\t\ttreePs.push(getBlobManagerTreeFromTree(subTree, blobs, storage));\n\t\t} else {\n\t\t\ttreePs.push(getBlobContentsFromTreeCore(subTree, blobs, storage, false));\n\t\t}\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = await storage.readBlob(id);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n\treturn Promise.all(treePs);\n}\n\n// save redirect table from .blobs tree but nothing else\nasync function getBlobManagerTreeFromTree(\n\ttree: ISnapshotTree,\n\tblobs: ISerializableBlobContents,\n\tstorage: IDocumentStorageService,\n) {\n\tconst id = tree.blobs[redirectTableBlobName];\n\tconst blob = await storage.readBlob(id);\n\t// ArrayBufferLike will not survive JSON.stringify()\n\tblobs[id] = bufferToString(blob, \"utf8\");\n}\n\n/**\n * Extract blob contents from a snapshot tree with blob contents\n */\nexport function getBlobContentsFromTreeWithBlobContents(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISerializableBlobContents {\n\tconst blobs = {};\n\tgetBlobContentsFromTreeWithBlobContentsCore(snapshot, blobs);\n\treturn blobs;\n}\n\nfunction getBlobContentsFromTreeWithBlobContentsCore(\n\ttree: ISnapshotTreeWithBlobContents,\n\tblobs: ISerializableBlobContents,\n\troot = true,\n) {\n\tfor (const [key, subTree] of Object.entries(tree.trees)) {\n\t\tif (root && key === blobsTreeName) {\n\t\t\tgetBlobManagerTreeFromTreeWithBlobContents(subTree, blobs);\n\t\t} else {\n\t\t\tgetBlobContentsFromTreeWithBlobContentsCore(subTree, blobs, false);\n\t\t}\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = tree.blobsContents[id];\n\t\tassert(blob !== undefined, 0x2ec /* \"Blob must be present in blobsContents\" */);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n}\n\n// save redirect table from .blobs tree but nothing else\nfunction getBlobManagerTreeFromTreeWithBlobContents(\n\ttree: ISnapshotTreeWithBlobContents,\n\tblobs: ISerializableBlobContents,\n) {\n\tconst id = tree.blobs[redirectTableBlobName];\n\tconst blob = tree.blobsContents[id];\n\tassert(blob !== undefined, 0x70f /* Blob must be present in blobsContents */);\n\t// ArrayBufferLike will not survive JSON.stringify()\n\tblobs[id] = bufferToString(blob, \"utf8\");\n}\n"]}
|
package/dist/contracts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iFAO+C;AAY/C,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,gCAAe,CAAA;IACf,sCAAqB,CAAA;IACrB,oCAAmB,CAAA;AACpB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AA0KD;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAC7B,WAA0C,EAClB,EAAE;IAC1B,IAAI,oBAAoB,CAAC;IACzB,IAAI,WAAW,IAAI,MAAM,IAAI,WAAW,EAAE;QACzC,oBAAoB,GAAG,WAAW,CAAC;KACnC;SAAM,IAAI,IAAA,sCAAc,EAAC,WAAW,EAAE,OAAO,CAAC,EAAE;QAChD,oBAAoB,GAAG,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC;KACjD;SAAM;QACN,oBAAoB,GAAG,WAAW,EAAE,OAAO,CAAC;KAC5C;IACD,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;AACvC,CAAC,CAAC;AAZW,QAAA,cAAc,kBAYzB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IErrorBase, ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport {\n\tIConnectionDetails,\n\tICriticalContainerError,\n\tIDeltaQueue,\n\tIFluidCodeDetails,\n\tisFluidPackage,\n\tReadOnlyInfo,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIClientDetails,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { IContainerPackageInfo } from \"@fluidframework/driver-definitions\";\n\nexport enum ReconnectMode {\n\tNever = \"Never\",\n\tDisabled = \"Disabled\",\n\tEnabled = \"Enabled\",\n}\n\nexport interface IConnectionStateChangeReason<T extends IErrorBase = IErrorBase> {\n\ttext: string;\n\terror?: T;\n}\n\n/**\n * Internal version of IConnectionDetails with props are only exposed internally\n */\nexport interface IConnectionDetailsInternal extends IConnectionDetails {\n\tmode: ConnectionMode;\n\tversion: string;\n\tinitialClients: ISignalClient[];\n\treason: IConnectionStateChangeReason;\n}\n\n/**\n * Connection manager (implements this interface) is responsible for maintaining connection\n * to relay service.\n */\nexport interface IConnectionManager {\n\treadonly connected: boolean;\n\n\treadonly clientId: string | undefined;\n\n\t/** The queue of outbound delta messages */\n\treadonly outbound: IDeltaQueue<IDocumentMessage[]>;\n\n\t/** Details of client */\n\treadonly clientDetails: IClientDetails;\n\n\t/** Protocol version being used to communicate with the service */\n\treadonly version: string;\n\n\t/** Max message size allowed to the delta manager */\n\treadonly maxMessageSize: number;\n\n\t/** Service configuration provided by the service. */\n\treadonly serviceConfiguration: IClientConfiguration | undefined;\n\n\treadonly readOnlyInfo: ReadOnlyInfo;\n\n\t// Various connectivity properties for telemetry describing type of current connection\n\t// Things like connection mode, service info, etc.\n\t// Called when connection state changes (connect / disconnect)\n\treadonly connectionProps: ITelemetryProperties;\n\n\t// Verbose information about connection logged to telemetry in case of issues with\n\t// maintaining healthy connection, including op gaps, not receiving join op in time, etc.\n\t// Contains details information, like sequence numbers at connection time, initial ops info, etc.\n\treadonly connectionVerboseProps: ITelemetryProperties;\n\n\t/**\n\t * Prepares message to be sent. Fills in clientSequenceNumber.\n\t * Called only when active connection is present.\n\t */\n\tprepareMessageToSend(\n\t\tmessage: Omit<IDocumentMessage, \"clientSequenceNumber\">,\n\t): IDocumentMessage | undefined;\n\n\t/**\n\t * Called before incoming message is processed. Incoming messages can be combing from connection,\n\t * but also could come from storage.\n\t * This call allows connection manager to adjust knowledge about acked ops sent on previous connection.\n\t * Can be called at any time, including when there is no active connection.\n\t */\n\tbeforeProcessingIncomingOp(message: ISequencedDocumentMessage): void;\n\n\t/**\n\t * Submits signal to relay service.\n\t * Called only when active connection is present.\n\t */\n\tsubmitSignal(content: any, targetClientId?: string): void;\n\n\t/**\n\t * Submits messages to relay service.\n\t * Called only when active connection is present.\n\t */\n\tsendMessages(messages: IDocumentMessage[]): void;\n\n\t/**\n\t * Initiates connection to relay service (noop if already connected).\n\t */\n\tconnect(reason: IConnectionStateChangeReason, connectionMode?: ConnectionMode): void;\n\n\t/**\n\t * Disposed connection manager\n\t */\n\tdispose(error?: ICriticalContainerError, switchToReadonly?: boolean): void;\n\n\tget connectionMode(): ConnectionMode;\n}\n\n/**\n * This interface represents a set of callbacks provided by DeltaManager to IConnectionManager on its creation\n * IConnectionManager instance will use them to communicate to DeltaManager about various events.\n */\nexport interface IConnectionManagerFactoryArgs {\n\t/**\n\t * Called by connection manager for each incoming op. Some ops maybe delivered before\n\t * connectHandler is called (initial ops on socket connection)\n\t */\n\treadonly incomingOpHandler: (messages: ISequencedDocumentMessage[], reason: string) => void;\n\n\t/**\n\t * Called by connection manager for each incoming signal.\n\t * May be called before connectHandler is called (due to initial signals on socket connection)\n\t */\n\treadonly signalHandler: (signals: ISignalMessage[]) => void;\n\n\t/**\n\t * Called when connection manager experiences delay in connecting to relay service.\n\t * This can happen because client is offline, or service is busy and asks to not connect for some time.\n\t * Can be called many times while not connected.\n\t * Situation is considered resolved when connection is established and connectHandler is called.\n\t */\n\treadonly reconnectionDelayHandler: (delayMs: number, error: unknown) => void;\n\n\t/**\n\t * Called by connection manager whenever critical error happens and container should be closed.\n\t * Expects dispose() call in response to this call.\n\t */\n\treadonly closeHandler: (error?: any) => void;\n\n\t/**\n\t * Called whenever connection to relay service is lost.\n\t */\n\treadonly disconnectHandler: (reason: IConnectionStateChangeReason) => void;\n\n\t/**\n\t * Called whenever new connection to rely service is established\n\t */\n\treadonly connectHandler: (connection: IConnectionDetailsInternal) => void;\n\n\t/**\n\t * Called whenever ping/pong messages are roundtripped on connection.\n\t */\n\treadonly pongHandler: (latency: number) => void;\n\n\t/**\n\t * Called whenever connection type changes from writable to read-only or vice versa.\n\t *\n\t * @remarks\n\t *\n\t * Connection can be read-only if user has no edit permissions, or if container forced\n\t * connection to be read-only.\n\t * This should not be confused with \"read\" / \"write\"connection mode which is internal\n\t * optimization.\n\t *\n\t * @param readonly - Whether or not the container is now read-only.\n\t * `undefined` indicates that user permissions are not yet known.\n\t * @param readonlyConnectionReason - reason/error if any for the change\n\t */\n\treadonly readonlyChangeHandler: (\n\t\treadonly?: boolean,\n\t\treadonlyConnectionReason?: IConnectionStateChangeReason,\n\t) => void;\n\n\t/**\n\t * Called whenever we try to start establishing a new connection.\n\t */\n\treadonly establishConnectionHandler: (reason: IConnectionStateChangeReason) => void;\n\n\t/**\n\t * Called whenever we cancel the connection in progress.\n\t */\n\treadonly cancelConnectionHandler: (reason: IConnectionStateChangeReason) => void;\n}\n\n/**\n *\n * @param codeDetails- - Data structure used to describe the code to load on the Fluid document\n * @returns The name of the Fluid package\n */\nexport const getPackageName = (\n\tcodeDetails: IFluidCodeDetails | undefined,\n): IContainerPackageInfo => {\n\tlet containerPackageName;\n\tif (codeDetails && \"name\" in codeDetails) {\n\t\tcontainerPackageName = codeDetails;\n\t} else if (isFluidPackage(codeDetails?.package)) {\n\t\tcontainerPackageName = codeDetails?.package.name;\n\t} else {\n\t\tcontainerPackageName = codeDetails?.package;\n\t}\n\treturn { name: containerPackageName };\n};\n"]}
|
package/dist/debugLogger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debugLogger.js","sourceRoot":"","sources":["../src/debugLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,+DAA2D;AAC3D,iCAA0D;AAC1D,qEAMyC;AAEzC;;GAEG;AACH,MAAa,WAAW;IACvB;;;;;;;OAOG;IACI,MAAM,CAAC,gBAAgB,CAC7B,SAAiB,EACjB,UAAiC,EACjC,UAAyC;QAEzC,uEAAuE;QACvE,MAAM,KAAK,GAAG,IAAA,aAAa,EAAC,SAAS,CAAC,CAAC;QAEvC,+CAA+C;QAC/C,uFAAuF;QACvF,MAAM,QAAQ,GAAG,IAAA,aAAa,EAAC,SAAS,CAAC,CAAC;QAC1C,QA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ACD,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC;QAE/B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,QAAQ,IAAA,4BAAU,EAAC,0BAAW,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;QAE/C,8FAA8F;QAC9F,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;QACnC,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC;QAE3B,qEAAqE;QACrE,wEAAwE;QACxE,sFAAsF;QACtF,IAAI,OAAe,CAAC;QACpB,IAAI;YACH,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;SACnC;QAAC,OAAO,KAAK,EAAE;YACf,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC;YAC3B,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;SACnC;QAED,IAAI,OAAO,KAAK,IAAI,EAAE;YACrB,OAAO,GAAG,EAAE,CAAC;SACb;QAED,6CAA6C;QAC7C,IAAI,OAAO,EAAE;YACZ,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;SACtB;QAED,oBAAoB;QACpB,gEAAgE;QAChE,MAAM,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;IAC/C,CAAC;CACD;AA7FD,kCA6FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { debug as registerDebug, IDebugger } from \"debug\";\nimport {\n\tITelemetryLoggerExt,\n\tITelemetryLoggerPropertyBags,\n\tcreateMultiSinkLogger,\n\teventNamespaceSeparator,\n\tformatTick,\n} from \"@fluidframework/telemetry-utils\";\n\n/**\n * Implementation of debug logger\n */\nexport class DebugLogger implements ITelemetryBaseLogger {\n\t/**\n\t * Mix in debug logger with another logger.\n\t * Returned logger will output events to both newly created debug logger, as well as base logger\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param propertyGetters - Getters to add additional properties to all events\n\t * @param baseLogger - Base logger to output events (in addition to debug logger being created). Can be undefined.\n\t */\n\tpublic static mixinDebugLogger(\n\t\tnamespace: string,\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): ITelemetryLoggerExt {\n\t\t// Setup base logger upfront, such that host can disable it (if needed)\n\t\tconst debug = registerDebug(namespace);\n\n\t\t// Create one for errors that is always enabled\n\t\t// It can be silenced by replacing console.error if the debug namespace is not enabled.\n\t\tconst debugErr = registerDebug(namespace);\n\t\tdebugErr.log = function (...args) {\n\t\t\tif (debug.enabled === true) {\n\t\t\t\t// if the namespace is enabled, just use the default logger\n\t\t\t\tregisterDebug.log(...args);\n\t\t\t} else {\n\t\t\t\t// other wise, use the console logger (which could be replaced and silenced)\n\t\t\t\tconsole.error(...args);\n\t\t\t}\n\t\t};\n\t\tdebugErr.enabled = true;\n\n\t\treturn createMultiSinkLogger({\n\t\t\tnamespace,\n\t\t\tloggers: [baseLogger, new DebugLogger(debug, debugErr)],\n\t\t\tproperties,\n\t\t\ttryInheritProperties: true,\n\t\t});\n\t}\n\n\tprivate constructor(\n\t\tprivate readonly debug: IDebugger,\n\t\tprivate readonly debugErr: IDebugger,\n\t) {}\n\n\t/**\n\t * Send an event to debug loggers\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tconst newEvent: ITelemetryProperties = { ...event };\n\t\tconst isError = newEvent.category === \"error\";\n\t\tlet logger = isError ? this.debugErr : this.debug;\n\n\t\t// Use debug's coloring schema for base of the event\n\t\tconst index = event.eventName.lastIndexOf(eventNamespaceSeparator);\n\t\tconst name = event.eventName.substring(index + 1);\n\t\tif (index > 0) {\n\t\t\tlogger = logger.extend(event.eventName.substring(0, index));\n\t\t}\n\t\tnewEvent.eventName = undefined;\n\n\t\tlet tick = \"\";\n\t\ttick = `tick=${formatTick(performance.now())}`;\n\n\t\t// Extract stack to put it last, but also to avoid escaping '\\n' in it by JSON.stringify below\n\t\tconst stack = newEvent.stack ?? \"\";\n\t\tnewEvent.stack = undefined;\n\n\t\t// Watch out for circular references - they can come from two sources\n\t\t// 1) error object - we do not control it and should remove it and retry\n\t\t// 2) properties supplied by telemetry caller - that's a bug that should be addressed!\n\t\tlet payload: string;\n\t\ttry {\n\t\t\tpayload = JSON.stringify(newEvent);\n\t\t} catch (error) {\n\t\t\tnewEvent.error = undefined;\n\t\t\tpayload = JSON.stringify(newEvent);\n\t\t}\n\n\t\tif (payload === \"{}\") {\n\t\t\tpayload = \"\";\n\t\t}\n\n\t\t// Force errors out, to help with diagnostics\n\t\tif (isError) {\n\t\t\tlogger.enabled = true;\n\t\t}\n\n\t\t// Print multi-line.\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tlogger(`${name} ${payload} ${tick} ${stack}`);\n\t}\n}\n"]}
|