@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
|
@@ -7,19 +7,19 @@ import { IDisposable, ITelemetryLogger } from "@fluidframework/common-definition
|
|
|
7
7
|
import { assert } from "@fluidframework/common-utils";
|
|
8
8
|
import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
FetchSource,
|
|
11
|
+
IDocumentService,
|
|
12
|
+
IDocumentStorageService,
|
|
13
|
+
IDocumentStorageServicePolicies,
|
|
14
|
+
ISummaryContext,
|
|
15
15
|
} from "@fluidframework/driver-definitions";
|
|
16
16
|
import { UsageError } from "@fluidframework/driver-utils";
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
ICreateBlobResponse,
|
|
19
|
+
ISnapshotTree,
|
|
20
|
+
ISummaryHandle,
|
|
21
|
+
ISummaryTree,
|
|
22
|
+
IVersion,
|
|
23
23
|
} from "@fluidframework/protocol-definitions";
|
|
24
24
|
import { IDetachedBlobStorage } from "./loader";
|
|
25
25
|
import { ProtocolTreeStorageService } from "./protocolTreeDocumentStorageService";
|
|
@@ -30,103 +30,113 @@ import { RetriableDocumentStorageService } from "./retriableDocumentStorageServi
|
|
|
30
30
|
* container attach state.
|
|
31
31
|
*/
|
|
32
32
|
export class ContainerStorageAdapter implements IDocumentStorageService, IDisposable {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
33
|
+
private readonly blobContents: { [id: string]: ArrayBufferLike } = {};
|
|
34
|
+
private _storageService: IDocumentStorageService & Partial<IDisposable>;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
detachedBlobStorage: IDetachedBlobStorage | undefined,
|
|
38
|
+
private readonly logger: ITelemetryLogger,
|
|
39
|
+
private readonly captureProtocolSummary?: () => ISummaryTree,
|
|
40
|
+
) {
|
|
41
|
+
this._storageService = new BlobOnlyStorage(detachedBlobStorage, logger);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
disposed: boolean = false;
|
|
45
|
+
dispose(error?: Error): void {
|
|
46
|
+
this._storageService?.dispose?.(error);
|
|
47
|
+
this.disposed = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async connectToService(service: IDocumentService): Promise<void> {
|
|
51
|
+
if (!(this._storageService instanceof BlobOnlyStorage)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const storageService = await service.connectToStorage();
|
|
56
|
+
const retriableStorage = (this._storageService = new RetriableDocumentStorageService(
|
|
57
|
+
storageService,
|
|
58
|
+
this.logger,
|
|
59
|
+
));
|
|
60
|
+
|
|
61
|
+
if (this.captureProtocolSummary !== undefined) {
|
|
62
|
+
this.logger.sendTelemetryEvent({ eventName: "summarizeProtocolTreeEnabled" });
|
|
63
|
+
this._storageService = new ProtocolTreeStorageService(
|
|
64
|
+
retriableStorage,
|
|
65
|
+
this.captureProtocolSummary,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ensure we did not lose that policy in the process of wrapping
|
|
70
|
+
assert(
|
|
71
|
+
storageService.policies?.minBlobSize === this._storageService.policies?.minBlobSize,
|
|
72
|
+
0x0e0 /* "lost minBlobSize policy" */,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public loadSnapshotForRehydratingContainer(snapshotTree: ISnapshotTreeWithBlobContents) {
|
|
77
|
+
this.getBlobContents(snapshotTree);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private getBlobContents(snapshotTree: ISnapshotTreeWithBlobContents) {
|
|
81
|
+
for (const [id, value] of Object.entries(snapshotTree.blobsContents)) {
|
|
82
|
+
this.blobContents[id] = value;
|
|
83
|
+
}
|
|
84
|
+
for (const [_, tree] of Object.entries(snapshotTree.trees)) {
|
|
85
|
+
this.getBlobContents(tree);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public get policies(): IDocumentStorageServicePolicies | undefined {
|
|
90
|
+
// back-compat 0.40 containerRuntime requests policies even in detached container if storage is present
|
|
91
|
+
// and storage is always present in >=0.41.
|
|
92
|
+
try {
|
|
93
|
+
return this._storageService.policies;
|
|
94
|
+
} catch (e) {}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public get repositoryUrl(): string {
|
|
99
|
+
return this._storageService.repositoryUrl;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public async getSnapshotTree(
|
|
103
|
+
version?: IVersion,
|
|
104
|
+
scenarioName?: string,
|
|
105
|
+
): Promise<ISnapshotTree | null> {
|
|
106
|
+
return this._storageService.getSnapshotTree(version, scenarioName);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public async readBlob(id: string): Promise<ArrayBufferLike> {
|
|
110
|
+
const blob = this.blobContents[id];
|
|
111
|
+
if (blob !== undefined) {
|
|
112
|
+
return blob;
|
|
113
|
+
}
|
|
114
|
+
return this._storageService.readBlob(id);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public async getVersions(
|
|
118
|
+
versionId: string | null,
|
|
119
|
+
count: number,
|
|
120
|
+
scenarioName?: string,
|
|
121
|
+
fetchSource?: FetchSource,
|
|
122
|
+
): Promise<IVersion[]> {
|
|
123
|
+
return this._storageService.getVersions(versionId, count, scenarioName, fetchSource);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public async uploadSummaryWithContext(
|
|
127
|
+
summary: ISummaryTree,
|
|
128
|
+
context: ISummaryContext,
|
|
129
|
+
): Promise<string> {
|
|
130
|
+
return this._storageService.uploadSummaryWithContext(summary, context);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {
|
|
134
|
+
return this._storageService.downloadSummary(handle);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {
|
|
138
|
+
return this._storageService.createBlob(file);
|
|
139
|
+
}
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
/**
|
|
@@ -134,50 +144,50 @@ export class ContainerStorageAdapter implements IDocumentStorageService, IDispos
|
|
|
134
144
|
* blobs in detached containers.
|
|
135
145
|
*/
|
|
136
146
|
class BlobOnlyStorage implements IDocumentStorageService {
|
|
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
|
-
|
|
147
|
+
constructor(
|
|
148
|
+
private readonly detachedStorage: IDetachedBlobStorage | undefined,
|
|
149
|
+
private readonly logger: ITelemetryLogger,
|
|
150
|
+
) {}
|
|
151
|
+
|
|
152
|
+
public async createBlob(content: ArrayBufferLike): Promise<ICreateBlobResponse> {
|
|
153
|
+
return this.verifyStorage().createBlob(content);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public async readBlob(blobId: string): Promise<ArrayBufferLike> {
|
|
157
|
+
return this.verifyStorage().readBlob(blobId);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private verifyStorage(): IDetachedBlobStorage {
|
|
161
|
+
if (this.detachedStorage === undefined) {
|
|
162
|
+
throw new UsageError("Real storage calls not allowed in Unattached container");
|
|
163
|
+
}
|
|
164
|
+
return this.detachedStorage;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public get policies(): IDocumentStorageServicePolicies | undefined {
|
|
168
|
+
return this.notCalled();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public get repositoryUrl(): string {
|
|
172
|
+
return this.notCalled();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
176
|
+
public getSnapshotTree: () => Promise<ISnapshotTree | null> = this.notCalled;
|
|
177
|
+
public getVersions: () => Promise<IVersion[]> = this.notCalled;
|
|
178
|
+
public write: () => Promise<IVersion> = this.notCalled;
|
|
179
|
+
public uploadSummaryWithContext: () => Promise<string> = this.notCalled;
|
|
180
|
+
public downloadSummary: () => Promise<ISummaryTree> = this.notCalled;
|
|
181
|
+
/* eslint-enable @typescript-eslint/unbound-method */
|
|
182
|
+
|
|
183
|
+
private notCalled(): never {
|
|
184
|
+
this.verifyStorage();
|
|
185
|
+
try {
|
|
186
|
+
// some browsers may not populate stack unless exception is thrown
|
|
187
|
+
throw new Error("BlobOnlyStorage not implemented method used");
|
|
188
|
+
} catch (err) {
|
|
189
|
+
this.logger.sendTelemetryEvent({ eventName: "BlobOnlyStorageWrongCall" }, err);
|
|
190
|
+
throw err;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
183
193
|
}
|