@fluidframework/container-loader 2.20.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/connectionManager.js +7 -7
- package/dist/connectionManager.js.map +1 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +18 -14
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +6 -1
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +7 -0
- package/dist/containerContext.js.map +1 -1
- package/dist/debugLogger.js +1 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +2 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/layerCompatState.d.ts +19 -0
- package/dist/layerCompatState.d.ts.map +1 -0
- package/dist/layerCompatState.js +64 -0
- package/dist/layerCompatState.js.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol/quorum.d.ts +0 -10
- package/dist/protocol/quorum.d.ts.map +1 -1
- package/dist/protocol/quorum.js +0 -14
- package/dist/protocol/quorum.js.map +1 -1
- package/lib/connectionManager.js +8 -8
- package/lib/connectionManager.js.map +1 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +19 -15
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +6 -1
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +7 -0
- package/lib/containerContext.js.map +1 -1
- package/lib/debugLogger.js +2 -2
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +3 -3
- package/lib/deltaQueue.js.map +1 -1
- package/lib/layerCompatState.d.ts +19 -0
- package/lib/layerCompatState.d.ts.map +1 -0
- package/lib/layerCompatState.js +60 -0
- package/lib/layerCompatState.js.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol/quorum.d.ts +0 -10
- package/lib/protocol/quorum.d.ts.map +1 -1
- package/lib/protocol/quorum.js +0 -14
- package/lib/protocol/quorum.js.map +1 -1
- package/package.json +14 -14
- package/src/connectionManager.ts +8 -8
- package/src/container.ts +28 -15
- package/src/containerContext.ts +14 -1
- package/src/debugLogger.ts +2 -2
- package/src/deltaQueue.ts +3 -3
- package/src/layerCompatState.ts +75 -0
- package/src/packageVersion.ts +1 -1
- package/src/protocol/quorum.ts +0 -16
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import type { ILayerCompatDetails, IProvideLayerCompatDetails } from "@fluid-internal/client-utils";
|
|
5
6
|
import { AttachState, IAudience, ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
6
7
|
import { IBatchMessage, IContainerContext, ILoader, ILoaderOptions, IDeltaManager } from "@fluidframework/container-definitions/internal";
|
|
7
8
|
import { type FluidObject } from "@fluidframework/core-interfaces";
|
|
@@ -12,7 +13,7 @@ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
|
12
13
|
/**
|
|
13
14
|
* {@inheritDoc @fluidframework/container-definitions#IContainerContext}
|
|
14
15
|
*/
|
|
15
|
-
export declare class ContainerContext implements IContainerContext {
|
|
16
|
+
export declare class ContainerContext implements IContainerContext, IProvideLayerCompatDetails {
|
|
16
17
|
readonly options: ILoaderOptions;
|
|
17
18
|
readonly scope: FluidObject;
|
|
18
19
|
readonly baseSnapshot: ISnapshotTree | undefined;
|
|
@@ -47,6 +48,9 @@ export declare class ContainerContext implements IContainerContext {
|
|
|
47
48
|
readonly taggedLogger: ITelemetryLoggerExt;
|
|
48
49
|
readonly pendingLocalState?: unknown;
|
|
49
50
|
readonly snapshotWithContents?: ISnapshot | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated - This has been replaced by ILayerCompatDetails.
|
|
53
|
+
*/
|
|
50
54
|
readonly supportedFeatures: ReadonlyMap<string, unknown>;
|
|
51
55
|
get clientId(): string | undefined;
|
|
52
56
|
/**
|
|
@@ -58,6 +62,7 @@ export declare class ContainerContext implements IContainerContext {
|
|
|
58
62
|
* When false, ops should be kept as pending or rejected
|
|
59
63
|
*/
|
|
60
64
|
get connected(): boolean;
|
|
65
|
+
get ILayerCompatDetails(): ILayerCompatDetails;
|
|
61
66
|
constructor(options: ILoaderOptions, scope: FluidObject, baseSnapshot: ISnapshotTree | undefined, _version: IVersion | undefined, deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, storage: IDocumentStorageService, quorum: IQuorumClients, audience: IAudience, loader: ILoader, submitFn: (type: MessageType, contents: unknown, batch: boolean, appData: unknown) => number, submitSummaryFn: (summaryOp: ISummaryContent, referenceSequenceNumber?: number) => number,
|
|
62
67
|
/**
|
|
63
68
|
* @returns clientSequenceNumber of last message in a batch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.d.ts","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EACX,SAAS,EACT,uBAAuB,EACvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,cAAc,EACd,aAAa,EACb,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EACN,uBAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,QAAQ,EACR,WAAW,EACX,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"containerContext.d.ts","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,mBAAmB,EACnB,0BAA0B,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,WAAW,EACX,SAAS,EACT,uBAAuB,EACvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,cAAc,EACd,aAAa,EACb,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EACN,uBAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,QAAQ,EACR,WAAW,EACX,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAI/E;;GAEG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB,EAAE,0BAA0B;aAqCpE,OAAO,EAAE,cAAc;aACvB,KAAK,EAAE,WAAW;aAClB,YAAY,EAAE,aAAa,GAAG,SAAS;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ;aACT,YAAY,EAAE,aAAa,CAAC,yBAAyB,EAAE,gBAAgB,CAAC;aACxE,OAAO,EAAE,uBAAuB;aAChC,MAAM,EAAE,cAAc;aACtB,QAAQ,EAAE,SAAS;aACnB,MAAM,EAAE,OAAO;aACf,QAAQ,EAAE,CACzB,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,O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AEpC;CACD"}
|
package/lib/containerContext.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { LoaderCompatDetails } from "./layerCompatState.js";
|
|
5
6
|
/**
|
|
6
7
|
* {@inheritDoc @fluidframework/container-definitions#IContainerContext}
|
|
7
8
|
*/
|
|
@@ -22,6 +23,9 @@ export class ContainerContext {
|
|
|
22
23
|
get connected() {
|
|
23
24
|
return this._getConnected();
|
|
24
25
|
}
|
|
26
|
+
get ILayerCompatDetails() {
|
|
27
|
+
return LoaderCompatDetails;
|
|
28
|
+
}
|
|
25
29
|
constructor(options, scope, baseSnapshot, _version, deltaManager, storage, quorum, audience, loader, submitFn, submitSummaryFn,
|
|
26
30
|
/**
|
|
27
31
|
* @returns clientSequenceNumber of last message in a batch
|
|
@@ -59,6 +63,9 @@ export class ContainerContext {
|
|
|
59
63
|
this.taggedLogger = taggedLogger;
|
|
60
64
|
this.pendingLocalState = pendingLocalState;
|
|
61
65
|
this.snapshotWithContents = snapshotWithContents;
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated - This has been replaced by ILayerCompatDetails.
|
|
68
|
+
*/
|
|
62
69
|
this.supportedFeatures = new Map([
|
|
63
70
|
/**
|
|
64
71
|
* This version of the loader accepts `referenceSequenceNumber`, provided by the container runtime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiCH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAa5B,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,YAA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;QACnD,iBAAY,GAAZ,YAAY,CAA0B;QACtC,oBAAe,GAAf,eAAe,CAAmB;QAClC,kBAAa,GAAb,aAAa,CAAe;QAC7B,kBAAa,GAAb,aAAa,CAAgB;QAC7B,aAAQ,GAAR,QAAQ,CAAS;QACjB,iBAAY,GAAZ,YAAY,CAAqB;QACjC,sBAAiB,GAAjB,iBAAiB,CAAU;QAC3B,yBAAoB,GAApB,oBAAoB,CAAY;QApFjD;;WAEG;QACa,sBAAiB,GAAiC,IAAI,GAAG,CAAC;YACzE;;;;eAIG;YACH,CAAC,0BAA0B,EAAE,IAAI,CAAC;SAClC,CAAC,CAAC;IA2EA,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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tILayerCompatDetails,\n\tIProvideLayerCompatDetails,\n} from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\tIAudience,\n\tICriticalContainerError,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIBatchMessage,\n\tIContainerContext,\n\tILoader,\n\tILoaderOptions,\n\tIDeltaManager,\n} from \"@fluidframework/container-definitions/internal\";\nimport { type FluidObject } from \"@fluidframework/core-interfaces\";\nimport { type ISignalEnvelope } from \"@fluidframework/core-interfaces/internal\";\nimport { IClientDetails, IQuorumClients } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tISnapshot,\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISummaryContent,\n\tIVersion,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { LoaderCompatDetails } from \"./layerCompatState.js\";\n\n/**\n * {@inheritDoc @fluidframework/container-definitions#IContainerContext}\n */\nexport class ContainerContext implements IContainerContext, IProvideLayerCompatDetails {\n\t/**\n\t * @deprecated - This has been replaced by ILayerCompatDetails.\n\t */\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\tpublic get ILayerCompatDetails(): ILayerCompatDetails {\n\t\treturn LoaderCompatDetails;\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: unknown,\n\t\t\tbatch: boolean,\n\t\t\tappData: unknown,\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/**\n\t\t * @returns clientSequenceNumber of last message in a batch\n\t\t */\n\t\tpublic readonly submitBatchFn: (\n\t\t\tbatch: IBatchMessage[],\n\t\t\treferenceSequenceNumber?: number,\n\t\t) => number,\n\n\t\t/**\n\t\t * `unknown` should be removed once `@alpha` tag is removed from IContainerContext\n\t\t * @see {@link https://dev.azure.com/fluidframework/internal/_workitems/edit/7462}\n\t\t * Any changes to submitSignalFn `content` should be checked internally by temporarily changing IContainerContext and removing all `unknown`s\n\t\t */\n\t\tpublic readonly submitSignalFn: (\n\t\t\tcontent: unknown | ISignalEnvelope,\n\t\t\ttargetClientId?: string,\n\t\t) => 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 clientDetails: IClientDetails,\n\t\tpublic readonly existing: boolean,\n\t\tpublic readonly taggedLogger: ITelemetryLoggerExt,\n\t\tpublic readonly pendingLocalState?: unknown,\n\t\tpublic readonly snapshotWithContents?: ISnapshot,\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"]}
|
package/lib/debugLogger.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { performanceNow } from "@fluid-internal/client-utils";
|
|
6
6
|
import { createMultiSinkLogger, eventNamespaceSeparator, formatTick, } from "@fluidframework/telemetry-utils/internal";
|
|
7
7
|
// This import style is necessary to ensure the emitted JS code works in both CJS and ESM.
|
|
8
8
|
import debugPkg from "debug";
|
|
@@ -64,7 +64,7 @@ export class DebugLogger {
|
|
|
64
64
|
}
|
|
65
65
|
newEvent.eventName = undefined;
|
|
66
66
|
let tick = "";
|
|
67
|
-
tick = `tick=${formatTick(
|
|
67
|
+
tick = `tick=${formatTick(performanceNow())}`;
|
|
68
68
|
// Extract stack to put it last, but also to avoid escaping '\n' in it by JSON.stringify below
|
|
69
69
|
const stack = newEvent.stack ?? "";
|
|
70
70
|
newEvent.stack = undefined;
|
package/lib/debugLogger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugLogger.js","sourceRoot":"","sources":["../src/debugLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"debugLogger.js","sourceRoot":"","sources":["../src/debugLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EAGN,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,GACV,MAAM,0CAA0C,CAAC;AAClD,0FAA0F;AAC1F,OAAO,QAAQ,MAAM,OAAO,CAAC;AAG7B,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,WAAW;IACvB;;;;;;;OAOG;IACI,MAAM,CAAC,gBAAgB,CAC7B,SAAiB,EACjB,UAAiC,EACjC,UAAyC;QAEzC,uEAAuE;QACvE,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAEvC,+CAA+C;QAC/C,uFAAuF;QACvF,MAAM,QAAQ,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAC1C,QAAQ,CAAC,GAAG,GAAG,UAAU,GAAG,IAAe;YAC1C,IAAI,KAAK,CAAC,OAAO,KAAK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AAQ,CAAC,SAAS,GAAG,SAAS,CAAC;QAE/B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,QAAQ,UAAU,CAAC,cAAc,EAAE,CAAC,EAAE,CAAC;QAE9C,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,CAAC;YACJ,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACR,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC;YAC3B,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QAED,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACtB,OAAO,GAAG,EAAE,CAAC;QACd,CAAC;QAED,6CAA6C;QAC7C,IAAI,OAAO,EAAE,CAAC;YACb,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC;QAED,oBAAoB;QACpB,gEAAgE;QAChE,MAAM,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;IAC/C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\tITelemetryLoggerPropertyBags,\n\tcreateMultiSinkLogger,\n\teventNamespaceSeparator,\n\tformatTick,\n} from \"@fluidframework/telemetry-utils/internal\";\n// This import style is necessary to ensure the emitted JS code works in both CJS and ESM.\nimport debugPkg from \"debug\";\nimport type { IDebugger } from \"debug\";\n\nconst { debug: registerDebug } = debugPkg;\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: unknown[]): void {\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: ITelemetryBaseProperties = { ...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.slice(Math.max(0, index + 1));\n\t\tif (index > 0) {\n\t\t\tlogger = logger.extend(event.eventName.slice(0, index));\n\t\t}\n\t\tnewEvent.eventName = undefined;\n\n\t\tlet tick = \"\";\n\t\ttick = `tick=${formatTick(performanceNow())}`;\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 {\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"]}
|
package/lib/deltaQueue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaQueue.d.ts","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"deltaQueue.d.ts","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAkB,MAAM,8BAA8B,CAAC;AACjF,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,MAAM,gDAAgD,CAAC;AAIxD,MAAM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-2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { TypedEventEmitter,
|
|
5
|
+
import { TypedEventEmitter, performanceNow } from "@fluid-internal/client-utils";
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import Deque from "double-ended-queue";
|
|
8
8
|
export class DeltaQueue extends TypedEventEmitter {
|
|
@@ -107,7 +107,7 @@ export class DeltaQueue extends TypedEventEmitter {
|
|
|
107
107
|
* Executes the delta processing loop until a stop condition is reached.
|
|
108
108
|
*/
|
|
109
109
|
processDeltas() {
|
|
110
|
-
const start =
|
|
110
|
+
const start = performanceNow();
|
|
111
111
|
let count = 0;
|
|
112
112
|
// For grouping to work we must process all local messages immediately and in the single turn.
|
|
113
113
|
// So loop over them until no messages to process, we have become paused, or hit an error.
|
|
@@ -121,7 +121,7 @@ export class DeltaQueue extends TypedEventEmitter {
|
|
|
121
121
|
this.worker(next);
|
|
122
122
|
this.emit("op", next);
|
|
123
123
|
}
|
|
124
|
-
const duration =
|
|
124
|
+
const duration = performanceNow() - start;
|
|
125
125
|
if (this.q.length === 0) {
|
|
126
126
|
this.emit("idle", count, duration);
|
|
127
127
|
}
|
package/lib/deltaQueue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaQueue.js","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"deltaQueue.js","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKjF,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,KAAK,MAAM,oBAAoB,CAAC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* Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter, performanceNow } from \"@fluid-internal/client-utils\";\nimport {\n\tIDeltaQueue,\n\tIDeltaQueueEvents,\n} from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport Deque from \"double-ended-queue\";\n\nexport interface IDeltaQueueWriter<T> {\n\tpush(task: T): void;\n\tclear(): void;\n}\n\nexport class DeltaQueue<T>\n\textends TypedEventEmitter<IDeltaQueueEvents<T>>\n\timplements IDeltaQueue<T>, IDeltaQueueWriter<T>\n{\n\tprivate isDisposed: boolean = false;\n\tprivate readonly q = new Deque<T>();\n\n\t/**\n\t * Tracks the number of pause requests for the queue.\n\t * The DeltaQueue is created initially paused.\n\t */\n\tprivate pauseCount = 1;\n\n\tprivate error: Error | undefined;\n\n\t/**\n\t * When processing is ongoing, holds a deferred that will resolve once processing stops.\n\t * Undefined when not processing.\n\t */\n\tprivate processingPromise: Promise<{ count: number; duration: number }> | undefined;\n\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\n\t/**\n\t * Whether or not the queue is paused.\n\t */\n\tpublic get paused(): boolean {\n\t\treturn this.pauseCount !== 0;\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.q.length;\n\t}\n\n\tpublic get idle(): boolean {\n\t\treturn this.processingPromise === undefined && this.q.length === 0;\n\t}\n\n\tpublic async waitTillProcessingDone(): Promise<{\n\t\tcount: number;\n\t\tduration: number;\n\t}> {\n\t\treturn this.processingPromise ?? { count: 0, duration: 0 };\n\t}\n\n\t/**\n\t * @param worker - A callback to process a delta.\n\t */\n\tconstructor(private readonly worker: (delta: T) => void) {\n\t\tsuper();\n\t}\n\n\tpublic dispose(): void {\n\t\tthrow new Error(\"Not implemented.\");\n\t\tthis.isDisposed = true;\n\t}\n\n\tpublic clear(): void {\n\t\tthis.q.clear();\n\t}\n\n\tpublic peek(): T | undefined {\n\t\treturn this.q.peekFront();\n\t}\n\n\tpublic toArray(): T[] {\n\t\treturn this.q.toArray();\n\t}\n\n\tpublic push(task: T): void {\n\t\ttry {\n\t\t\tthis.q.push(task);\n\t\t\tthis.emit(\"push\", task);\n\t\t\tthis.ensureProcessing();\n\t\t} catch (error) {\n\t\t\tthis.emit(\"error\", error);\n\t\t}\n\t}\n\n\tpublic async pause(): Promise<void> {\n\t\tthis.pauseCount++;\n\t\t// If called from within the processing loop, we are in the middle of processing an op. Return a promise\n\t\t// that will resolve when processing has actually stopped.\n\t\tawait this.waitTillProcessingDone();\n\t}\n\n\tpublic resume(): void {\n\t\tassert(this.pauseCount > 0, 0x0f4 /* \"Nonzero pause-count on resume()\" */);\n\t\tthis.pauseCount--;\n\t\tthis.ensureProcessing();\n\t}\n\n\t/**\n\t * There are several actions that may need to kick off delta processing, so we want to guard against\n\t * accidental reentrancy. ensureProcessing can be called safely to start the processing loop if it is\n\t * not already started.\n\t */\n\tprivate ensureProcessing(): void {\n\t\tif (this.anythingToProcess() && this.processingPromise === undefined) {\n\t\t\t// Use a resolved promise to start the processing on a separate stack.\n\t\t\tthis.processingPromise = Promise.resolve()\n\t\t\t\t.then(() => {\n\t\t\t\t\tassert(this.processingPromise !== undefined, 0x37f /* reentrancy? */);\n\t\t\t\t\tconst result = this.processDeltas();\n\t\t\t\t\tassert(this.processingPromise !== undefined, 0x380 /* reentrancy? */);\n\t\t\t\t\t// WARNING: Do not move next line to .finally() clause!\n\t\t\t\t\t// It runs async and creates a race condition where incoming ensureProcessing() call observes\n\t\t\t\t\t// from previous run while previous run is over (but finally clause was not scheduled yet)\n\t\t\t\t\tthis.processingPromise = undefined;\n\t\t\t\t\treturn result;\n\t\t\t\t})\n\t\t\t\t.catch((error: Error) => {\n\t\t\t\t\tthis.error = error;\n\t\t\t\t\tthis.processingPromise = undefined;\n\t\t\t\t\tthis.emit(\"error\", error);\n\t\t\t\t\treturn { count: 0, duration: 0 };\n\t\t\t\t});\n\t\t\tassert(\n\t\t\t\tthis.processingPromise !== undefined,\n\t\t\t\t0x381 /* processDeltas() should run async */,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate anythingToProcess(): boolean {\n\t\treturn this.q.length > 0 && !this.paused && this.error === undefined;\n\t}\n\n\t/**\n\t * Executes the delta processing loop until a stop condition is reached.\n\t */\n\tprivate processDeltas(): {\n\t\tcount: number;\n\t\tduration: number;\n\t} {\n\t\tconst start = performanceNow();\n\t\tlet count = 0;\n\n\t\t// For grouping to work we must process all local messages immediately and in the single turn.\n\t\t// So loop over them until no messages to process, we have become paused, or hit an error.\n\t\twhile (this.anythingToProcess()) {\n\t\t\t// Get the next message in the queue\n\t\t\tconst next = this.q.shift();\n\t\t\tcount++;\n\t\t\t// Process the message.\n\t\t\t// We know next is defined since we did a length check just prior to shifting.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.worker(next!);\n\t\t\tthis.emit(\"op\", next);\n\t\t}\n\n\t\tconst duration = performanceNow() - start;\n\t\tif (this.q.length === 0) {\n\t\t\tthis.emit(\"idle\", count, duration);\n\t\t}\n\t\treturn { count, duration };\n\t}\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { type ILayerCompatDetails, type ILayerCompatSupportRequirements } from "@fluid-internal/client-utils";
|
|
6
|
+
import type { ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
7
|
+
/**
|
|
8
|
+
* Loader's compatibility details that is exposed to the Runtime layer.
|
|
9
|
+
*/
|
|
10
|
+
export declare const LoaderCompatDetails: ILayerCompatDetails;
|
|
11
|
+
/**
|
|
12
|
+
* The requirements that the Runtime layer must meet to be compatible with this Loader.
|
|
13
|
+
*/
|
|
14
|
+
export declare const RuntimeSupportRequirements: ILayerCompatSupportRequirements;
|
|
15
|
+
/**
|
|
16
|
+
* Validates that the Runtime layer is compatible with the Loader.
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateRuntimeCompatibility(maybeRuntimeCompatDetails: ILayerCompatDetails | undefined, disposeFn: (error?: ICriticalContainerError) => void): void;
|
|
19
|
+
//# sourceMappingURL=layerCompatState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerCompatState.d.ts","sourceRoot":"","sources":["../src/layerCompatState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,EACpC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAKrF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,mBAajC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,+BAUxC,CAAC;AAEF;;GAEG;AACH,wBAAgB,4BAA4B,CAC3C,yBAAyB,EAAE,mBAAmB,GAAG,SAAS,EAC1D,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,uBAAuB,KAAK,IAAI,GAClD,IAAI,CAoBN"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { checkLayerCompatibility, } from "@fluid-internal/client-utils";
|
|
6
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
8
|
+
/**
|
|
9
|
+
* Loader's compatibility details that is exposed to the Runtime layer.
|
|
10
|
+
*/
|
|
11
|
+
export const LoaderCompatDetails = {
|
|
12
|
+
/**
|
|
13
|
+
* The package version of the Loader layer.
|
|
14
|
+
*/
|
|
15
|
+
pkgVersion,
|
|
16
|
+
/**
|
|
17
|
+
* The current generation of the Loader layer.
|
|
18
|
+
*/
|
|
19
|
+
generation: 1,
|
|
20
|
+
/**
|
|
21
|
+
* The features supported by the Loader layer across the Loader / Runtime boundary.
|
|
22
|
+
*/
|
|
23
|
+
supportedFeatures: new Set(),
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The requirements that the Runtime layer must meet to be compatible with this Loader.
|
|
27
|
+
*/
|
|
28
|
+
export const RuntimeSupportRequirements = {
|
|
29
|
+
/**
|
|
30
|
+
* Minimum generation that Runtime must be at to be compatible with Loader. Note that 0 is used here for
|
|
31
|
+
* Runtime layers before the introduction of the layer compatibility enforcement.
|
|
32
|
+
*/
|
|
33
|
+
minSupportedGeneration: 0,
|
|
34
|
+
/**
|
|
35
|
+
* The features that the Runtime must support to be compatible with Loader.
|
|
36
|
+
*/
|
|
37
|
+
requiredFeatures: [],
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Validates that the Runtime layer is compatible with the Loader.
|
|
41
|
+
*/
|
|
42
|
+
export function validateRuntimeCompatibility(maybeRuntimeCompatDetails, disposeFn) {
|
|
43
|
+
const layerCheckResult = checkLayerCompatibility(RuntimeSupportRequirements, maybeRuntimeCompatDetails);
|
|
44
|
+
if (!layerCheckResult.isCompatible) {
|
|
45
|
+
const error = new UsageError("Loader is not compatible with Runtime", {
|
|
46
|
+
errorDetails: JSON.stringify({
|
|
47
|
+
loaderVersion: LoaderCompatDetails.pkgVersion,
|
|
48
|
+
runtimeVersion: maybeRuntimeCompatDetails?.pkgVersion,
|
|
49
|
+
loaderGeneration: LoaderCompatDetails.generation,
|
|
50
|
+
runtimeGeneration: maybeRuntimeCompatDetails?.generation,
|
|
51
|
+
minSupportedGeneration: RuntimeSupportRequirements.minSupportedGeneration,
|
|
52
|
+
isGenerationCompatible: layerCheckResult.isGenerationCompatible,
|
|
53
|
+
unsupportedFeatures: layerCheckResult.unsupportedFeatures,
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
56
|
+
disposeFn(error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=layerCompatState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerCompatState.js","sourceRoot":"","sources":["../src/layerCompatState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,uBAAuB,GAGvB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAwB;IACvD;;OAEG;IACH,UAAU;IACV;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,EAAU;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAoC;IAC1E;;;OAGG;IACH,sBAAsB,EAAE,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,EAAE;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC3C,yBAA0D,EAC1D,SAAoD;IAEpD,MAAM,gBAAgB,GAAG,uBAAuB,CAC/C,0BAA0B,EAC1B,yBAAyB,CACzB,CAAC;IACF,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,uCAAuC,EAAE;YACrE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC;gBAC5B,aAAa,EAAE,mBAAmB,CAAC,UAAU;gBAC7C,cAAc,EAAE,yBAAyB,EAAE,UAAU;gBACrD,gBAAgB,EAAE,mBAAmB,CAAC,UAAU;gBAChD,iBAAiB,EAAE,yBAAyB,EAAE,UAAU;gBACxD,sBAAsB,EAAE,0BAA0B,CAAC,sBAAsB;gBACzE,sBAAsB,EAAE,gBAAgB,CAAC,sBAAsB;gBAC/D,mBAAmB,EAAE,gBAAgB,CAAC,mBAAmB;aACzD,CAAC;SACF,CAAC,CAAC;QACH,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tcheckLayerCompatibility,\n\ttype ILayerCompatDetails,\n\ttype ILayerCompatSupportRequirements,\n} from \"@fluid-internal/client-utils\";\nimport type { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Loader's compatibility details that is exposed to the Runtime layer.\n */\nexport const LoaderCompatDetails: ILayerCompatDetails = {\n\t/**\n\t * The package version of the Loader layer.\n\t */\n\tpkgVersion,\n\t/**\n\t * The current generation of the Loader layer.\n\t */\n\tgeneration: 1,\n\t/**\n\t * The features supported by the Loader layer across the Loader / Runtime boundary.\n\t */\n\tsupportedFeatures: new Set<string>(),\n};\n\n/**\n * The requirements that the Runtime layer must meet to be compatible with this Loader.\n */\nexport const RuntimeSupportRequirements: ILayerCompatSupportRequirements = {\n\t/**\n\t * Minimum generation that Runtime must be at to be compatible with Loader. Note that 0 is used here for\n\t * Runtime layers before the introduction of the layer compatibility enforcement.\n\t */\n\tminSupportedGeneration: 0,\n\t/**\n\t * The features that the Runtime must support to be compatible with Loader.\n\t */\n\trequiredFeatures: [],\n};\n\n/**\n * Validates that the Runtime layer is compatible with the Loader.\n */\nexport function validateRuntimeCompatibility(\n\tmaybeRuntimeCompatDetails: ILayerCompatDetails | undefined,\n\tdisposeFn: (error?: ICriticalContainerError) => void,\n): void {\n\tconst layerCheckResult = checkLayerCompatibility(\n\t\tRuntimeSupportRequirements,\n\t\tmaybeRuntimeCompatDetails,\n\t);\n\tif (!layerCheckResult.isCompatible) {\n\t\tconst error = new UsageError(\"Loader is not compatible with Runtime\", {\n\t\t\terrorDetails: JSON.stringify({\n\t\t\t\tloaderVersion: LoaderCompatDetails.pkgVersion,\n\t\t\t\truntimeVersion: maybeRuntimeCompatDetails?.pkgVersion,\n\t\t\t\tloaderGeneration: LoaderCompatDetails.generation,\n\t\t\t\truntimeGeneration: maybeRuntimeCompatDetails?.generation,\n\t\t\t\tminSupportedGeneration: RuntimeSupportRequirements.minSupportedGeneration,\n\t\t\t\tisGenerationCompatible: layerCheckResult.isGenerationCompatible,\n\t\t\t\tunsupportedFeatures: layerCheckResult.unsupportedFeatures,\n\t\t\t}),\n\t\t});\n\t\tdisposeFn(error);\n\t\tthrow error;\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.21.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.21.0\";\n"]}
|
package/lib/protocol/quorum.d.ts
CHANGED
|
@@ -99,11 +99,6 @@ export declare class QuorumProposals extends TypedEventEmitter<IQuorumProposals[
|
|
|
99
99
|
* Returns the consensus value for the given key
|
|
100
100
|
*/
|
|
101
101
|
get(key: string): unknown;
|
|
102
|
-
/**
|
|
103
|
-
* Returns additional data about the approved consensus value
|
|
104
|
-
* @deprecated Removed in recent protocol-definitions. Use get() instead.
|
|
105
|
-
*/
|
|
106
|
-
getApprovalData(key: string): ICommittedProposal | undefined;
|
|
107
102
|
/**
|
|
108
103
|
* Proposes a new value. Returns a promise that will either:
|
|
109
104
|
* - Resolve when the proposal is accepted
|
|
@@ -147,11 +142,6 @@ export declare class Quorum extends TypedEventEmitter<IQuorum["on"]> implements
|
|
|
147
142
|
* Returns the consensus value for the given key
|
|
148
143
|
*/
|
|
149
144
|
get(key: string): unknown;
|
|
150
|
-
/**
|
|
151
|
-
* Returns additional data about the approved consensus value
|
|
152
|
-
* @deprecated Removed in recent protocol-definitions. Use get() instead.
|
|
153
|
-
*/
|
|
154
|
-
getApprovalData(key: string): ICommittedProposal | undefined;
|
|
155
145
|
/**
|
|
156
146
|
* Adds a new client to the quorum
|
|
157
147
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quorum.d.ts","sourceRoot":"","sources":["../../src/protocol/quorum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EACN,yBAAyB,E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G,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,MAAM;IA6B/C,KAAK,IAAI,IAAI;IAIpB;;;OAGG;IACI,QAAQ,IAAI,eAAe;IAUlC;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAInE;;OAEG;IACI,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI3C;;OAEG;IACI,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAIlD;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAIhE;;;OAGG;IACU,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhE;;OAEG;IACI,WAAW,CACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,EACd,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,OAAO,EACd,oBAAoB,EAAE,MAAM,GAC1B,IAAI;IAUP;;;OAGG;IACI,2BAA2B,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAIrE,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAI/D,OAAO,IAAI,IAAI;CAGtB"}
|
package/lib/protocol/quorum.js
CHANGED
|
@@ -130,13 +130,6 @@ export class QuorumProposals extends TypedEventEmitter {
|
|
|
130
130
|
get(key) {
|
|
131
131
|
return this.values.get(key)?.value;
|
|
132
132
|
}
|
|
133
|
-
/**
|
|
134
|
-
* Returns additional data about the approved consensus value
|
|
135
|
-
* @deprecated Removed in recent protocol-definitions. Use get() instead.
|
|
136
|
-
*/
|
|
137
|
-
getApprovalData(key) {
|
|
138
|
-
return this.values.get(key);
|
|
139
|
-
}
|
|
140
133
|
/**
|
|
141
134
|
* Proposes a new value. Returns a promise that will either:
|
|
142
135
|
* - Resolve when the proposal is accepted
|
|
@@ -349,13 +342,6 @@ export class Quorum extends TypedEventEmitter {
|
|
|
349
342
|
get(key) {
|
|
350
343
|
return this.quorumProposals.get(key);
|
|
351
344
|
}
|
|
352
|
-
/**
|
|
353
|
-
* Returns additional data about the approved consensus value
|
|
354
|
-
* @deprecated Removed in recent protocol-definitions. Use get() instead.
|
|
355
|
-
*/
|
|
356
|
-
getApprovalData(key) {
|
|
357
|
-
return this.quorumProposals.getApprovalData(key);
|
|
358
|
-
}
|
|
359
345
|
/**
|
|
360
346
|
* Adds a new client to the quorum
|
|
361
347
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quorum.js","sourceRoot":"","sources":["../../src/protocol/quorum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAS7D,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;AAEpC;;GAEG;AACH,MAAM,eAAe;IACpB,YACiB,cAAsB,EACtB,GAAW,EACX,KAAc,EACd,KAAc;QAHd,mBAAc,GAAd,cAAc,CAAQ;QACtB,QAAG,GAAH,GAAG,CAAQ;QACX,UAAK,GAAL,KAAK,CAAS;QACd,UAAK,GAAL,KAAK,CAAS;IAC5B,CAAC;CACJ;AA+BD;;;GAGG;AACH,MAAM,OAAO,aACZ,SAAQ,iBAAuC;IAK/C,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAQD,YAAY,QAA+B;QAC1C,KAAK,EAAE,CAAC;QAZD,eAAU,GAAY,KAAK,CAAC;QA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e,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,WAAW,CACjB,GAAW,EACX,KAAc,EACd,cAAsB,EACtB,KAAc,EACd,oBAA4B;QAE5B,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CACtC,GAAG,EACH,KAAK,EACL,cAAc,EACd,KAAK,EACL,oBAAoB,CACpB,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,2BAA2B,CAAC,OAAkC;QACpE,IAAI,CAAC,eAAe,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IAEM,kBAAkB,CAAC,SAAkB,EAAE,QAAiB;QAC9D,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAEM,OAAO;QACb,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IQuorumClients, ISequencedClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tISequencedDocumentMessage,\n\tICommittedProposal,\n\tIQuorum,\n\tIQuorumProposals,\n\tISequencedProposal,\n} from \"@fluidframework/driver-definitions/internal\";\nimport events_pkg from \"events_pkg\";\nconst { EventEmitter } = events_pkg;\n\n/**\n * Structure for tracking proposals that have been sequenced but not approved yet.\n */\nclass PendingProposal implements ISequencedProposal {\n\tconstructor(\n\t\tpublic readonly sequenceNumber: number,\n\t\tpublic readonly key: string,\n\t\tpublic readonly value: unknown,\n\t\tpublic readonly local: boolean,\n\t) {}\n}\n\n/**\n * Snapshot format for a QuorumClients\n * @legacy\n * @alpha\n */\nexport type QuorumClientsSnapshot = [string, ISequencedClient][];\n\n/**\n * Snapshot format for a QuorumProposals\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type QuorumProposalsSnapshot = {\n\tproposals: [number, ISequencedProposal, string[]][];\n\tvalues: [string, ICommittedProposal][];\n};\n\n/**\n * Snapshot format for a Quorum\n * @legacy\n * @alpha\n */\nexport interface IQuorumSnapshot {\n\tmembers: QuorumClientsSnapshot;\n\tproposals: QuorumProposalsSnapshot[\"proposals\"];\n\tvalues: QuorumProposalsSnapshot[\"values\"];\n}\n\n/**\n * The QuorumClients is used to track members joining and leaving the collaboration session.\n * @internal\n */\nexport class QuorumClients\n\textends TypedEventEmitter<IQuorumClients[\"on\"]>\n\timplements IQuorumClients\n{\n\tprivate readonly members: Map<string, ISequencedClient>;\n\tprivate isDisposed: boolean = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\n\t/**\n\t * Cached snapshot state, to avoid unnecessary deep clones on repeated snapshot calls.\n\t * Cleared immediately (set to undefined) when the cache becomes invalid.\n\t */\n\tprivate snapshotCache: QuorumClientsSnapshot | undefined;\n\n\tconstructor(snapshot: QuorumClientsSnapshot) {\n\t\tsuper();\n\n\t\tthis.members = new Map(snapshot);\n\t\tthis.snapshotCache = snapshot;\n\t}\n\n\t/**\n\t * Snapshots the current state of the QuorumClients\n\t * @returns a snapshot of the clients in the quorum\n\t */\n\tpublic snapshot(): QuorumClientsSnapshot {\n\t\tthis.snapshotCache ??= [...this.members];\n\n\t\treturn this.snapshotCache;\n\t}\n\n\t/**\n\t * Adds a new client to the quorum\n\t */\n\tpublic addMember(clientId: string, details: ISequencedClient): void {\n\t\tassert(!!clientId, 0x9a0 /* clientId has to be non-empty string */);\n\t\tassert(!this.members.has(clientId), 0x9a1 /* clientId not found */);\n\t\tthis.members.set(clientId, details);\n\t\tthis.emit(\"addMember\", clientId, details);\n\n\t\t// clear the cache\n\t\tthis.snapshotCache = undefined;\n\t}\n\n\t/**\n\t * Removes a client from the quorum\n\t */\n\tpublic removeMember(clientId: string): void {\n\t\tassert(!!clientId, 0x9a2 /* clientId has to be non-empty string */);\n\t\tassert(this.members.has(clientId), 0x9a3 /* clientId not found */);\n\t\tthis.members.delete(clientId);\n\t\tthis.emit(\"removeMember\", clientId);\n\n\t\t// clear the cache\n\t\tthis.snapshotCache = undefined;\n\t}\n\n\t/**\n\t * Retrieves all the members in the quorum\n\t */\n\tpublic getMembers(): Map<string, ISequencedClient> {\n\t\treturn new Map(this.members);\n\t}\n\n\t/**\n\t * Retrieves a specific member of the quorum\n\t */\n\tpublic getMember(clientId: string): ISequencedClient | undefined {\n\t\treturn this.members.get(clientId);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.isDisposed = true;\n\t}\n}\n\n/**\n * The QuorumProposals holds a key/value store. Proposed values become finalized in the store once all connected\n * clients have seen the proposal.\n * @internal\n */\nexport class QuorumProposals\n\textends TypedEventEmitter<IQuorumProposals[\"on\"]>\n\timplements IQuorumProposals\n{\n\tprivate readonly proposals: Map<number, PendingProposal>;\n\tprivate readonly values: Map<string, ICommittedProposal>;\n\tprivate isDisposed: boolean = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\n\t// Event emitter for changes to the environment that affect pending proposal promises.\n\tprivate readonly stateEvents = new EventEmitter();\n\n\t/**\n\t * Cached snapshot state, to avoid unnecessary deep clones on repeated snapshot calls.\n\t * Cleared immediately (set to undefined) when the cache becomes invalid.\n\t */\n\tprivate proposalsSnapshotCache: QuorumProposalsSnapshot[\"proposals\"] | undefined;\n\tprivate valuesSnapshotCache: QuorumProposalsSnapshot[\"values\"] | undefined;\n\n\tconstructor(\n\t\tsnapshot: QuorumProposalsSnapshot,\n\t\tprivate readonly sendProposal: (key: string, value: unknown) => number,\n\t) {\n\t\tsuper();\n\n\t\tthis.proposals = new Map(\n\t\t\tsnapshot.proposals.map(([, proposal]) => {\n\t\t\t\treturn [\n\t\t\t\t\tproposal.sequenceNumber,\n\t\t\t\t\tnew PendingProposal(\n\t\t\t\t\t\tproposal.sequenceNumber,\n\t\t\t\t\t\tproposal.key,\n\t\t\t\t\t\tproposal.value,\n\t\t\t\t\t\tfalse, // local\n\t\t\t\t\t),\n\t\t\t\t] as [number, PendingProposal];\n\t\t\t}),\n\t\t);\n\t\tthis.values = new Map(snapshot.values);\n\t\tthis.proposalsSnapshotCache = snapshot.proposals;\n\t\tthis.valuesSnapshotCache = snapshot.values;\n\t}\n\n\t/**\n\t * Snapshots the current state of the QuorumProposals\n\t * @returns arrays of proposals and values\n\t */\n\tpublic snapshot(): QuorumProposalsSnapshot {\n\t\tthis.proposalsSnapshotCache ??= [...this.proposals].map(([sequenceNumber, proposal]) => [\n\t\t\tsequenceNumber,\n\t\t\t{ sequenceNumber, key: proposal.key, value: proposal.value },\n\t\t\t[], // rejections, which has been removed\n\t\t]);\n\t\tthis.valuesSnapshotCache ??= [...this.values];\n\n\t\treturn {\n\t\t\tproposals: this.proposalsSnapshotCache,\n\t\t\tvalues: this.valuesSnapshotCache,\n\t\t};\n\t}\n\n\t/**\n\t * Returns whether the quorum has achieved a consensus for the given key.\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.values.has(key);\n\t}\n\n\t/**\n\t * Returns the consensus value for the given key\n\t */\n\tpublic get(key: string): unknown {\n\t\treturn this.values.get(key)?.value;\n\t}\n\n\t/**\n\t * Returns additional data about the approved consensus value\n\t * @deprecated Removed in recent protocol-definitions. Use get() instead.\n\t */\n\tpublic getApprovalData(key: string): ICommittedProposal | undefined {\n\t\treturn this.values.get(key);\n\t}\n\n\t/**\n\t * Proposes a new value. Returns a promise that will either:\n\t * - Resolve when the proposal is accepted\n\t * - Reject if the proposal fails to send or if the QuorumProposals is disposed\n\t */\n\tpublic async propose(key: string, value: unknown): Promise<void> {\n\t\tconst clientSequenceNumber = this.sendProposal(key, value);\n\t\tif (clientSequenceNumber < 0) {\n\t\t\tthis.emit(\"error\", { eventName: \"ProposalInDisconnectedState\", key });\n\t\t\tthrow new Error(\"Can't propose in disconnected state\");\n\t\t}\n\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t// The sequence number that our proposal was assigned and went pending.\n\t\t\t// If undefined, then it's not sequenced yet.\n\t\t\tlet thisProposalSequenceNumber: number | undefined;\n\n\t\t\t// A proposal goes through two phases before this promise resolves:\n\t\t\t// 1. Sequencing - waiting for the proposal to be ack'd by the server.\n\t\t\t// 2. Approval - waiting for the proposal to be approved by connected clients.\n\t\t\tconst localProposalSequencedHandler = (\n\t\t\t\tsequencedCSN: number,\n\t\t\t\tsequenceNumber: number,\n\t\t\t): void => {\n\t\t\t\tif (sequencedCSN === clientSequenceNumber) {\n\t\t\t\t\tthisProposalSequenceNumber = sequenceNumber;\n\t\t\t\t\tthis.stateEvents.off(\"localProposalSequenced\", localProposalSequencedHandler);\n\t\t\t\t\tthis.stateEvents.off(\"disconnected\", disconnectedHandler);\n\t\t\t\t\tthis.stateEvents.on(\"localProposalApproved\", localProposalApprovedHandler);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst localProposalApprovedHandler = (sequenceNumber: number): void => {\n\t\t\t\t// Proposals can be uniquely identified by the sequenceNumber they were assigned.\n\t\t\t\tif (sequenceNumber === thisProposalSequenceNumber) {\n\t\t\t\t\tresolve();\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// There are two error flows we consider: disconnect and disposal.\n\t\t\t// If we get disconnected before the proposal is sequenced, it has one of two possible futures:\n\t\t\t// 1. We reconnect and see the proposal was sequenced in the meantime.\n\t\t\t// -> The promise can still resolve, once it is approved.\n\t\t\t// 2. We reconnect and see the proposal was not sequenced in the meantime, so it will never sequence.\n\t\t\t// -> The promise rejects.\n\t\t\tconst disconnectedHandler = (): void => {\n\t\t\t\t// If we haven't seen the ack by the time we disconnect, we hope to see it by the time we reconnect.\n\t\t\t\tif (thisProposalSequenceNumber === undefined) {\n\t\t\t\t\tthis.stateEvents.once(\"connected\", () => {\n\t\t\t\t\t\t// If we don't see the ack by the time reconnection finishes, it failed to send.\n\t\t\t\t\t\tif (thisProposalSequenceNumber === undefined) {\n\t\t\t\t\t\t\treject(new Error(\"Client disconnected without successfully sending proposal\"));\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t\t// If the QuorumProposals is disposed of, we assume something catastrophic has happened\n\t\t\t// All outstanding proposals are considered rejected.\n\t\t\tconst disposedHandler = (): void => {\n\t\t\t\treject(new Error(\"QuorumProposals was disposed\"));\n\t\t\t\tremoveListeners();\n\t\t\t};\n\t\t\t// Convenience function to clean up our listeners.\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.stateEvents.off(\"localProposalSequenced\", localProposalSequencedHandler);\n\t\t\t\tthis.stateEvents.off(\"localProposalApproved\", localProposalApprovedHandler);\n\t\t\t\tthis.stateEvents.off(\"disconnected\", disconnectedHandler);\n\t\t\t\tthis.stateEvents.off(\"disposed\", disposedHandler);\n\t\t\t};\n\t\t\tthis.stateEvents.on(\"localProposalSequenced\", localProposalSequencedHandler);\n\t\t\tthis.stateEvents.on(\"disconnected\", disconnectedHandler);\n\t\t\tthis.stateEvents.on(\"disposed\", disposedHandler);\n\t\t});\n\t}\n\n\t/**\n\t * Begins tracking a new proposal\n\t */\n\tpublic addProposal(\n\t\tkey: string,\n\t\tvalue: unknown,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t\tclientSequenceNumber: number,\n\t): void {\n\t\tassert(!this.proposals.has(sequenceNumber), 0x9a4 /* sequenceNumber not found */);\n\n\t\tconst proposal = new PendingProposal(sequenceNumber, key, value, local);\n\t\tthis.proposals.set(sequenceNumber, proposal);\n\n\t\t// Legacy event, from rejection support. May still have some use for clients to learn that a proposal is\n\t\t// likely to be approved soon.\n\t\tthis.emit(\"addProposal\", proposal);\n\n\t\tif (local) {\n\t\t\tthis.stateEvents.emit(\"localProposalSequenced\", clientSequenceNumber, sequenceNumber);\n\t\t}\n\n\t\t// clear the proposal cache\n\t\tthis.proposalsSnapshotCache = undefined;\n\t}\n\n\t/**\n\t * Updates the minimum sequence number. If the MSN advances past the sequence number for any proposal then it\n\t * becomes an approved value.\n\t */\n\tpublic updateMinimumSequenceNumber(message: ISequencedDocumentMessage): void {\n\t\tconst msn = message.minimumSequenceNumber;\n\n\t\t// Accept proposals proposals whose sequenceNumber is <= the minimumSequenceNumber\n\n\t\t// Return a sorted list of approved proposals. We sort so that we apply them in their sequence number order\n\t\t// TODO this can be optimized if necessary to avoid the linear search+sort\n\t\tconst completed: PendingProposal[] = [];\n\t\tfor (const [sequenceNumber, proposal] of this.proposals) {\n\t\t\tif (sequenceNumber <= msn) {\n\t\t\t\tcompleted.push(proposal);\n\t\t\t}\n\t\t}\n\t\tcompleted.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\n\t\tfor (const proposal of completed) {\n\t\t\tconst committedProposal: ICommittedProposal = {\n\t\t\t\tapprovalSequenceNumber: message.sequenceNumber,\n\t\t\t\t// No longer used. We still stamp a -1 for compat with older versions of the quorum.\n\t\t\t\t// Can be removed after 0.1035 and higher is ubiquitous.\n\t\t\t\tcommitSequenceNumber: -1,\n\t\t\t\tkey: proposal.key,\n\t\t\t\tsequenceNumber: proposal.sequenceNumber,\n\t\t\t\tvalue: proposal.value,\n\t\t\t};\n\n\t\t\tthis.values.set(committedProposal.key, committedProposal);\n\n\t\t\t// clear the values cache\n\t\t\tthis.valuesSnapshotCache = undefined;\n\n\t\t\t// check if there are multiple proposals with matching keys\n\t\t\tlet proposalSettled = false;\n\t\t\tlet proposalKeySeen = false;\n\t\t\tfor (const [, p] of this.proposals) {\n\t\t\t\tif (p.key === committedProposal.key) {\n\t\t\t\t\tif (proposalKeySeen) {\n\t\t\t\t\t\t// set proposalSettled to false if matching proposal key is not unique\n\t\t\t\t\t\tproposalSettled = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// set proposalSettled to true if the proposal key match is unique thus far\n\t\t\t\t\t\tproposalSettled = true;\n\t\t\t\t\t}\n\t\t\t\t\tproposalKeySeen = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.emit(\n\t\t\t\t\"approveProposal\",\n\t\t\t\tcommittedProposal.sequenceNumber,\n\t\t\t\tcommittedProposal.key,\n\t\t\t\tcommittedProposal.value,\n\t\t\t\tcommittedProposal.approvalSequenceNumber,\n\t\t\t);\n\n\t\t\t// emit approveProposalComplete when all pending proposals are processed\n\t\t\tif (proposalSettled) {\n\t\t\t\tthis.emit(\n\t\t\t\t\t\"approveProposalComplete\",\n\t\t\t\t\tcommittedProposal.sequenceNumber,\n\t\t\t\t\tcommittedProposal.key,\n\t\t\t\t\tcommittedProposal.value,\n\t\t\t\t\tcommittedProposal.approvalSequenceNumber,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.proposals.delete(proposal.sequenceNumber);\n\n\t\t\t// clear the proposals cache\n\t\t\tthis.proposalsSnapshotCache = undefined;\n\t\t\tif (proposal.local) {\n\t\t\t\tthis.stateEvents.emit(\"localProposalApproved\", proposal.sequenceNumber);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic setConnectionState(connected: boolean): void {\n\t\tif (connected) {\n\t\t\tthis.stateEvents.emit(\"connected\");\n\t\t} else {\n\t\t\tthis.stateEvents.emit(\"disconnected\");\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.isDisposed = true;\n\t\tthis.stateEvents.emit(\"disposed\");\n\t}\n}\n\n/**\n * A quorum represents all clients currently within the collaboration window. As well as the values\n * they have agreed upon and any pending proposals.\n * @internal\n */\nexport class Quorum extends TypedEventEmitter<IQuorum[\"on\"]> implements IQuorum {\n\tprivate readonly quorumClients: QuorumClients;\n\tprivate readonly quorumProposals: QuorumProposals;\n\tprivate readonly isDisposed: boolean = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\n\tconstructor(\n\t\tmembers: QuorumClientsSnapshot,\n\t\tproposals: QuorumProposalsSnapshot[\"proposals\"],\n\t\tvalues: QuorumProposalsSnapshot[\"values\"],\n\t\tsendProposal: (key: string, value: unknown) => number,\n\t) {\n\t\tsuper();\n\n\t\tthis.quorumClients = new QuorumClients(members);\n\t\tthis.quorumClients.on(\"addMember\", (clientId: string, details: ISequencedClient) => {\n\t\t\tthis.emit(\"addMember\", clientId, details);\n\t\t});\n\t\tthis.quorumClients.on(\"removeMember\", (clientId: string) => {\n\t\t\tthis.emit(\"removeMember\", clientId);\n\t\t});\n\n\t\tthis.quorumProposals = new QuorumProposals({ proposals, values }, sendProposal);\n\t\tthis.quorumProposals.on(\"addProposal\", (proposal: ISequencedProposal) => {\n\t\t\tthis.emit(\"addProposal\", proposal);\n\t\t});\n\t\tthis.quorumProposals.on(\n\t\t\t\"approveProposal\",\n\t\t\t(\n\t\t\t\tsequenceNumber: number,\n\t\t\t\tkey: string,\n\t\t\t\tvalue: unknown,\n\t\t\t\tapprovalSequenceNumber: number,\n\t\t\t) => {\n\t\t\t\tthis.emit(\"approveProposal\", sequenceNumber, key, value, approvalSequenceNumber);\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic close(): void {\n\t\tthis.removeAllListeners();\n\t}\n\n\t/**\n\t * Snapshots the entire quorum\n\t * @returns a quorum snapshot\n\t */\n\tpublic snapshot(): IQuorumSnapshot {\n\t\tconst members = this.quorumClients.snapshot();\n\t\tconst { proposals, values } = this.quorumProposals.snapshot();\n\t\treturn {\n\t\t\tmembers,\n\t\t\tproposals,\n\t\t\tvalues,\n\t\t};\n\t}\n\n\t/**\n\t * Returns whether the quorum has achieved a consensus for the given key.\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.quorumProposals.has(key);\n\t}\n\n\t/**\n\t * Returns the consensus value for the given key\n\t */\n\tpublic get(key: string): unknown {\n\t\treturn this.quorumProposals.get(key);\n\t}\n\n\t/**\n\t * Returns additional data about the approved consensus value\n\t * @deprecated Removed in recent protocol-definitions. Use get() instead.\n\t */\n\tpublic getApprovalData(key: string): ICommittedProposal | undefined {\n\t\treturn this.quorumProposals.getApprovalData(key);\n\t}\n\n\t/**\n\t * Adds a new client to the quorum\n\t */\n\tpublic addMember(clientId: string, details: ISequencedClient): void {\n\t\tthis.quorumClients.addMember(clientId, details);\n\t}\n\n\t/**\n\t * Removes a client from the quorum\n\t */\n\tpublic removeMember(clientId: string): void {\n\t\tthis.quorumClients.removeMember(clientId);\n\t}\n\n\t/**\n\t * Retrieves all the members in the quorum\n\t */\n\tpublic getMembers(): Map<string, ISequencedClient> {\n\t\treturn this.quorumClients.getMembers();\n\t}\n\n\t/**\n\t * Retrieves a specific member of the quorum\n\t */\n\tpublic getMember(clientId: string): ISequencedClient | undefined {\n\t\treturn this.quorumClients.getMember(clientId);\n\t}\n\n\t/**\n\t * Proposes a new value. Returns a promise that will resolve when the proposal is either accepted, or reject if\n\t * the proposal fails to send.\n\t */\n\tpublic async propose(key: string, value: unknown): Promise<void> {\n\t\treturn this.quorumProposals.propose(key, value);\n\t}\n\n\t/**\n\t * Begins tracking a new proposal\n\t */\n\tpublic addProposal(\n\t\tkey: string,\n\t\tvalue: unknown,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t\tclientSequenceNumber: number,\n\t): void {\n\t\treturn this.quorumProposals.addProposal(\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\tsequenceNumber,\n\t\t\tlocal,\n\t\t\tclientSequenceNumber,\n\t\t);\n\t}\n\n\t/**\n\t * Updates the minimum sequence number. If the MSN advances past the sequence number for any proposal then it\n\t * becomes an approved value.\n\t */\n\tpublic updateMinimumSequenceNumber(message: ISequencedDocumentMessage): void {\n\t\tthis.quorumProposals.updateMinimumSequenceNumber(message);\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string): void {\n\t\tthis.quorumProposals.setConnectionState(connected);\n\t}\n\n\tpublic dispose(): void {\n\t\tthrow new Error(\"Not implemented.\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"quorum.js","sourceRoot":"","sources":["../../src/protocol/quorum.ts"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,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,QAAgB;QACnC,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,UAAU;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,QAAgB;QAChC,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAc;QAC/C,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,WAAW,CACjB,GAAW,EACX,KAAc,EACd,cAAsB,EACtB,KAAc,EACd,oBAA4B;QAE5B,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CACtC,GAAG,EACH,KAAK,EACL,cAAc,EACd,KAAK,EACL,oBAAoB,CACpB,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,2BAA2B,CAAC,OAAkC;QACpE,IAAI,CAAC,eAAe,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IAEM,kBAAkB,CAAC,SAAkB,EAAE,QAAiB;QAC9D,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAEM,OAAO;QACb,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IQuorumClients, ISequencedClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tISequencedDocumentMessage,\n\tICommittedProposal,\n\tIQuorum,\n\tIQuorumProposals,\n\tISequencedProposal,\n} from \"@fluidframework/driver-definitions/internal\";\nimport events_pkg from \"events_pkg\";\nconst { EventEmitter } = events_pkg;\n\n/**\n * Structure for tracking proposals that have been sequenced but not approved yet.\n */\nclass PendingProposal implements ISequencedProposal {\n\tconstructor(\n\t\tpublic readonly sequenceNumber: number,\n\t\tpublic readonly key: string,\n\t\tpublic readonly value: unknown,\n\t\tpublic readonly local: boolean,\n\t) {}\n}\n\n/**\n * Snapshot format for a QuorumClients\n * @legacy\n * @alpha\n */\nexport type QuorumClientsSnapshot = [string, ISequencedClient][];\n\n/**\n * Snapshot format for a QuorumProposals\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type QuorumProposalsSnapshot = {\n\tproposals: [number, ISequencedProposal, string[]][];\n\tvalues: [string, ICommittedProposal][];\n};\n\n/**\n * Snapshot format for a Quorum\n * @legacy\n * @alpha\n */\nexport interface IQuorumSnapshot {\n\tmembers: QuorumClientsSnapshot;\n\tproposals: QuorumProposalsSnapshot[\"proposals\"];\n\tvalues: QuorumProposalsSnapshot[\"values\"];\n}\n\n/**\n * The QuorumClients is used to track members joining and leaving the collaboration session.\n * @internal\n */\nexport class QuorumClients\n\textends TypedEventEmitter<IQuorumClients[\"on\"]>\n\timplements IQuorumClients\n{\n\tprivate readonly members: Map<string, ISequencedClient>;\n\tprivate isDisposed: boolean = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\n\t/**\n\t * Cached snapshot state, to avoid unnecessary deep clones on repeated snapshot calls.\n\t * Cleared immediately (set to undefined) when the cache becomes invalid.\n\t */\n\tprivate snapshotCache: QuorumClientsSnapshot | undefined;\n\n\tconstructor(snapshot: QuorumClientsSnapshot) {\n\t\tsuper();\n\n\t\tthis.members = new Map(snapshot);\n\t\tthis.snapshotCache = snapshot;\n\t}\n\n\t/**\n\t * Snapshots the current state of the QuorumClients\n\t * @returns a snapshot of the clients in the quorum\n\t */\n\tpublic snapshot(): QuorumClientsSnapshot {\n\t\tthis.snapshotCache ??= [...this.members];\n\n\t\treturn this.snapshotCache;\n\t}\n\n\t/**\n\t * Adds a new client to the quorum\n\t */\n\tpublic addMember(clientId: string, details: ISequencedClient): void {\n\t\tassert(!!clientId, 0x9a0 /* clientId has to be non-empty string */);\n\t\tassert(!this.members.has(clientId), 0x9a1 /* clientId not found */);\n\t\tthis.members.set(clientId, details);\n\t\tthis.emit(\"addMember\", clientId, details);\n\n\t\t// clear the cache\n\t\tthis.snapshotCache = undefined;\n\t}\n\n\t/**\n\t * Removes a client from the quorum\n\t */\n\tpublic removeMember(clientId: string): void {\n\t\tassert(!!clientId, 0x9a2 /* clientId has to be non-empty string */);\n\t\tassert(this.members.has(clientId), 0x9a3 /* clientId not found */);\n\t\tthis.members.delete(clientId);\n\t\tthis.emit(\"removeMember\", clientId);\n\n\t\t// clear the cache\n\t\tthis.snapshotCache = undefined;\n\t}\n\n\t/**\n\t * Retrieves all the members in the quorum\n\t */\n\tpublic getMembers(): Map<string, ISequencedClient> {\n\t\treturn new Map(this.members);\n\t}\n\n\t/**\n\t * Retrieves a specific member of the quorum\n\t */\n\tpublic getMember(clientId: string): ISequencedClient | undefined {\n\t\treturn this.members.get(clientId);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.isDisposed = true;\n\t}\n}\n\n/**\n * The QuorumProposals holds a key/value store. Proposed values become finalized in the store once all connected\n * clients have seen the proposal.\n * @internal\n */\nexport class QuorumProposals\n\textends TypedEventEmitter<IQuorumProposals[\"on\"]>\n\timplements IQuorumProposals\n{\n\tprivate readonly proposals: Map<number, PendingProposal>;\n\tprivate readonly values: Map<string, ICommittedProposal>;\n\tprivate isDisposed: boolean = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\n\t// Event emitter for changes to the environment that affect pending proposal promises.\n\tprivate readonly stateEvents = new EventEmitter();\n\n\t/**\n\t * Cached snapshot state, to avoid unnecessary deep clones on repeated snapshot calls.\n\t * Cleared immediately (set to undefined) when the cache becomes invalid.\n\t */\n\tprivate proposalsSnapshotCache: QuorumProposalsSnapshot[\"proposals\"] | undefined;\n\tprivate valuesSnapshotCache: QuorumProposalsSnapshot[\"values\"] | undefined;\n\n\tconstructor(\n\t\tsnapshot: QuorumProposalsSnapshot,\n\t\tprivate readonly sendProposal: (key: string, value: unknown) => number,\n\t) {\n\t\tsuper();\n\n\t\tthis.proposals = new Map(\n\t\t\tsnapshot.proposals.map(([, proposal]) => {\n\t\t\t\treturn [\n\t\t\t\t\tproposal.sequenceNumber,\n\t\t\t\t\tnew PendingProposal(\n\t\t\t\t\t\tproposal.sequenceNumber,\n\t\t\t\t\t\tproposal.key,\n\t\t\t\t\t\tproposal.value,\n\t\t\t\t\t\tfalse, // local\n\t\t\t\t\t),\n\t\t\t\t] as [number, PendingProposal];\n\t\t\t}),\n\t\t);\n\t\tthis.values = new Map(snapshot.values);\n\t\tthis.proposalsSnapshotCache = snapshot.proposals;\n\t\tthis.valuesSnapshotCache = snapshot.values;\n\t}\n\n\t/**\n\t * Snapshots the current state of the QuorumProposals\n\t * @returns arrays of proposals and values\n\t */\n\tpublic snapshot(): QuorumProposalsSnapshot {\n\t\tthis.proposalsSnapshotCache ??= [...this.proposals].map(([sequenceNumber, proposal]) => [\n\t\t\tsequenceNumber,\n\t\t\t{ sequenceNumber, key: proposal.key, value: proposal.value },\n\t\t\t[], // rejections, which has been removed\n\t\t]);\n\t\tthis.valuesSnapshotCache ??= [...this.values];\n\n\t\treturn {\n\t\t\tproposals: this.proposalsSnapshotCache,\n\t\t\tvalues: this.valuesSnapshotCache,\n\t\t};\n\t}\n\n\t/**\n\t * Returns whether the quorum has achieved a consensus for the given key.\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.values.has(key);\n\t}\n\n\t/**\n\t * Returns the consensus value for the given key\n\t */\n\tpublic get(key: string): unknown {\n\t\treturn this.values.get(key)?.value;\n\t}\n\n\t/**\n\t * Proposes a new value. Returns a promise that will either:\n\t * - Resolve when the proposal is accepted\n\t * - Reject if the proposal fails to send or if the QuorumProposals is disposed\n\t */\n\tpublic async propose(key: string, value: unknown): Promise<void> {\n\t\tconst clientSequenceNumber = this.sendProposal(key, value);\n\t\tif (clientSequenceNumber < 0) {\n\t\t\tthis.emit(\"error\", { eventName: \"ProposalInDisconnectedState\", key });\n\t\t\tthrow new Error(\"Can't propose in disconnected state\");\n\t\t}\n\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t// The sequence number that our proposal was assigned and went pending.\n\t\t\t// If undefined, then it's not sequenced yet.\n\t\t\tlet thisProposalSequenceNumber: number | undefined;\n\n\t\t\t// A proposal goes through two phases before this promise resolves:\n\t\t\t// 1. Sequencing - waiting for the proposal to be ack'd by the server.\n\t\t\t// 2. Approval - waiting for the proposal to be approved by connected clients.\n\t\t\tconst localProposalSequencedHandler = (\n\t\t\t\tsequencedCSN: number,\n\t\t\t\tsequenceNumber: number,\n\t\t\t): void => {\n\t\t\t\tif (sequencedCSN === clientSequenceNumber) {\n\t\t\t\t\tthisProposalSequenceNumber = sequenceNumber;\n\t\t\t\t\tthis.stateEvents.off(\"localProposalSequenced\", localProposalSequencedHandler);\n\t\t\t\t\tthis.stateEvents.off(\"disconnected\", disconnectedHandler);\n\t\t\t\t\tthis.stateEvents.on(\"localProposalApproved\", localProposalApprovedHandler);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst localProposalApprovedHandler = (sequenceNumber: number): void => {\n\t\t\t\t// Proposals can be uniquely identified by the sequenceNumber they were assigned.\n\t\t\t\tif (sequenceNumber === thisProposalSequenceNumber) {\n\t\t\t\t\tresolve();\n\t\t\t\t\tremoveListeners();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// There are two error flows we consider: disconnect and disposal.\n\t\t\t// If we get disconnected before the proposal is sequenced, it has one of two possible futures:\n\t\t\t// 1. We reconnect and see the proposal was sequenced in the meantime.\n\t\t\t// -> The promise can still resolve, once it is approved.\n\t\t\t// 2. We reconnect and see the proposal was not sequenced in the meantime, so it will never sequence.\n\t\t\t// -> The promise rejects.\n\t\t\tconst disconnectedHandler = (): void => {\n\t\t\t\t// If we haven't seen the ack by the time we disconnect, we hope to see it by the time we reconnect.\n\t\t\t\tif (thisProposalSequenceNumber === undefined) {\n\t\t\t\t\tthis.stateEvents.once(\"connected\", () => {\n\t\t\t\t\t\t// If we don't see the ack by the time reconnection finishes, it failed to send.\n\t\t\t\t\t\tif (thisProposalSequenceNumber === undefined) {\n\t\t\t\t\t\t\treject(new Error(\"Client disconnected without successfully sending proposal\"));\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t\t// If the QuorumProposals is disposed of, we assume something catastrophic has happened\n\t\t\t// All outstanding proposals are considered rejected.\n\t\t\tconst disposedHandler = (): void => {\n\t\t\t\treject(new Error(\"QuorumProposals was disposed\"));\n\t\t\t\tremoveListeners();\n\t\t\t};\n\t\t\t// Convenience function to clean up our listeners.\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.stateEvents.off(\"localProposalSequenced\", localProposalSequencedHandler);\n\t\t\t\tthis.stateEvents.off(\"localProposalApproved\", localProposalApprovedHandler);\n\t\t\t\tthis.stateEvents.off(\"disconnected\", disconnectedHandler);\n\t\t\t\tthis.stateEvents.off(\"disposed\", disposedHandler);\n\t\t\t};\n\t\t\tthis.stateEvents.on(\"localProposalSequenced\", localProposalSequencedHandler);\n\t\t\tthis.stateEvents.on(\"disconnected\", disconnectedHandler);\n\t\t\tthis.stateEvents.on(\"disposed\", disposedHandler);\n\t\t});\n\t}\n\n\t/**\n\t * Begins tracking a new proposal\n\t */\n\tpublic addProposal(\n\t\tkey: string,\n\t\tvalue: unknown,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t\tclientSequenceNumber: number,\n\t): void {\n\t\tassert(!this.proposals.has(sequenceNumber), 0x9a4 /* sequenceNumber not found */);\n\n\t\tconst proposal = new PendingProposal(sequenceNumber, key, value, local);\n\t\tthis.proposals.set(sequenceNumber, proposal);\n\n\t\t// Legacy event, from rejection support. May still have some use for clients to learn that a proposal is\n\t\t// likely to be approved soon.\n\t\tthis.emit(\"addProposal\", proposal);\n\n\t\tif (local) {\n\t\t\tthis.stateEvents.emit(\"localProposalSequenced\", clientSequenceNumber, sequenceNumber);\n\t\t}\n\n\t\t// clear the proposal cache\n\t\tthis.proposalsSnapshotCache = undefined;\n\t}\n\n\t/**\n\t * Updates the minimum sequence number. If the MSN advances past the sequence number for any proposal then it\n\t * becomes an approved value.\n\t */\n\tpublic updateMinimumSequenceNumber(message: ISequencedDocumentMessage): void {\n\t\tconst msn = message.minimumSequenceNumber;\n\n\t\t// Accept proposals proposals whose sequenceNumber is <= the minimumSequenceNumber\n\n\t\t// Return a sorted list of approved proposals. We sort so that we apply them in their sequence number order\n\t\t// TODO this can be optimized if necessary to avoid the linear search+sort\n\t\tconst completed: PendingProposal[] = [];\n\t\tfor (const [sequenceNumber, proposal] of this.proposals) {\n\t\t\tif (sequenceNumber <= msn) {\n\t\t\t\tcompleted.push(proposal);\n\t\t\t}\n\t\t}\n\t\tcompleted.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\n\t\tfor (const proposal of completed) {\n\t\t\tconst committedProposal: ICommittedProposal = {\n\t\t\t\tapprovalSequenceNumber: message.sequenceNumber,\n\t\t\t\t// No longer used. We still stamp a -1 for compat with older versions of the quorum.\n\t\t\t\t// Can be removed after 0.1035 and higher is ubiquitous.\n\t\t\t\tcommitSequenceNumber: -1,\n\t\t\t\tkey: proposal.key,\n\t\t\t\tsequenceNumber: proposal.sequenceNumber,\n\t\t\t\tvalue: proposal.value,\n\t\t\t};\n\n\t\t\tthis.values.set(committedProposal.key, committedProposal);\n\n\t\t\t// clear the values cache\n\t\t\tthis.valuesSnapshotCache = undefined;\n\n\t\t\t// check if there are multiple proposals with matching keys\n\t\t\tlet proposalSettled = false;\n\t\t\tlet proposalKeySeen = false;\n\t\t\tfor (const [, p] of this.proposals) {\n\t\t\t\tif (p.key === committedProposal.key) {\n\t\t\t\t\tif (proposalKeySeen) {\n\t\t\t\t\t\t// set proposalSettled to false if matching proposal key is not unique\n\t\t\t\t\t\tproposalSettled = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// set proposalSettled to true if the proposal key match is unique thus far\n\t\t\t\t\t\tproposalSettled = true;\n\t\t\t\t\t}\n\t\t\t\t\tproposalKeySeen = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.emit(\n\t\t\t\t\"approveProposal\",\n\t\t\t\tcommittedProposal.sequenceNumber,\n\t\t\t\tcommittedProposal.key,\n\t\t\t\tcommittedProposal.value,\n\t\t\t\tcommittedProposal.approvalSequenceNumber,\n\t\t\t);\n\n\t\t\t// emit approveProposalComplete when all pending proposals are processed\n\t\t\tif (proposalSettled) {\n\t\t\t\tthis.emit(\n\t\t\t\t\t\"approveProposalComplete\",\n\t\t\t\t\tcommittedProposal.sequenceNumber,\n\t\t\t\t\tcommittedProposal.key,\n\t\t\t\t\tcommittedProposal.value,\n\t\t\t\t\tcommittedProposal.approvalSequenceNumber,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.proposals.delete(proposal.sequenceNumber);\n\n\t\t\t// clear the proposals cache\n\t\t\tthis.proposalsSnapshotCache = undefined;\n\t\t\tif (proposal.local) {\n\t\t\t\tthis.stateEvents.emit(\"localProposalApproved\", proposal.sequenceNumber);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic setConnectionState(connected: boolean): void {\n\t\tif (connected) {\n\t\t\tthis.stateEvents.emit(\"connected\");\n\t\t} else {\n\t\t\tthis.stateEvents.emit(\"disconnected\");\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.isDisposed = true;\n\t\tthis.stateEvents.emit(\"disposed\");\n\t}\n}\n\n/**\n * A quorum represents all clients currently within the collaboration window. As well as the values\n * they have agreed upon and any pending proposals.\n * @internal\n */\nexport class Quorum extends TypedEventEmitter<IQuorum[\"on\"]> implements IQuorum {\n\tprivate readonly quorumClients: QuorumClients;\n\tprivate readonly quorumProposals: QuorumProposals;\n\tprivate readonly isDisposed: boolean = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\n\tconstructor(\n\t\tmembers: QuorumClientsSnapshot,\n\t\tproposals: QuorumProposalsSnapshot[\"proposals\"],\n\t\tvalues: QuorumProposalsSnapshot[\"values\"],\n\t\tsendProposal: (key: string, value: unknown) => number,\n\t) {\n\t\tsuper();\n\n\t\tthis.quorumClients = new QuorumClients(members);\n\t\tthis.quorumClients.on(\"addMember\", (clientId: string, details: ISequencedClient) => {\n\t\t\tthis.emit(\"addMember\", clientId, details);\n\t\t});\n\t\tthis.quorumClients.on(\"removeMember\", (clientId: string) => {\n\t\t\tthis.emit(\"removeMember\", clientId);\n\t\t});\n\n\t\tthis.quorumProposals = new QuorumProposals({ proposals, values }, sendProposal);\n\t\tthis.quorumProposals.on(\"addProposal\", (proposal: ISequencedProposal) => {\n\t\t\tthis.emit(\"addProposal\", proposal);\n\t\t});\n\t\tthis.quorumProposals.on(\n\t\t\t\"approveProposal\",\n\t\t\t(\n\t\t\t\tsequenceNumber: number,\n\t\t\t\tkey: string,\n\t\t\t\tvalue: unknown,\n\t\t\t\tapprovalSequenceNumber: number,\n\t\t\t) => {\n\t\t\t\tthis.emit(\"approveProposal\", sequenceNumber, key, value, approvalSequenceNumber);\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic close(): void {\n\t\tthis.removeAllListeners();\n\t}\n\n\t/**\n\t * Snapshots the entire quorum\n\t * @returns a quorum snapshot\n\t */\n\tpublic snapshot(): IQuorumSnapshot {\n\t\tconst members = this.quorumClients.snapshot();\n\t\tconst { proposals, values } = this.quorumProposals.snapshot();\n\t\treturn {\n\t\t\tmembers,\n\t\t\tproposals,\n\t\t\tvalues,\n\t\t};\n\t}\n\n\t/**\n\t * Returns whether the quorum has achieved a consensus for the given key.\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.quorumProposals.has(key);\n\t}\n\n\t/**\n\t * Returns the consensus value for the given key\n\t */\n\tpublic get(key: string): unknown {\n\t\treturn this.quorumProposals.get(key);\n\t}\n\n\t/**\n\t * Adds a new client to the quorum\n\t */\n\tpublic addMember(clientId: string, details: ISequencedClient): void {\n\t\tthis.quorumClients.addMember(clientId, details);\n\t}\n\n\t/**\n\t * Removes a client from the quorum\n\t */\n\tpublic removeMember(clientId: string): void {\n\t\tthis.quorumClients.removeMember(clientId);\n\t}\n\n\t/**\n\t * Retrieves all the members in the quorum\n\t */\n\tpublic getMembers(): Map<string, ISequencedClient> {\n\t\treturn this.quorumClients.getMembers();\n\t}\n\n\t/**\n\t * Retrieves a specific member of the quorum\n\t */\n\tpublic getMember(clientId: string): ISequencedClient | undefined {\n\t\treturn this.quorumClients.getMember(clientId);\n\t}\n\n\t/**\n\t * Proposes a new value. Returns a promise that will resolve when the proposal is either accepted, or reject if\n\t * the proposal fails to send.\n\t */\n\tpublic async propose(key: string, value: unknown): Promise<void> {\n\t\treturn this.quorumProposals.propose(key, value);\n\t}\n\n\t/**\n\t * Begins tracking a new proposal\n\t */\n\tpublic addProposal(\n\t\tkey: string,\n\t\tvalue: unknown,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t\tclientSequenceNumber: number,\n\t): void {\n\t\treturn this.quorumProposals.addProposal(\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\tsequenceNumber,\n\t\t\tlocal,\n\t\t\tclientSequenceNumber,\n\t\t);\n\t}\n\n\t/**\n\t * Updates the minimum sequence number. If the MSN advances past the sequence number for any proposal then it\n\t * becomes an approved value.\n\t */\n\tpublic updateMinimumSequenceNumber(message: ISequencedDocumentMessage): void {\n\t\tthis.quorumProposals.updateMinimumSequenceNumber(message);\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string): void {\n\t\tthis.quorumProposals.setConnectionState(connected);\n\t}\n\n\tpublic dispose(): void {\n\t\tthrow new Error(\"Not implemented.\");\n\t}\n}\n"]}
|