@fluidframework/container-loader 1.2.2 → 2.0.0-internal.1.0.0.82159

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 (127) hide show
  1. package/dist/audience.d.ts +2 -2
  2. package/dist/audience.d.ts.map +1 -1
  3. package/dist/audience.js.map +1 -1
  4. package/dist/catchUpMonitor.d.ts +40 -0
  5. package/dist/catchUpMonitor.d.ts.map +1 -0
  6. package/dist/catchUpMonitor.js +74 -0
  7. package/dist/catchUpMonitor.js.map +1 -0
  8. package/dist/connectionManager.d.ts.map +1 -1
  9. package/dist/connectionManager.js +0 -1
  10. package/dist/connectionManager.js.map +1 -1
  11. package/dist/connectionState.d.ts +0 -5
  12. package/dist/connectionState.d.ts.map +1 -1
  13. package/dist/connectionState.js +0 -5
  14. package/dist/connectionState.js.map +1 -1
  15. package/dist/connectionStateHandler.d.ts +12 -4
  16. package/dist/connectionStateHandler.d.ts.map +1 -1
  17. package/dist/connectionStateHandler.js +47 -15
  18. package/dist/connectionStateHandler.js.map +1 -1
  19. package/dist/container.d.ts +8 -6
  20. package/dist/container.d.ts.map +1 -1
  21. package/dist/container.js +82 -46
  22. package/dist/container.js.map +1 -1
  23. package/dist/containerStorageAdapter.d.ts +2 -2
  24. package/dist/containerStorageAdapter.d.ts.map +1 -1
  25. package/dist/containerStorageAdapter.js +2 -2
  26. package/dist/containerStorageAdapter.js.map +1 -1
  27. package/dist/deltaManager.d.ts.map +1 -1
  28. package/dist/deltaManager.js +6 -6
  29. package/dist/deltaManager.js.map +1 -1
  30. package/dist/deltaManagerProxy.d.ts +4 -1
  31. package/dist/deltaManagerProxy.d.ts.map +1 -1
  32. package/dist/deltaQueue.d.ts +9 -2
  33. package/dist/deltaQueue.d.ts.map +1 -1
  34. package/dist/deltaQueue.js +31 -26
  35. package/dist/deltaQueue.js.map +1 -1
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/loader.d.ts +7 -0
  40. package/dist/loader.d.ts.map +1 -1
  41. package/dist/loader.js +4 -3
  42. package/dist/loader.js.map +1 -1
  43. package/dist/packageVersion.d.ts +1 -1
  44. package/dist/packageVersion.d.ts.map +1 -1
  45. package/dist/packageVersion.js +1 -1
  46. package/dist/packageVersion.js.map +1 -1
  47. package/dist/protocol.d.ts +22 -0
  48. package/dist/protocol.d.ts.map +1 -0
  49. package/dist/protocol.js +52 -0
  50. package/dist/protocol.js.map +1 -0
  51. package/dist/protocolTreeDocumentStorageService.d.ts +1 -1
  52. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  53. package/dist/retriableDocumentStorageService.d.ts +2 -2
  54. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  55. package/dist/retriableDocumentStorageService.js +2 -2
  56. package/dist/retriableDocumentStorageService.js.map +1 -1
  57. package/lib/audience.d.ts +2 -2
  58. package/lib/audience.d.ts.map +1 -1
  59. package/lib/audience.js.map +1 -1
  60. package/lib/catchUpMonitor.d.ts +40 -0
  61. package/lib/catchUpMonitor.d.ts.map +1 -0
  62. package/lib/catchUpMonitor.js +69 -0
  63. package/lib/catchUpMonitor.js.map +1 -0
  64. package/lib/connectionManager.d.ts.map +1 -1
  65. package/lib/connectionManager.js +0 -1
  66. package/lib/connectionManager.js.map +1 -1
  67. package/lib/connectionState.d.ts +0 -5
  68. package/lib/connectionState.d.ts.map +1 -1
  69. package/lib/connectionState.js +0 -5
  70. package/lib/connectionState.js.map +1 -1
  71. package/lib/connectionStateHandler.d.ts +12 -4
  72. package/lib/connectionStateHandler.d.ts.map +1 -1
  73. package/lib/connectionStateHandler.js +47 -15
  74. package/lib/connectionStateHandler.js.map +1 -1
  75. package/lib/container.d.ts +8 -6
  76. package/lib/container.d.ts.map +1 -1
  77. package/lib/container.js +82 -46
  78. package/lib/container.js.map +1 -1
  79. package/lib/containerStorageAdapter.d.ts +2 -2
  80. package/lib/containerStorageAdapter.d.ts.map +1 -1
  81. package/lib/containerStorageAdapter.js +2 -2
  82. package/lib/containerStorageAdapter.js.map +1 -1
  83. package/lib/deltaManager.d.ts.map +1 -1
  84. package/lib/deltaManager.js +6 -6
  85. package/lib/deltaManager.js.map +1 -1
  86. package/lib/deltaManagerProxy.d.ts +4 -1
  87. package/lib/deltaManagerProxy.d.ts.map +1 -1
  88. package/lib/deltaQueue.d.ts +9 -2
  89. package/lib/deltaQueue.d.ts.map +1 -1
  90. package/lib/deltaQueue.js +32 -27
  91. package/lib/deltaQueue.js.map +1 -1
  92. package/lib/index.d.ts +1 -0
  93. package/lib/index.d.ts.map +1 -1
  94. package/lib/index.js.map +1 -1
  95. package/lib/loader.d.ts +7 -0
  96. package/lib/loader.d.ts.map +1 -1
  97. package/lib/loader.js +4 -3
  98. package/lib/loader.js.map +1 -1
  99. package/lib/packageVersion.d.ts +1 -1
  100. package/lib/packageVersion.d.ts.map +1 -1
  101. package/lib/packageVersion.js +1 -1
  102. package/lib/packageVersion.js.map +1 -1
  103. package/lib/protocol.d.ts +22 -0
  104. package/lib/protocol.d.ts.map +1 -0
  105. package/lib/protocol.js +48 -0
  106. package/lib/protocol.js.map +1 -0
  107. package/lib/protocolTreeDocumentStorageService.d.ts +1 -1
  108. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  109. package/lib/retriableDocumentStorageService.d.ts +2 -2
  110. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  111. package/lib/retriableDocumentStorageService.js +2 -2
  112. package/lib/retriableDocumentStorageService.js.map +1 -1
  113. package/package.json +23 -15
  114. package/src/audience.ts +2 -2
  115. package/src/catchUpMonitor.ts +99 -0
  116. package/src/connectionManager.ts +0 -1
  117. package/src/connectionState.ts +0 -6
  118. package/src/connectionStateHandler.ts +55 -15
  119. package/src/container.ts +115 -63
  120. package/src/containerStorageAdapter.ts +8 -2
  121. package/src/deltaManager.ts +6 -4
  122. package/src/deltaQueue.ts +34 -28
  123. package/src/index.ts +4 -0
  124. package/src/loader.ts +13 -2
  125. package/src/packageVersion.ts +1 -1
  126. package/src/protocol.ts +96 -0
  127. package/src/retriableDocumentStorageService.ts +8 -2
package/lib/deltaQueue.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 { assert, performance, Deferred, TypedEventEmitter } from "@fluidframework/common-utils";
5
+ import { assert, performance, TypedEventEmitter } from "@fluidframework/common-utils";
6
6
  import Deque from "double-ended-queue";
7
7
  export class DeltaQueue extends TypedEventEmitter {
8
8
  /**
@@ -33,12 +33,11 @@ export class DeltaQueue extends TypedEventEmitter {
33
33
  return this.q.length;
34
34
  }
35
35
  get idle() {
36
- return this.processingDeferred === undefined && this.q.length === 0;
36
+ return this.processingPromise === undefined && this.q.length === 0;
37
37
  }
38
38
  async waitTillProcessingDone() {
39
- if (this.processingDeferred !== undefined) {
40
- return this.processingDeferred.promise;
41
- }
39
+ var _a;
40
+ return (_a = this.processingPromise) !== null && _a !== void 0 ? _a : { count: 0, duration: 0 };
42
41
  }
43
42
  dispose() {
44
43
  throw new Error("Not implemented.");
@@ -67,7 +66,7 @@ export class DeltaQueue extends TypedEventEmitter {
67
66
  this.pauseCount++;
68
67
  // If called from within the processing loop, we are in the middle of processing an op. Return a promise
69
68
  // that will resolve when processing has actually stopped.
70
- return this.waitTillProcessingDone();
69
+ await this.waitTillProcessingDone();
71
70
  }
72
71
  resume() {
73
72
  assert(this.pauseCount > 0, 0x0f4 /* "Nonzero pause-count on resume()" */);
