@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.
Files changed (75) hide show
  1. package/.mocharc.cjs +3 -0
  2. package/CHANGELOG.md +8 -0
  3. package/README.md +1 -0
  4. package/dist/connectionManager.js +7 -7
  5. package/dist/connectionManager.js.map +1 -1
  6. package/dist/container.d.ts +2 -2
  7. package/dist/container.d.ts.map +1 -1
  8. package/dist/container.js +21 -18
  9. package/dist/container.js.map +1 -1
  10. package/dist/containerContext.d.ts +6 -1
  11. package/dist/containerContext.d.ts.map +1 -1
  12. package/dist/containerContext.js +7 -0
  13. package/dist/containerContext.js.map +1 -1
  14. package/dist/debugLogger.js +1 -1
  15. package/dist/debugLogger.js.map +1 -1
  16. package/dist/deltaQueue.d.ts.map +1 -1
  17. package/dist/deltaQueue.js +2 -2
  18. package/dist/deltaQueue.js.map +1 -1
  19. package/dist/layerCompatState.d.ts +19 -0
  20. package/dist/layerCompatState.d.ts.map +1 -0
  21. package/dist/layerCompatState.js +64 -0
  22. package/dist/layerCompatState.js.map +1 -0
  23. package/dist/loader.js +1 -1
  24. package/dist/loader.js.map +1 -1
  25. package/dist/packageVersion.d.ts +1 -1
  26. package/dist/packageVersion.js +1 -1
  27. package/dist/packageVersion.js.map +1 -1
  28. package/dist/protocol/quorum.d.ts +0 -10
  29. package/dist/protocol/quorum.d.ts.map +1 -1
  30. package/dist/protocol/quorum.js +4 -18
  31. package/dist/protocol/quorum.js.map +1 -1
  32. package/dist/utils.d.ts.map +1 -1
  33. package/dist/utils.js +2 -4
  34. package/dist/utils.js.map +1 -1
  35. package/lib/connectionManager.js +8 -8
  36. package/lib/connectionManager.js.map +1 -1
  37. package/lib/container.d.ts +2 -2
  38. package/lib/container.d.ts.map +1 -1
  39. package/lib/container.js +22 -19
  40. package/lib/container.js.map +1 -1
  41. package/lib/containerContext.d.ts +6 -1
  42. package/lib/containerContext.d.ts.map +1 -1
  43. package/lib/containerContext.js +7 -0
  44. package/lib/containerContext.js.map +1 -1
  45. package/lib/debugLogger.js +2 -2
  46. package/lib/debugLogger.js.map +1 -1
  47. package/lib/deltaQueue.d.ts.map +1 -1
  48. package/lib/deltaQueue.js +3 -3
  49. package/lib/deltaQueue.js.map +1 -1
  50. package/lib/layerCompatState.d.ts +19 -0
  51. package/lib/layerCompatState.d.ts.map +1 -0
  52. package/lib/layerCompatState.js +60 -0
  53. package/lib/layerCompatState.js.map +1 -0
  54. package/lib/loader.js +1 -1
  55. package/lib/loader.js.map +1 -1
  56. package/lib/packageVersion.d.ts +1 -1
  57. package/lib/packageVersion.js +1 -1
  58. package/lib/packageVersion.js.map +1 -1
  59. package/lib/protocol/quorum.d.ts +0 -10
  60. package/lib/protocol/quorum.d.ts.map +1 -1
  61. package/lib/protocol/quorum.js +4 -18
  62. package/lib/protocol/quorum.js.map +1 -1
  63. package/lib/utils.d.ts.map +1 -1
  64. package/lib/utils.js +2 -4
  65. package/lib/utils.js.map +1 -1
  66. package/package.json +16 -16
  67. package/src/connectionManager.ts +8 -8
  68. package/src/container.ts +37 -23
  69. package/src/containerContext.ts +14 -1
  70. package/src/debugLogger.ts +2 -2
  71. package/src/deltaQueue.ts +3 -3
  72. package/src/layerCompatState.ts +75 -0
  73. package/src/packageVersion.ts +1 -1
  74. package/src/protocol/quorum.ts +0 -16
  75. package/src/utils.ts +2 -5
@@ -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,
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { performance } from "@fluid-internal/client-utils";
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(performance.now())}`;
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, performance } from "@fluid-internal/client-utils";
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 = performance.now();
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 = performance.now() - start;
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
+ }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-loader";
9
- export const pkgVersion = "2.20.0";
9
+ export const pkgVersion = "2.22.0";
@@ -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 keys = Object.keys(summary.tree);
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
  }