@fluidframework/container-loader 0.59.4001 → 1.1.0-75972

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 (135) hide show
  1. package/.eslintrc.js +1 -1
  2. package/README.md +1 -1
  3. package/dist/connectionManager.d.ts.map +1 -1
  4. package/dist/connectionManager.js +3 -1
  5. package/dist/connectionManager.js.map +1 -1
  6. package/dist/connectionState.d.ts +15 -3
  7. package/dist/connectionState.d.ts.map +1 -1
  8. package/dist/connectionState.js +15 -3
  9. package/dist/connectionState.js.map +1 -1
  10. package/dist/connectionStateHandler.d.ts +47 -11
  11. package/dist/connectionStateHandler.d.ts.map +1 -1
  12. package/dist/connectionStateHandler.js +108 -38
  13. package/dist/connectionStateHandler.js.map +1 -1
  14. package/dist/container.d.ts +20 -28
  15. package/dist/container.d.ts.map +1 -1
  16. package/dist/container.js +97 -153
  17. package/dist/container.js.map +1 -1
  18. package/dist/containerContext.d.ts +6 -4
  19. package/dist/containerContext.d.ts.map +1 -1
  20. package/dist/containerContext.js +8 -7
  21. package/dist/containerContext.js.map +1 -1
  22. package/dist/containerStorageAdapter.d.ts +4 -5
  23. package/dist/containerStorageAdapter.d.ts.map +1 -1
  24. package/dist/containerStorageAdapter.js +4 -7
  25. package/dist/containerStorageAdapter.js.map +1 -1
  26. package/dist/contracts.d.ts +1 -1
  27. package/dist/contracts.js +1 -1
  28. package/dist/contracts.js.map +1 -1
  29. package/dist/deltaManager.d.ts.map +1 -1
  30. package/dist/deltaManager.js +9 -1
  31. package/dist/deltaManager.js.map +1 -1
  32. package/dist/deltaManagerProxy.d.ts +0 -1
  33. package/dist/deltaManagerProxy.d.ts.map +1 -1
  34. package/dist/deltaManagerProxy.js +0 -3
  35. package/dist/deltaManagerProxy.js.map +1 -1
  36. package/dist/deltaQueue.d.ts.map +1 -1
  37. package/dist/deltaQueue.js +8 -3
  38. package/dist/deltaQueue.js.map +1 -1
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/loader.d.ts +1 -13
  43. package/dist/loader.d.ts.map +1 -1
  44. package/dist/loader.js +2 -3
  45. package/dist/loader.js.map +1 -1
  46. package/dist/packageVersion.d.ts +1 -1
  47. package/dist/packageVersion.d.ts.map +1 -1
  48. package/dist/packageVersion.js +1 -1
  49. package/dist/packageVersion.js.map +1 -1
  50. package/dist/protocolTreeDocumentStorageService.d.ts +2 -3
  51. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  52. package/dist/protocolTreeDocumentStorageService.js +0 -1
  53. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  54. package/dist/retriableDocumentStorageService.d.ts +3 -4
  55. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  56. package/dist/retriableDocumentStorageService.js +4 -7
  57. package/dist/retriableDocumentStorageService.js.map +1 -1
  58. package/dist/utils.d.ts.map +1 -1
  59. package/dist/utils.js +3 -2
  60. package/dist/utils.js.map +1 -1
  61. package/lib/connectionManager.d.ts.map +1 -1
  62. package/lib/connectionManager.js +4 -2
  63. package/lib/connectionManager.js.map +1 -1
  64. package/lib/connectionState.d.ts +15 -3
  65. package/lib/connectionState.d.ts.map +1 -1
  66. package/lib/connectionState.js +15 -3
  67. package/lib/connectionState.js.map +1 -1
  68. package/lib/connectionStateHandler.d.ts +47 -11
  69. package/lib/connectionStateHandler.d.ts.map +1 -1
  70. package/lib/connectionStateHandler.js +108 -38
  71. package/lib/connectionStateHandler.js.map +1 -1
  72. package/lib/container.d.ts +20 -28
  73. package/lib/container.d.ts.map +1 -1
  74. package/lib/container.js +98 -154
  75. package/lib/container.js.map +1 -1
  76. package/lib/containerContext.d.ts +6 -4
  77. package/lib/containerContext.d.ts.map +1 -1
  78. package/lib/containerContext.js +8 -7
  79. package/lib/containerContext.js.map +1 -1
  80. package/lib/containerStorageAdapter.d.ts +4 -5
  81. package/lib/containerStorageAdapter.d.ts.map +1 -1
  82. package/lib/containerStorageAdapter.js +4 -7
  83. package/lib/containerStorageAdapter.js.map +1 -1
  84. package/lib/contracts.d.ts +1 -1
  85. package/lib/contracts.js +1 -1
  86. package/lib/contracts.js.map +1 -1
  87. package/lib/deltaManager.d.ts.map +1 -1
  88. package/lib/deltaManager.js +9 -1
  89. package/lib/deltaManager.js.map +1 -1
  90. package/lib/deltaManagerProxy.d.ts +0 -1
  91. package/lib/deltaManagerProxy.d.ts.map +1 -1
  92. package/lib/deltaManagerProxy.js +0 -3
  93. package/lib/deltaManagerProxy.js.map +1 -1
  94. package/lib/deltaQueue.d.ts.map +1 -1
  95. package/lib/deltaQueue.js +8 -3
  96. package/lib/deltaQueue.js.map +1 -1
  97. package/lib/index.d.ts +1 -1
  98. package/lib/index.d.ts.map +1 -1
  99. package/lib/index.js.map +1 -1
  100. package/lib/loader.d.ts +1 -13
  101. package/lib/loader.d.ts.map +1 -1
  102. package/lib/loader.js +2 -3
  103. package/lib/loader.js.map +1 -1
  104. package/lib/packageVersion.d.ts +1 -1
  105. package/lib/packageVersion.d.ts.map +1 -1
  106. package/lib/packageVersion.js +1 -1
  107. package/lib/packageVersion.js.map +1 -1
  108. package/lib/protocolTreeDocumentStorageService.d.ts +2 -3
  109. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  110. package/lib/protocolTreeDocumentStorageService.js +0 -1
  111. package/lib/protocolTreeDocumentStorageService.js.map +1 -1
  112. package/lib/retriableDocumentStorageService.d.ts +3 -4
  113. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  114. package/lib/retriableDocumentStorageService.js +4 -7
  115. package/lib/retriableDocumentStorageService.js.map +1 -1
  116. package/lib/utils.d.ts.map +1 -1
  117. package/lib/utils.js +3 -2
  118. package/lib/utils.js.map +1 -1
  119. package/package.json +14 -27
  120. package/src/connectionManager.ts +4 -6
  121. package/src/connectionState.ts +20 -6
  122. package/src/connectionStateHandler.ts +136 -56
  123. package/src/container.ts +139 -185
  124. package/src/containerContext.ts +10 -10
  125. package/src/containerStorageAdapter.ts +5 -10
  126. package/src/contracts.ts +1 -1
  127. package/src/deltaManager.ts +8 -2
  128. package/src/deltaManagerProxy.ts +0 -4
  129. package/src/deltaQueue.ts +7 -3
  130. package/src/index.ts +1 -0
  131. package/src/loader.ts +4 -21
  132. package/src/packageVersion.ts +1 -1
  133. package/src/protocolTreeDocumentStorageService.ts +0 -1
  134. package/src/retriableDocumentStorageService.ts +4 -12
  135. package/src/utils.ts +3 -2
