@fluidframework/container-loader 2.70.0-361788 → 2.71.0
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/CHANGELOG.md +8 -0
- package/api-report/container-loader.legacy.alpha.api.md +13 -0
- package/dist/container.d.ts +7 -4
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +98 -15
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +1 -0
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +1 -0
- package/dist/containerContext.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/legacyAlpha.d.ts +1 -0
- 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/pendingLocalStateStore.d.ts +84 -0
- package/dist/pendingLocalStateStore.d.ts.map +1 -0
- package/dist/pendingLocalStateStore.js +157 -0
- package/dist/pendingLocalStateStore.js.map +1 -0
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +43 -1
- package/dist/protocol.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -4
- package/dist/utils.js.map +1 -1
- package/lib/container.d.ts +7 -4
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +99 -16
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +1 -0
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +1 -0
- package/lib/containerContext.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/legacyAlpha.d.ts +1 -0
- 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/pendingLocalStateStore.d.ts +84 -0
- package/lib/pendingLocalStateStore.d.ts.map +1 -0
- package/lib/pendingLocalStateStore.js +153 -0
- package/lib/pendingLocalStateStore.js.map +1 -0
- package/lib/protocol.d.ts +1 -0
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +41 -0
- package/lib/protocol.js.map +1 -1
- package/lib/utils.d.ts +1 -0
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +0 -4
- package/lib/utils.js.map +1 -1
- package/package.json +15 -15
- package/src/container.ts +133 -31
- package/src/containerContext.ts +2 -0
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/pendingLocalStateStore.ts +160 -0
- package/src/protocol.ts +49 -0
- package/src/utils.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -203,6 +203,19 @@ export interface OnDemandSummaryResults {
|
|
|
203
203
|
readonly summarySubmitted: boolean;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
// @alpha @legacy
|
|
207
|
+
export class PendingLocalStateStore<TKey> {
|
|
208
|
+
[Symbol.iterator](): Iterator<[TKey, string]>;
|
|
209
|
+
clear(): void;
|
|
210
|
+
delete(key: TKey): boolean;
|
|
211
|
+
entries(): Iterator<[TKey, string]>;
|
|
212
|
+
get(key: TKey): string | undefined;
|
|
213
|
+
has(key: TKey): boolean;
|
|
214
|
+
keys(): IterableIterator<TKey>;
|
|
215
|
+
set(key: TKey, pendingLocalState: string): this;
|
|
216
|
+
get size(): number;
|
|
217
|
+
}
|
|
218
|
+
|
|
206
219
|
// @beta @legacy
|
|
207
220
|
export type ProtocolHandlerBuilder = (attributes: IDocumentAttributes, snapshot: IQuorumSnapshot, sendProposal: (key: string, value: any) => number) => IProtocolHandler;
|
|
208
221
|
|
package/dist/container.d.ts
CHANGED
|
@@ -141,6 +141,7 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
|
|
|
141
141
|
private readonly subLogger;
|
|
142
142
|
private readonly detachedBlobStorage;
|
|
143
143
|
private readonly protocolHandlerBuilder;
|
|
144
|
+
private readonly signalAudience;
|
|
144
145
|
private readonly client;
|
|
145
146
|
private readonly mc;
|
|
146
147
|
/**
|
|
@@ -347,12 +348,14 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
|
|
|
347
348
|
private instantiateRuntime;
|
|
348
349
|
private readonly updateDirtyContainerState;
|
|
349
350
|
/**
|
|
350
|
-
*
|
|
351
|
-
* This controls the "connected" state of the ContainerRuntime as well
|
|
352
|
-
* @param connected - Is the container currently connected?
|
|
351
|
+
* Send the connected status to the runtime.
|
|
353
352
|
* @param readonly - Is the container in readonly mode?
|
|
353
|
+
* @param onlyCallSetConnectionStateIfConnectedOrDisconnected - If true, only
|
|
354
|
+
* call older `setConnectionState` on the runtime if the connection state is
|
|
355
|
+
* either Connected or Disconnected. This exists to preserve older behavior
|
|
356
|
+
* where the runtime was only notified of these two states.
|
|
354
357
|
*/
|
|
355
|
-
private
|
|
358
|
+
private setConnectionStatus;
|
|
356
359
|
private handleDeltaConnectionArg;
|
|
357
360
|
}
|
|
358
361
|
/**
|
package/dist/container.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EACN,WAAW,EACX,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAGX,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EAMjB,YAAY,EAEZ,cAAc,EAEd,MAAM,gDAAgD,CAAC;AAExD,OAAO,EACN,KAAK,WAAW,EAEhB,KAAK,QAAQ,EACb,KAAK,wBAAwB,EAE7B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAEN,KAAK,cAAc,EAC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e,SAAQ,UAAU;IACjD;;;;;OAKG;IACH,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAE9D"}
|
package/dist/container.js
CHANGED
|
@@ -216,12 +216,16 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
216
216
|
// in the order that is not possible in real life, that it may not expect.
|
|
217
217
|
// Ideally, we should supply pendingLocalState?.clientId here as well, not in constructor, but it does not matter (at least today)
|
|
218
218
|
this.connectionStateHandler.initProtocol(this.protocolHandler);
|
|
219
|
-
// Propagate current connection state through the system.
|
|
220
|
-
const readonly = this.readOnlyInfo.readonly ?? false;
|
|
221
219
|
// This call does not look like needed any more, with delaying all connection-related events past loaded phase.
|
|
222
220
|
// Yet, there could be some customer code that would break if we do not deliver it.
|
|
223
221
|
// Will be removed in further PRs with proper changeset.
|
|
224
|
-
|
|
222
|
+
const runtime = this._runtime;
|
|
223
|
+
if (runtime !== undefined &&
|
|
224
|
+
// Check for older runtime that may need this call
|
|
225
|
+
!("setConnectionStatus" in runtime) &&
|
|
226
|
+
runtime.disposed === false) {
|
|
227
|
+
runtime.setConnectionState(false /* canSendOps */, this.clientId);
|
|
228
|
+
}
|
|
225
229
|
// Deliver delayed calls to DeltaManager - we ignored "connect" events while loading.
|
|
226
230
|
const cm = this._deltaManager.connectionManager;
|
|
227
231
|
if (cm.connected) {
|
|
@@ -381,6 +385,7 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
381
385
|
}, error);
|
|
382
386
|
this.close((0, internal_5.normalizeError)(error));
|
|
383
387
|
});
|
|
388
|
+
this.signalAudience = new audience_js_1.Audience();
|
|
384
389
|
/**
|
|
385
390
|
* Lifecycle state of the container, used mainly to prevent re-entrancy and telemetry
|
|
386
391
|
*
|
|
@@ -524,9 +529,8 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
524
529
|
// Tracking alternative ways to handle this in AB#4129.
|
|
525
530
|
this.options = { ...options };
|
|
526
531
|
this.scope = scope;
|
|
527
|
-
this.protocolHandlerBuilder =
|
|
528
|
-
|
|
529
|
-
((attributes, quorumSnapshot, sendProposal) => new protocol_js_1.ProtocolHandler(attributes, quorumSnapshot, sendProposal, new audience_js_1.Audience(), (clientId) => this.clientsWhoShouldHaveLeft.has(clientId)));
|
|
532
|
+
this.protocolHandlerBuilder = (0, protocol_js_1.wrapProtocolHandlerBuilder)(protocolHandlerBuilder ??
|
|
533
|
+
((attributes, quorumSnapshot, sendProposal) => new protocol_js_1.ProtocolHandler(attributes, quorumSnapshot, sendProposal, new audience_js_1.Audience(), (clientId) => this.clientsWhoShouldHaveLeft.has(clientId))), this.signalAudience);
|
|
530
534
|
// Note that we capture the createProps here so we can replicate the creation call when we want to clone.
|
|
531
535
|
this.clone = async (_loadProps, createParamOverrides) => {
|
|
532
536
|
return Container.load(_loadProps, {
|
|
@@ -1330,7 +1334,7 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
1330
1334
|
});
|
|
1331
1335
|
deltaManager.on("readonly", (readonly) => {
|
|
1332
1336
|
if (this.loaded) {
|
|
1333
|
-
this.
|
|
1337
|
+
this.setConnectionStatus(readonly);
|
|
1334
1338
|
}
|
|
1335
1339
|
this.emit("readonly", readonly);
|
|
1336
1340
|
});
|
|
@@ -1406,7 +1410,18 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
1406
1410
|
const clientId = this.connectionStateHandler.clientId;
|
|
1407
1411
|
(0, internal_2.assert)(clientId !== undefined, 0x96e /* there has to be clientId */);
|
|
1408
1412
|
this.protocolHandler.audience.setCurrentClientId(clientId);
|
|
1413
|
+
this.signalAudience.setCurrentClientId(clientId);
|
|
1414
|
+
}
|
|
1415
|
+
else if (this.connectionState === connectionState_js_1.ConnectionState.CatchingUp) {
|
|
1416
|
+
// Signal-based Audience does not wait for ops. So provide clientId
|
|
1417
|
+
// as soon as possible.
|
|
1418
|
+
const clientId = this.connectionStateHandler.pendingClientId;
|
|
1419
|
+
(0, internal_2.assert)(clientId !== undefined, 0xc89 /* catching up without clientId */);
|
|
1420
|
+
this.signalAudience.setCurrentClientId(clientId);
|
|
1409
1421
|
}
|
|
1422
|
+
this.setConnectionStatus(
|
|
1423
|
+
/* readonly */ this.readOnlyInfo.readonly ?? false,
|
|
1424
|
+
/* onlyCallSetConnectionStateIfConnectedOrDisconnected */ true);
|
|
1410
1425
|
// We communicate only transitions to Connected & Disconnected states, skipping all other states.
|
|
1411
1426
|
// This can be changed in the future, for example we likely should add "CatchingUp" event on Container.
|
|
1412
1427
|
if (this.connectionState !== connectionState_js_1.ConnectionState.Connected &&
|
|
@@ -1414,7 +1429,6 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
1414
1429
|
return;
|
|
1415
1430
|
}
|
|
1416
1431
|
// Both protocol and context should not be undefined if we got so far.
|
|
1417
|
-
this.setContextConnectedState(connected, this.readOnlyInfo.readonly ?? false);
|
|
1418
1432
|
this.protocolHandler.setConnectionState(connected, this.clientId);
|
|
1419
1433
|
(0, internal_5.raiseConnectedEvent)(this.mc.logger, this, connected, this.clientId, disconnectedReason?.text);
|
|
1420
1434
|
}
|
|
@@ -1512,7 +1526,15 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
1512
1526
|
this.protocolHandler.processSignal(message);
|
|
1513
1527
|
}
|
|
1514
1528
|
else {
|
|
1515
|
-
const local =
|
|
1529
|
+
const local =
|
|
1530
|
+
// Check against signal audience to detect current signals
|
|
1531
|
+
// including very early signals before reaching "Connected".
|
|
1532
|
+
message.clientId === this.signalAudience.getSelf()?.clientId ||
|
|
1533
|
+
// and use "regular" audience to detect signals from past
|
|
1534
|
+
// connection bouncing slowly back from service. This may never
|
|
1535
|
+
// happen, but is kept as it was used historically as the only
|
|
1536
|
+
// check.
|
|
1537
|
+
message.clientId === this.clientId;
|
|
1516
1538
|
this.runtime.processSignal(message, local);
|
|
1517
1539
|
}
|
|
1518
1540
|
}
|
|
@@ -1546,6 +1568,7 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
1546
1568
|
storage: this.storageAdapter,
|
|
1547
1569
|
quorum: this.protocolHandler.quorum,
|
|
1548
1570
|
audience: this.protocolHandler.audience,
|
|
1571
|
+
signalAudience: this.signalAudience,
|
|
1549
1572
|
loader,
|
|
1550
1573
|
submitFn: (type, contents, batch, metadata) => this.submitContainerMessage(type, contents, batch, metadata),
|
|
1551
1574
|
submitSummaryFn: (summaryOp, referenceSequenceNumber) => this.submitSummaryMessage(summaryOp, referenceSequenceNumber),
|
|
@@ -1580,15 +1603,75 @@ class Container extends internal_5.EventEmitterWithErrorHandling {
|
|
|
1580
1603
|
}
|
|
1581
1604
|
}
|
|
1582
1605
|
/**
|
|
1583
|
-
*
|
|
1584
|
-
* This controls the "connected" state of the ContainerRuntime as well
|
|
1585
|
-
* @param connected - Is the container currently connected?
|
|
1606
|
+
* Send the connected status to the runtime.
|
|
1586
1607
|
* @param readonly - Is the container in readonly mode?
|
|
1608
|
+
* @param onlyCallSetConnectionStateIfConnectedOrDisconnected - If true, only
|
|
1609
|
+
* call older `setConnectionState` on the runtime if the connection state is
|
|
1610
|
+
* either Connected or Disconnected. This exists to preserve older behavior
|
|
1611
|
+
* where the runtime was only notified of these two states.
|
|
1587
1612
|
*/
|
|
1588
|
-
|
|
1613
|
+
setConnectionStatus(readonly, onlyCallSetConnectionStateIfConnectedOrDisconnected = false) {
|
|
1589
1614
|
if (this._runtime?.disposed === false && this.loaded) {
|
|
1590
|
-
this.runtime.
|
|
1591
|
-
|
|
1615
|
+
const setConnectionStatus = this.runtime.setConnectionStatus?.bind(this.runtime);
|
|
1616
|
+
if (setConnectionStatus === undefined) {
|
|
1617
|
+
if (!onlyCallSetConnectionStateIfConnectedOrDisconnected ||
|
|
1618
|
+
this.connectionState === connectionState_js_1.ConnectionState.Connected ||
|
|
1619
|
+
this.connectionState === connectionState_js_1.ConnectionState.Disconnected) {
|
|
1620
|
+
this.runtime.setConnectionState(this.connectionState === connectionState_js_1.ConnectionState.Connected &&
|
|
1621
|
+
!readonly /* container can send ops if connected to service and not in readonly mode */, this.clientId);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
else {
|
|
1625
|
+
const pendingClientConnectionId = this.connectionStateHandler.pendingClientId;
|
|
1626
|
+
const connectionState = this.connectionState;
|
|
1627
|
+
switch (connectionState) {
|
|
1628
|
+
case connectionState_js_1.ConnectionState.EstablishingConnection: {
|
|
1629
|
+
setConnectionStatus({
|
|
1630
|
+
connectionState,
|
|
1631
|
+
canSendOps: false,
|
|
1632
|
+
readonly,
|
|
1633
|
+
});
|
|
1634
|
+
break;
|
|
1635
|
+
}
|
|
1636
|
+
case connectionState_js_1.ConnectionState.CatchingUp: {
|
|
1637
|
+
// When catching up, we have a pending clientId, but it
|
|
1638
|
+
// is not usable for ops. Send clientId with canSendOps false.
|
|
1639
|
+
(0, internal_2.assert)(pendingClientConnectionId !== undefined, 0xc8a /* catching up without clientId */);
|
|
1640
|
+
setConnectionStatus({
|
|
1641
|
+
connectionState,
|
|
1642
|
+
pendingClientConnectionId,
|
|
1643
|
+
canSendOps: false,
|
|
1644
|
+
readonly,
|
|
1645
|
+
});
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
case connectionState_js_1.ConnectionState.Connected: {
|
|
1649
|
+
// When connected, we have an active clientId. Pass it along
|
|
1650
|
+
// with canSendOps true/false based on readonly.
|
|
1651
|
+
const clientConnectionId = this.clientId;
|
|
1652
|
+
(0, internal_2.assert)(clientConnectionId !== undefined, 0xc8b /* connected without clientId */);
|
|
1653
|
+
(0, internal_2.assert)(clientConnectionId === pendingClientConnectionId, 0xc8c /* connected with different clientId than pending */);
|
|
1654
|
+
setConnectionStatus({
|
|
1655
|
+
connectionState,
|
|
1656
|
+
clientConnectionId,
|
|
1657
|
+
canSendOps: !readonly,
|
|
1658
|
+
readonly,
|
|
1659
|
+
});
|
|
1660
|
+
break;
|
|
1661
|
+
}
|
|
1662
|
+
case connectionState_js_1.ConnectionState.Disconnected: {
|
|
1663
|
+
setConnectionStatus({
|
|
1664
|
+
connectionState,
|
|
1665
|
+
priorPendingClientConnectionId: pendingClientConnectionId,
|
|
1666
|
+
priorConnectedClientConnectionId: this.clientId,
|
|
1667
|
+
canSendOps: false,
|
|
1668
|
+
readonly,
|
|
1669
|
+
});
|
|
1670
|
+
break;
|
|
1671
|
+
}
|
|
1672
|
+
// No default
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1592
1675
|
}
|
|
1593
1676
|
}
|
|
1594
1677
|
handleDeltaConnectionArg(deltaConnectionArg, connectionArgs) {
|