@fluidframework/container-loader 2.20.0 → 2.22.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/.mocharc.cjs +3 -0
- package/CHANGELOG.md +8 -0
- package/README.md +1 -0
- package/dist/connectionManager.js +7 -7
- package/dist/connectionManager.js.map +1 -1
- package/dist/container.d.ts +2 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +21 -18
- 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/loader.js +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol/quorum.d.ts +0 -10
- package/dist/protocol/quorum.d.ts.map +1 -1
- package/dist/protocol/quorum.js +4 -18
- package/dist/protocol/quorum.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -4
- package/dist/utils.js.map +1 -1
- package/lib/connectionManager.js +8 -8
- package/lib/connectionManager.js.map +1 -1
- package/lib/container.d.ts +2 -2
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +22 -19
- 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/loader.js +1 -1
- package/lib/loader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol/quorum.d.ts +0 -10
- package/lib/protocol/quorum.d.ts.map +1 -1
- package/lib/protocol/quorum.js +4 -18
- package/lib/protocol/quorum.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +2 -4
- package/lib/utils.js.map +1 -1
- package/package.json +16 -16
- package/src/connectionManager.ts +8 -8
- package/src/container.ts +37 -23
- 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
- package/src/utils.ts +2 -5
package/src/containerContext.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type {
|
|
7
|
+
ILayerCompatDetails,
|
|
8
|
+
IProvideLayerCompatDetails,
|
|
9
|
+
} from "@fluid-internal/client-utils";
|
|
6
10
|
import {
|
|
7
11
|
AttachState,
|
|
8
12
|
IAudience,
|
|
@@ -30,10 +34,15 @@ import {
|
|
|
30
34
|
} from "@fluidframework/driver-definitions/internal";
|
|
31
35
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
32
36
|
|
|
37
|
+
import { LoaderCompatDetails } from "./layerCompatState.js";
|
|
38
|
+
|
|
33
39
|
/**
|
|
34
40
|
* {@inheritDoc @fluidframework/container-definitions#IContainerContext}
|
|
35
41
|
*/
|
|
36
|
-
export class ContainerContext implements IContainerContext {
|
|
42
|
+
export class ContainerContext implements IContainerContext, IProvideLayerCompatDetails {
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated - This has been replaced by ILayerCompatDetails.
|
|
45
|
+
*/
|
|
37
46
|
public readonly supportedFeatures: ReadonlyMap<string, unknown> = new Map([
|
|
38
47
|
/**
|
|
39
48
|
* This version of the loader accepts `referenceSequenceNumber`, provided by the container runtime,
|
|
@@ -62,6 +71,10 @@ export class ContainerContext implements IContainerContext {
|
|
|
62
71
|
return this._getConnected();
|
|
63
72
|
}
|
|
64
73
|
|
|
74
|
+
public get ILayerCompatDetails(): ILayerCompatDetails {
|
|
75
|
+
return LoaderCompatDetails;
|
|
76
|
+
}
|
|
77
|
+
|
|
65
78
|
constructor(
|
|
66
79
|
public readonly options: ILoaderOptions,
|
|
67
80
|
public readonly scope: FluidObject,
|
package/src/debugLogger.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { performanceNow } from "@fluid-internal/client-utils";
|
|
7
7
|
import {
|
|
8
8
|
ITelemetryBaseEvent,
|
|
9
9
|
ITelemetryBaseLogger,
|
|
@@ -88,7 +88,7 @@ export class DebugLogger implements ITelemetryBaseLogger {
|
|
|
88
88
|
newEvent.eventName = undefined;
|
|
89
89
|
|
|
90
90
|
let tick = "";
|
|
91
|
-
tick = `tick=${formatTick(
|
|
91
|
+
tick = `tick=${formatTick(performanceNow())}`;
|
|
92
92
|
|
|
93
93
|
// Extract stack to put it last, but also to avoid escaping '\n' in it by JSON.stringify below
|
|
94
94
|
const stack = newEvent.stack ?? "";
|
package/src/deltaQueue.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { TypedEventEmitter,
|
|
6
|
+
import { TypedEventEmitter, performanceNow } from "@fluid-internal/client-utils";
|
|
7
7
|
import {
|
|
8
8
|
IDeltaQueue,
|
|
9
9
|
IDeltaQueueEvents,
|
|
@@ -153,7 +153,7 @@ export class DeltaQueue<T>
|
|
|
153
153
|
count: number;
|
|
154
154
|
duration: number;
|
|
155
155
|
} {
|
|
156
|
-
const start =
|
|
156
|
+
const start = performanceNow();
|
|
157
157
|
let count = 0;
|
|
158
158
|
|
|
159
159
|
// For grouping to work we must process all local messages immediately and in the single turn.
|
|
@@ -169,7 +169,7 @@ export class DeltaQueue<T>
|
|
|
169
169
|
this.emit("op", next);
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
const duration =
|
|
172
|
+
const duration = performanceNow() - start;
|
|
173
173
|
if (this.q.length === 0) {
|
|
174
174
|
this.emit("idle", count, duration);
|
|
175
175
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
checkLayerCompatibility,
|
|
8
|
+
type ILayerCompatDetails,
|
|
9
|
+
type ILayerCompatSupportRequirements,
|
|
10
|
+
} from "@fluid-internal/client-utils";
|
|
11
|
+
import type { ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
12
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
13
|
+
|
|
14
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Loader's compatibility details that is exposed to the Runtime layer.
|
|
18
|
+
*/
|
|
19
|
+
export const LoaderCompatDetails: ILayerCompatDetails = {
|
|
20
|
+
/**
|
|
21
|
+
* The package version of the Loader layer.
|
|
22
|
+
*/
|
|
23
|
+
pkgVersion,
|
|
24
|
+
/**
|
|
25
|
+
* The current generation of the Loader layer.
|
|
26
|
+
*/
|
|
27
|
+
generation: 1,
|
|
28
|
+
/**
|
|
29
|
+
* The features supported by the Loader layer across the Loader / Runtime boundary.
|
|
30
|
+
*/
|
|
31
|
+
supportedFeatures: new Set<string>(),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The requirements that the Runtime layer must meet to be compatible with this Loader.
|
|
36
|
+
*/
|
|
37
|
+
export const RuntimeSupportRequirements: ILayerCompatSupportRequirements = {
|
|
38
|
+
/**
|
|
39
|
+
* Minimum generation that Runtime must be at to be compatible with Loader. Note that 0 is used here for
|
|
40
|
+
* Runtime layers before the introduction of the layer compatibility enforcement.
|
|
41
|
+
*/
|
|
42
|
+
minSupportedGeneration: 0,
|
|
43
|
+
/**
|
|
44
|
+
* The features that the Runtime must support to be compatible with Loader.
|
|
45
|
+
*/
|
|
46
|
+
requiredFeatures: [],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Validates that the Runtime layer is compatible with the Loader.
|
|
51
|
+
*/
|
|
52
|
+
export function validateRuntimeCompatibility(
|
|
53
|
+
maybeRuntimeCompatDetails: ILayerCompatDetails | undefined,
|
|
54
|
+
disposeFn: (error?: ICriticalContainerError) => void,
|
|
55
|
+
): void {
|
|
56
|
+
const layerCheckResult = checkLayerCompatibility(
|
|
57
|
+
RuntimeSupportRequirements,
|
|
58
|
+
maybeRuntimeCompatDetails,
|
|
59
|
+
);
|
|
60
|
+
if (!layerCheckResult.isCompatible) {
|
|
61
|
+
const error = new UsageError("Loader is not compatible with Runtime", {
|
|
62
|
+
errorDetails: JSON.stringify({
|
|
63
|
+
loaderVersion: LoaderCompatDetails.pkgVersion,
|
|
64
|
+
runtimeVersion: maybeRuntimeCompatDetails?.pkgVersion,
|
|
65
|
+
loaderGeneration: LoaderCompatDetails.generation,
|
|
66
|
+
runtimeGeneration: maybeRuntimeCompatDetails?.generation,
|
|
67
|
+
minSupportedGeneration: RuntimeSupportRequirements.minSupportedGeneration,
|
|
68
|
+
isGenerationCompatible: layerCheckResult.isGenerationCompatible,
|
|
69
|
+
unsupportedFeatures: layerCheckResult.unsupportedFeatures,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
disposeFn(error);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
package/src/packageVersion.ts
CHANGED
package/src/protocol/quorum.ts
CHANGED
|
@@ -221,14 +221,6 @@ export class QuorumProposals
|
|
|
221
221
|
return this.values.get(key)?.value;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
/**
|
|
225
|
-
* Returns additional data about the approved consensus value
|
|
226
|
-
* @deprecated Removed in recent protocol-definitions. Use get() instead.
|
|
227
|
-
*/
|
|
228
|
-
public getApprovalData(key: string): ICommittedProposal | undefined {
|
|
229
|
-
return this.values.get(key);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
224
|
/**
|
|
233
225
|
* Proposes a new value. Returns a promise that will either:
|
|
234
226
|
* - Resolve when the proposal is accepted
|
|
@@ -505,14 +497,6 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
505
497
|
return this.quorumProposals.get(key);
|
|
506
498
|
}
|
|
507
499
|
|
|
508
|
-
/**
|
|
509
|
-
* Returns additional data about the approved consensus value
|
|
510
|
-
* @deprecated Removed in recent protocol-definitions. Use get() instead.
|
|
511
|
-
*/
|
|
512
|
-
public getApprovalData(key: string): ICommittedProposal | undefined {
|
|
513
|
-
return this.quorumProposals.getApprovalData(key);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
500
|
/**
|
|
517
501
|
* Adds a new client to the quorum
|
|
518
502
|
*/
|
package/src/utils.ts
CHANGED
|
@@ -145,10 +145,7 @@ function convertSummaryToSnapshotAndBlobs(summary: ISummaryTree): SnapshotWithBl
|
|
|
145
145
|
unreferenced: summary.unreferenced,
|
|
146
146
|
groupId: summary.groupId,
|
|
147
147
|
};
|
|
148
|
-
const
|
|
149
|
-
for (const key of keys) {
|
|
150
|
-
const summaryObject = summary.tree[key];
|
|
151
|
-
|
|
148
|
+
for (const [key, summaryObject] of Object.entries(summary.tree)) {
|
|
152
149
|
switch (summaryObject.type) {
|
|
153
150
|
case SummaryType.Tree: {
|
|
154
151
|
const innerSnapshot = convertSummaryToSnapshotAndBlobs(summaryObject);
|
|
@@ -280,7 +277,7 @@ export const combineSnapshotTreeAndSnapshotBlobs = (
|
|
|
280
277
|
|
|
281
278
|
// Process blobs in the current level
|
|
282
279
|
for (const [, id] of Object.entries(baseSnapshot.blobs)) {
|
|
283
|
-
if (snapshotBlobs[id]) {
|
|
280
|
+
if (snapshotBlobs[id] !== undefined) {
|
|
284
281
|
blobsContents[id] = stringToBuffer(snapshotBlobs[id], "utf8");
|
|
285
282
|
}
|
|
286
283
|
}
|