@@ -80,19 +79,29 @@ export class DeltaQueue extends TypedEventEmitter {
80
79
  * not already started.
81
80
  */
82
81
  ensureProcessing() {
83
- if (!this.paused && this.processingDeferred === undefined) {
84
- this.processingDeferred = new Deferred();
82
+ if (this.anythingToProcess() && this.processingPromise === undefined) {
85
83
  // Use a resolved promise to start the processing on a separate stack.
86
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
87
- Promise.resolve().then(() => {
88
- this.processDeltas();
89
- if (this.processingDeferred !== undefined) {
90
- this.processingDeferred.resolve();
91
- this.processingDeferred = undefined;
92
- }
84
+ this.processingPromise = Promise.resolve().then(() => {
85
+ assert(this.processingPromise !== undefined, "reentrancy?");
86
+ const result = this.processDeltas();
87
+ assert(this.processingPromise !== undefined, "reentrancy?");
88
+ // WARNING: Do not move next line to .finally() clause!
89
+ // It runs async and creates a race condition where incoming ensureProcessing() call observes
90
+ // from previous run while previous run is over (but finally clause was not scheduled yet)
91
+ this.processingPromise = undefined;
92
+ return result;
93
+ }).catch((error) => {
94
+ this.error = error;
95
+ this.processingPromise = undefined;
96
+ this.emit("error", error);
97
+ return { count: 0, duration: 0 };
93
98
  });
99
+ assert(this.processingPromise !== undefined, "processDeltas() should run async");
94
100
  }
95
101
  }
102
+ anythingToProcess() {
103
+ return this.q.length !== 0 && !this.paused && this.error === undefined;
104
+ }
96
105
  /**
97
106
  * Executes the delta processing loop until a stop condition is reached.
98
107
  */
@@ -101,25 +110,21 @@ export class DeltaQueue extends TypedEventEmitter {
101
110
  let count = 0;
102
111
  // For grouping to work we must process all local messages immediately and in the single turn.
103
112
  // So loop over them until no messages to process, we have become paused, or hit an error.
104
- while (!(this.q.length === 0 || this.paused || this.error !== undefined)) {
113
+ while (this.anythingToProcess()) {
105
114
  // Get the next message in the queue
106
115
  const next = this.q.shift();
107
116
  count++;
108
117
  // Process the message.
109
- try {
110
- // We know next is defined since we did a length check just prior to shifting.
111
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
112
- this.worker(next);
113
- this.emit("op", next);
114
- }
115
- catch (error) {
116
- this.error = error;
117
- this.emit("error", error);
118
- }
118
+ // We know next is defined since we did a length check just prior to shifting.
119
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
120
+ this.worker(next);
121
+ this.emit("op", next);
119
122
  }
123
+ const duration = performance.now() - start;
120
124
  if (this.q.length === 0) {
121
- this.emit("idle", count, performance.now() - start);
125
+ this.emit("idle", count, duration);
122
126
  }
127
+ return { count, duration };
123
128
  }
124
129
  }
125
130
  //# sourceMappingURL=deltaQueue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deltaQueue.js","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAChG,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAOvC,MAAM,OAAO,UACT,SAAQ,iBAAuC;IA4C/C;;;OAGG;IACH,YACqB,MAA0B;QAE3C,KAAK,EAAE,CAAC;QAFS,WAAM,GAAN,MAAM,CAAoB;QA/CvC,eAAU,GAAY,KAAK,CAAC;QACnB,MAAC,GAAG,IAAI,KAAK,EAAK,CAAC;QAEpC;;;WAGG;QACK,eAAU,GAAG,CAAC,CAAC;IA2CvB,CAAC;IAjCD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,kBAAkB,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACxE,CAAC;IAEM,KAAK,CAAC,sBAAsB;QAC/B,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE;YACvC,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;SAC1C;IACL,CAAC;IAYM,OAAO;QACV,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC3B,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,C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,GAAG,SAAS,CAAC;iBACvC;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAED;;OAEG;IACK,aAAa;QACjB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,8FAA8F;QAC9F,0FAA0F;QAC1F,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,EAAE;YACtE,oCAAoC;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAC5B,KAAK,EAAE,CAAC;YACR,uBAAuB;YACvB,IAAI;gBACA,8EAA8E;gBAC9E,oEAAoE;gBACpE,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC;gBACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aACzB;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;gBACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;aAC7B;SACJ;QAED,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;SACvD;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaQueue, IDeltaQueueEvents } from \"@fluidframework/container-definitions\";\nimport { assert, performance, Deferred, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport Deque from \"double-ended-queue\";\n\nexport interface IDeltaQueueWriter<T> {\n push(task: T): void;\n clear(): void;\n}\n\nexport class DeltaQueue<T>\n extends TypedEventEmitter<IDeltaQueueEvents<T>>\n implements IDeltaQueue<T>, IDeltaQueueWriter<T> {\n private isDisposed: boolean = false;\n private readonly q = new Deque<T>();\n\n /**\n * Tracks the number of pause requests for the queue\n * The DeltaQueue is create initially paused.\n */\n private pauseCount = 1;\n\n private error: any | undefined;\n\n /**\n * When processing is ongoing, holds a deferred that will resolve once processing stops.\n * Undefined when not processing.\n */\n private processingDeferred: Deferred<void> | undefined;\n\n public get disposed(): boolean {\n return this.isDisposed;\n }\n\n /**\n * @returns True if the queue is paused, false if not.\n */\n public get paused(): boolean {\n return this.pauseCount !== 0;\n }\n\n public get length(): number {\n return this.q.length;\n }\n\n public get idle(): boolean {\n return this.processingDeferred === undefined && this.q.length === 0;\n }\n\n public async waitTillProcessingDone(): Promise<void> {\n if (this.processingDeferred !== undefined) {\n return this.processingDeferred.promise;\n }\n }\n\n /**\n * @param worker - A callback to process a delta.\n * @param logger - For logging telemetry.\n */\n constructor(\n private readonly worker: (delta: T) => void,\n ) {\n super();\n }\n\n public dispose() {\n throw new Error(\"Not implemented.\");\n this.isDisposed = true;\n }\n\n public clear(): void {\n this.q.clear();\n }\n\n public peek(): T | undefined {\n return this.q.peekFront();\n }\n\n public toArray(): T[] {\n return this.q.toArray();\n }\n\n public push(task: T) {\n try {\n this.q.push(task);\n this.emit(\"push\", task);\n this.ensureProcessing();\n } catch (error) {\n this.emit(\"error\", error);\n }\n }\n\n public async pause(): Promise<void> {\n this.pauseCount++;\n // If called from within the processing loop, we are in the middle of processing an op. Return a promise\n // that will resolve when processing has actually stopped.\n return this.waitTillProcessingDone();\n }\n\n public resume(): void {\n assert(this.pauseCount > 0, 0x0f4 /* \"Nonzero pause-count on resume()\" */);\n this.pauseCount--;\n this.ensureProcessing();\n }\n\n /**\n * There are several actions that may need to kick off delta processing, so we want to guard against\n * accidental reentrancy. ensureProcessing can be called safely to start the processing loop if it is\n * not already started.\n */\n private ensureProcessing() {\n if (!this.paused && this.processingDeferred === undefined) {\n this.processingDeferred = new Deferred<void>();\n // Use a resolved promise to start the processing on a separate stack.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => {\n this.processDeltas();\n if (this.processingDeferred !== undefined) {\n this.processingDeferred.resolve();\n this.processingDeferred = undefined;\n }\n });\n }\n }\n\n /**\n * Executes the delta processing loop until a stop condition is reached.\n */\n private processDeltas() {\n const start = performance.now();\n let count = 0;\n\n // For grouping to work we must process all local messages immediately and in the single turn.\n // So loop over them until no messages to process, we have become paused, or hit an error.\n while (!(this.q.length === 0 || this.paused || this.error !== undefined)) {\n // Get the next message in the queue\n const next = this.q.shift();\n count++;\n // Process the message.\n try {\n // We know next is defined since we did a length check just prior to shifting.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.worker(next!);\n this.emit(\"op\", next);\n } catch (error) {\n this.error = error;\n this.emit(\"error\", error);\n }\n }\n\n if (this.q.length === 0) {\n this.emit(\"idle\", count, performance.now() - start);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"deltaQueue.js","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAOvC,MAAM,OAAO,UACT,SAAQ,iBAAuC;IA0C/C;;;OAGG;IACH,YACqB,MAA0B;QAE3C,KAAK,EAAE,CAAC;QAFS,WAAM,GAAN,MAAM,CAAoB;QA7CvC,eAAU,GAAY,KAAK,CAAC;QACnB,MAAC,GAAG,IAAI,KAAK,EAAK,CAAC;QAEpC;;;WAGG;QACK,eAAU,GAAG,CAAC,CAAC;IAyCvB,CAAC;IA/BD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC;IACjC,CAA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KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,8FAA8F;QAC9F,0FAA0F;QAC1F,OAAO,IAAI,CAAC,iBAAiB,EAAE,EAAE;YAC7B,oCAAoC;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAC5B,KAAK,EAAE,CAAC;YACR,uBAAuB;YACvB,8EAA8E;YAC9E,oEAAoE;YACpE,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACzB;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAC3C,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;SACtC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaQueue, IDeltaQueueEvents } from \"@fluidframework/container-definitions\";\nimport { assert, performance, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport Deque from \"double-ended-queue\";\n\nexport interface IDeltaQueueWriter<T> {\n push(task: T): void;\n clear(): void;\n}\n\nexport class DeltaQueue<T>\n extends TypedEventEmitter<IDeltaQueueEvents<T>>\n implements IDeltaQueue<T>, IDeltaQueueWriter<T> {\n private isDisposed: boolean = false;\n private readonly q = new Deque<T>();\n\n /**\n * Tracks the number of pause requests for the queue\n * The DeltaQueue is create initially paused.\n */\n private pauseCount = 1;\n\n private error: any | undefined;\n\n /**\n * When processing is ongoing, holds a deferred that will resolve once processing stops.\n * Undefined when not processing.\n */\n private processingPromise: Promise<{ count: number; duration: number; }> | undefined;\n\n public get disposed(): boolean {\n return this.isDisposed;\n }\n\n /**\n * @returns True if the queue is paused, false if not.\n */\n public get paused(): boolean {\n return this.pauseCount !== 0;\n }\n\n public get length(): number {\n return this.q.length;\n }\n\n public get idle(): boolean {\n return this.processingPromise === undefined && this.q.length === 0;\n }\n\n public async waitTillProcessingDone() {\n return this.processingPromise ?? { count: 0, duration: 0 };\n }\n\n /**\n * @param worker - A callback to process a delta.\n * @param logger - For logging telemetry.\n */\n constructor(\n private readonly worker: (delta: T) => void,\n ) {\n super();\n }\n\n public dispose() {\n throw new Error(\"Not implemented.\");\n this.isDisposed = true;\n }\n\n public clear(): void {\n this.q.clear();\n }\n\n public peek(): T | undefined {\n return this.q.peekFront();\n }\n\n public toArray(): T[] {\n return this.q.toArray();\n }\n\n public push(task: T) {\n try {\n this.q.push(task);\n this.emit(\"push\", task);\n this.ensureProcessing();\n } catch (error) {\n this.emit(\"error\", error);\n }\n }\n\n public async pause(): Promise<void> {\n this.pauseCount++;\n // If called from within the processing loop, we are in the middle of processing an op. Return a promise\n // that will resolve when processing has actually stopped.\n await this.waitTillProcessingDone();\n }\n\n public resume(): void {\n assert(this.pauseCount > 0, 0x0f4 /* \"Nonzero pause-count on resume()\" */);\n this.pauseCount--;\n this.ensureProcessing();\n }\n\n /**\n * There are several actions that may need to kick off delta processing, so we want to guard against\n * accidental reentrancy. ensureProcessing can be called safely to start the processing loop if it is\n * not already started.\n */\n private ensureProcessing() {\n if (this.anythingToProcess() && this.processingPromise === undefined) {\n // Use a resolved promise to start the processing on a separate stack.\n this.processingPromise = Promise.resolve().then(() => {\n assert(this.processingPromise !== undefined, \"reentrancy?\");\n const result = this.processDeltas();\n assert(this.processingPromise !== undefined, \"reentrancy?\");\n // WARNING: Do not move next line to .finally() clause!\n // It runs async and creates a race condition where incoming ensureProcessing() call observes\n // from previous run while previous run is over (but finally clause was not scheduled yet)\n this.processingPromise = undefined;\n return result;\n }).catch((error) => {\n this.error = error;\n this.processingPromise = undefined;\n this.emit(\"error\", error);\n return { count: 0, duration: 0 };\n });\n assert(this.processingPromise !== undefined, \"processDeltas() should run async\");\n }\n }\n\n private anythingToProcess() {\n return this.q.length !== 0 && !this.paused && this.error === undefined;\n }\n\n /**\n * Executes the delta processing loop until a stop condition is reached.\n */\n private processDeltas() {\n const start = performance.now();\n let count = 0;\n\n // For grouping to work we must process all local messages immediately and in the single turn.\n // So loop over them until no messages to process, we have become paused, or hit an error.\n while (this.anythingToProcess()) {\n // Get the next message in the queue\n const next = this.q.shift();\n count++;\n // Process the message.\n // We know next is defined since we did a length check just prior to shifting.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.worker(next!);\n this.emit(\"op\", next);\n }\n\n const duration = performance.now() - start;\n if (this.q.length === 0) {\n this.emit(\"idle\", count, duration);\n }\n return { count, duration };\n }\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -5,4 +5,5 @@
5
5
  export { ConnectionState } from "./connectionState";
6
6
  export { Container, IContainerLoadOptions, IContainerConfig, IPendingContainerState, waitContainerToCatchUp, } from "./container";
7
7
  export { ICodeDetailsLoader, IDetachedBlobStorage, IFluidModuleWithDetails, ILoaderOptions, ILoaderProps, ILoaderServices, Loader, RelativeLoader, } from "./loader";
8
+ export { IProtocolHandler, ProtocolHandlerBuilder, } from "./protocol";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,gBAAgB,EAChB,sBAAsB,GACzB,MAAM,YAAY,CAAC"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EAIT,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAOH,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConnectionState } from \"./connectionState\";\nexport {\n Container,\n IContainerLoadOptions,\n IContainerConfig,\n IPendingContainerState,\n waitContainerToCatchUp,\n} from \"./container\";\nexport {\n ICodeDetailsLoader,\n IDetachedBlobStorage,\n IFluidModuleWithDetails,\n ILoaderOptions,\n ILoaderProps,\n ILoaderServices,\n Loader,\n RelativeLoader,\n} from \"./loader\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EAIT,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAOH,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConnectionState } from \"./connectionState\";\nexport {\n Container,\n IContainerLoadOptions,\n IContainerConfig,\n IPendingContainerState,\n waitContainerToCatchUp,\n} from \"./container\";\nexport {\n ICodeDetailsLoader,\n IDetachedBlobStorage,\n IFluidModuleWithDetails,\n ILoaderOptions,\n ILoaderProps,\n ILoaderServices,\n Loader,\n RelativeLoader,\n} from \"./loader\";\nexport {\n IProtocolHandler,\n ProtocolHandlerBuilder,\n} from \"./protocol\";\n"]}
package/lib/loader.d.ts CHANGED
@@ -8,6 +8,7 @@ import { IContainer, IFluidModule, IHostLoader, ILoader, ILoaderOptions as ILoad
8
8
  import { IConfigProviderBase } from "@fluidframework/telemetry-utils";
9
9
  import { IDocumentServiceFactory, IDocumentStorageService, IUrlResolver } from "@fluidframework/driver-definitions";
10
10
  import { Container } from "./container";
11
+ import { ProtocolHandlerBuilder } from "./protocol";
11
12
  export declare class RelativeLoader implements ILoader {
12
13
  private readonly container;
13
14
  private readonly loader;
@@ -93,6 +94,11 @@ export interface ILoaderProps {
93
94
  * The configuration provider which may be used to control features.
94
95
  */
95
96
  readonly configProvider?: IConfigProviderBase;
97
+ /**
98
+ * Optional property for allowing the container to use a custom
99
+ * protocol implementation for handling the quorum and/or the audience.
100
+ */
101
+ readonly protocolHandlerBuilder?: ProtocolHandlerBuilder;
96
102
  }
97
103
  /**
98
104
  * Services and properties used by and exposed by the loader
@@ -152,6 +158,7 @@ export declare class Loader implements IHostLoader {
152
158
  private readonly containers;
153
159
  readonly services: ILoaderServices;
154
160
  private readonly mc;
161
+ private readonly protocolHandlerBuilder;
155
162
  constructor(loaderProps: ILoaderProps);
156
163
  get IFluidRouter(): IFluidRouter;
157
164
  createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer>;
@@ -1 +1 @@
1
-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AG,OAAO,CAAC,UAAU,CAAC;IAoB5E,sCAAsC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI7E,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAW3E,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAU3D,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,mBAAmB;YAcb,WAAW;IA+DzB,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,WAAW;YAqBL,aAAa;CAkB9B"}
package/lib/loader.js CHANGED
@@ -100,10 +100,11 @@ export class Loader {
100
100
  detachedBlobStorage: loaderProps.detachedBlobStorage,
101
101
  };
102
102
  this.mc = loggerToMonitoringContext(ChildLogger.create(this.services.subLogger, "Loader"));
103
+ this.protocolHandlerBuilder = loaderProps.protocolHandlerBuilder;
103
104
  }
104
105
  get IFluidRouter() { return this; }
105
106
  async createDetachedContainer(codeDetails) {
106
- const container = await Container.createDetached(this, codeDetails);
107
+ const container = await Container.createDetached(this, codeDetails, this.protocolHandlerBuilder);
107
108
  if (this.cachingEnabled) {
108
109
  container.once("attached", () => {
109
110
  ensureFluidResolvedUrl(container.resolvedUrl);
@@ -116,7 +117,7 @@ export class Loader {
116
117
  return container;
117
118
  }
118
119
  async rehydrateDetachedContainerFromSnapshot(snapshot) {
119
- return Container.rehydrateDetachedFromSnapshot(this, snapshot);
120
+ return Container.rehydrateDetachedFromSnapshot(this, snapshot, this.protocolHandlerBuilder);
120
121
  }
121
122
  async resolve(request, pendingLocalState) {
122
123
  const eventName = pendingLocalState === undefined ? "Resolve" : "ResolveWithPendingState";
@@ -230,7 +231,7 @@ export class Loader {
230
231
  resolvedUrl: resolved,
231
232
  version: (_d = (_c = request.headers) === null || _c === void 0 ? void 0 : _c[LoaderHeader.version]) !== null && _d !== void 0 ? _d : undefined,
232
233
  loadMode: (_e = request.headers) === null || _e === void 0 ? void 0 : _e[LoaderHeader.loadMode],
233
- }, pendingLocalState);
234
+ }, pendingLocalState, this.protocolHandlerBuilder);
234
235
  }
235
236
  }
236
237
  //# sourceMappingURL=loader.js.map
package/lib/loader.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AASlC,OAAO,EAMH,YAAY,GAGf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,WAAW,EACX,WAAW,EAEX,yBAAyB,EACzB,sBAAsB,EAEtB,gBAAgB,EAChB,4BAA4B,GAC/B,MAAM,iCAAiC,CAAC;AASzC,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,2BAA2B,GAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAc,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,SAAS,WAAW,CAAC,OAAiB;IAClC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;QAC/B,OAAO,IAAI,CAAC;KACf;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;AACzD,CAAC;AAED,MAAM,OAAO,cAAc;IACvB,YACqB,SAAoB,EACpB,MAA2B;QAD3B,cAAS,GAAT,SAAS,CAAW;QACpB,WAAM,GAAN,MAAM,CAAqB;IAEhD,CAAC;IAED,IAAW,YAAY,KAAmB,OAAO,IAAI,CAAC,CAAC,CAAC;IAEjD,KAAK,CAAC,OAAO,CAAC,OAAiB;;QAClC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CA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O,CAAC,OAAO,CAAC,CAAC;QAE1D,OAAO;YACH,QAAQ;YACR,kBAAkB;SACrB,CAAC;IACN,CAAC;IAEO,KAAK,CAAC,aAAa,CACvB,OAAiB,EACjB,QAA2B,EAC3B,iBAA0C;;QAE1C,OAAO,SAAS,CAAC,IAAI,CACjB,IAAI,EACJ;YACI,YAAY,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,SAAS,CAAC;YACvD,qBAAqB,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,aAAa,CAAC;YACpE,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,OAAO,CAAC,mCAAI,SAAS;YAC7D,QAAQ,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,QAAQ,CAAC;SACrD,EACD,iBAAiB,CACpB,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n FluidObject,\n IFluidRouter,\n IRequest,\n IRequestHeader,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IContainer,\n IFluidModule,\n IHostLoader,\n ILoader,\n ILoaderOptions as ILoaderOptions1,\n LoaderHeader,\n IProvideFluidCodeDetailsComparer,\n IFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n ChildLogger,\n DebugLogger,\n IConfigProviderBase,\n loggerToMonitoringContext,\n mixinMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n sessionStorageConfigProvider,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentServiceFactory,\n IDocumentStorageService,\n IFluidResolvedUrl,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n ensureFluidResolvedUrl,\n MultiUrlResolver,\n MultiDocumentServiceFactory,\n} from \"@fluidframework/driver-utils\";\nimport { Container, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\n\nfunction canUseCache(request: IRequest): boolean {\n if (request.headers === undefined) {\n return true;\n }\n\n return request.headers[LoaderHeader.cache] !== false;\n}\n\nexport class RelativeLoader implements ILoader {\n constructor(\n private readonly container: Container,\n private readonly loader: ILoader | undefined,\n ) {\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async resolve(request: IRequest): Promise<IContainer> {\n if (request.url.startsWith(\"/\")) {\n if (canUseCache(request)) {\n return this.container;\n } else {\n const resolvedUrl = this.container.resolvedUrl;\n ensureFluidResolvedUrl(resolvedUrl);\n const container = await Container.load(\n this.loader as Loader,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: { ...resolvedUrl },\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n );\n return container;\n }\n }\n\n if (this.loader === undefined) {\n throw new Error(\"Cannot resolve external containers\");\n }\n return this.loader.resolve(request);\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n if (request.url.startsWith(\"/\")) {\n const container = await this.resolve(request);\n return container.request(request);\n }\n\n if (this.loader === undefined) {\n return {\n status: 404,\n value: \"Cannot request external containers\",\n mimeType: \"plain/text\",\n };\n }\n return this.loader.request(request);\n }\n}\n\nfunction createCachedResolver(resolver: IUrlResolver) {\n const cacheResolver = Object.create(resolver) as IUrlResolver;\n const resolveCache = new Map<string, Promise<IResolvedUrl | undefined>>();\n cacheResolver.resolve = async (request: IRequest): Promise<IResolvedUrl | undefined> => {\n if (!canUseCache(request)) {\n return resolver.resolve(request);\n }\n if (!resolveCache.has(request.url)) {\n resolveCache.set(request.url, resolver.resolve(request));\n }\n\n return resolveCache.get(request.url);\n };\n return cacheResolver;\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1 {\n summarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definition#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n /** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n module: IFluidModule;\n /**\n * Code details associated with the module. Represents a document schema this module supports.\n * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n */\n details: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader\n extends Partial<IProvideFluidCodeDetailsComparer> {\n /**\n * Load the code module (package) that is capable to interact with the document.\n *\n * @param source - Code proposal that articulates the current schema the document is written in.\n * @returns - Code module entry point along with the code details associated with it.\n */\n load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options?: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope?: FluidObject;\n\n /**\n * The logger that all telemetry should be pushed to.\n */\n readonly logger?: ITelemetryBaseLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\n\n /**\n * The configuration provider which may be used to control features.\n */\n readonly configProvider?: IConfigProviderBase;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope: FluidObject;\n\n /**\n * The logger downstream consumers should construct their loggers from\n */\n readonly subLogger: ITelemetryLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n size: number;\n /**\n * Return an array of all blob IDs present in storage\n */\n getBlobIds(): string[];\n };\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n private readonly containers = new Map<string, Promise<Container>>();\n public readonly services: ILoaderServices;\n private readonly mc: MonitoringContext;\n\n constructor(loaderProps: ILoaderProps) {\n const scope: FluidObject<ILoader> = { ...loaderProps.scope };\n if (loaderProps.options?.provideScopeLoader !== false) {\n scope.ILoader = this;\n }\n const telemetryProps = {\n loaderId: uuid(),\n loaderVersion: pkgVersion,\n };\n\n const subMc = mixinMonitoringContext(\n DebugLogger.mixinDebugLogger(\"fluid:telemetry\", loaderProps.logger, { all: telemetryProps }),\n sessionStorageConfigProvider.value,\n loaderProps.configProvider,\n );\n\n this.services = {\n urlResolver: createCachedResolver(MultiUrlResolver.create(loaderProps.urlResolver)),\n documentServiceFactory: MultiDocumentServiceFactory.create(loaderProps.documentServiceFactory),\n codeLoader: loaderProps.codeLoader,\n options: loaderProps.options ?? {},\n scope,\n subLogger: subMc.logger,\n detachedBlobStorage: loaderProps.detachedBlobStorage,\n };\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(this.services.subLogger, \"Loader\"));\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n const container = await Container.createDetached(\n this,\n codeDetails,\n );\n\n if (this.cachingEnabled) {\n container.once(\"attached\", () => {\n ensureFluidResolvedUrl(container.resolvedUrl);\n const parsedUrl = parseUrl(container.resolvedUrl.url);\n if (parsedUrl !== undefined) {\n this.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n }\n });\n }\n\n return container;\n }\n\n public async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n return Container.rehydrateDetachedFromSnapshot(this, snapshot);\n }\n\n public async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n const eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n const resolved = await this.resolveCore(\n request,\n pendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n );\n return resolved.container;\n });\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: \"Request\" }, async () => {\n const resolved = await this.resolveCore(request);\n return resolved.container.request({\n ...request,\n url: `${resolved.parsed.path}${resolved.parsed.query}`,\n });\n });\n }\n\n private getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n const key = request.headers?.[LoaderHeader.version] !== undefined\n ? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n : parsedUrl.id;\n return key;\n }\n\n private addToContainerCache(key: string, containerP: Promise<Container>) {\n this.containers.set(key, containerP);\n containerP.then((container) => {\n // If the container is closed or becomes closed after we resolve it, remove it from the cache.\n if (container.closed) {\n this.containers.delete(key);\n } else {\n container.once(\"closed\", () => {\n this.containers.delete(key);\n });\n }\n }).catch((error) => {});\n }\n\n private async resolveCore(\n request: IRequest,\n pendingLocalState?: IPendingContainerState,\n ): Promise<{ container: Container; parsed: IParsedUrl; }> {\n const resolvedAsFluid = await this.services.urlResolver.resolve(request);\n ensureFluidResolvedUrl(resolvedAsFluid);\n\n // Parse URL into data stores\n const parsed = parseUrl(resolvedAsFluid.url);\n if (parsed === undefined) {\n throw new Error(`Invalid URL ${resolvedAsFluid.url}`);\n }\n\n if (pendingLocalState !== undefined) {\n const parsedPendingUrl = parseUrl(pendingLocalState.url);\n if (parsedPendingUrl?.id !== parsed.id ||\n parsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")) {\n const message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n throw new Error(message);\n }\n }\n\n const { canCache, fromSequenceNumber } = this.parseHeader(parsed, request);\n const shouldCache = pendingLocalState !== undefined ? false : canCache;\n\n let container: Container;\n if (shouldCache) {\n const key = this.getKeyForContainerCache(request, parsed);\n const maybeContainer = await this.containers.get(key);\n if (maybeContainer !== undefined) {\n container = maybeContainer;\n } else {\n const containerP =\n this.loadContainer(\n request,\n resolvedAsFluid);\n this.addToContainerCache(key, containerP);\n container = await containerP;\n }\n } else {\n container =\n await this.loadContainer(\n request,\n resolvedAsFluid,\n pendingLocalState);\n }\n\n if (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {\n await new Promise<void>((resolve, reject) => {\n function opHandler(message: ISequencedDocumentMessage) {\n if (message.sequenceNumber > fromSequenceNumber) {\n resolve();\n container.removeListener(\"op\", opHandler);\n }\n }\n\n container.on(\"op\", opHandler);\n });\n }\n\n return { container, parsed };\n }\n\n private get cachingEnabled() {\n return this.services.options.cache !== false;\n }\n\n private canCacheForRequest(headers: IRequestHeader): boolean {\n return this.cachingEnabled && headers[LoaderHeader.cache] !== false;\n }\n\n private parseHeader(parsed: IParsedUrl, request: IRequest) {\n let fromSequenceNumber = -1;\n\n request.headers = request.headers ?? {};\n\n const headerSeqNum = request.headers[LoaderHeader.sequenceNumber];\n if (headerSeqNum !== undefined) {\n fromSequenceNumber = headerSeqNum;\n }\n\n // If set in both query string and headers, use query string\n request.headers[LoaderHeader.version] = parsed.version ?? request.headers[LoaderHeader.version];\n\n const canCache = this.canCacheForRequest(request.headers);\n\n return {\n canCache,\n fromSequenceNumber,\n };\n }\n\n private async loadContainer(\n request: IRequest,\n resolved: IFluidResolvedUrl,\n pendingLocalState?: IPendingContainerState,\n ): Promise<Container> {\n return Container.load(\n this,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: resolved,\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n pendingLocalState,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AASlC,OAAO,EAMH,YAAY,GAGf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,WAAW,EACX,WAAW,EAEX,yBAAyB,EACzB,sBAAsB,EAEtB,gBAAgB,EAChB,4BAA4B,GAC/B,MAAM,iCAAiC,CAAC;AASzC,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,2BAA2B,GAC9B,MAAM,8BAA8B,CAAC;AACtC,OA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OAAO,0CAAG,YAAY,CAAC,QAAQ,CAAC;SACrD,EACD,iBAAiB,EACjB,IAAI,CAAC,sBAAsB,CAC9B,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n FluidObject,\n IFluidRouter,\n IRequest,\n IRequestHeader,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IContainer,\n IFluidModule,\n IHostLoader,\n ILoader,\n ILoaderOptions as ILoaderOptions1,\n LoaderHeader,\n IProvideFluidCodeDetailsComparer,\n IFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n ChildLogger,\n DebugLogger,\n IConfigProviderBase,\n loggerToMonitoringContext,\n mixinMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n sessionStorageConfigProvider,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentServiceFactory,\n IDocumentStorageService,\n IFluidResolvedUrl,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n ensureFluidResolvedUrl,\n MultiUrlResolver,\n MultiDocumentServiceFactory,\n} from \"@fluidframework/driver-utils\";\nimport { Container, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { ProtocolHandlerBuilder } from \"./protocol\";\n\nfunction canUseCache(request: IRequest): boolean {\n if (request.headers === undefined) {\n return true;\n }\n\n return request.headers[LoaderHeader.cache] !== false;\n}\n\nexport class RelativeLoader implements ILoader {\n constructor(\n private readonly container: Container,\n private readonly loader: ILoader | undefined,\n ) {\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async resolve(request: IRequest): Promise<IContainer> {\n if (request.url.startsWith(\"/\")) {\n if (canUseCache(request)) {\n return this.container;\n } else {\n const resolvedUrl = this.container.resolvedUrl;\n ensureFluidResolvedUrl(resolvedUrl);\n const container = await Container.load(\n this.loader as Loader,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: { ...resolvedUrl },\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n );\n return container;\n }\n }\n\n if (this.loader === undefined) {\n throw new Error(\"Cannot resolve external containers\");\n }\n return this.loader.resolve(request);\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n if (request.url.startsWith(\"/\")) {\n const container = await this.resolve(request);\n return container.request(request);\n }\n\n if (this.loader === undefined) {\n return {\n status: 404,\n value: \"Cannot request external containers\",\n mimeType: \"plain/text\",\n };\n }\n return this.loader.request(request);\n }\n}\n\nfunction createCachedResolver(resolver: IUrlResolver) {\n const cacheResolver = Object.create(resolver) as IUrlResolver;\n const resolveCache = new Map<string, Promise<IResolvedUrl | undefined>>();\n cacheResolver.resolve = async (request: IRequest): Promise<IResolvedUrl | undefined> => {\n if (!canUseCache(request)) {\n return resolver.resolve(request);\n }\n if (!resolveCache.has(request.url)) {\n resolveCache.set(request.url, resolver.resolve(request));\n }\n\n return resolveCache.get(request.url);\n };\n return cacheResolver;\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1 {\n summarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definition#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n /** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n module: IFluidModule;\n /**\n * Code details associated with the module. Represents a document schema this module supports.\n * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n */\n details: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader\n extends Partial<IProvideFluidCodeDetailsComparer> {\n /**\n * Load the code module (package) that is capable to interact with the document.\n *\n * @param source - Code proposal that articulates the current schema the document is written in.\n * @returns - Code module entry point along with the code details associated with it.\n */\n load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options?: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope?: FluidObject;\n\n /**\n * The logger that all telemetry should be pushed to.\n */\n readonly logger?: ITelemetryBaseLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\n\n /**\n * The configuration provider which may be used to control features.\n */\n readonly configProvider?: IConfigProviderBase;\n\n /**\n * Optional property for allowing the container to use a custom\n * protocol implementation for handling the quorum and/or the audience.\n */\n readonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope: FluidObject;\n\n /**\n * The logger downstream consumers should construct their loggers from\n */\n readonly subLogger: ITelemetryLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n size: number;\n /**\n * Return an array of all blob IDs present in storage\n */\n getBlobIds(): string[];\n };\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n private readonly containers = new Map<string, Promise<Container>>();\n public readonly services: ILoaderServices;\n private readonly mc: MonitoringContext;\n private readonly protocolHandlerBuilder: ProtocolHandlerBuilder | undefined;\n\n constructor(loaderProps: ILoaderProps) {\n const scope: FluidObject<ILoader> = { ...loaderProps.scope };\n if (loaderProps.options?.provideScopeLoader !== false) {\n scope.ILoader = this;\n }\n const telemetryProps = {\n loaderId: uuid(),\n loaderVersion: pkgVersion,\n };\n\n const subMc = mixinMonitoringContext(\n DebugLogger.mixinDebugLogger(\"fluid:telemetry\", loaderProps.logger, { all: telemetryProps }),\n sessionStorageConfigProvider.value,\n loaderProps.configProvider,\n );\n\n this.services = {\n urlResolver: createCachedResolver(MultiUrlResolver.create(loaderProps.urlResolver)),\n documentServiceFactory: MultiDocumentServiceFactory.create(loaderProps.documentServiceFactory),\n codeLoader: loaderProps.codeLoader,\n options: loaderProps.options ?? {},\n scope,\n subLogger: subMc.logger,\n detachedBlobStorage: loaderProps.detachedBlobStorage,\n };\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(this.services.subLogger, \"Loader\"));\n this.protocolHandlerBuilder = loaderProps.protocolHandlerBuilder;\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n const container = await Container.createDetached(\n this,\n codeDetails,\n this.protocolHandlerBuilder,\n );\n\n if (this.cachingEnabled) {\n container.once(\"attached\", () => {\n ensureFluidResolvedUrl(container.resolvedUrl);\n const parsedUrl = parseUrl(container.resolvedUrl.url);\n if (parsedUrl !== undefined) {\n this.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n }\n });\n }\n\n return container;\n }\n\n public async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n return Container.rehydrateDetachedFromSnapshot(this, snapshot, this.protocolHandlerBuilder);\n }\n\n public async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n const eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n const resolved = await this.resolveCore(\n request,\n pendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n );\n return resolved.container;\n });\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: \"Request\" }, async () => {\n const resolved = await this.resolveCore(request);\n return resolved.container.request({\n ...request,\n url: `${resolved.parsed.path}${resolved.parsed.query}`,\n });\n });\n }\n\n private getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n const key = request.headers?.[LoaderHeader.version] !== undefined\n ? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n : parsedUrl.id;\n return key;\n }\n\n private addToContainerCache(key: string, containerP: Promise<Container>) {\n this.containers.set(key, containerP);\n containerP.then((container) => {\n // If the container is closed or becomes closed after we resolve it, remove it from the cache.\n if (container.closed) {\n this.containers.delete(key);\n } else {\n container.once(\"closed\", () => {\n this.containers.delete(key);\n });\n }\n }).catch((error) => {});\n }\n\n private async resolveCore(\n request: IRequest,\n pendingLocalState?: IPendingContainerState,\n ): Promise<{ container: Container; parsed: IParsedUrl; }> {\n const resolvedAsFluid = await this.services.urlResolver.resolve(request);\n ensureFluidResolvedUrl(resolvedAsFluid);\n\n // Parse URL into data stores\n const parsed = parseUrl(resolvedAsFluid.url);\n if (parsed === undefined) {\n throw new Error(`Invalid URL ${resolvedAsFluid.url}`);\n }\n\n if (pendingLocalState !== undefined) {\n const parsedPendingUrl = parseUrl(pendingLocalState.url);\n if (parsedPendingUrl?.id !== parsed.id ||\n parsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")) {\n const message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n throw new Error(message);\n }\n }\n\n const { canCache, fromSequenceNumber } = this.parseHeader(parsed, request);\n const shouldCache = pendingLocalState !== undefined ? false : canCache;\n\n let container: Container;\n if (shouldCache) {\n const key = this.getKeyForContainerCache(request, parsed);\n const maybeContainer = await this.containers.get(key);\n if (maybeContainer !== undefined) {\n container = maybeContainer;\n } else {\n const containerP =\n this.loadContainer(\n request,\n resolvedAsFluid);\n this.addToContainerCache(key, containerP);\n container = await containerP;\n }\n } else {\n container =\n await this.loadContainer(\n request,\n resolvedAsFluid,\n pendingLocalState);\n }\n\n if (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {\n await new Promise<void>((resolve, reject) => {\n function opHandler(message: ISequencedDocumentMessage) {\n if (message.sequenceNumber > fromSequenceNumber) {\n resolve();\n container.removeListener(\"op\", opHandler);\n }\n }\n\n container.on(\"op\", opHandler);\n });\n }\n\n return { container, parsed };\n }\n\n private get cachingEnabled() {\n return this.services.options.cache !== false;\n }\n\n private canCacheForRequest(headers: IRequestHeader): boolean {\n return this.cachingEnabled && headers[LoaderHeader.cache] !== false;\n }\n\n private parseHeader(parsed: IParsedUrl, request: IRequest) {\n let fromSequenceNumber = -1;\n\n request.headers = request.headers ?? {};\n\n const headerSeqNum = request.headers[LoaderHeader.sequenceNumber];\n if (headerSeqNum !== undefined) {\n fromSequenceNumber = headerSeqNum;\n }\n\n // If set in both query string and headers, use query string\n request.headers[LoaderHeader.version] = parsed.version ?? request.headers[LoaderHeader.version];\n\n const canCache = this.canCacheForRequest(request.headers);\n\n return {\n canCache,\n fromSequenceNumber,\n };\n }\n\n private async loadContainer(\n request: IRequest,\n resolved: IFluidResolvedUrl,\n pendingLocalState?: IPendingContainerState,\n ): Promise<Container> {\n return Container.load(\n this,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: resolved,\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n pendingLocalState,\n this.protocolHandlerBuilder,\n );\n }\n}\n"]}
@@ -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 = "1.2.2";
8
+ export declare const pkgVersion = "2.0.0-internal.1.0.0.82159";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,qCAAqC,CAAC;AAC1D,eAAO,MAAM,UAAU,UAAU,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,qCAAqC,CAAC;AAC1D,eAAO,MAAM,UAAU,+BAA+B,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/container-loader";
8
- export const pkgVersion = "1.2.2";
8
+ export const pkgVersion = "2.0.0-internal.1.0.0.82159";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -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,OAAO,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 = \"1.2.2\";\n"]}
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,4BAA4B,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.0.0-internal.1.0.0.82159\";\n"]}
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IAudienceOwner } from "@fluidframework/container-definitions";
6
+ import { IProtocolHandler as IBaseProtocolHandler, IQuorumSnapshot, ProtocolOpHandler } from "@fluidframework/protocol-base";
7
+ import { IDocumentAttributes, IProcessMessageResult, ISequencedDocumentMessage, ISignalClient, ISignalMessage } from "@fluidframework/protocol-definitions";
8
+ /**
9
+ * Function to be used for creating a protocol handler.
10
+ */
11
+ export declare type ProtocolHandlerBuilder = (attributes: IDocumentAttributes, snapshot: IQuorumSnapshot, sendProposal: (key: string, value: any) => number, initialClients: ISignalClient[]) => IProtocolHandler;
12
+ export interface IProtocolHandler extends IBaseProtocolHandler {
13
+ readonly audience: IAudienceOwner;
14
+ processSignal(message: ISignalMessage): any;
15
+ }
16
+ export declare class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandler {
17
+ readonly audience: IAudienceOwner;
18
+ constructor(attributes: IDocumentAttributes, quorumSnapshot: IQuorumSnapshot, sendProposal: (key: string, value: any) => number, initialClients: ISignalClient[], audience: IAudienceOwner);
19
+ processMessage(message: ISequencedDocumentMessage, local: boolean): IProcessMessageResult;
20
+ processSignal(message: ISignalMessage): void;
21
+ }
22
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAEH,gBAAgB,IAAI,oBAAoB,EACxC,eAAe,EACf,iBAAiB,EACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,cAAc,EAEjB,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,oBAAY,sBAAsB,GAAG,CACjC,UAAU,EAAE,mBAAmB,EAC/B,QAAQ,EAAE,eAAe,EACzB,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,EACjD,cAAc,EAAE,aAAa,EAAE,KAC9B,gBAAgB,CAAC;AAEtB,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC1D,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,aAAa,CAAC,OAAO,EAAE,cAAc,OAAE;CAC1C;AAED,qBAAa,eAAgB,SAAQ,iBAAkB,YAAW,gBAAgB;IAM1E,QAAQ,CAAC,QAAQ,EAAE,cAAc;gBAJjC,UAAU,EAAE,mBAAmB,EAC/B,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,EACjD,cAAc,EAAE,aAAa,EAAE,EACtB,QAAQ,EAAE,cAAc;IAiB9B,cAAc,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,GAAG,qBAAqB;IAoBzF,aAAa,CAAC,OAAO,EAAE,cAAc;CAgB/C"}
@@ -0,0 +1,48 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ProtocolOpHandler, } from "@fluidframework/protocol-base";
6
+ import { MessageType, } from "@fluidframework/protocol-definitions";
7
+ export class ProtocolHandler extends ProtocolOpHandler {
8
+ constructor(attributes, quorumSnapshot, sendProposal, initialClients, audience) {
9
+ super(attributes.minimumSequenceNumber, attributes.sequenceNumber, attributes.term, quorumSnapshot.members, quorumSnapshot.proposals, quorumSnapshot.values, sendProposal);
10
+ this.audience = audience;
11
+ for (const initialClient of initialClients) {
12
+ this.audience.addMember(initialClient.clientId, initialClient.client);
13
+ }
14
+ }
15
+ processMessage(message, local) {
16
+ const client = this.quorum.getMember(message.clientId);
17
+ // Check and report if we're getting messages from a clientId that we previously
18
+ // flagged as shouldHaveLeft, or from a client that's not in the quorum but should be
19
+ if (message.clientId != null) {
20
+ if (client === undefined && message.type !== MessageType.ClientJoin) {
21
+ // pre-0.58 error message: messageClientIdMissingFromQuorum
22
+ throw new Error("Remote message's clientId is missing from the quorum");
23
+ }
24
+ if ((client === null || client === void 0 ? void 0 : client.shouldHaveLeft) === true && message.type !== MessageType.NoOp) {
25
+ // pre-0.58 error message: messageClientIdShouldHaveLeft
26
+ throw new Error("Remote message's clientId already should have left");
27
+ }
28
+ }
29
+ return super.processMessage(message, local);
30
+ }
31
+ processSignal(message) {
32
+ const innerContent = message.content;
33
+ switch (innerContent.type) {
34
+ case MessageType.ClientJoin: {
35
+ const newClient = innerContent.content;
36
+ this.audience.addMember(newClient.clientId, newClient.client);
37
+ break;
38
+ }
39
+ case MessageType.ClientLeave: {
40
+ const leftClientId = innerContent.content;
41
+ this.audience.removeMember(leftClientId);
42
+ break;
43
+ }
44
+ default: break;
45
+ }
46
+ }
47
+ }
48
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAIH,iBAAiB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAMH,WAAW,GACd,MAAM,sCAAsC,CAAC;AAiB9C,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAClD,YACI,UAA+B,EAC/B,cAA+B,EAC/B,YAAiD,EACjD,cAA+B,EACtB,QAAwB;QAEjC,KAAK,CACD,UAAU,CAAC,qBAAqB,EAChC,UAAU,CAAC,cAAc,EACzB,UAAU,CAAC,IAAI,EACf,cAAc,CAAC,OAAO,EACtB,cAAc,CAAC,SAAS,EACxB,cAAc,CAAC,MAAM,EACrB,YAAY,CACf,CAAC;QAVO,aAAQ,GAAR,QAAQ,CAAgB;QAYjC,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE;YACxC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SACzE;IACL,CAAC;IAEM,cAAc,CAAC,OAAkC,EAAE,KAAc;QACpE,MAAM,MAAM,GAAsC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE1F,gFAAgF;QAChF,qFAAqF;QACrF,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE;YAC1B,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,EAAE;gBACjE,2DAA2D;gBAC3D,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;aAC3E;YAED,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,MAAK,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE;gBACtE,wDAAwD;gBACxD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;aACzE;SACJ;QAED,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,aAAa,CAAC,OAAuB;QACxC,MAAM,YAAY,GAAG,OAAO,CAAC,OAA0C,CAAC;QACxE,QAAQ,YAAY,CAAC,IAAI,EAAE;YACvB,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC;gBACzB,MAAM,SAAS,GAAG,YAAY,CAAC,OAAwB,CAAC;gBACxD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;gBAC9D,MAAM;aACT;YACD,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC1B,MAAM,YAAY,GAAG,YAAY,CAAC,OAAiB,CAAC;gBACpD,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;gBACzC,MAAM;aACT;YACD,OAAO,CAAC,CAAC,MAAM;SAClB;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IAudienceOwner } from \"@fluidframework/container-definitions\";\nimport {\n ILocalSequencedClient,\n IProtocolHandler as IBaseProtocolHandler,\n IQuorumSnapshot,\n ProtocolOpHandler,\n} from \"@fluidframework/protocol-base\";\nimport {\n IDocumentAttributes,\n IProcessMessageResult,\n ISequencedDocumentMessage,\n ISignalClient,\n ISignalMessage,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Function to be used for creating a protocol handler.\n */\nexport type ProtocolHandlerBuilder = (\n attributes: IDocumentAttributes,\n snapshot: IQuorumSnapshot,\n sendProposal: (key: string, value: any) => number,\n initialClients: ISignalClient[],\n) => IProtocolHandler;\n\nexport interface IProtocolHandler extends IBaseProtocolHandler {\n readonly audience: IAudienceOwner;\n processSignal(message: ISignalMessage);\n}\n\nexport class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandler {\n constructor(\n attributes: IDocumentAttributes,\n quorumSnapshot: IQuorumSnapshot,\n sendProposal: (key: string, value: any) => number,\n initialClients: ISignalClient[],\n readonly audience: IAudienceOwner,\n ) {\n super(\n attributes.minimumSequenceNumber,\n attributes.sequenceNumber,\n attributes.term,\n quorumSnapshot.members,\n quorumSnapshot.proposals,\n quorumSnapshot.values,\n sendProposal,\n );\n\n for (const initialClient of initialClients) {\n this.audience.addMember(initialClient.clientId, initialClient.client);\n }\n }\n\n public processMessage(message: ISequencedDocumentMessage, local: boolean): IProcessMessageResult {\n const client: ILocalSequencedClient | undefined = this.quorum.getMember(message.clientId);\n\n // Check and report if we're getting messages from a clientId that we previously\n // flagged as shouldHaveLeft, or from a client that's not in the quorum but should be\n if (message.clientId != null) {\n if (client === undefined && message.type !== MessageType.ClientJoin) {\n // pre-0.58 error message: messageClientIdMissingFromQuorum\n throw new Error(\"Remote message's clientId is missing from the quorum\");\n }\n\n if (client?.shouldHaveLeft === true && message.type !== MessageType.NoOp) {\n // pre-0.58 error message: messageClientIdShouldHaveLeft\n throw new Error(\"Remote message's clientId already should have left\");\n }\n }\n\n return super.processMessage(message, local);\n }\n\n public processSignal(message: ISignalMessage) {\n const innerContent = message.content as { content: any; type: string; };\n switch (innerContent.type) {\n case MessageType.ClientJoin: {\n const newClient = innerContent.content as ISignalClient;\n this.audience.addMember(newClient.clientId, newClient.client);\n break;\n }\n case MessageType.ClientLeave: {\n const leftClientId = innerContent.content as string;\n this.audience.removeMember(leftClientId);\n break;\n }\n default: break;\n }\n }\n}\n"]}
@@ -13,7 +13,7 @@ export declare class ProtocolTreeStorageService implements IDocumentStorageServi
13
13
  get repositoryUrl(): string;
14
14
  get disposed(): boolean;
15
15
  getSnapshotTree: (version?: import("@fluidframework/protocol-definitions").IVersion | undefined, scenarioName?: string | undefined) => Promise<import("@fluidframework/protocol-definitions").ISnapshotTree | null>;
16
- getVersions: (versionId: string | null, count: number, scenarioName?: string | undefined) => Promise<import("@fluidframework/protocol-definitions").IVersion[]>;
16
+ getVersions: (versionId: string | null, count: number, scenarioName?: string | undefined, fetchSource?: import("@fluidframework/driver-definitions").FetchSource | undefined) => Promise<import("@fluidframework/protocol-definitions").IVersion[]>;
17
17
  createBlob: (file: ArrayBufferLike) => Promise<import("@fluidframework/protocol-definitions").ICreateBlobResponse>;
18
18
  readBlob: (id: string) => Promise<ArrayBufferLike>;
19
19
  downloadSummary: (handle: import("@fluidframework/protocol-definitions").ISummaryHandle) => Promise<ISummaryTree>;
@@ -1 +1 @@
1
- {"version":3,"file":"protocolTreeDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EACH,uBAAuB,EACvB,eAAe,EAClB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,YAAY,EACf,MAAM,sCAAsC,CAAC;AAE9C,qBAAa,0BAA2B,YAAW,uBAAuB,EAAE,WAAW;IAE/E,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBADpB,sBAAsB,EAAE,uBAAuB,GAAG,WAAW,EAC7D,oBAAoB,EAAE,MAAM,YAAY;IAG7D,IAAW,QAAQ,6FAElB;IACD,IAAW,aAAa,WAEvB;IACD,IAAW,QAAQ,YAElB;IAED,eAAe,qMAAiF;IAChG,WAAW,qJAA6E;IACxF,UAAU,yGAA4E;IACtF,QAAQ,2CAA0E;IAClF,eAAe,mGAAiF;IAChG,OAAO,sCAAyE;IAE1E,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;CAMnG"}
1
+ {"version":3,"file":"protocolTreeDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EACH,uBAAuB,EACvB,eAAe,EAClB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,YAAY,EACf,MAAM,sCAAsC,CAAC;AAE9C,qBAAa,0BAA2B,YAAW,uBAAuB,EAAE,WAAW;IAE/E,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBADpB,sBAAsB,EAAE,uBAAuB,GAAG,WAAW,EAC7D,oBAAoB,EAAE,MAAM,YAAY;IAG7D,IAAW,QAAQ,6FAElB;IACD,IAAW,aAAa,WAEvB;IACD,IAAW,QAAQ,YAElB;IAED,eAAe,qMAAiF;IAChG,WAAW,yOAA6E;IACxF,UAAU,yGAA4E;IACtF,QAAQ,2CAA0E;IAClF,eAAe,mGAAiF;IAChG,OAAO,sCAAyE;IAE1E,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;CAMnG"}
@@ -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 { IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
5
+ import { FetchSource, IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
6
6
  import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
7
7
  import { IDisposable, ITelemetryLogger } from "@fluidframework/common-definitions";
8
8
  export declare class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {
@@ -16,7 +16,7 @@ export declare class RetriableDocumentStorageService implements IDocumentStorage
16
16
  get repositoryUrl(): string;
17
17
  getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null>;
18
18
  readBlob(id: string): Promise<ArrayBufferLike>;
19
- getVersions(versionId: string | null, count: number, scenarioName?: string): Promise<IVersion[]>;
19
+ getVersions(versionId: string | null, count: number, scenarioName?: string, fetchSource?: FetchSource): Promise<IVersion[]>;
20
20
  uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
21
21
  downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
22
22
  createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGnF,qBAAa,+BAAgC,YAAW,uBAAuB,EAAE,WAAW;IAGpF,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAH3B,OAAO,CAAC,SAAS,CAAS;gBAEL,sBAAsB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OAAO,CAAC,QAAQ,CAAC,MAAM;IAH3B,OAAO,CAAC,SAAS,CAAS;gBAEL,sBAAsB,EAAE,uBAAuB,EAC/C,MAAM,EAAE,gBAAgB;IAI7C,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAEjE;IACD,IAAW,QAAQ,YAA6B;IACzC,OAAO;IAId,IAAW,aAAa,IAAI,MAAM,CAEjC;IAEY,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAOzF,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9C,WAAW,CACpB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GAC1B,OAAO,CAAC,QAAQ,EAAE,CAAC;IAOT,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAuB1F,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAO9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,OAAO,CAAC,oBAAoB;YAQd,YAAY;CAU7B"}
@@ -27,8 +27,8 @@ export class RetriableDocumentStorageService {
27
27
  async readBlob(id) {
28
28
  return this.runWithRetry(async () => this.internalStorageService.readBlob(id), "storage_readBlob");
29
29
  }
30
- async getVersions(versionId, count, scenarioName) {
31
- return this.runWithRetry(async () => this.internalStorageService.getVersions(versionId, count, scenarioName), "storage_getVersions");
30
+ async getVersions(versionId, count, scenarioName, fetchSource) {
31
+ return this.runWithRetry(async () => this.internalStorageService.getVersions(versionId, count, scenarioName, fetchSource), "storage_getVersions");
32
32
  }
33
33
  async uploadSummaryWithContext(summary, context) {
34
34
  // Not using retry loop here. Couple reasons:
@@ -1 +1 @@
1
- {"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAc/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,OAAO,+BAA+B;IAExC,YACqB,sBAA+C,EAC/C,MAAwB;QADxB,2BAAsB,GAAtB,sBAAsB,CAAyB;QAC/C,WAAM,GAAN,MAAM,CAAkB;QAHrC,cAAS,GAAG,KAAK,CAAC;IAK1B,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAChD,CAAC;IACD,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACzC,OAAO;QACV,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,OAAkB,EAAE,YAAqB;QAClE,OAAO,IAAI,CAAC,YAAY,CACpB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,EAC9E,yBAAyB,CAC5B,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC5B,OAAO,IAAI,CAAC,YAAY,CACpB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,EACpD,kBAAkB,CACrB,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,SAAwB,EAAE,KAAa,EAAE,YAAqB;Q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,CAAC,SAAS,EAAE;YAChB,4DAA4D;YAC5D,MAAM,IAAI,YAAY,CAAC,2CAA2C,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;SAC5F;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,YAAY,CAAI,GAAqB,EAAE,QAAgB;QACjE,OAAO,YAAY,CACf,GAAG,EACH,QAAQ,EACR,IAAI,CAAC,MAAM,EACX;YACI,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE;SAC7C,CACJ,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { GenericError } from \"@fluidframework/container-utils\";\nimport {\n IDocumentStorageService,\n IDocumentStorageServicePolicies,\n ISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n private _disposed = false;\n constructor(\n private readonly internalStorageService: IDocumentStorageService,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n public get policies(): IDocumentStorageServicePolicies | undefined {\n return this.internalStorageService.policies;\n }\n public get disposed() { return this._disposed; }\n public dispose() {\n this._disposed = true;\n }\n\n public get repositoryUrl(): string {\n return this.internalStorageService.repositoryUrl;\n }\n\n public async getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null> {\n return this.runWithRetry(\n async () => this.internalStorageService.getSnapshotTree(version, scenarioName),\n \"storage_getSnapshotTree\",\n );\n }\n\n public async readBlob(id: string): Promise<ArrayBufferLike> {\n return this.runWithRetry(\n async () => this.internalStorageService.readBlob(id),\n \"storage_readBlob\",\n );\n }\n\n public async getVersions(versionId: string | null, count: number, scenarioName?: string): Promise<IVersion[]> {\n return this.runWithRetry(\n async () => this.internalStorageService.getVersions(versionId, count, scenarioName),\n \"storage_getVersions\",\n );\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n // Not using retry loop here. Couple reasons:\n // 1. If client lost connectivity, then retry loop will result in uploading stale summary\n // by stale summarizer after connectivity comes back. It will cause failures for this client and for\n // real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n // on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n // 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n // upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n // retryAfter into account!\n // But retry loop is required for creation flow (Container.attach)\n assert((context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n 0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */);\n if (context.referenceSequenceNumber !== 0) {\n return this.internalStorageService.uploadSummaryWithContext(summary, context);\n }\n\n // Creation flow with attachment blobs - need to do retries!\n return this.runWithRetry(\n async () => this.internalStorageService.uploadSummaryWithContext(summary, context),\n \"storage_uploadSummaryWithContext\",\n );\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n return this.runWithRetry(\n async () => this.internalStorageService.downloadSummary(handle),\n \"storage_downloadSummary\",\n );\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.runWithRetry(\n async () => this.internalStorageService.createBlob(file),\n \"storage_createBlob\",\n );\n }\n\n private checkStorageDisposed() {\n if (this._disposed) {\n // pre-0.58 error message: storageServiceDisposedCannotRetry\n throw new GenericError(\"Storage Service is disposed. Cannot retry\", { canRetry: false });\n }\n return undefined;\n }\n\n private async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n return runWithRetry(\n api,\n callName,\n this.logger,\n {\n onRetry: () => this.checkStorageDisposed(),\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAe/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,OAAO,+BAA+B;IAExC,YACqB,sBAA+C,EAC/C,MAAwB;QADxB,2BAAsB,GAAtB,sBAAsB,CAAyB;QAC/C,WAAM,GAAN,MAAM,CAAkB;QAHrC,cAAS,GAAG,KAAK,CAAC;IAK1B,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAChD,CAAC;IACD,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACzC,OAAO;QACV,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,OAAkB,EAAE,YAAqB;QAClE,OAAO,IAAI,CAAC,YAAY,CACpB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,EAC9E,yBAAyB,CAC5B,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC5B,OAAO,IAAI,CAAC,YAAY,CACpB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,EACpD,kBAAkB,CACrB,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,WAAW,CACpB,SAAwB,EACxB,KAAa,EACb,Y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C;IAEO,oBAAoB;QACxB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,4DAA4D;YAC5D,MAAM,IAAI,YAAY,CAAC,2CAA2C,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;SAC5F;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,YAAY,CAAI,GAAqB,EAAE,QAAgB;QACjE,OAAO,YAAY,CACf,GAAG,EACH,QAAQ,EACR,IAAI,CAAC,MAAM,EACX;YACI,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE;SAC7C,CACJ,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { GenericError } from \"@fluidframework/container-utils\";\nimport {\n FetchSource,\n IDocumentStorageService,\n IDocumentStorageServicePolicies,\n ISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n private _disposed = false;\n constructor(\n private readonly internalStorageService: IDocumentStorageService,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n public get policies(): IDocumentStorageServicePolicies | undefined {\n return this.internalStorageService.policies;\n }\n public get disposed() { return this._disposed; }\n public dispose() {\n this._disposed = true;\n }\n\n public get repositoryUrl(): string {\n return this.internalStorageService.repositoryUrl;\n }\n\n public async getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null> {\n return this.runWithRetry(\n async () => this.internalStorageService.getSnapshotTree(version, scenarioName),\n \"storage_getSnapshotTree\",\n );\n }\n\n public async readBlob(id: string): Promise<ArrayBufferLike> {\n return this.runWithRetry(\n async () => this.internalStorageService.readBlob(id),\n \"storage_readBlob\",\n );\n }\n\n public async getVersions(\n versionId: string | null,\n count: number,\n scenarioName?: string,\n fetchSource?: FetchSource,\n ): Promise<IVersion[]> {\n return this.runWithRetry(\n async () => this.internalStorageService.getVersions(versionId, count, scenarioName, fetchSource),\n \"storage_getVersions\",\n );\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n // Not using retry loop here. Couple reasons:\n // 1. If client lost connectivity, then retry loop will result in uploading stale summary\n // by stale summarizer after connectivity comes back. It will cause failures for this client and for\n // real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n // on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n // 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n // upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n // retryAfter into account!\n // But retry loop is required for creation flow (Container.attach)\n assert((context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n 0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */);\n if (context.referenceSequenceNumber !== 0) {\n return this.internalStorageService.uploadSummaryWithContext(summary, context);\n }\n\n // Creation flow with attachment blobs - need to do retries!\n return this.runWithRetry(\n async () => this.internalStorageService.uploadSummaryWithContext(summary, context),\n \"storage_uploadSummaryWithContext\",\n );\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n return this.runWithRetry(\n async () => this.internalStorageService.downloadSummary(handle),\n \"storage_downloadSummary\",\n );\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.runWithRetry(\n async () => this.internalStorageService.createBlob(file),\n \"storage_createBlob\",\n );\n }\n\n private checkStorageDisposed() {\n if (this._disposed) {\n // pre-0.58 error message: storageServiceDisposedCannotRetry\n throw new GenericError(\"Storage Service is disposed. Cannot retry\", { canRetry: false });\n }\n return undefined;\n }\n\n private async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n return runWithRetry(\n api,\n callName,\n this.logger,\n {\n onRetry: () => this.checkStorageDisposed(),\n },\n );\n }\n}\n"]}