@fluidframework/container-loader 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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.js +18 -21
- package/.mocharc.js +2 -2
- package/README.md +45 -43
- package/api-extractor.json +2 -2
- package/closeAndGetPendingLocalState.md +51 -0
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/collabWindowTracker.d.ts.map +1 -1
- package/dist/collabWindowTracker.js.map +1 -1
- package/dist/connectionManager.d.ts +2 -2
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +51 -24
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +35 -16
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +1 -10
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +89 -44
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +6 -2
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +2 -4
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/deltaManager.d.ts +3 -3
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +56 -27
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaManagerProxy.d.ts.map +1 -1
- package/dist/deltaManagerProxy.js.map +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +4 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +3 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +18 -15
- package/dist/loader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +2 -1
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/quorum.d.ts.map +1 -1
- package/dist/quorum.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +6 -2
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +6 -4
- package/dist/utils.js.map +1 -1
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/collabWindowTracker.d.ts.map +1 -1
- package/lib/collabWindowTracker.js.map +1 -1
- package/lib/connectionManager.d.ts +2 -2
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +53 -26
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionState.d.ts.map +1 -1
- package/lib/connectionState.js.map +1 -1
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +35 -16
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +1 -10
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +93 -48
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +6 -2
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +2 -4
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/deltaManager.d.ts +3 -3
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +58 -29
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaManagerProxy.d.ts.map +1 -1
- package/lib/deltaManagerProxy.js.map +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +4 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +3 -3
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +18 -15
- package/lib/loader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +2 -1
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/quorum.d.ts.map +1 -1
- package/lib/quorum.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +6 -2
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +6 -4
- package/lib/utils.js.map +1 -1
- package/package.json +115 -114
- package/prettier.config.cjs +1 -1
- package/src/audience.ts +51 -46
- package/src/catchUpMonitor.ts +39 -37
- package/src/collabWindowTracker.ts +75 -70
- package/src/connectionManager.ts +1006 -944
- package/src/connectionState.ts +19 -19
- package/src/connectionStateHandler.ts +544 -465
- package/src/container.ts +2056 -1909
- package/src/containerContext.ts +350 -340
- package/src/containerStorageAdapter.ts +163 -153
- package/src/contracts.ts +155 -153
- package/src/deltaManager.ts +1069 -992
- package/src/deltaManagerProxy.ts +143 -137
- package/src/deltaQueue.ts +155 -151
- package/src/index.ts +14 -17
- package/src/loader.ts +428 -430
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +93 -87
- package/src/protocolTreeDocumentStorageService.ts +30 -33
- package/src/quorum.ts +34 -34
- package/src/retriableDocumentStorageService.ts +118 -102
- package/src/utils.ts +89 -82
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/src/containerContext.ts
CHANGED
|
@@ -6,44 +6,40 @@
|
|
|
6
6
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
7
|
import { LazyPromise } from "@fluidframework/common-utils";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
IAudience,
|
|
10
|
+
IContainerContext,
|
|
11
|
+
IDeltaManager,
|
|
12
|
+
ILoader,
|
|
13
|
+
IRuntime,
|
|
14
|
+
ICriticalContainerError,
|
|
15
|
+
AttachState,
|
|
16
|
+
ILoaderOptions,
|
|
17
|
+
IRuntimeFactory,
|
|
18
|
+
IProvideRuntimeFactory,
|
|
19
|
+
IFluidCodeDetails,
|
|
20
|
+
IFluidCodeDetailsComparer,
|
|
21
|
+
IProvideFluidCodeDetailsComparer,
|
|
22
|
+
ICodeDetailsLoader,
|
|
23
|
+
IFluidModuleWithDetails,
|
|
24
|
+
ISnapshotTreeWithBlobContents,
|
|
25
|
+
IBatchMessage,
|
|
26
26
|
} from "@fluidframework/container-definitions";
|
|
27
|
-
import {
|
|
28
|
-
IRequest,
|
|
29
|
-
IResponse,
|
|
30
|
-
FluidObject,
|
|
31
|
-
} from "@fluidframework/core-interfaces";
|
|
27
|
+
import { IRequest, IResponse, FluidObject } from "@fluidframework/core-interfaces";
|
|
32
28
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
33
29
|
import { isFluidResolvedUrl } from "@fluidframework/driver-utils";
|
|
34
30
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
IClientConfiguration,
|
|
32
|
+
IClientDetails,
|
|
33
|
+
IDocumentMessage,
|
|
34
|
+
IQuorum,
|
|
35
|
+
IQuorumClients,
|
|
36
|
+
ISequencedDocumentMessage,
|
|
37
|
+
ISignalMessage,
|
|
38
|
+
ISnapshotTree,
|
|
39
|
+
ISummaryTree,
|
|
40
|
+
IVersion,
|
|
41
|
+
MessageType,
|
|
42
|
+
ISummaryContent,
|
|
47
43
|
} from "@fluidframework/protocol-definitions";
|
|
48
44
|
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
49
45
|
import { Container } from "./container";
|
|
@@ -51,312 +47,326 @@ import { Container } from "./container";
|
|
|
51
47
|
const PackageNotFactoryError = "Code package does not implement IRuntimeFactory";
|
|
52
48
|
|
|
53
49
|
export class ContainerContext implements IContainerContext {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
50
|
+
public static async createOrLoad(
|
|
51
|
+
container: Container,
|
|
52
|
+
scope: FluidObject,
|
|
53
|
+
codeLoader: ICodeDetailsLoader,
|
|
54
|
+
codeDetails: IFluidCodeDetails,
|
|
55
|
+
baseSnapshot: ISnapshotTree | undefined,
|
|
56
|
+
deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,
|
|
57
|
+
quorum: IQuorum,
|
|
58
|
+
loader: ILoader,
|
|
59
|
+
submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,
|
|
60
|
+
submitSummaryFn: (summaryOp: ISummaryContent) => number,
|
|
61
|
+
submitBatchFn: (batch: IBatchMessage[]) => number,
|
|
62
|
+
submitSignalFn: (contents: any) => void,
|
|
63
|
+
disposeFn: (error?: ICriticalContainerError) => void,
|
|
64
|
+
closeFn: (error?: ICriticalContainerError) => void,
|
|
65
|
+
version: string,
|
|
66
|
+
updateDirtyContainerState: (dirty: boolean) => void,
|
|
67
|
+
existing: boolean,
|
|
68
|
+
pendingLocalState?: unknown,
|
|
69
|
+
): Promise<ContainerContext> {
|
|
70
|
+
const context = new ContainerContext(
|
|
71
|
+
container,
|
|
72
|
+
scope,
|
|
73
|
+
codeLoader,
|
|
74
|
+
codeDetails,
|
|
75
|
+
baseSnapshot,
|
|
76
|
+
deltaManager,
|
|
77
|
+
quorum,
|
|
78
|
+
loader,
|
|
79
|
+
submitFn,
|
|
80
|
+
submitSummaryFn,
|
|
81
|
+
submitBatchFn,
|
|
82
|
+
submitSignalFn,
|
|
83
|
+
disposeFn,
|
|
84
|
+
closeFn,
|
|
85
|
+
version,
|
|
86
|
+
updateDirtyContainerState,
|
|
87
|
+
existing,
|
|
88
|
+
pendingLocalState,
|
|
89
|
+
);
|
|
90
|
+
await context.instantiateRuntime(existing);
|
|
91
|
+
return context;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public readonly taggedLogger: ITelemetryLogger;
|
|
95
|
+
|
|
96
|
+
public get clientId(): string | undefined {
|
|
97
|
+
return this.container.clientId;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* DISCLAIMER: this id is only for telemetry purposes. Not suitable for any other usages.
|
|
102
|
+
*/
|
|
103
|
+
public get id(): string {
|
|
104
|
+
const resolvedUrl = this.container.resolvedUrl;
|
|
105
|
+
if (isFluidResolvedUrl(resolvedUrl)) {
|
|
106
|
+
return resolvedUrl.id;
|
|
107
|
+
}
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public get clientDetails(): IClientDetails {
|
|
112
|
+
return this.container.clientDetails;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private _connected: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* When true, ops are free to flow
|
|
118
|
+
* When false, ops should be kept as pending or rejected
|
|
119
|
+
*/
|
|
120
|
+
public get connected(): boolean {
|
|
121
|
+
return this._connected;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public get canSummarize(): boolean {
|
|
125
|
+
return "summarize" in this.runtime;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public get serviceConfiguration(): IClientConfiguration | undefined {
|
|
129
|
+
return this.container.serviceConfiguration;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public get audience(): IAudience {
|
|
133
|
+
return this.container.audience;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public get options(): ILoaderOptions {
|
|
137
|
+
return this.container.options;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public get baseSnapshot() {
|
|
141
|
+
return this._baseSnapshot;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public get storage(): IDocumentStorageService {
|
|
145
|
+
return this.container.storage;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private _runtime: IRuntime | undefined;
|
|
149
|
+
private get runtime() {
|
|
150
|
+
if (this._runtime === undefined) {
|
|
151
|
+
throw new Error("Attempted to access runtime before it was defined");
|
|
152
|
+
}
|
|
153
|
+
return this._runtime;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private _disposed = false;
|
|
157
|
+
|
|
158
|
+
public get disposed() {
|
|
159
|
+
return this._disposed;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public get codeDetails() {
|
|
163
|
+
return this._codeDetails;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private readonly _quorum: IQuorum;
|
|
167
|
+
public get quorum(): IQuorumClients {
|
|
168
|
+
return this._quorum;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private readonly _fluidModuleP: Promise<IFluidModuleWithDetails>;
|
|
172
|
+
|
|
173
|
+
constructor(
|
|
174
|
+
private readonly container: Container,
|
|
175
|
+
public readonly scope: FluidObject,
|
|
176
|
+
private readonly codeLoader: ICodeDetailsLoader,
|
|
177
|
+
private readonly _codeDetails: IFluidCodeDetails,
|
|
178
|
+
private _baseSnapshot: ISnapshotTree | undefined,
|
|
179
|
+
public readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,
|
|
180
|
+
quorum: IQuorum,
|
|
181
|
+
public readonly loader: ILoader,
|
|
182
|
+
public readonly submitFn: (
|
|
183
|
+
type: MessageType,
|
|
184
|
+
contents: any,
|
|
185
|
+
batch: boolean,
|
|
186
|
+
appData: any,
|
|
187
|
+
) => number,
|
|
188
|
+
public readonly submitSummaryFn: (summaryOp: ISummaryContent) => number,
|
|
189
|
+
/** @returns clientSequenceNumber of last message in a batch */
|
|
190
|
+
public readonly submitBatchFn: (batch: IBatchMessage[]) => number,
|
|
191
|
+
public readonly submitSignalFn: (contents: any) => void,
|
|
192
|
+
public readonly disposeFn: (error?: ICriticalContainerError) => void,
|
|
193
|
+
public readonly closeFn: (error?: ICriticalContainerError) => void,
|
|
194
|
+
public readonly version: string,
|
|
195
|
+
public readonly updateDirtyContainerState: (dirty: boolean) => void,
|
|
196
|
+
public readonly existing: boolean,
|
|
197
|
+
public readonly pendingLocalState?: unknown,
|
|
198
|
+
) {
|
|
199
|
+
this._connected = this.container.connected;
|
|
200
|
+
this._quorum = quorum;
|
|
201
|
+
this.taggedLogger = container.subLogger;
|
|
202
|
+
this._fluidModuleP = new LazyPromise<IFluidModuleWithDetails>(async () =>
|
|
203
|
+
this.loadCodeModule(_codeDetails),
|
|
204
|
+
);
|
|
205
|
+
this.attachListener();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @deprecated Temporary migratory API, to be removed when customers no longer need it.
|
|
210
|
+
* When removed, `ContainerContext` should only take an {@link @fluidframework/container-definitions#IQuorumClients}
|
|
211
|
+
* rather than an {@link @fluidframework/protocol-definitions#IQuorum}.
|
|
212
|
+
* See {@link @fluidframework/container-definitions#IContainerContext} for more details.
|
|
213
|
+
*/
|
|
214
|
+
public getSpecifiedCodeDetails(): IFluidCodeDetails | undefined {
|
|
215
|
+
return (this._quorum.get("code") ?? this._quorum.get("code2")) as
|
|
216
|
+
| IFluidCodeDetails
|
|
217
|
+
| undefined;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public dispose(error?: Error): void {
|
|
221
|
+
if (this._disposed) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
this._disposed = true;
|
|
225
|
+
|
|
226
|
+
this.runtime.dispose(error);
|
|
227
|
+
this._quorum.dispose();
|
|
228
|
+
this.deltaManager.dispose();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public getLoadedFromVersion(): IVersion | undefined {
|
|
232
|
+
return this.container.loadedFromVersion;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
public get attachState(): AttachState {
|
|
236
|
+
return this.container.attachState;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Create a summary. Used when attaching or serializing a detached container.
|
|
241
|
+
*
|
|
242
|
+
* @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported
|
|
243
|
+
* using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the
|
|
244
|
+
* new storage IDs so requests can be redirected.
|
|
245
|
+
*/
|
|
246
|
+
public createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree {
|
|
247
|
+
return this.runtime.createSummary(blobRedirectTable);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
public setConnectionState(connected: boolean, clientId?: string) {
|
|
251
|
+
const runtime = this.runtime;
|
|
252
|
+
this._connected = connected;
|
|
253
|
+
runtime.setConnectionState(connected, clientId);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public process(message: ISequencedDocumentMessage, local: boolean) {
|
|
257
|
+
this.runtime.process(message, local);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public processSignal(message: ISignalMessage, local: boolean) {
|
|
261
|
+
this.runtime.processSignal(message, local);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public async request(path: IRequest): Promise<IResponse> {
|
|
265
|
+
return this.runtime.request(path);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
public async getAbsoluteUrl(relativeUrl: string): Promise<string | undefined> {
|
|
269
|
+
return this.container.getAbsoluteUrl(relativeUrl);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
public getPendingLocalState(): unknown {
|
|
273
|
+
return this.runtime.getPendingLocalState();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Determines if the current code details of the context
|
|
278
|
+
* satisfy the incoming constraint code details
|
|
279
|
+
*/
|
|
280
|
+
public async satisfies(constraintCodeDetails: IFluidCodeDetails) {
|
|
281
|
+
const comparers: IFluidCodeDetailsComparer[] = [];
|
|
282
|
+
|
|
283
|
+
const maybeCompareCodeLoader = this.codeLoader;
|
|
284
|
+
if (maybeCompareCodeLoader.IFluidCodeDetailsComparer !== undefined) {
|
|
285
|
+
comparers.push(maybeCompareCodeLoader.IFluidCodeDetailsComparer);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const moduleWithDetails = await this._fluidModuleP;
|
|
289
|
+
const maybeCompareExport: Partial<IProvideFluidCodeDetailsComparer> | undefined =
|
|
290
|
+
moduleWithDetails.module?.fluidExport;
|
|
291
|
+
if (maybeCompareExport?.IFluidCodeDetailsComparer !== undefined) {
|
|
292
|
+
comparers.push(maybeCompareExport.IFluidCodeDetailsComparer);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// if there are not comparers it is not possible to know
|
|
296
|
+
// if the current satisfy the incoming, so return false,
|
|
297
|
+
// as assuming they do not satisfy is safer .e.g we will
|
|
298
|
+
// reload, rather than potentially running with
|
|
299
|
+
// incompatible code
|
|
300
|
+
if (comparers.length === 0) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
for (const comparer of comparers) {
|
|
305
|
+
const satisfies = await comparer.satisfies(
|
|
306
|
+
moduleWithDetails.details,
|
|
307
|
+
constraintCodeDetails,
|
|
308
|
+
);
|
|
309
|
+
if (satisfies === false) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
public notifyAttaching(snapshot: ISnapshotTreeWithBlobContents) {
|
|
317
|
+
this._baseSnapshot = snapshot;
|
|
318
|
+
this.runtime.notifyAttaching?.(snapshot);
|
|
319
|
+
this.runtime.setAttachState(AttachState.Attaching);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// #region private
|
|
323
|
+
|
|
324
|
+
private async getRuntimeFactory(): Promise<IRuntimeFactory> {
|
|
325
|
+
const fluidExport: FluidObject<IProvideRuntimeFactory> | undefined = (
|
|
326
|
+
await this._fluidModuleP
|
|
327
|
+
).module?.fluidExport;
|
|
328
|
+
const runtimeFactory = fluidExport?.IRuntimeFactory;
|
|
329
|
+
if (runtimeFactory === undefined) {
|
|
330
|
+
throw new Error(PackageNotFactoryError);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return runtimeFactory;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
private async instantiateRuntime(existing: boolean) {
|
|
337
|
+
const runtimeFactory = await this.getRuntimeFactory();
|
|
338
|
+
this._runtime = await PerformanceEvent.timedExecAsync(
|
|
330
339
|
this.taggedLogger,
|
|
331
340
|
{ eventName: "InstantiateRuntime" },
|
|
332
|
-
async () => runtimeFactory.instantiateRuntime(this, existing)
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
341
|
+
async () => runtimeFactory.instantiateRuntime(this, existing),
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
private attachListener() {
|
|
346
|
+
this.container.once("attached", () => {
|
|
347
|
+
this.runtime.setAttachState(AttachState.Attached);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
private async loadCodeModule(codeDetails: IFluidCodeDetails): Promise<IFluidModuleWithDetails> {
|
|
352
|
+
const loadCodeResult = await PerformanceEvent.timedExecAsync(
|
|
353
|
+
this.taggedLogger,
|
|
354
|
+
{ eventName: "CodeLoad" },
|
|
355
|
+
async () => this.codeLoader.load(codeDetails),
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
if ("module" in loadCodeResult) {
|
|
359
|
+
const { module, details } = loadCodeResult;
|
|
360
|
+
return {
|
|
361
|
+
module,
|
|
362
|
+
details: details ?? codeDetails,
|
|
363
|
+
};
|
|
364
|
+
} else {
|
|
365
|
+
// If "module" is not in the result, we are using a legacy ICodeLoader. Fix the result up with details.
|
|
366
|
+
// Once usage drops to 0 we can remove this compat path.
|
|
367
|
+
this.taggedLogger.sendTelemetryEvent({ eventName: "LegacyCodeLoader" });
|
|
368
|
+
return loadCodeResult;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// #endregion
|
|
362
372
|
}
|