@fluidframework/container-loader 2.0.0-dev-rc.1.0.0.232845 → 2.0.0-dev-rc.2.0.0.245554
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +5 -6
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +48 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/container-loader.api.md +2 -2
- package/dist/attachment.d.ts +6 -7
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js +6 -5
- package/dist/attachment.js.map +1 -1
- package/dist/audience.d.ts +9 -4
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +10 -4
- package/dist/audience.js.map +1 -1
- package/dist/connectionManager.d.ts +3 -3
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +20 -18
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts +1 -0
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js +1 -0
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +7 -7
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +32 -32
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container-loader-alpha.d.ts +1 -0
- package/dist/container-loader-beta.d.ts +3 -0
- package/dist/container-loader-public.d.ts +3 -0
- package/dist/container-loader-untrimmed.d.ts +4 -4
- package/dist/container.d.ts +11 -22
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +101 -194
- package/dist/container.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +2 -3
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +4 -10
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +3 -3
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +5 -5
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +6 -6
- package/dist/deltaManager.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +2 -2
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +13 -17
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/index.d.ts +1 -1
- package/dist/location-redirection-utilities/index.d.ts.map +1 -1
- package/dist/location-redirection-utilities/index.js +3 -3
- package/dist/location-redirection-utilities/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +0 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +0 -3
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +0 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +0 -6
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +44 -0
- package/dist/serializedStateManager.d.ts.map +1 -0
- package/dist/serializedStateManager.js +149 -0
- package/dist/serializedStateManager.js.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils.d.ts +5 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +10 -4
- package/dist/utils.js.map +1 -1
- package/lib/{attachment.d.mts → attachment.d.ts} +11 -8
- package/lib/attachment.d.ts.map +1 -0
- package/lib/{attachment.mjs → attachment.js} +11 -6
- package/lib/attachment.js.map +1 -0
- package/lib/{audience.d.mts → audience.d.ts} +14 -5
- package/lib/audience.d.ts.map +1 -0
- package/lib/{audience.mjs → audience.js} +14 -4
- package/lib/audience.js.map +1 -0
- package/lib/{catchUpMonitor.d.mts → catchUpMonitor.d.ts} +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -0
- package/lib/{catchUpMonitor.mjs → catchUpMonitor.js} +1 -1
- package/lib/catchUpMonitor.js.map +1 -0
- package/lib/{connectionManager.d.mts → connectionManager.d.ts} +4 -4
- package/lib/connectionManager.d.ts.map +1 -0
- package/lib/{connectionManager.mjs → connectionManager.js} +9 -7
- package/lib/connectionManager.js.map +1 -0
- package/lib/{connectionState.d.mts → connectionState.d.ts} +2 -1
- package/lib/connectionState.d.ts.map +1 -0
- package/lib/{connectionState.mjs → connectionState.js} +2 -1
- package/lib/connectionState.js.map +1 -0
- package/lib/{connectionStateHandler.d.mts → connectionStateHandler.d.ts} +8 -8
- package/lib/connectionStateHandler.d.ts.map +1 -0
- package/lib/{connectionStateHandler.mjs → connectionStateHandler.js} +3 -3
- package/lib/connectionStateHandler.js.map +1 -0
- package/lib/{container-loader-alpha.d.mts → container-loader-alpha.d.ts} +1 -0
- package/lib/{container-loader-beta.d.mts → container-loader-beta.d.ts} +3 -0
- package/lib/{container-loader-public.d.mts → container-loader-public.d.ts} +3 -0
- package/lib/{container-loader-untrimmed.d.mts → container-loader-untrimmed.d.ts} +4 -4
- package/lib/{container.d.mts → container.d.ts} +12 -23
- package/lib/container.d.ts.map +1 -0
- package/lib/{container.mjs → container.js} +55 -148
- package/lib/container.js.map +1 -0
- package/lib/{containerContext.d.mts → containerContext.d.ts} +1 -1
- package/lib/containerContext.d.ts.map +1 -0
- package/lib/{containerContext.mjs → containerContext.js} +1 -1
- package/lib/containerContext.js.map +1 -0
- package/lib/{containerStorageAdapter.d.mts → containerStorageAdapter.d.ts} +3 -4
- package/lib/containerStorageAdapter.d.ts.map +1 -0
- package/lib/{containerStorageAdapter.mjs → containerStorageAdapter.js} +3 -9
- package/lib/containerStorageAdapter.js.map +1 -0
- package/lib/{contracts.d.mts → contracts.d.ts} +4 -4
- package/lib/contracts.d.ts.map +1 -0
- package/lib/{contracts.mjs → contracts.js} +1 -1
- package/lib/contracts.js.map +1 -0
- package/lib/{debugLogger.d.mts → debugLogger.d.ts} +1 -1
- package/lib/debugLogger.d.ts.map +1 -0
- package/lib/{debugLogger.mjs → debugLogger.js} +2 -1
- package/lib/debugLogger.js.map +1 -0
- package/lib/{deltaManager.d.mts → deltaManager.d.ts} +6 -6
- package/lib/deltaManager.d.ts.map +1 -0
- package/lib/{deltaManager.mjs → deltaManager.js} +4 -4
- package/lib/deltaManager.js.map +1 -0
- package/lib/{deltaQueue.d.mts → deltaQueue.d.ts} +1 -1
- package/lib/deltaQueue.d.ts.map +1 -0
- package/lib/{deltaQueue.mjs → deltaQueue.js} +1 -1
- package/lib/deltaQueue.js.map +1 -0
- package/lib/{disposal.d.mts → disposal.d.ts} +1 -1
- package/lib/disposal.d.ts.map +1 -0
- package/lib/{disposal.mjs → disposal.js} +1 -1
- package/lib/disposal.js.map +1 -0
- package/lib/{error.d.mts → error.d.ts} +1 -1
- package/lib/error.d.ts.map +1 -0
- package/lib/{error.mjs → error.js} +1 -1
- package/lib/error.js.map +1 -0
- package/lib/{index.d.mts → index.d.ts} +7 -7
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/{loader.d.mts → loader.d.ts} +3 -3
- package/lib/loader.d.ts.map +1 -0
- package/lib/{loader.mjs → loader.js} +7 -11
- package/lib/loader.js.map +1 -0
- package/lib/location-redirection-utilities/{index.mjs → index.d.ts} +2 -2
- package/lib/location-redirection-utilities/index.d.ts.map +1 -0
- package/lib/location-redirection-utilities/{index.d.mts → index.js} +2 -2
- package/lib/location-redirection-utilities/index.js.map +1 -0
- package/lib/location-redirection-utilities/{resolveWithLocationRedirection.d.mts → resolveWithLocationRedirection.d.ts} +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
- package/lib/location-redirection-utilities/{resolveWithLocationRedirection.mjs → resolveWithLocationRedirection.js} +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
- package/lib/{noopHeuristic.d.mts → noopHeuristic.d.ts} +1 -1
- package/lib/noopHeuristic.d.ts.map +1 -0
- package/lib/{noopHeuristic.mjs → noopHeuristic.js} +1 -1
- package/lib/noopHeuristic.js.map +1 -0
- package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
- package/lib/packageVersion.js.map +1 -0
- package/lib/{protocol.d.mts → protocol.d.ts} +1 -1
- package/lib/protocol.d.ts.map +1 -0
- package/lib/{protocol.mjs → protocol.js} +1 -1
- package/lib/protocol.js.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.d.mts → protocolTreeDocumentStorageService.d.ts} +1 -2
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.mjs → protocolTreeDocumentStorageService.js} +1 -4
- package/lib/protocolTreeDocumentStorageService.js.map +1 -0
- package/lib/{quorum.d.mts → quorum.d.ts} +5 -1
- package/lib/quorum.d.ts.map +1 -0
- package/lib/{quorum.mjs → quorum.js} +1 -1
- package/lib/quorum.js.map +1 -0
- package/lib/{retriableDocumentStorageService.d.mts → retriableDocumentStorageService.d.ts} +1 -2
- package/lib/retriableDocumentStorageService.d.ts.map +1 -0
- package/lib/{retriableDocumentStorageService.mjs → retriableDocumentStorageService.js} +1 -7
- package/lib/retriableDocumentStorageService.js.map +1 -0
- package/lib/serializedStateManager.d.ts +44 -0
- package/lib/serializedStateManager.d.ts.map +1 -0
- package/lib/serializedStateManager.js +145 -0
- package/lib/serializedStateManager.js.map +1 -0
- package/lib/test/attachment.spec.js +380 -0
- package/lib/test/attachment.spec.js.map +1 -0
- package/lib/test/catchUpMonitor.spec.js +88 -0
- package/lib/test/catchUpMonitor.spec.js.map +1 -0
- package/lib/test/connectionManager.spec.js +201 -0
- package/lib/test/connectionManager.spec.js.map +1 -0
- package/lib/test/connectionStateHandler.spec.js +555 -0
- package/lib/test/connectionStateHandler.spec.js.map +1 -0
- package/lib/test/container.spec.js +64 -0
- package/lib/test/container.spec.js.map +1 -0
- package/lib/test/deltaManager.spec.js +405 -0
- package/lib/test/deltaManager.spec.js.map +1 -0
- package/lib/test/loader.spec.js +212 -0
- package/lib/test/loader.spec.js.map +1 -0
- package/lib/test/locationRedirectionTests.spec.js +44 -0
- package/lib/test/locationRedirectionTests.spec.js.map +1 -0
- package/lib/test/serializedStateManager.spec.js +148 -0
- package/lib/test/serializedStateManager.spec.js.map +1 -0
- package/lib/test/snapshotConversionTest.spec.js +79 -0
- package/lib/test/snapshotConversionTest.spec.js.map +1 -0
- package/lib/test/types/validateContainerLoaderPrevious.generated.js +38 -0
- package/lib/test/types/validateContainerLoaderPrevious.generated.js.map +1 -0
- package/lib/test/utils.spec.js +31 -0
- package/lib/test/utils.spec.js.map +1 -0
- package/lib/{utils.d.mts → utils.d.ts} +6 -7
- package/lib/utils.d.ts.map +1 -0
- package/lib/{utils.mjs → utils.js} +11 -5
- package/lib/utils.js.map +1 -0
- package/package.json +56 -62
- package/src/attachment.ts +15 -12
- package/src/audience.ts +9 -3
- package/src/connectionManager.ts +13 -9
- package/src/connectionState.ts +1 -0
- package/src/connectionStateHandler.ts +8 -7
- package/src/container.ts +96 -191
- package/src/containerStorageAdapter.ts +6 -14
- package/src/contracts.ts +3 -3
- package/src/debugLogger.ts +2 -2
- package/src/deltaManager.ts +8 -8
- package/src/error.ts +2 -2
- package/src/index.ts +6 -6
- package/src/loader.ts +8 -12
- package/src/location-redirection-utilities/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocolTreeDocumentStorageService.ts +0 -3
- package/src/retriableDocumentStorageService.ts +0 -7
- package/src/serializedStateManager.ts +217 -0
- package/src/utils.ts +15 -10
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/attachment.d.mts.map +0 -1
- package/lib/attachment.mjs.map +0 -1
- package/lib/audience.d.mts.map +0 -1
- package/lib/audience.mjs.map +0 -1
- package/lib/catchUpMonitor.d.mts.map +0 -1
- package/lib/catchUpMonitor.mjs.map +0 -1
- package/lib/connectionManager.d.mts.map +0 -1
- package/lib/connectionManager.mjs.map +0 -1
- package/lib/connectionState.d.mts.map +0 -1
- package/lib/connectionState.mjs.map +0 -1
- package/lib/connectionStateHandler.d.mts.map +0 -1
- package/lib/connectionStateHandler.mjs.map +0 -1
- package/lib/container.d.mts.map +0 -1
- package/lib/container.mjs.map +0 -1
- package/lib/containerContext.d.mts.map +0 -1
- package/lib/containerContext.mjs.map +0 -1
- package/lib/containerStorageAdapter.d.mts.map +0 -1
- package/lib/containerStorageAdapter.mjs.map +0 -1
- package/lib/contracts.d.mts.map +0 -1
- package/lib/contracts.mjs.map +0 -1
- package/lib/debugLogger.d.mts.map +0 -1
- package/lib/debugLogger.mjs.map +0 -1
- package/lib/deltaManager.d.mts.map +0 -1
- package/lib/deltaManager.mjs.map +0 -1
- package/lib/deltaQueue.d.mts.map +0 -1
- package/lib/deltaQueue.mjs.map +0 -1
- package/lib/disposal.d.mts.map +0 -1
- package/lib/disposal.mjs.map +0 -1
- package/lib/error.d.mts.map +0 -1
- package/lib/error.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -10
- package/lib/index.mjs.map +0 -1
- package/lib/loader.d.mts.map +0 -1
- package/lib/loader.mjs.map +0 -1
- package/lib/location-redirection-utilities/index.d.mts.map +0 -1
- package/lib/location-redirection-utilities/index.mjs.map +0 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts.map +0 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +0 -1
- package/lib/noopHeuristic.d.mts.map +0 -1
- package/lib/noopHeuristic.mjs.map +0 -1
- package/lib/packageVersion.d.mts.map +0 -1
- package/lib/packageVersion.mjs.map +0 -1
- package/lib/protocol.d.mts.map +0 -1
- package/lib/protocol.mjs.map +0 -1
- package/lib/protocolTreeDocumentStorageService.d.mts.map +0 -1
- package/lib/protocolTreeDocumentStorageService.mjs.map +0 -1
- package/lib/quorum.d.mts.map +0 -1
- package/lib/quorum.mjs.map +0 -1
- package/lib/retriableDocumentStorageService.d.mts.map +0 -1
- package/lib/retriableDocumentStorageService.mjs.map +0 -1
- package/lib/utils.d.mts.map +0 -1
- package/lib/utils.mjs.map +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { v4 as uuid } from "uuid";
|
|
6
|
-
import { assert, unreachableCase } from "@fluidframework/core-utils";
|
|
6
|
+
import { assert, unreachableCase, isPromiseLike } from "@fluidframework/core-utils";
|
|
7
7
|
import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
|
|
8
8
|
import { LogLevel, } from "@fluidframework/core-interfaces";
|
|
9
9
|
import { AttachState, isFluidCodeDetails, } from "@fluidframework/container-definitions";
|
|
@@ -11,21 +11,22 @@ import { readAndParse, OnlineStatus, isOnline, isCombinedAppAndProtocolSummary,
|
|
|
11
11
|
import { MessageType, SummaryType, } from "@fluidframework/protocol-definitions";
|
|
12
12
|
import { createChildLogger, EventEmitterWithErrorHandling, PerformanceEvent, raiseConnectedEvent, connectedEventName, normalizeError, createChildMonitoringContext, wrapError, formatTick, GenericError, UsageError, } from "@fluidframework/telemetry-utils";
|
|
13
13
|
import structuredClone from "@ungap/structured-clone";
|
|
14
|
-
import { Audience } from "./audience.
|
|
15
|
-
import { ContainerContext } from "./containerContext.
|
|
16
|
-
import { ReconnectMode, getPackageName, } from "./contracts.
|
|
17
|
-
import { DeltaManager } from "./deltaManager.
|
|
18
|
-
import { RelativeLoader } from "./loader.
|
|
19
|
-
import { pkgVersion } from "./packageVersion.
|
|
20
|
-
import { ContainerStorageAdapter
|
|
21
|
-
import { createConnectionStateHandler } from "./connectionStateHandler.
|
|
22
|
-
import { combineAppAndProtocolSummary, getProtocolSnapshotTree, getSnapshotTreeAndBlobsFromSerializedContainer, combineSnapshotTreeAndSnapshotBlobs, getDetachedContainerStateFromSerializedContainer, runSingle, } from "./utils.
|
|
23
|
-
import { initQuorumValuesFromCodeDetails } from "./quorum.
|
|
24
|
-
import { NoopHeuristic } from "./noopHeuristic.
|
|
25
|
-
import { ConnectionManager } from "./connectionManager.
|
|
26
|
-
import { ConnectionState } from "./connectionState.
|
|
27
|
-
import { ProtocolHandler, protocolHandlerShouldProcessSignal, } from "./protocol.
|
|
28
|
-
import { runRetriableAttachProcess } from "./attachment.
|
|
14
|
+
import { Audience } from "./audience.js";
|
|
15
|
+
import { ContainerContext } from "./containerContext.js";
|
|
16
|
+
import { ReconnectMode, getPackageName, } from "./contracts.js";
|
|
17
|
+
import { DeltaManager } from "./deltaManager.js";
|
|
18
|
+
import { RelativeLoader } from "./loader.js";
|
|
19
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
20
|
+
import { ContainerStorageAdapter } from "./containerStorageAdapter.js";
|
|
21
|
+
import { createConnectionStateHandler } from "./connectionStateHandler.js";
|
|
22
|
+
import { combineAppAndProtocolSummary, getProtocolSnapshotTree, getSnapshotTreeAndBlobsFromSerializedContainer, combineSnapshotTreeAndSnapshotBlobs, getDetachedContainerStateFromSerializedContainer, runSingle, } from "./utils.js";
|
|
23
|
+
import { initQuorumValuesFromCodeDetails } from "./quorum.js";
|
|
24
|
+
import { NoopHeuristic } from "./noopHeuristic.js";
|
|
25
|
+
import { ConnectionManager } from "./connectionManager.js";
|
|
26
|
+
import { ConnectionState } from "./connectionState.js";
|
|
27
|
+
import { ProtocolHandler, protocolHandlerShouldProcessSignal, } from "./protocol.js";
|
|
28
|
+
import { runRetriableAttachProcess } from "./attachment.js";
|
|
29
|
+
import { SerializedStateManager } from "./serializedStateManager.js";
|
|
29
30
|
const detachedContainerRefSeqNumber = 0;
|
|
30
31
|
const dirtyContainerEvent = "dirty";
|
|
31
32
|
const savedContainerEvent = "saved";
|
|
@@ -104,9 +105,7 @@ export async function waitContainerToCatchUp(container) {
|
|
|
104
105
|
}
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
|
-
const getCodeProposal =
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
109
|
-
(quorum) => quorum.get("code") ?? quorum.get("code2");
|
|
108
|
+
const getCodeProposal = (quorum) => quorum.get("code") ?? quorum.get("code2");
|
|
110
109
|
/**
|
|
111
110
|
* Helper function to report to telemetry cases where operation takes longer than expected (200ms)
|
|
112
111
|
* @param logger - logger to use
|
|
@@ -124,7 +123,6 @@ const summarizerClientType = "summarizer";
|
|
|
124
123
|
export class Container extends EventEmitterWithErrorHandling {
|
|
125
124
|
/**
|
|
126
125
|
* Load an existing container.
|
|
127
|
-
* @internal
|
|
128
126
|
*/
|
|
129
127
|
static async load(loadProps, createProps) {
|
|
130
128
|
const { version, pendingLocalState, loadMode, resolvedUrl, loadToSequenceNumber } = loadProps;
|
|
@@ -272,11 +270,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
272
270
|
get clientId() {
|
|
273
271
|
return this._clientId;
|
|
274
272
|
}
|
|
275
|
-
get
|
|
276
|
-
|
|
277
|
-
this.options?.enableOfflineLoad === true;
|
|
278
|
-
// summarizer will not have any pending state we want to save
|
|
279
|
-
return enabled && this.deltaManager.clientDetails.capabilities.interactive;
|
|
273
|
+
get isInteractiveClient() {
|
|
274
|
+
return this.deltaManager.clientDetails.capabilities.interactive;
|
|
280
275
|
}
|
|
281
276
|
/**
|
|
282
277
|
* Get the code details that are currently specified for the container.
|
|
@@ -331,9 +326,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
331
326
|
this._lifecycleEvents.once("disposed", disposedHandler);
|
|
332
327
|
});
|
|
333
328
|
}
|
|
334
|
-
/**
|
|
335
|
-
* @internal
|
|
336
|
-
*/
|
|
337
329
|
constructor(createProps, loadProps) {
|
|
338
330
|
super((name, error) => {
|
|
339
331
|
this.mc.logger.sendErrorEvent({
|
|
@@ -362,7 +354,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
362
354
|
this.firstConnection = true;
|
|
363
355
|
this.connectionTransitionTimes = [];
|
|
364
356
|
this._dirtyContainer = false;
|
|
365
|
-
this.savedOps = [];
|
|
366
357
|
this.attachmentData = { state: AttachState.Detached };
|
|
367
358
|
this.clientsWhoShouldHaveLeft = new Set();
|
|
368
359
|
this._containerMetadata = {};
|
|
@@ -423,7 +414,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
423
414
|
};
|
|
424
415
|
let attachP = runRetriableAttachProcess({
|
|
425
416
|
initialAttachmentData: this.attachmentData,
|
|
426
|
-
offlineLoadEnabled: this.offlineLoadEnabled,
|
|
417
|
+
offlineLoadEnabled: this.serializedStateManager.offlineLoadEnabled,
|
|
427
418
|
detachedBlobStorage: this.detachedBlobStorage,
|
|
428
419
|
setAttachmentData,
|
|
429
420
|
createAttachmentSummary,
|
|
@@ -435,7 +426,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
435
426
|
throw normalizeErrorAndClose(error);
|
|
436
427
|
});
|
|
437
428
|
}
|
|
438
|
-
await attachP;
|
|
429
|
+
this.serializedStateManager.setSnapshot(await attachP);
|
|
439
430
|
if (!this.closed) {
|
|
440
431
|
this.handleDeltaConnectionArg({
|
|
441
432
|
fetchOpsFromStorage: false,
|
|
@@ -487,7 +478,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
487
478
|
});
|
|
488
479
|
};
|
|
489
480
|
this._containerId = uuid();
|
|
490
|
-
this.client = Container.setupClient(this._containerId,
|
|
481
|
+
this.client = Container.setupClient(this._containerId, options.client, this.clientDetailsOverride);
|
|
491
482
|
// Create logger for data stores to use
|
|
492
483
|
const type = this.client.details.type;
|
|
493
484
|
const interactive = this.client.details.capabilities.interactive;
|
|
@@ -593,6 +584,10 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
593
584
|
const forceEnableSummarizeProtocolTree = this.mc.config.getBoolean("Fluid.Container.summarizeProtocolTree2") ??
|
|
594
585
|
options.summarizeProtocolTree;
|
|
595
586
|
this.storageAdapter = new ContainerStorageAdapter(detachedBlobStorage, this.mc.logger, pendingLocalState?.snapshotBlobs, addProtocolSummaryIfMissing, forceEnableSummarizeProtocolTree);
|
|
587
|
+
const offlineLoadEnabled = (this.isInteractiveClient &&
|
|
588
|
+
this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad")) ??
|
|
589
|
+
options.enableOfflineLoad === true;
|
|
590
|
+
this.serializedStateManager = new SerializedStateManager(pendingLocalState, this.subLogger, this.storageAdapter, offlineLoadEnabled);
|
|
596
591
|
const isDomAvailable = typeof document === "object" &&
|
|
597
592
|
document !== null &&
|
|
598
593
|
typeof document.addEventListener === "function" &&
|
|
@@ -731,47 +726,32 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
731
726
|
return this.getPendingLocalStateCore({ notifyImminentClosure: false });
|
|
732
727
|
}
|
|
733
728
|
async getPendingLocalStateCore(props) {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
throw new UsageError("Can't get pending local state unless offline load is enabled");
|
|
742
|
-
}
|
|
743
|
-
if (this.closed || this._disposed) {
|
|
744
|
-
throw new UsageError("Pending state cannot be retried if the container is closed or disposed");
|
|
745
|
-
}
|
|
746
|
-
assert(this.attachmentData.state === AttachState.Attached, 0x0d1 /* "Container should be attached before close" */);
|
|
747
|
-
assert(this.resolvedUrl !== undefined && this.resolvedUrl.type === "fluid", 0x0d2 /* "resolved url should be valid Fluid url" */);
|
|
748
|
-
assert(this.attachmentData.snapshot !== undefined, 0x5d5 /* no base data */);
|
|
749
|
-
const pendingRuntimeState = await this.runtime.getPendingLocalState(props);
|
|
750
|
-
const pendingState = {
|
|
751
|
-
pendingRuntimeState,
|
|
752
|
-
baseSnapshot: this.attachmentData.snapshot.tree,
|
|
753
|
-
snapshotBlobs: this.attachmentData.snapshot.blobs,
|
|
754
|
-
savedOps: this.savedOps,
|
|
755
|
-
url: this.resolvedUrl.url,
|
|
756
|
-
// no need to save this if there is no pending runtime state
|
|
757
|
-
clientId: pendingRuntimeState !== undefined ? this.clientId : undefined,
|
|
758
|
-
};
|
|
759
|
-
return JSON.stringify(pendingState);
|
|
760
|
-
});
|
|
729
|
+
if (this.closed || this._disposed) {
|
|
730
|
+
throw new UsageError("Pending state cannot be retried if the container is closed or disposed");
|
|
731
|
+
}
|
|
732
|
+
assert(this.attachmentData.state === AttachState.Attached, 0x0d1 /* "Container should be attached before close" */);
|
|
733
|
+
assert(this.resolvedUrl !== undefined && this.resolvedUrl.type === "fluid", 0x0d2 /* "resolved url should be valid Fluid url" */);
|
|
734
|
+
const pendingState = await this.serializedStateManager.getPendingLocalStateCore(props, this.clientId, this.runtime, this.resolvedUrl);
|
|
735
|
+
return pendingState;
|
|
761
736
|
}
|
|
762
737
|
get attachState() {
|
|
763
738
|
return this.attachmentData.state;
|
|
764
739
|
}
|
|
765
740
|
serialize() {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
const
|
|
741
|
+
if (this.attachmentData.state === AttachState.Attached || this.closed) {
|
|
742
|
+
throw new UsageError("Container must not be attached or closed.");
|
|
743
|
+
}
|
|
744
|
+
const attachingData = this.attachmentData.state === AttachState.Attaching ? this.attachmentData : undefined;
|
|
745
|
+
const combinedSummary = attachingData?.summary ??
|
|
746
|
+
combineAppAndProtocolSummary(this.runtime.createSummary(), this.captureProtocolSummary());
|
|
770
747
|
const { tree: snapshot, blobs } = getSnapshotTreeAndBlobsFromSerializedContainer(combinedSummary);
|
|
748
|
+
const pendingRuntimeState = attachingData !== undefined ? this.runtime.getPendingLocalState() : undefined;
|
|
749
|
+
assert(!isPromiseLike(pendingRuntimeState), 0x8e3 /* should not be a promise */);
|
|
771
750
|
const detachedContainerState = {
|
|
772
751
|
attached: false,
|
|
773
752
|
baseSnapshot: snapshot,
|
|
774
753
|
snapshotBlobs: blobs,
|
|
754
|
+
pendingRuntimeState,
|
|
775
755
|
hasAttachmentBlobs: !!this.detachedBlobStorage && this.detachedBlobStorage.size > 0,
|
|
776
756
|
};
|
|
777
757
|
return JSON.stringify(detachedContainerState);
|
|
@@ -904,10 +884,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
904
884
|
}
|
|
905
885
|
return true;
|
|
906
886
|
}
|
|
907
|
-
async getVersion(version) {
|
|
908
|
-
const versions = await this.storageAdapter.getVersions(version, 1);
|
|
909
|
-
return versions[0];
|
|
910
|
-
}
|
|
911
887
|
connectToDeltaStream(args) {
|
|
912
888
|
// All agents need "write" access, including summarizer.
|
|
913
889
|
if (!this._canReconnect || !this.client.details.capabilities.interactive) {
|
|
@@ -952,31 +928,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
952
928
|
};
|
|
953
929
|
timings.phase2 = performance.now();
|
|
954
930
|
// Fetch specified snapshot.
|
|
955
|
-
const {
|
|
956
|
-
|
|
957
|
-
: { snapshot: pendingLocalState.baseSnapshot, versionId: undefined };
|
|
958
|
-
const snapshotTree = isInstanceOfISnapshot(snapshot)
|
|
959
|
-
? snapshot.snapshotTree
|
|
960
|
-
: snapshot;
|
|
961
|
-
if (pendingLocalState) {
|
|
962
|
-
this.attachmentData = {
|
|
963
|
-
state: AttachState.Attached,
|
|
964
|
-
snapshot: {
|
|
965
|
-
tree: pendingLocalState.baseSnapshot,
|
|
966
|
-
blobs: pendingLocalState.snapshotBlobs,
|
|
967
|
-
},
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
else {
|
|
971
|
-
assert(snapshotTree !== undefined, 0x237 /* "Snapshot should exist" */);
|
|
972
|
-
if (this.offlineLoadEnabled) {
|
|
973
|
-
const blobs = await getBlobContentsFromTree(snapshotTree, this.storageAdapter);
|
|
974
|
-
this.attachmentData = {
|
|
975
|
-
state: AttachState.Attached,
|
|
976
|
-
snapshot: { tree: snapshotTree, blobs },
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
}
|
|
931
|
+
const { snapshotTree, version } = await this.serializedStateManager.fetchSnapshot(specifiedVersion, this.service?.policies?.supportGetSnapshotApi);
|
|
932
|
+
this._loadedFromVersion = version;
|
|
980
933
|
const attributes = await this.getDocumentAttributes(this.storageAdapter, snapshotTree);
|
|
981
934
|
// If we saved ops, we will replay them and don't need DeltaManager to fetch them
|
|
982
935
|
const sequenceNumber = pendingLocalState?.savedOps[pendingLocalState.savedOps.length - 1]?.sequenceNumber;
|
|
@@ -1047,7 +1000,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1047
1000
|
const codeDetails = this.getCodeDetailsFromQuorum();
|
|
1048
1001
|
await this.instantiateRuntime(codeDetails, snapshotTree,
|
|
1049
1002
|
// give runtime a dummy value so it knows we're loading from a stash blob
|
|
1050
|
-
pendingLocalState ? pendingLocalState?.pendingRuntimeState ?? {} : undefined, isInstanceOfISnapshot(
|
|
1003
|
+
pendingLocalState ? pendingLocalState?.pendingRuntimeState ?? {} : undefined, isInstanceOfISnapshot(snapshotTree) ? snapshotTree : undefined);
|
|
1051
1004
|
// replay saved ops
|
|
1052
1005
|
if (pendingLocalState) {
|
|
1053
1006
|
for (const message of pendingLocalState.savedOps) {
|
|
@@ -1102,7 +1055,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1102
1055
|
}, undefined, LogLevel.verbose);
|
|
1103
1056
|
return {
|
|
1104
1057
|
sequenceNumber: attributes.sequenceNumber,
|
|
1105
|
-
version:
|
|
1058
|
+
version: version?.id,
|
|
1106
1059
|
dmLastProcessedSeqNumber: this._deltaManager.lastSequenceNumber,
|
|
1107
1060
|
dmLastKnownSeqNumber: this._deltaManager.lastKnownSeqNumber,
|
|
1108
1061
|
};
|
|
@@ -1123,7 +1076,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1123
1076
|
await this.instantiateRuntime(codeDetails, undefined);
|
|
1124
1077
|
this.setLoaded();
|
|
1125
1078
|
}
|
|
1126
|
-
async rehydrateDetachedFromSnapshot({
|
|
1079
|
+
async rehydrateDetachedFromSnapshot({ baseSnapshot, snapshotBlobs, hasAttachmentBlobs, pendingRuntimeState, }) {
|
|
1127
1080
|
if (hasAttachmentBlobs) {
|
|
1128
1081
|
assert(!!this.detachedBlobStorage && this.detachedBlobStorage.size > 0, 0x250 /* "serialized container with attachment blobs must be rehydrated with detached blob storage" */);
|
|
1129
1082
|
}
|
|
@@ -1140,7 +1093,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1140
1093
|
values: qValues,
|
|
1141
1094
|
});
|
|
1142
1095
|
const codeDetails = this.getCodeDetailsFromQuorum();
|
|
1143
|
-
await this.instantiateRuntime(codeDetails, snapshotTreeWithBlobContents);
|
|
1096
|
+
await this.instantiateRuntime(codeDetails, snapshotTreeWithBlobContents, pendingRuntimeState);
|
|
1144
1097
|
this.setLoaded();
|
|
1145
1098
|
}
|
|
1146
1099
|
async getDocumentAttributes(storage, tree) {
|
|
@@ -1240,10 +1193,9 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1240
1193
|
const pkg = getCodeProposal(quorum);
|
|
1241
1194
|
return pkg;
|
|
1242
1195
|
}
|
|
1243
|
-
static setupClient(containerId,
|
|
1244
|
-
const loaderOptionsClient = structuredClone(options?.client);
|
|
1196
|
+
static setupClient(containerId, loaderOptionsClient, clientDetailsOverride) {
|
|
1245
1197
|
const client = loaderOptionsClient !== undefined
|
|
1246
|
-
? loaderOptionsClient
|
|
1198
|
+
? structuredClone(loaderOptionsClient)
|
|
1247
1199
|
: {
|
|
1248
1200
|
details: {
|
|
1249
1201
|
capabilities: { interactive: true },
|
|
@@ -1297,10 +1249,10 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1297
1249
|
deltaManager.on("cancelEstablishingConnection", (reason) => {
|
|
1298
1250
|
this.connectionStateHandler.cancelEstablishingConnection(reason);
|
|
1299
1251
|
});
|
|
1300
|
-
deltaManager.on("disconnect", (
|
|
1252
|
+
deltaManager.on("disconnect", (text, error) => {
|
|
1301
1253
|
this.noopHeuristic?.notifyDisconnect();
|
|
1302
1254
|
if (!this.closed) {
|
|
1303
|
-
this.connectionStateHandler.receivedDisconnectEvent(
|
|
1255
|
+
this.connectionStateHandler.receivedDisconnectEvent({ text, error });
|
|
1304
1256
|
}
|
|
1305
1257
|
});
|
|
1306
1258
|
deltaManager.on("throttled", (warning) => {
|
|
@@ -1445,14 +1397,12 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1445
1397
|
return this._deltaManager.submit(type, contents, batch, metadata, compression, referenceSequenceNumber);
|
|
1446
1398
|
}
|
|
1447
1399
|
processRemoteMessage(message) {
|
|
1448
|
-
if (this.offlineLoadEnabled) {
|
|
1449
|
-
this.savedOps.push(message);
|
|
1450
|
-
}
|
|
1451
1400
|
const local = this.clientId === message.clientId;
|
|
1452
1401
|
// Allow the protocol handler to process the message
|
|
1453
1402
|
const result = this.protocolHandler.processMessage(message, local);
|
|
1454
1403
|
// Forward messages to the loaded runtime for processing
|
|
1455
1404
|
this.runtime.process(message, local);
|
|
1405
|
+
this.serializedStateManager.addProcessedOp(message);
|
|
1456
1406
|
// Inactive (not in quorum or not writers) clients don't take part in the minimum sequence number calculation.
|
|
1457
1407
|
if (this.activeConnection()) {
|
|
1458
1408
|
if (this.noopHeuristic === undefined) {
|
|
@@ -1493,49 +1443,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1493
1443
|
this.runtime.processSignal(message, local);
|
|
1494
1444
|
}
|
|
1495
1445
|
}
|
|
1496
|
-
/**
|
|
1497
|
-
* Get the most recent snapshot, or a specific version.
|
|
1498
|
-
* @param specifiedVersion - The specific version of the snapshot to retrieve
|
|
1499
|
-
* @returns The snapshot requested, or the latest snapshot if no version was specified, plus version ID
|
|
1500
|
-
*/
|
|
1501
|
-
async fetchSnapshotTree(specifiedVersion) {
|
|
1502
|
-
const version = await this.getVersion(specifiedVersion ?? null);
|
|
1503
|
-
if (version === undefined && specifiedVersion !== undefined) {
|
|
1504
|
-
// We should have a defined version to load from if specified version requested
|
|
1505
|
-
this.mc.logger.sendErrorEvent({
|
|
1506
|
-
eventName: "NoVersionFoundWhenSpecified",
|
|
1507
|
-
id: specifiedVersion,
|
|
1508
|
-
});
|
|
1509
|
-
}
|
|
1510
|
-
this._loadedFromVersion = version;
|
|
1511
|
-
const snapshot = (await this.storageAdapter.getSnapshotTree(version)) ?? undefined;
|
|
1512
|
-
if (snapshot === undefined && version !== undefined) {
|
|
1513
|
-
this.mc.logger.sendErrorEvent({ eventName: "getSnapshotTreeFailed", id: version.id });
|
|
1514
|
-
}
|
|
1515
|
-
return { snapshot, versionId: version?.id };
|
|
1516
|
-
}
|
|
1517
|
-
async fetchSnapshot(specifiedVersion) {
|
|
1518
|
-
if (this.mc.config.getBoolean("Fluid.Container.FetchSnapshotUsingGetSnapshotApi") ===
|
|
1519
|
-
true &&
|
|
1520
|
-
this.service?.policies?.supportGetSnapshotApi === true) {
|
|
1521
|
-
const snapshot = await this.storageAdapter.getSnapshot({
|
|
1522
|
-
versionId: specifiedVersion,
|
|
1523
|
-
});
|
|
1524
|
-
const version = {
|
|
1525
|
-
id: snapshot.snapshotTree.id ?? "",
|
|
1526
|
-
treeId: snapshot.snapshotTree.id ?? "",
|
|
1527
|
-
};
|
|
1528
|
-
this._loadedFromVersion = version;
|
|
1529
|
-
if (snapshot === undefined && specifiedVersion !== undefined) {
|
|
1530
|
-
this.mc.logger.sendErrorEvent({
|
|
1531
|
-
eventName: "getSnapshotTreeFailed",
|
|
1532
|
-
id: version.id,
|
|
1533
|
-
});
|
|
1534
|
-
}
|
|
1535
|
-
return { snapshot, versionId: version.id };
|
|
1536
|
-
}
|
|
1537
|
-
return this.fetchSnapshotTree(specifiedVersion);
|
|
1538
|
-
}
|
|
1539
1446
|
async instantiateRuntime(codeDetails, snapshotTree, pendingLocalState, snapshot) {
|
|
1540
1447
|
assert(this._runtime?.disposed !== false, 0x0dd /* "Existing runtime not disposed" */);
|
|
1541
1448
|
// The relative loader will proxy requests to '/' to the loader itself assuming no non-cache flags
|
|
@@ -1601,4 +1508,4 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1601
1508
|
}
|
|
1602
1509
|
}
|
|
1603
1510
|
}
|
|
1604
|
-
//# sourceMappingURL=container.
|
|
1511
|
+
//# sourceMappingURL=container.js.map
|