@fluidframework/container-loader 2.0.2 → 2.1.0-276326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +2 -5
- package/api-extractor/api-extractor.legacy.json +4 -0
- package/api-report/container-loader.beta.api.md +0 -27
- package/api-report/{container-loader.alpha.api.md → container-loader.legacy.alpha.api.md} +0 -27
- package/api-report/container-loader.public.api.md +0 -27
- package/dist/attachment.d.ts +2 -1
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js.map +1 -1
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +4 -4
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts +15 -4
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js +12 -3
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts +24 -8
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +36 -23
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +30 -20
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +15 -11
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +7 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +45 -28
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +8 -4
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +3 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +12 -6
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +17 -8
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +4 -2
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.js +3 -3
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +13 -9
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +32 -23
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +1 -4
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +2 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/disposal.d.ts +1 -1
- package/dist/disposal.d.ts.map +1 -1
- package/dist/disposal.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/loadPaused.d.ts +2 -2
- package/dist/loadPaused.d.ts.map +1 -1
- package/dist/loadPaused.js +7 -3
- package/dist/loadPaused.js.map +1 -1
- package/dist/loader.d.ts +10 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +11 -1
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/dist/memoryBlobStorage.d.ts.map +1 -1
- package/dist/memoryBlobStorage.js +4 -2
- package/dist/memoryBlobStorage.js.map +1 -1
- package/dist/noopHeuristic.js +1 -1
- package/dist/noopHeuristic.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol/protocol.d.ts +4 -3
- package/dist/protocol/protocol.d.ts.map +1 -1
- package/dist/protocol/protocol.js +6 -5
- package/dist/protocol/protocol.js.map +1 -1
- package/dist/protocol/quorum.d.ts +11 -8
- package/dist/protocol/quorum.d.ts.map +1 -1
- package/dist/protocol/quorum.js +8 -8
- package/dist/protocol/quorum.js.map +1 -1
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +7 -2
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +2 -2
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +4 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +29 -12
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +55 -24
- package/dist/serializedStateManager.js.map +1 -1
- package/dist/utils.d.ts +4 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +15 -6
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.ts +2 -1
- package/lib/attachment.d.ts.map +1 -1
- package/lib/attachment.js.map +1 -1
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js +4 -4
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts +15 -4
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js +12 -3
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts +24 -8
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +36 -23
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +30 -20
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +14 -12
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +7 -2
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +45 -28
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +8 -4
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +3 -1
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +12 -6
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +17 -8
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +4 -2
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.js +3 -3
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +13 -9
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +32 -23
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +1 -4
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +2 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/disposal.d.ts +1 -1
- package/lib/disposal.d.ts.map +1 -1
- package/lib/disposal.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/loadPaused.d.ts +2 -2
- package/lib/loadPaused.d.ts.map +1 -1
- package/lib/loadPaused.js +8 -4
- package/lib/loadPaused.js.map +1 -1
- package/lib/loader.d.ts +10 -1
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +11 -1
- package/lib/loader.js.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/lib/memoryBlobStorage.d.ts.map +1 -1
- package/lib/memoryBlobStorage.js +4 -2
- package/lib/memoryBlobStorage.js.map +1 -1
- package/lib/noopHeuristic.js +1 -1
- package/lib/noopHeuristic.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol/protocol.d.ts +4 -3
- package/lib/protocol/protocol.d.ts.map +1 -1
- package/lib/protocol/protocol.js +6 -5
- package/lib/protocol/protocol.js.map +1 -1
- package/lib/protocol/quorum.d.ts +11 -8
- package/lib/protocol/quorum.d.ts.map +1 -1
- package/lib/protocol/quorum.js +8 -8
- package/lib/protocol/quorum.js.map +1 -1
- package/lib/protocol.d.ts +2 -0
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +7 -2
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts +2 -2
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +4 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/serializedStateManager.d.ts +29 -12
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +56 -25
- package/lib/serializedStateManager.js.map +1 -1
- package/lib/utils.d.ts +4 -2
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +16 -7
- package/lib/utils.js.map +1 -1
- package/package.json +21 -17
- package/src/attachment.ts +2 -1
- package/src/audience.ts +4 -4
- package/src/catchUpMonitor.ts +23 -8
- package/src/connectionManager.ts +85 -60
- package/src/connectionStateHandler.ts +85 -63
- package/src/container.ts +118 -84
- package/src/containerContext.ts +5 -3
- package/src/containerStorageAdapter.ts +20 -13
- package/src/contracts.ts +21 -9
- package/src/debugLogger.ts +4 -4
- package/src/deltaManager.ts +75 -56
- package/src/deltaQueue.ts +16 -10
- package/src/disposal.ts +3 -3
- package/src/error.ts +2 -1
- package/src/loadPaused.ts +16 -8
- package/src/loader.ts +20 -2
- package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +7 -3
- package/src/memoryBlobStorage.ts +5 -3
- package/src/noopHeuristic.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocol/protocol.ts +12 -11
- package/src/protocol/quorum.ts +49 -40
- package/src/protocol.ts +12 -4
- package/src/protocolTreeDocumentStorageService.ts +3 -2
- package/src/retriableDocumentStorageService.ts +6 -3
- package/src/serializedStateManager.ts +95 -39
- package/src/utils.ts +26 -10
package/src/deltaQueue.ts
CHANGED
|
@@ -29,7 +29,7 @@ export class DeltaQueue<T>
|
|
|
29
29
|
*/
|
|
30
30
|
private pauseCount = 1;
|
|
31
31
|
|
|
32
|
-
private error:
|
|
32
|
+
private error: Error | undefined;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* When processing is ongoing, holds a deferred that will resolve once processing stops.
|
|
@@ -42,7 +42,7 @@ export class DeltaQueue<T>
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Whether or not the queue is paused.
|
|
46
46
|
*/
|
|
47
47
|
public get paused(): boolean {
|
|
48
48
|
return this.pauseCount !== 0;
|
|
@@ -56,7 +56,10 @@ export class DeltaQueue<T>
|
|
|
56
56
|
return this.processingPromise === undefined && this.q.length === 0;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
public async waitTillProcessingDone() {
|
|
59
|
+
public async waitTillProcessingDone(): Promise<{
|
|
60
|
+
count: number;
|
|
61
|
+
duration: number;
|
|
62
|
+
}> {
|
|
60
63
|
return this.processingPromise ?? { count: 0, duration: 0 };
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -67,7 +70,7 @@ export class DeltaQueue<T>
|
|
|
67
70
|
super();
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
public dispose() {
|
|
73
|
+
public dispose(): void {
|
|
71
74
|
throw new Error("Not implemented.");
|
|
72
75
|
this.isDisposed = true;
|
|
73
76
|
}
|
|
@@ -84,7 +87,7 @@ export class DeltaQueue<T>
|
|
|
84
87
|
return this.q.toArray();
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
public push(task: T) {
|
|
90
|
+
public push(task: T): void {
|
|
88
91
|
try {
|
|
89
92
|
this.q.push(task);
|
|
90
93
|
this.emit("push", task);
|
|
@@ -112,7 +115,7 @@ export class DeltaQueue<T>
|
|
|
112
115
|
* accidental reentrancy. ensureProcessing can be called safely to start the processing loop if it is
|
|
113
116
|
* not already started.
|
|
114
117
|
*/
|
|
115
|
-
private ensureProcessing() {
|
|
118
|
+
private ensureProcessing(): void {
|
|
116
119
|
if (this.anythingToProcess() && this.processingPromise === undefined) {
|
|
117
120
|
// Use a resolved promise to start the processing on a separate stack.
|
|
118
121
|
this.processingPromise = Promise.resolve()
|
|
@@ -126,7 +129,7 @@ export class DeltaQueue<T>
|
|
|
126
129
|
this.processingPromise = undefined;
|
|
127
130
|
return result;
|
|
128
131
|
})
|
|
129
|
-
.catch((error) => {
|
|
132
|
+
.catch((error: Error) => {
|
|
130
133
|
this.error = error;
|
|
131
134
|
this.processingPromise = undefined;
|
|
132
135
|
this.emit("error", error);
|
|
@@ -139,14 +142,17 @@ export class DeltaQueue<T>
|
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
|
|
142
|
-
private anythingToProcess() {
|
|
143
|
-
return this.q.length
|
|
145
|
+
private anythingToProcess(): boolean {
|
|
146
|
+
return this.q.length > 0 && !this.paused && this.error === undefined;
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
/**
|
|
147
150
|
* Executes the delta processing loop until a stop condition is reached.
|
|
148
151
|
*/
|
|
149
|
-
private processDeltas() {
|
|
152
|
+
private processDeltas(): {
|
|
153
|
+
count: number;
|
|
154
|
+
duration: number;
|
|
155
|
+
} {
|
|
150
156
|
const start = performance.now();
|
|
151
157
|
let count = 0;
|
|
152
158
|
|
package/src/disposal.ts
CHANGED
|
@@ -13,9 +13,9 @@ import { IDisposable } from "@fluidframework/core-interfaces";
|
|
|
13
13
|
*/
|
|
14
14
|
export function doIfNotDisposed<T>(
|
|
15
15
|
disposable: IDisposable,
|
|
16
|
-
f: (...args:
|
|
17
|
-
): (...args:
|
|
18
|
-
return (...args:
|
|
16
|
+
f: (...args: unknown[]) => T,
|
|
17
|
+
): (...args: unknown[]) => T {
|
|
18
|
+
return (...args: unknown[]): T => {
|
|
19
19
|
if (disposable.disposed) {
|
|
20
20
|
throw new Error("Already disposed");
|
|
21
21
|
} else {
|
package/src/error.ts
CHANGED
|
@@ -42,7 +42,8 @@ export class ThrottlingWarning
|
|
|
42
42
|
retryAfterSeconds: number,
|
|
43
43
|
logger: ITelemetryLoggerExt,
|
|
44
44
|
): IThrottlingWarning {
|
|
45
|
-
const newErrorFn = (errMsg: string)
|
|
45
|
+
const newErrorFn = (errMsg: string): ThrottlingWarning =>
|
|
46
|
+
new ThrottlingWarning(errMsg, retryAfterSeconds);
|
|
46
47
|
return wrapErrorAndLog(error, newErrorFn, logger);
|
|
47
48
|
}
|
|
48
49
|
}
|
package/src/loadPaused.ts
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ILoader,
|
|
8
|
+
LoaderHeader,
|
|
9
|
+
type IContainer,
|
|
10
|
+
} from "@fluidframework/container-definitions/internal";
|
|
7
11
|
import { IRequest } from "@fluidframework/core-interfaces";
|
|
8
12
|
import type { IErrorBase } from "@fluidframework/core-interfaces";
|
|
9
13
|
import { GenericError } from "@fluidframework/telemetry-utils/internal";
|
|
@@ -42,7 +46,7 @@ export async function loadContainerPaused(
|
|
|
42
46
|
request: IRequest,
|
|
43
47
|
loadToSequenceNumber?: number,
|
|
44
48
|
signal?: AbortSignal,
|
|
45
|
-
) {
|
|
49
|
+
): Promise<IContainer> {
|
|
46
50
|
const container = await loader.resolve({
|
|
47
51
|
url: request.url,
|
|
48
52
|
headers: {
|
|
@@ -58,8 +62,10 @@ export async function loadContainerPaused(
|
|
|
58
62
|
const dm = container.deltaManager;
|
|
59
63
|
const lastProcessedSequenceNumber = dm.initialSequenceNumber;
|
|
60
64
|
|
|
61
|
-
const pauseContainer = () => {
|
|
65
|
+
const pauseContainer = (): void => {
|
|
66
|
+
// eslint-disable-next-line no-void
|
|
62
67
|
void dm.inbound.pause();
|
|
68
|
+
// eslint-disable-next-line no-void
|
|
63
69
|
void dm.outbound.pause();
|
|
64
70
|
};
|
|
65
71
|
|
|
@@ -86,12 +92,12 @@ export async function loadContainerPaused(
|
|
|
86
92
|
let onAbort: () => void;
|
|
87
93
|
let onClose: (error?: IErrorBase) => void;
|
|
88
94
|
|
|
89
|
-
const promise = new Promise<void>((resolve,
|
|
90
|
-
onAbort = () =>
|
|
91
|
-
onClose = (error?: IErrorBase) =>
|
|
95
|
+
const promise = new Promise<void>((resolve, reject) => {
|
|
96
|
+
onAbort = (): void => reject(new GenericError("Canceled due to cancellation request."));
|
|
97
|
+
onClose = (error?: IErrorBase): void => reject(error);
|
|
92
98
|
|
|
93
99
|
// We need to setup a listener to stop op processing once we reach the desired sequence number (if specified).
|
|
94
|
-
opHandler = () => {
|
|
100
|
+
opHandler = (): void => {
|
|
95
101
|
// If there is a specified sequence number, keep processing until we reach it.
|
|
96
102
|
if (
|
|
97
103
|
loadToSequenceNumber !== undefined &&
|
|
@@ -119,7 +125,9 @@ export async function loadContainerPaused(
|
|
|
119
125
|
|
|
120
126
|
// Wait for the ops to be processed.
|
|
121
127
|
await promise
|
|
122
|
-
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
.catch((error: any) => {
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
123
131
|
container.close(error);
|
|
124
132
|
throw error;
|
|
125
133
|
})
|
package/src/loader.ts
CHANGED
|
@@ -68,11 +68,15 @@ export class RelativeLoader implements ILoader {
|
|
|
68
68
|
const container = await this.container.clone(
|
|
69
69
|
{
|
|
70
70
|
resolvedUrl: { ...this.container.resolvedUrl },
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
71
72
|
version: request.headers?.[LoaderHeader.version] ?? undefined,
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
72
74
|
loadMode: request.headers?.[LoaderHeader.loadMode],
|
|
73
75
|
},
|
|
74
76
|
{
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
75
78
|
canReconnect: request.headers?.[LoaderHeader.reconnect],
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
76
80
|
clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],
|
|
77
81
|
},
|
|
78
82
|
);
|
|
@@ -87,6 +91,7 @@ export class RelativeLoader implements ILoader {
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
/**
|
|
94
|
+
* @legacy
|
|
90
95
|
* @alpha
|
|
91
96
|
*/
|
|
92
97
|
export interface ILoaderOptions extends ILoaderOptions1 {
|
|
@@ -98,10 +103,13 @@ export interface ILoaderOptions extends ILoaderOptions1 {
|
|
|
98
103
|
* {@link @fluidframework/container-definitions#IFluidModuleWithDetails}
|
|
99
104
|
* to have all the code loading modules in one package. #8193
|
|
100
105
|
* Encapsulates a module entry point with corresponding code details.
|
|
106
|
+
* @legacy
|
|
101
107
|
* @alpha
|
|
102
108
|
*/
|
|
103
109
|
export interface IFluidModuleWithDetails {
|
|
104
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Fluid code module that implements the runtime factory needed to instantiate the container runtime.
|
|
112
|
+
*/
|
|
105
113
|
module: IFluidModule;
|
|
106
114
|
/**
|
|
107
115
|
* Code details associated with the module. Represents a document schema this module supports.
|
|
@@ -116,6 +124,7 @@ export interface IFluidModuleWithDetails {
|
|
|
116
124
|
* to have code loading modules in one package. #8193
|
|
117
125
|
* Fluid code loader resolves a code module matching the document schema, i.e. code details, such as
|
|
118
126
|
* a package name and package version range.
|
|
127
|
+
* @legacy
|
|
119
128
|
* @alpha
|
|
120
129
|
*/
|
|
121
130
|
export interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {
|
|
@@ -130,6 +139,7 @@ export interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComp
|
|
|
130
139
|
|
|
131
140
|
/**
|
|
132
141
|
* Services and properties necessary for creating a loader
|
|
142
|
+
* @legacy
|
|
133
143
|
* @alpha
|
|
134
144
|
*/
|
|
135
145
|
export interface ILoaderProps {
|
|
@@ -187,6 +197,7 @@ export interface ILoaderProps {
|
|
|
187
197
|
|
|
188
198
|
/**
|
|
189
199
|
* Services and properties used by and exposed by the loader
|
|
200
|
+
* @legacy
|
|
190
201
|
* @alpha
|
|
191
202
|
*/
|
|
192
203
|
export interface ILoaderServices {
|
|
@@ -241,6 +252,7 @@ export interface ILoaderServices {
|
|
|
241
252
|
/**
|
|
242
253
|
* Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support
|
|
243
254
|
* blobs in detached containers.
|
|
255
|
+
* @legacy
|
|
244
256
|
* @alpha
|
|
245
257
|
*
|
|
246
258
|
* @deprecated - IDetachedBlobStorage will be removed in a future release without a replacement. Blobs created while detached will be stored in memory to align with attached container behavior. AB#8049
|
|
@@ -260,6 +272,7 @@ export type IDetachedBlobStorage = Pick<IDocumentStorageService, "createBlob" |
|
|
|
260
272
|
|
|
261
273
|
/**
|
|
262
274
|
* Manages Fluid resource loading
|
|
275
|
+
* @legacy
|
|
263
276
|
* @alpha
|
|
264
277
|
*/
|
|
265
278
|
export class Loader implements IHostLoader {
|
|
@@ -298,7 +311,7 @@ export class Loader implements IHostLoader {
|
|
|
298
311
|
codeLoader,
|
|
299
312
|
options: options ?? {},
|
|
300
313
|
scope:
|
|
301
|
-
options?.provideScopeLoader
|
|
314
|
+
options?.provideScopeLoader === false ? { ...scope } : { ...scope, ILoader: this },
|
|
302
315
|
detachedBlobStorage,
|
|
303
316
|
protocolHandlerBuilder,
|
|
304
317
|
subLogger: subMc.logger,
|
|
@@ -377,6 +390,7 @@ export class Loader implements IHostLoader {
|
|
|
377
390
|
|
|
378
391
|
request.headers ??= {};
|
|
379
392
|
// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.
|
|
393
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
380
394
|
request.headers[LoaderHeader.version] =
|
|
381
395
|
parsed.version ?? request.headers[LoaderHeader.version];
|
|
382
396
|
|
|
@@ -391,12 +405,16 @@ export class Loader implements IHostLoader {
|
|
|
391
405
|
return Container.load(
|
|
392
406
|
{
|
|
393
407
|
resolvedUrl,
|
|
408
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
394
409
|
version: request.headers?.[LoaderHeader.version] ?? undefined,
|
|
410
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
395
411
|
loadMode: request.headers?.[LoaderHeader.loadMode],
|
|
396
412
|
pendingLocalState,
|
|
397
413
|
},
|
|
398
414
|
{
|
|
415
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
399
416
|
canReconnect: request.headers?.[LoaderHeader.reconnect],
|
|
417
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
400
418
|
clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],
|
|
401
419
|
...this.services,
|
|
402
420
|
},
|
|
@@ -17,11 +17,14 @@ import { createChildLogger } from "@fluidframework/telemetry-utils/internal";
|
|
|
17
17
|
* @returns `true` is the error is location redirection error, otherwise `false`.
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
|
-
export function isLocationRedirectionError(
|
|
20
|
+
export function isLocationRedirectionError(
|
|
21
|
+
error: unknown,
|
|
22
|
+
): error is ILocationRedirectionError {
|
|
21
23
|
return (
|
|
22
24
|
typeof error === "object" &&
|
|
23
25
|
error !== null &&
|
|
24
|
-
error.errorType ===
|
|
26
|
+
(error as Partial<ILocationRedirectionError>).errorType ===
|
|
27
|
+
DriverErrorTypes.locationRedirection
|
|
25
28
|
);
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -32,6 +35,7 @@ export function isLocationRedirectionError(error: any): error is ILocationRedire
|
|
|
32
35
|
* @param urlResolver - resolver used to resolve the url.
|
|
33
36
|
* @param logger - logger to send events.
|
|
34
37
|
* @returns Response from the API call.
|
|
38
|
+
* @legacy
|
|
35
39
|
* @alpha
|
|
36
40
|
*/
|
|
37
41
|
export async function resolveWithLocationRedirectionHandling<T>(
|
|
@@ -45,7 +49,7 @@ export async function resolveWithLocationRedirectionHandling<T>(
|
|
|
45
49
|
for (;;) {
|
|
46
50
|
try {
|
|
47
51
|
return await api(req);
|
|
48
|
-
} catch (error:
|
|
52
|
+
} catch (error: unknown) {
|
|
49
53
|
if (!isLocationRedirectionError(error)) {
|
|
50
54
|
throw error;
|
|
51
55
|
}
|
package/src/memoryBlobStorage.ts
CHANGED
|
@@ -48,7 +48,7 @@ export function tryInitializeMemoryDetachedBlobStorage(
|
|
|
48
48
|
// eslint-disable-next-line import/no-deprecated
|
|
49
49
|
detachedStorage: IDetachedBlobStorage | undefined,
|
|
50
50
|
attachmentBlobs: string,
|
|
51
|
-
) {
|
|
51
|
+
): void {
|
|
52
52
|
if (!isMemoryDetachedBlobStorage(detachedStorage)) {
|
|
53
53
|
throw new Error(
|
|
54
54
|
"DetachedBlobStorage was not provided to the loader during serialize so cannot be provided during rehydrate.",
|
|
@@ -56,9 +56,11 @@ export function tryInitializeMemoryDetachedBlobStorage(
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
assert(detachedStorage.size === 0, 0x99e /* Blob storage already initialized */);
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
59
60
|
const maybeAttachmentBlobs = JSON.parse(attachmentBlobs);
|
|
60
61
|
assert(Array.isArray(maybeAttachmentBlobs), 0x99f /* Invalid attachmentBlobs */);
|
|
61
62
|
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
62
64
|
detachedStorage.initialize(maybeAttachmentBlobs);
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -77,9 +79,9 @@ export function createMemoryDetachedBlobStorage(): IDetachedBlobStorage {
|
|
|
77
79
|
},
|
|
78
80
|
getBlobIds: (): string[] => blobs.map((_, i) => `${i}`),
|
|
79
81
|
dispose: () => blobs.splice(0),
|
|
80
|
-
serialize: () => JSON.stringify(blobs.map((b) => bufferToString(b, "
|
|
82
|
+
serialize: () => JSON.stringify(blobs.map((b) => bufferToString(b, "utf8"))),
|
|
81
83
|
initialize: (attachmentBlobs: string[]) =>
|
|
82
|
-
blobs.push(...attachmentBlobs.map((maybeBlob) => stringToBuffer(maybeBlob, "
|
|
84
|
+
blobs.push(...attachmentBlobs.map((maybeBlob) => stringToBuffer(maybeBlob, "utf8"))),
|
|
83
85
|
};
|
|
84
86
|
return storage;
|
|
85
87
|
}
|
package/src/noopHeuristic.ts
CHANGED
|
@@ -44,7 +44,7 @@ export class NoopHeuristic extends TypedEventEmitter<INoopSenderEvents> {
|
|
|
44
44
|
private readonly NoopCountFrequency: number = defaultNoopCountFrequency,
|
|
45
45
|
) {
|
|
46
46
|
super();
|
|
47
|
-
if (NoopTimeFrequency !==
|
|
47
|
+
if (NoopTimeFrequency !== Number.POSITIVE_INFINITY) {
|
|
48
48
|
this.timer = new Timer(NoopTimeFrequency, () => {
|
|
49
49
|
// We allow the timer to expire even if an op is sent or we disconnect.
|
|
50
50
|
// This condition is to guard against trying to send a noop anyway in that case.
|
package/src/packageVersion.ts
CHANGED
package/src/protocol/protocol.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ISequencedClient } from "@fluidframework/driver-definitions";
|
|
7
|
-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
8
7
|
import {
|
|
8
|
+
ISequencedDocumentMessage,
|
|
9
9
|
IDocumentAttributes,
|
|
10
10
|
IClientJoin,
|
|
11
11
|
ICommittedProposal,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import { IQuorumSnapshot, Quorum } from "./quorum.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
+
* @legacy
|
|
23
24
|
* @alpha
|
|
24
25
|
*/
|
|
25
26
|
export interface IScribeProtocolState {
|
|
@@ -31,6 +32,7 @@ export interface IScribeProtocolState {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/**
|
|
35
|
+
* @legacy
|
|
34
36
|
* @alpha
|
|
35
37
|
*/
|
|
36
38
|
export interface IProtocolHandler {
|
|
@@ -61,7 +63,7 @@ export class ProtocolOpHandler implements IProtocolHandler {
|
|
|
61
63
|
members: [string, ISequencedClient][],
|
|
62
64
|
proposals: [number, ISequencedProposal, string[]][],
|
|
63
65
|
values: [string, ICommittedProposal][],
|
|
64
|
-
sendProposal: (key: string, value:
|
|
66
|
+
sendProposal: (key: string, value: unknown) => number,
|
|
65
67
|
) {
|
|
66
68
|
this._quorum = new Quorum(members, proposals, values, sendProposal);
|
|
67
69
|
}
|
|
@@ -73,7 +75,7 @@ export class ProtocolOpHandler implements IProtocolHandler {
|
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
setConnectionState(connected: boolean, clientId: string | undefined) {
|
|
78
|
+
setConnectionState(connected: boolean, clientId: string | undefined): void {
|
|
77
79
|
this._quorum.setConnectionState(connected, clientId);
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -81,7 +83,7 @@ export class ProtocolOpHandler implements IProtocolHandler {
|
|
|
81
83
|
return this._quorum.snapshot();
|
|
82
84
|
}
|
|
83
85
|
|
|
84
|
-
public close() {
|
|
86
|
+
public close(): void {
|
|
85
87
|
this._quorum.close();
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -103,10 +105,8 @@ export class ProtocolOpHandler implements IProtocolHandler {
|
|
|
103
105
|
|
|
104
106
|
let immediateNoOp = false;
|
|
105
107
|
|
|
106
|
-
/* eslint-disable no-case-declarations */
|
|
107
|
-
|
|
108
108
|
switch (message.type) {
|
|
109
|
-
case MessageType.ClientJoin:
|
|
109
|
+
case MessageType.ClientJoin: {
|
|
110
110
|
const systemJoinMessage = message as ISequencedDocumentSystemMessage;
|
|
111
111
|
const join = JSON.parse(systemJoinMessage.data) as IClientJoin;
|
|
112
112
|
const member: ISequencedClient = {
|
|
@@ -115,14 +115,16 @@ export class ProtocolOpHandler implements IProtocolHandler {
|
|
|
115
115
|
};
|
|
116
116
|
this._quorum.addMember(join.clientId, member);
|
|
117
117
|
break;
|
|
118
|
+
}
|
|
118
119
|
|
|
119
|
-
case MessageType.ClientLeave:
|
|
120
|
+
case MessageType.ClientLeave: {
|
|
120
121
|
const systemLeaveMessage = message as ISequencedDocumentSystemMessage;
|
|
121
122
|
const clientId = JSON.parse(systemLeaveMessage.data) as string;
|
|
122
123
|
this._quorum.removeMember(clientId);
|
|
123
124
|
break;
|
|
125
|
+
}
|
|
124
126
|
|
|
125
|
-
case MessageType.Propose:
|
|
127
|
+
case MessageType.Propose: {
|
|
126
128
|
// back-compat: ADO #1385: This should become unconditional eventually.
|
|
127
129
|
// Can be done only after Container.processRemoteMessage() stops parsing content!
|
|
128
130
|
if (typeof message.contents === "string") {
|
|
@@ -140,12 +142,11 @@ export class ProtocolOpHandler implements IProtocolHandler {
|
|
|
140
142
|
// On a quorum proposal, immediately send a response to expedite the approval.
|
|
141
143
|
immediateNoOp = true;
|
|
142
144
|
break;
|
|
145
|
+
}
|
|
143
146
|
|
|
144
147
|
default:
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
/* eslint-enable no-case-declarations */
|
|
148
|
-
|
|
149
150
|
// Notify the quorum of the MSN from the message. We rely on it to handle duplicate values but may
|
|
150
151
|
// want to move that logic to this class.
|
|
151
152
|
this._quorum.updateMinimumSequenceNumber(message);
|