@@ -21,7 +21,7 @@ import {
21
21
  IProvideFluidCodeDetailsComparer,
22
22
  ICodeDetailsLoader,
23
23
  IFluidModuleWithDetails,
24
- IFluidModule,
24
+ ISnapshotTreeWithBlobContents,
25
25
  } from "@fluidframework/container-definitions";
26
26
  import {
27
27
  IRequest,
@@ -92,7 +92,9 @@ export class ContainerContext implements IContainerContext {
92
92
  return this.container.clientId;
93
93
  }
94
94
 
95
- /** @deprecated Added back to unblock 0.56 integration */
95
+ /**
96
+ * DISCLAIMER: this id is only for telemetry purposes. Not suitable for any other usages.
97
+ */
96
98
  public get id(): string {
97
99
  const resolvedUrl = this.container.resolvedUrl;
98
100
  if (isFluidResolvedUrl(resolvedUrl)) {
@@ -159,7 +161,7 @@ export class ContainerContext implements IContainerContext {
159
161
  public readonly scope: FluidObject,
160
162
  private readonly codeLoader: ICodeDetailsLoader,
161
163
  private readonly _codeDetails: IFluidCodeDetails,
162
- private readonly _baseSnapshot: ISnapshotTree | undefined,
164
+ private _baseSnapshot: ISnapshotTree | undefined,
163
165
  public readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,
164
166
  quorum: IQuorum,
165
167
  public readonly loader: ILoader,
@@ -287,7 +289,9 @@ export class ContainerContext implements IContainerContext {
287
289
  return true;
288
290
  }
289
291
 
290
- public notifyAttaching() {
292
+ public notifyAttaching(snapshot: ISnapshotTreeWithBlobContents) {
293
+ this._baseSnapshot = snapshot;
294
+ this.runtime.notifyAttaching?.(snapshot);
291
295
  this.runtime.setAttachState(AttachState.Attaching);
292
296
  }
293
297
 
@@ -316,11 +320,7 @@ export class ContainerContext implements IContainerContext {
316
320
  }
317
321
 
318
322
  private async loadCodeModule(codeDetails: IFluidCodeDetails): Promise<IFluidModuleWithDetails> {
319
- // load may actually produce a IFluidModule if using a legacy ICodeLoader.
320
- // Because the type system currently does not capture this in load,
321
- // explicitly declare the type here to support both cases.
322
- // See also comment about this below.
323
- const loadCodeResult: IFluidModuleWithDetails | IFluidModule = await PerformanceEvent.timedExecAsync(
323
+ const loadCodeResult = await PerformanceEvent.timedExecAsync(
324
324
  this.taggedLogger,
325
325
  { eventName: "CodeLoad" },
326
326
  async () => this.codeLoader.load(codeDetails),
@@ -336,7 +336,7 @@ export class ContainerContext implements IContainerContext {
336
336
  // If "module" is not in the result, we are using a legacy ICodeLoader. Fix the result up with details.
337
337
  // Once usage drops to 0 we can remove this compat path.
338
338
  this.taggedLogger.sendTelemetryEvent({ eventName: "LegacyCodeLoader" });
339
- return { module: loadCodeResult, details: codeDetails };
339
+ return loadCodeResult;
340
340
  }
341
341
  }
342
342
  // #endregion
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
+ import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
7
8
  import {
8
9
  IDocumentStorageService,
9
10
  IDocumentStorageServicePolicies,
@@ -14,11 +15,9 @@ import {
14
15
  ISnapshotTree,
15
16
  ISummaryHandle,
16
17
  ISummaryTree,
17
- ITree,
18
18
  IVersion,
19
19
  } from "@fluidframework/protocol-definitions";
20
20
  import { IDetachedBlobStorage } from "./loader";
21
- import { ISnapshotTreeWithBlobContents } from "./utils";
22
21
 
23
22
  /**
24
23
  * This class wraps the actual storage and make sure no wrong apis are called according to
@@ -54,8 +53,8 @@ export class ContainerStorageAdapter implements IDocumentStorageService {
54
53
  return this.storageGetter().repositoryUrl;
55
54
  }
56
55
 
57
- public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
58
- return this.storageGetter().getSnapshotTree(version);
56
+ public async getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null> {
57
+ return this.storageGetter().getSnapshotTree(version, scenarioName);
59
58
  }
60
59
 
61
60
  public async readBlob(id: string): Promise<ArrayBufferLike> {
@@ -66,12 +65,8 @@ export class ContainerStorageAdapter implements IDocumentStorageService {
66
65
  return this.storageGetter().readBlob(id);
67
66
  }
68
67
 
69
- public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
70
- return this.storageGetter().getVersions(versionId, count);
71
- }
72
-
73
- public async write(tree: ITree, parents: string[], message: string, ref: string): Promise<IVersion> {
74
- return this.storageGetter().write(tree, parents, message, ref);
68
+ public async getVersions(versionId: string | null, count: number, scenarioName?: string): Promise<IVersion[]> {
69
+ return this.storageGetter().getVersions(versionId, count, scenarioName);
75
70
  }
76
71
 
77
72
  public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {
package/src/contracts.ts CHANGED
@@ -163,7 +163,7 @@ export interface IConnectionManagerFactoryArgs {
163
163
 
164
164
  /**
165
165
  *
166
- * @param codeDetails- Data structure used to describe the code to load on the Fluid document
166
+ * @param codeDetails- - Data structure used to describe the code to load on the Fluid document
167
167
  * @returns The name of the Fluid package
168
168
  */
169
169
  export const getPackageName = (codeDetails: IFluidCodeDetails | undefined): IContainerPackageInfo => {
@@ -267,8 +267,14 @@ export class DeltaManager<TConnectionManager extends IConnectionManager>
267
267
  ) {
268
268
  super();
269
269
  const props: IConnectionManagerFactoryArgs = {
270
- incomingOpHandler: (messages: ISequencedDocumentMessage[], reason: string) =>
271
- this.enqueueMessages(messages, reason),
270
+ incomingOpHandler: (messages: ISequencedDocumentMessage[], reason: string) => {
271
+ try {
272
+ this.enqueueMessages(messages, reason);
273
+ } catch (error) {
274
+ this.logger.sendErrorEvent({ eventName: "EnqueueMessages_Exception" }, error);
275
+ this.close(normalizeError(error));
276
+ }
277
+ },
272
278
  signalHandler: (message: ISignalMessage) => this._inboundSignal.push(message),
273
279
  reconnectionDelayHandler: (delayMs: number, error: unknown) =>
274
280
  this.emitDelayInfo(this.deltaStreamDelayId, delayMs, error),
@@ -148,10 +148,6 @@ export class DeltaManagerProxy
148
148
  super.dispose();
149
149
  }
150
150
 
151
- public close(): void {
152
- return this.deltaManager.close();
153
- }
154
-
155
151
  public submitSignal(content: any): void {
156
152
  return this.deltaManager.submitSignal(content);
157
153
  }
package/src/deltaQueue.ts CHANGED
@@ -85,9 +85,13 @@ export class DeltaQueue<T>
85
85
  }
86
86
 
87
87
  public push(task: T) {
88
- this.q.push(task);
89
- this.emit("push", task);
90
- this.ensureProcessing();
88
+ try {
89
+ this.q.push(task);
90
+ this.emit("push", task);
91
+ this.ensureProcessing();
92
+ } catch (error) {
93
+ this.emit("error", error);
94
+ }
91
95
  }
92
96
 
93
97
  public async pause(): Promise<void> {
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export {
8
8
  Container,
9
9
  IContainerLoadOptions,
10
10
  IContainerConfig,
11
+ IPendingContainerState,
11
12
  waitContainerToCatchUp,
12
13
  } from "./container";
13
14
  export {
package/src/loader.ts CHANGED
@@ -17,9 +17,7 @@ import {
17
17
  IFluidModule,
18
18
  IHostLoader,
19
19
  ILoader,
20
- IPendingLocalState,
21
20
  ILoaderOptions as ILoaderOptions1,
22
- IProxyLoaderFactory,
23
21
  LoaderHeader,
24
22
  IProvideFluidCodeDetailsComparer,
25
23
  IFluidCodeDetails,
@@ -47,7 +45,7 @@ import {
47
45
  MultiUrlResolver,
48
46
  MultiDocumentServiceFactory,
49
47
  } from "@fluidframework/driver-utils";
50
- import { Container } from "./container";
48
+ import { Container, IPendingContainerState } from "./container";
51
49
  import { IParsedUrl, parseUrl } from "./utils";
52
50
  import { pkgVersion } from "./packageVersion";
53
51
 
@@ -200,13 +198,6 @@ export interface ILoaderProps {
200
198
  */
201
199
  readonly scope?: FluidObject;
202
200
 
203
- /**
204
- * Proxy loader factories for loading containers via proxy in other contexts,
205
- * like web workers, or worker threads.
206
- * @deprecated Not recommended for general use and will be removed in an upcoming release.
207
- */
208
- readonly proxyLoaderFactories?: Map<string, IProxyLoaderFactory>;
209
-
210
201
  /**
211
202
  * The logger that all telemetry should be pushed to.
212
203
  */
@@ -257,13 +248,6 @@ export interface ILoaderServices {
257
248
  */
258
249
  readonly scope: FluidObject;
259
250
 
260
- /**
261
- * Proxy loader factories for loading containers via proxy in other contexts,
262
- * like web workers, or worker threads.
263
- * @deprecated Not recommended for general use and will be removed in an upcoming release.
264
- */
265
- readonly proxyLoaderFactories: Map<string, IProxyLoaderFactory>;
266
-
267
251
  /**
268
252
  * The logger downstream consumers should construct their loggers from
269
253
  */
@@ -318,7 +302,6 @@ export class Loader implements IHostLoader {
318
302
  options: loaderProps.options ?? {},
319
303
  scope,
320
304
  subLogger: subMc.logger,
321
- proxyLoaderFactories: loaderProps.proxyLoaderFactories ?? new Map<string, IProxyLoaderFactory>(),
322
305
  detachedBlobStorage: loaderProps.detachedBlobStorage,
323
306
  };
324
307
  this.mc = loggerToMonitoringContext(
@@ -394,7 +377,7 @@ export class Loader implements IHostLoader {
394
377
 
395
378
  private async resolveCore(
396
379
  request: IRequest,
397
- pendingLocalState?: IPendingLocalState,
380
+ pendingLocalState?: IPendingContainerState,
398
381
  ): Promise<{ container: Container; parsed: IParsedUrl; }> {
399
382
  const resolvedAsFluid = await this.services.urlResolver.resolve(request);
400
383
  ensureFluidResolvedUrl(resolvedAsFluid);
@@ -436,7 +419,7 @@ export class Loader implements IHostLoader {
436
419
  await this.loadContainer(
437
420
  request,
438
421
  resolvedAsFluid,
439
- pendingLocalState?.pendingRuntimeState);
422
+ pendingLocalState);
440
423
  }
441
424
 
442
425
  if (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {
@@ -487,7 +470,7 @@ export class Loader implements IHostLoader {
487
470
  private async loadContainer(
488
471
  request: IRequest,
489
472
  resolved: IFluidResolvedUrl,
490
- pendingLocalState?: unknown,
473
+ pendingLocalState?: IPendingContainerState,
491
474
  ): Promise<Container> {
492
475
  return Container.load(
493
476
  this,
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-loader";
9
- export const pkgVersion = "0.59.4001";
9
+ export const pkgVersion = "1.1.0-75972";
@@ -31,7 +31,6 @@ export class ProtocolTreeStorageService implements IDocumentStorageService, IDis
31
31
 
32
32
  getSnapshotTree = this.internalStorageService.getSnapshotTree.bind(this.internalStorageService);
33
33
  getVersions = this.internalStorageService.getVersions.bind(this.internalStorageService);
34
- write = this.internalStorageService.write.bind(this.internalStorageService);
35
34
  createBlob = this.internalStorageService.createBlob.bind(this.internalStorageService);
36
35
  readBlob = this.internalStorageService.readBlob.bind(this.internalStorageService);
37
36
  downloadSummary = this.internalStorageService.downloadSummary.bind(this.internalStorageService);
@@ -15,7 +15,6 @@ import {
15
15
  ISnapshotTree,
16
16
  ISummaryHandle,
17
17
  ISummaryTree,
18
- ITree,
19
18
  IVersion,
20
19
  } from "@fluidframework/protocol-definitions";
21
20
  import { IDisposable, ITelemetryLogger } from "@fluidframework/common-definitions";
@@ -41,9 +40,9 @@ export class RetriableDocumentStorageService implements IDocumentStorageService,
41
40
  return this.internalStorageService.repositoryUrl;
42
41
  }
43
42
 
44
- public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
43
+ public async getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null> {
45
44
  return this.runWithRetry(
46
- async () => this.internalStorageService.getSnapshotTree(version),
45
+ async () => this.internalStorageService.getSnapshotTree(version, scenarioName),
47
46
  "storage_getSnapshotTree",
48
47
  );
49
48
  }
@@ -55,20 +54,13 @@ export class RetriableDocumentStorageService implements IDocumentStorageService,
55
54
  );
56
55
  }
57
56
 
58
- public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
57
+ public async getVersions(versionId: string | null, count: number, scenarioName?: string): Promise<IVersion[]> {
59
58
  return this.runWithRetry(
60
- async () => this.internalStorageService.getVersions(versionId, count),
59
+ async () => this.internalStorageService.getVersions(versionId, count, scenarioName),
61
60
  "storage_getVersions",
62
61
  );
63
62
  }
64
63
 
65
- public async write(tree: ITree, parents: string[], message: string, ref: string): Promise<IVersion> {
66
- return this.runWithRetry(
67
- async () => this.internalStorageService.write(tree, parents, message, ref),
68
- "storage_write",
69
- );
70
- }
71
-
72
64
  public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {
73
65
  // Not using retry loop here. Couple reasons:
74
66
  // 1. If client lost connectivity, then retry loop will result in uploading stale summary
package/src/utils.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  unreachableCase,
13
13
  } from "@fluidframework/common-utils";
14
14
  import { ISummaryTree, ISnapshotTree, SummaryType } from "@fluidframework/protocol-definitions";
15
+ import { LoggingError } from "@fluidframework/telemetry-utils";
15
16
 
16
17
  // This is used when we rehydrate a container from the snapshot. Here we put the blob contents
17
18
  // in separate property: blobContents.
@@ -35,7 +36,7 @@ export interface IParsedUrl {
35
36
  export function parseUrl(url: string): IParsedUrl | undefined {
36
37
  const parsed = parse(url, true);
37
38
  if (typeof parsed.pathname !== "string") {
38
- throw new Error("Failed to parse pathname");
39
+ throw new LoggingError("Failed to parse pathname");
39
40
  }
40
41
  const query = parsed.search ?? "";
41
42
  const regex = /^\/([^/]*\/[^/]*)(\/?.*)$/;
@@ -86,7 +87,7 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(
86
87
  break;
87
88
  }
88
89
  case SummaryType.Handle:
89
- throw new Error("No handles should be there in summary in detached container!!");
90
+ throw new LoggingError("No handles should be there in summary in detached container!!");
90
91
  break;
91
92
  default: {
92
93
  unreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);