@fluidframework/container-loader 2.0.0-dev-rc.5.0.0.268409 → 2.0.0-dev-rc.5.0.0.270987

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 (166) hide show
  1. package/api-report/container-loader.alpha.api.md +59 -4
  2. package/api-report/container-loader.beta.api.md +7 -3
  3. package/api-report/container-loader.public.api.md +7 -3
  4. package/biome.jsonc +4 -0
  5. package/dist/audience.js +2 -1
  6. package/dist/audience.js.map +1 -1
  7. package/dist/catchUpMonitor.js +11 -8
  8. package/dist/catchUpMonitor.js.map +1 -1
  9. package/dist/connectionManager.d.ts +2 -2
  10. package/dist/connectionManager.d.ts.map +1 -1
  11. package/dist/connectionManager.js +91 -63
  12. package/dist/connectionManager.js.map +1 -1
  13. package/dist/connectionStateHandler.js +35 -11
  14. package/dist/connectionStateHandler.js.map +1 -1
  15. package/dist/container.d.ts +3 -2
  16. package/dist/container.d.ts.map +1 -1
  17. package/dist/container.js +162 -126
  18. package/dist/container.js.map +1 -1
  19. package/dist/containerContext.d.ts +2 -2
  20. package/dist/containerContext.d.ts.map +1 -1
  21. package/dist/containerContext.js +34 -8
  22. package/dist/containerContext.js.map +1 -1
  23. package/dist/containerStorageAdapter.js +17 -9
  24. package/dist/containerStorageAdapter.js.map +1 -1
  25. package/dist/contracts.d.ts +2 -2
  26. package/dist/contracts.d.ts.map +1 -1
  27. package/dist/contracts.js.map +1 -1
  28. package/dist/debugLogger.js +2 -0
  29. package/dist/debugLogger.js.map +1 -1
  30. package/dist/deltaManager.d.ts +2 -2
  31. package/dist/deltaManager.d.ts.map +1 -1
  32. package/dist/deltaManager.js +48 -35
  33. package/dist/deltaManager.js.map +1 -1
  34. package/dist/deltaQueue.js +14 -7
  35. package/dist/deltaQueue.js.map +1 -1
  36. package/dist/error.js +5 -4
  37. package/dist/error.js.map +1 -1
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/legacy.d.ts +5 -0
  42. package/dist/loader.js +5 -1
  43. package/dist/loader.js.map +1 -1
  44. package/dist/noopHeuristic.d.ts +1 -1
  45. package/dist/noopHeuristic.d.ts.map +1 -1
  46. package/dist/noopHeuristic.js +3 -1
  47. package/dist/noopHeuristic.js.map +1 -1
  48. package/dist/packageVersion.d.ts +1 -1
  49. package/dist/packageVersion.js +1 -1
  50. package/dist/packageVersion.js.map +1 -1
  51. package/dist/protocol/index.d.ts +7 -0
  52. package/dist/protocol/index.d.ts.map +1 -0
  53. package/dist/protocol/index.js +12 -0
  54. package/dist/protocol/index.js.map +1 -0
  55. package/dist/protocol/protocol.d.ts +52 -0
  56. package/dist/protocol/protocol.d.ts.map +1 -0
  57. package/dist/protocol/protocol.js +115 -0
  58. package/dist/protocol/protocol.js.map +1 -0
  59. package/dist/protocol/quorum.d.ts +185 -0
  60. package/dist/protocol/quorum.d.ts.map +1 -0
  61. package/dist/protocol/quorum.js +440 -0
  62. package/dist/protocol/quorum.js.map +1 -0
  63. package/dist/protocol.d.ts +2 -3
  64. package/dist/protocol.d.ts.map +1 -1
  65. package/dist/protocol.js +4 -2
  66. package/dist/protocol.js.map +1 -1
  67. package/dist/protocolTreeDocumentStorageService.d.ts +7 -7
  68. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  69. package/dist/protocolTreeDocumentStorageService.js +16 -7
  70. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  71. package/dist/retriableDocumentStorageService.js +4 -1
  72. package/dist/retriableDocumentStorageService.js.map +1 -1
  73. package/dist/serializedStateManager.d.ts +5 -3
  74. package/dist/serializedStateManager.d.ts.map +1 -1
  75. package/dist/serializedStateManager.js +26 -5
  76. package/dist/serializedStateManager.js.map +1 -1
  77. package/lib/audience.js +2 -1
  78. package/lib/audience.js.map +1 -1
  79. package/lib/catchUpMonitor.js +11 -8
  80. package/lib/catchUpMonitor.js.map +1 -1
  81. package/lib/connectionManager.d.ts +2 -2
  82. package/lib/connectionManager.d.ts.map +1 -1
  83. package/lib/connectionManager.js +91 -63
  84. package/lib/connectionManager.js.map +1 -1
  85. package/lib/connectionStateHandler.js +35 -11
  86. package/lib/connectionStateHandler.js.map +1 -1
  87. package/lib/container.d.ts +3 -2
  88. package/lib/container.d.ts.map +1 -1
  89. package/lib/container.js +162 -126
  90. package/lib/container.js.map +1 -1
  91. package/lib/containerContext.d.ts +2 -2
  92. package/lib/containerContext.d.ts.map +1 -1
  93. package/lib/containerContext.js +34 -8
  94. package/lib/containerContext.js.map +1 -1
  95. package/lib/containerStorageAdapter.js +17 -9
  96. package/lib/containerStorageAdapter.js.map +1 -1
  97. package/lib/contracts.d.ts +2 -2
  98. package/lib/contracts.d.ts.map +1 -1
  99. package/lib/contracts.js.map +1 -1
  100. package/lib/debugLogger.js +2 -0
  101. package/lib/debugLogger.js.map +1 -1
  102. package/lib/deltaManager.d.ts +2 -2
  103. package/lib/deltaManager.d.ts.map +1 -1
  104. package/lib/deltaManager.js +48 -35
  105. package/lib/deltaManager.js.map +1 -1
  106. package/lib/deltaQueue.js +14 -7
  107. package/lib/deltaQueue.js.map +1 -1
  108. package/lib/error.js +5 -4
  109. package/lib/error.js.map +1 -1
  110. package/lib/index.d.ts +1 -0
  111. package/lib/index.d.ts.map +1 -1
  112. package/lib/index.js.map +1 -1
  113. package/lib/legacy.d.ts +5 -0
  114. package/lib/loader.js +5 -1
  115. package/lib/loader.js.map +1 -1
  116. package/lib/noopHeuristic.d.ts +1 -1
  117. package/lib/noopHeuristic.d.ts.map +1 -1
  118. package/lib/noopHeuristic.js +3 -1
  119. package/lib/noopHeuristic.js.map +1 -1
  120. package/lib/packageVersion.d.ts +1 -1
  121. package/lib/packageVersion.js +1 -1
  122. package/lib/packageVersion.js.map +1 -1
  123. package/lib/protocol/index.d.ts +7 -0
  124. package/lib/protocol/index.d.ts.map +1 -0
  125. package/lib/protocol/index.js +7 -0
  126. package/lib/protocol/index.js.map +1 -0
  127. package/lib/protocol/protocol.d.ts +52 -0
  128. package/lib/protocol/protocol.d.ts.map +1 -0
  129. package/lib/protocol/protocol.js +111 -0
  130. package/lib/protocol/protocol.js.map +1 -0
  131. package/lib/protocol/quorum.d.ts +185 -0
  132. package/lib/protocol/quorum.d.ts.map +1 -0
  133. package/lib/protocol/quorum.js +431 -0
  134. package/lib/protocol/quorum.js.map +1 -0
  135. package/lib/protocol.d.ts +2 -3
  136. package/lib/protocol.d.ts.map +1 -1
  137. package/lib/protocol.js +3 -1
  138. package/lib/protocol.js.map +1 -1
  139. package/lib/protocolTreeDocumentStorageService.d.ts +7 -7
  140. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  141. package/lib/protocolTreeDocumentStorageService.js +16 -7
  142. package/lib/protocolTreeDocumentStorageService.js.map +1 -1
  143. package/lib/retriableDocumentStorageService.js +4 -1
  144. package/lib/retriableDocumentStorageService.js.map +1 -1
  145. package/lib/serializedStateManager.d.ts +5 -3
  146. package/lib/serializedStateManager.d.ts.map +1 -1
  147. package/lib/serializedStateManager.js +26 -5
  148. package/lib/serializedStateManager.js.map +1 -1
  149. package/package.json +19 -14
  150. package/src/catchUpMonitor.ts +1 -1
  151. package/src/connectionManager.ts +3 -7
  152. package/src/container.ts +16 -9
  153. package/src/containerContext.ts +2 -5
  154. package/src/contracts.ts +3 -6
  155. package/src/deltaManager.ts +3 -5
  156. package/src/index.ts +7 -0
  157. package/src/noopHeuristic.ts +1 -1
  158. package/src/packageVersion.ts +1 -1
  159. package/src/protocol/README.md +10 -0
  160. package/src/protocol/index.ts +16 -0
  161. package/src/protocol/protocol.ts +185 -0
  162. package/src/protocol/quorum.ts +584 -0
  163. package/src/protocol.ts +4 -6
  164. package/src/protocolTreeDocumentStorageService.ts +16 -8
  165. package/src/serializedStateManager.ts +25 -4
  166. package/tsconfig.json +2 -0
@@ -7,6 +7,7 @@
7
7
  import { FluidObject } from '@fluidframework/core-interfaces';
8
8
  import { IAudienceOwner } from '@fluidframework/container-definitions/internal';
9
9
  import { IClientDetails } from '@fluidframework/driver-definitions';
10
+ import { ICommittedProposal } from '@fluidframework/driver-definitions/internal';
10
11
  import { IConfigProviderBase } from '@fluidframework/core-interfaces';
11
12
  import { IContainer } from '@fluidframework/container-definitions/internal';
12
13
  import { IDocumentAttributes } from '@fluidframework/driver-definitions/internal';
@@ -18,11 +19,14 @@ import { IHostLoader } from '@fluidframework/container-definitions/internal';
18
19
  import { ILoader } from '@fluidframework/container-definitions/internal';
19
20
  import { ILoaderOptions as ILoaderOptions_2 } from '@fluidframework/container-definitions/internal';
20
21
  import { ILocationRedirectionError } from '@fluidframework/driver-definitions/internal';
21
- import { IProtocolHandler as IProtocolHandler_2 } from '@fluidframework/protocol-base';
22
+ import { IProcessMessageResult } from '@fluidframework/driver-definitions/internal';
22
23
  import { IProvideFluidCodeDetailsComparer } from '@fluidframework/container-definitions/internal';
23
- import { IQuorumSnapshot } from '@fluidframework/protocol-base';
24
+ import { IQuorum } from '@fluidframework/driver-definitions/internal';
24
25
  import { IRequest } from '@fluidframework/core-interfaces';
25
- import { ISignalMessage } from '@fluidframework/driver-definitions';
26
+ import { ISequencedClient } from '@fluidframework/driver-definitions';
27
+ import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';
28
+ import { ISequencedProposal } from '@fluidframework/driver-definitions/internal';
29
+ import { ISignalMessage } from '@fluidframework/driver-definitions/internal';
26
30
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
27
31
  import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils/internal';
28
32
  import { IUrlResolver } from '@fluidframework/driver-definitions/internal';
@@ -35,6 +39,24 @@ export enum ConnectionState {
35
39
  EstablishingConnection = 3
36
40
  }
37
41
 
42
+ // @alpha (undocumented)
43
+ export interface IBaseProtocolHandler {
44
+ // (undocumented)
45
+ readonly attributes: IDocumentAttributes;
46
+ // (undocumented)
47
+ close(): void;
48
+ // (undocumented)
49
+ getProtocolState(): IScribeProtocolState;
50
+ // (undocumented)
51
+ processMessage(message: ISequencedDocumentMessage, local: boolean): IProcessMessageResult;
52
+ // (undocumented)
53
+ readonly quorum: IQuorum;
54
+ // (undocumented)
55
+ setConnectionState(connected: boolean, clientId: string | undefined): any;
56
+ // (undocumented)
57
+ snapshot(): IQuorumSnapshot;
58
+ }
59
+
38
60
  // @alpha @deprecated (undocumented)
39
61
  export interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {
40
62
  load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;
@@ -94,13 +116,37 @@ export interface IParsedUrl {
94
116
  }
95
117
 
96
118
  // @alpha (undocumented)
97
- export interface IProtocolHandler extends IProtocolHandler_2 {
119
+ export interface IProtocolHandler extends IBaseProtocolHandler {
98
120
  // (undocumented)
99
121
  readonly audience: IAudienceOwner;
100
122
  // (undocumented)
101
123
  processSignal(message: ISignalMessage): any;
102
124
  }
103
125
 
126
+ // @alpha
127
+ export interface IQuorumSnapshot {
128
+ // (undocumented)
129
+ members: QuorumClientsSnapshot;
130
+ // (undocumented)
131
+ proposals: QuorumProposalsSnapshot["proposals"];
132
+ // (undocumented)
133
+ values: QuorumProposalsSnapshot["values"];
134
+ }
135
+
136
+ // @alpha (undocumented)
137
+ export interface IScribeProtocolState {
138
+ // (undocumented)
139
+ members: [string, ISequencedClient][];
140
+ // (undocumented)
141
+ minimumSequenceNumber: number;
142
+ // (undocumented)
143
+ proposals: [number, ISequencedProposal, string[]][];
144
+ // (undocumented)
145
+ sequenceNumber: number;
146
+ // (undocumented)
147
+ values: [string, ICommittedProposal][];
148
+ }
149
+
104
150
  // @alpha
105
151
  export class Loader implements IHostLoader {
106
152
  constructor(loaderProps: ILoaderProps);
@@ -123,6 +169,15 @@ export class Loader implements IHostLoader {
123
169
  // @alpha
124
170
  export type ProtocolHandlerBuilder = (attributes: IDocumentAttributes, snapshot: IQuorumSnapshot, sendProposal: (key: string, value: any) => number) => IProtocolHandler;
125
171
 
172
+ // @alpha
173
+ export type QuorumClientsSnapshot = [string, ISequencedClient][];
174
+
175
+ // @alpha
176
+ export type QuorumProposalsSnapshot = {
177
+ proposals: [number, ISequencedProposal, string[]][];
178
+ values: [string, ICommittedProposal][];
179
+ };
180
+
126
181
  // @alpha
127
182
  export function resolveWithLocationRedirectionHandling<T>(api: (request: IRequest) => Promise<T>, request: IRequest, urlResolver: IUrlResolver, logger?: ITelemetryBaseLogger): Promise<T>;
128
183
 
@@ -7,6 +7,7 @@
7
7
  import { FluidObject } from '@fluidframework/core-interfaces';
8
8
  import { IAudienceOwner } from '@fluidframework/container-definitions/internal';
9
9
  import { IClientDetails } from '@fluidframework/driver-definitions';
10
+ import { ICommittedProposal } from '@fluidframework/driver-definitions/internal';
10
11
  import { IConfigProviderBase } from '@fluidframework/core-interfaces';
11
12
  import { IContainer } from '@fluidframework/container-definitions/internal';
12
13
  import { IDocumentAttributes } from '@fluidframework/driver-definitions/internal';
@@ -18,11 +19,14 @@ import { IHostLoader } from '@fluidframework/container-definitions/internal';
18
19
  import { ILoader } from '@fluidframework/container-definitions/internal';
19
20
  import { ILoaderOptions as ILoaderOptions_2 } from '@fluidframework/container-definitions/internal';
20
21
  import { ILocationRedirectionError } from '@fluidframework/driver-definitions/internal';
21
- import { IProtocolHandler as IProtocolHandler_2 } from '@fluidframework/protocol-base';
22
+ import { IProcessMessageResult } from '@fluidframework/driver-definitions/internal';
22
23
  import { IProvideFluidCodeDetailsComparer } from '@fluidframework/container-definitions/internal';
23
- import { IQuorumSnapshot } from '@fluidframework/protocol-base';
24
+ import { IQuorum } from '@fluidframework/driver-definitions/internal';
24
25
  import { IRequest } from '@fluidframework/core-interfaces';
25
- import { ISignalMessage } from '@fluidframework/driver-definitions';
26
+ import { ISequencedClient } from '@fluidframework/driver-definitions';
27
+ import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';
28
+ import { ISequencedProposal } from '@fluidframework/driver-definitions/internal';
29
+ import { ISignalMessage } from '@fluidframework/driver-definitions/internal';
26
30
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
27
31
  import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils/internal';
28
32
  import { IUrlResolver } from '@fluidframework/driver-definitions/internal';
@@ -7,6 +7,7 @@
7
7
  import { FluidObject } from '@fluidframework/core-interfaces';
8
8
  import { IAudienceOwner } from '@fluidframework/container-definitions/internal';
9
9
  import { IClientDetails } from '@fluidframework/driver-definitions';
10
+ import { ICommittedProposal } from '@fluidframework/driver-definitions/internal';
10
11
  import { IConfigProviderBase } from '@fluidframework/core-interfaces';
11
12
  import { IContainer } from '@fluidframework/container-definitions/internal';
12
13
  import { IDocumentAttributes } from '@fluidframework/driver-definitions/internal';
@@ -18,11 +19,14 @@ import { IHostLoader } from '@fluidframework/container-definitions/internal';
18
19
  import { ILoader } from '@fluidframework/container-definitions/internal';
19
20
  import { ILoaderOptions as ILoaderOptions_2 } from '@fluidframework/container-definitions/internal';
20
21
  import { ILocationRedirectionError } from '@fluidframework/driver-definitions/internal';
21
- import { IProtocolHandler as IProtocolHandler_2 } from '@fluidframework/protocol-base';
22
+ import { IProcessMessageResult } from '@fluidframework/driver-definitions/internal';
22
23
  import { IProvideFluidCodeDetailsComparer } from '@fluidframework/container-definitions/internal';
23
- import { IQuorumSnapshot } from '@fluidframework/protocol-base';
24
+ import { IQuorum } from '@fluidframework/driver-definitions/internal';
24
25
  import { IRequest } from '@fluidframework/core-interfaces';
25
- import { ISignalMessage } from '@fluidframework/driver-definitions';
26
+ import { ISequencedClient } from '@fluidframework/driver-definitions';
27
+ import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';
28
+ import { ISequencedProposal } from '@fluidframework/driver-definitions/internal';
29
+ import { ISignalMessage } from '@fluidframework/driver-definitions/internal';
26
30
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
27
31
  import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils/internal';
28
32
  import { IUrlResolver } from '@fluidframework/driver-definitions/internal';
package/biome.jsonc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "extends": ["../../../biome.jsonc"]
4
+ }
package/dist/audience.js CHANGED
@@ -11,9 +11,10 @@ const internal_1 = require("@fluidframework/core-utils/internal");
11
11
  * Audience represents all clients connected to the op stream.
12
12
  */
13
13
  class Audience extends client_utils_1.TypedEventEmitter {
14
+ members = new Map();
15
+ _currentClientId;
14
16
  constructor() {
15
17
  super();
16
- this.members = new Map();
17
18
  // We are expecting this class to have many listeners, so we suppress noisy "MaxListenersExceededWarning" logging.
18
19
  super.setMaxListeners(0);
19
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAGjE,kEAA6D;AAG7D;;GAEG;AACH,MAAa,QAAS,SAAQ,gCAAkC;IAI/D;QACC,KAAK,EAAE,CAAC;QAJQ,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;QAKrD,kHAAkH;QAClH,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAEM,OAAO;QACb,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAS;YACzC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC;gBACA,QAAQ,EAAE,IAAI,CAAC,gBAAgB;gBAC/B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC;aAC5C,CAAC;IACN,CAAC;IAEM,kBAAkB,CAAC,QAAgB;QACzC,IAAI,IAAI,CAAC,gBAAgB,KAAK,QAAQ,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACpC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;YACjC,0EAA0E;YAC1E,yEAAyE;YACzE,qGAAqG;YACrG,IAAI,CAAC,IAAI,CACR,aAAa,EACb,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SA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AAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,QAAgB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACD;AAtFD,4BAsFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IAudienceEvents, ISelf } from \"@fluidframework/container-definitions\";\nimport { IAudienceOwner } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\n\n/**\n * Audience represents all clients connected to the op stream.\n */\nexport class Audience extends TypedEventEmitter<IAudienceEvents> implements IAudienceOwner {\n\tprivate readonly members = new Map<string, IClient>();\n\tprivate _currentClientId: string | undefined;\n\n\tconstructor() {\n\t\tsuper();\n\t\t// We are expecting this class to have many listeners, so we suppress noisy \"MaxListenersExceededWarning\" logging.\n\t\tsuper.setMaxListeners(0);\n\t}\n\n\tpublic getSelf(): ISelf | undefined {\n\t\treturn this._currentClientId === undefined\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tclientId: this._currentClientId,\n\t\t\t\t\tclient: this.getMember(this._currentClientId),\n\t\t\t };\n\t}\n\n\tpublic setCurrentClientId(clientId: string): void {\n\t\tif (this._currentClientId !== clientId) {\n\t\t\tconst oldId = this._currentClientId;\n\t\t\tthis._currentClientId = clientId;\n\t\t\t// this.getMember(clientId) could resolve to undefined in these two cases:\n\t\t\t// 1) Feature gates controlling ConnectionStateHandler() behavior are off\n\t\t\t// 2) we are loading from stashed state and audience is empty, but we remember and set prior clientId\n\t\t\tthis.emit(\n\t\t\t\t\"selfChanged\",\n\t\t\t\toldId === undefined ? undefined : ({ clientId: oldId } satisfies ISelf),\n\t\t\t\t{ clientId, client: this.getMember(clientId) } satisfies ISelf,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new client to the audience\n\t */\n\tpublic addMember(clientId: string, details: IClient) {\n\t\t// Given that signal delivery is unreliable process, we might observe same client being added twice\n\t\t// In such case we should see exactly same payload (IClient), and should not raise event twice!\n\t\tif (this.members.has(clientId)) {\n\t\t\tconst client = this.members.get(clientId);\n\t\t\tassert(\n\t\t\t\tJSON.stringify(client) === JSON.stringify(details),\n\t\t\t\t0x4b2 /* new client has different payload from existing one */,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.members.set(clientId, details);\n\t\t\tthis.emit(\"addMember\", clientId, details);\n\t\t}\n\t}\n\n\t/**\n\t * Removes a client from the audience. Only emits an event if a client is actually removed\n\t * @returns if a client was removed from the audience\n\t */\n\tpublic removeMember(clientId: string): boolean {\n\t\tconst removedClient = this.members.get(clientId);\n\t\tif (removedClient !== undefined) {\n\t\t\tthis.members.delete(clientId);\n\t\t\tthis.emit(\"removeMember\", clientId, removedClient);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves all the members in the audience.\n\t *\n\t * @remarks When the container is disconnected, this will keep returning the audience as it was last seen before the\n\t * container disconnected.\n\t */\n\tpublic getMembers(): Map<string, IClient> {\n\t\treturn new Map(this.members);\n\t}\n\n\t/**\n\t * Retrieves a specific member of the audience.\n\t *\n\t * @remarks When the container is disconnected, this will keep returning members from the audience as it was last seen\n\t * before the container disconnected.\n\t */\n\tpublic getMember(clientId: string): IClient | undefined {\n\t\treturn this.members.get(clientId);\n\t}\n}\n"]}
1
+ {"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAGjE,kEAA6D;AAG7D;;GAEG;AACH,MAAa,QAAS,SAAQ,gCAAkC;IAC9C,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,gBAAgB,CAAqB;IAE7C;QACC,KAAK,EAAE,CAAC;QACR,kHAAkH;QAClH,KAAK,CAAC,eAAe,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IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,QAAgB;QACnC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC;QACb,CAAC;aAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IAED;;;;;OAKG;IACI,UAAU;QAChB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,QAAgB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACD;AAtFD,4BAsFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IAudienceEvents, ISelf } from \"@fluidframework/container-definitions\";\nimport { IAudienceOwner } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\n\n/**\n * Audience represents all clients connected to the op stream.\n */\nexport class Audience extends TypedEventEmitter<IAudienceEvents> implements IAudienceOwner {\n\tprivate readonly members = new Map<string, IClient>();\n\tprivate _currentClientId: string | undefined;\n\n\tconstructor() {\n\t\tsuper();\n\t\t// We are expecting this class to have many listeners, so we suppress noisy \"MaxListenersExceededWarning\" logging.\n\t\tsuper.setMaxListeners(0);\n\t}\n\n\tpublic getSelf(): ISelf | undefined {\n\t\treturn this._currentClientId === undefined\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tclientId: this._currentClientId,\n\t\t\t\t\tclient: this.getMember(this._currentClientId),\n\t\t\t };\n\t}\n\n\tpublic setCurrentClientId(clientId: string): void {\n\t\tif (this._currentClientId !== clientId) {\n\t\t\tconst oldId = this._currentClientId;\n\t\t\tthis._currentClientId = clientId;\n\t\t\t// this.getMember(clientId) could resolve to undefined in these two cases:\n\t\t\t// 1) Feature gates controlling ConnectionStateHandler() behavior are off\n\t\t\t// 2) we are loading from stashed state and audience is empty, but we remember and set prior clientId\n\t\t\tthis.emit(\n\t\t\t\t\"selfChanged\",\n\t\t\t\toldId === undefined ? undefined : ({ clientId: oldId } satisfies ISelf),\n\t\t\t\t{ clientId, client: this.getMember(clientId) } satisfies ISelf,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new client to the audience\n\t */\n\tpublic addMember(clientId: string, details: IClient) {\n\t\t// Given that signal delivery is unreliable process, we might observe same client being added twice\n\t\t// In such case we should see exactly same payload (IClient), and should not raise event twice!\n\t\tif (this.members.has(clientId)) {\n\t\t\tconst client = this.members.get(clientId);\n\t\t\tassert(\n\t\t\t\tJSON.stringify(client) === JSON.stringify(details),\n\t\t\t\t0x4b2 /* new client has different payload from existing one */,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.members.set(clientId, details);\n\t\t\tthis.emit(\"addMember\", clientId, details);\n\t\t}\n\t}\n\n\t/**\n\t * Removes a client from the audience. Only emits an event if a client is actually removed\n\t * @returns if a client was removed from the audience\n\t */\n\tpublic removeMember(clientId: string): boolean {\n\t\tconst removedClient = this.members.get(clientId);\n\t\tif (removedClient !== undefined) {\n\t\t\tthis.members.delete(clientId);\n\t\t\tthis.emit(\"removeMember\", clientId, removedClient);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves all the members in the audience.\n\t *\n\t * @remarks When the container is disconnected, this will keep returning the audience as it was last seen before the\n\t * container disconnected.\n\t */\n\tpublic getMembers(): Map<string, IClient> {\n\t\treturn new Map(this.members);\n\t}\n\n\t/**\n\t * Retrieves a specific member of the audience.\n\t *\n\t * @remarks When the container is disconnected, this will keep returning members from the audience as it was last seen\n\t * before the container disconnected.\n\t */\n\tpublic getMember(clientId: string): IClient | undefined {\n\t\treturn this.members.get(clientId);\n\t}\n}\n"]}
@@ -11,26 +11,29 @@ const internal_1 = require("@fluidframework/core-utils/internal");
11
11
  * that were known at the time the monitor was created.
12
12
  */
13
13
  class CatchUpMonitor {
14
+ deltaManager;
15
+ listener;
16
+ targetSeqNumber;
17
+ caughtUp = false;
18
+ opHandler = (message) => {
19
+ if (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {
20
+ this.caughtUp = true;
21
+ this.listener();
22
+ }
23
+ };
14
24
  /**
15
25
  * Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.
16
26
  */
17
27
  constructor(deltaManager, listener) {
18
28
  this.deltaManager = deltaManager;
19
29
  this.listener = listener;
20
- this.caughtUp = false;
21
- this.opHandler = (message) => {
22
- if (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {
23
- this.caughtUp = true;
24
- this.listener();
25
- }
26
- };
27
- this.disposed = false;
28
30
  this.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;
29
31
  (0, internal_1.assert)(this.targetSeqNumber >= this.deltaManager.lastSequenceNumber, 0x37c /* Cannot wait for seqNumber below last processed sequence number */);
30
32
  this.deltaManager.on("op", this.opHandler);
31
33
  // Simulate the last processed op to set caughtUp in case we already are
32
34
  this.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });
33
35
  }
36
+ disposed = false;
34
37
  dispose() {
35
38
  if (this.disposed) {
36
39
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"catchUpMonitor.js","sourceRoot":"","sources":["../src/catchUpMonitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA6D;AAS7D;;;GAGG;AACH,MAAa,cAAc;IAW1B;;OAEG;IACH,YACkB,YAAqC,EACrC,QAA0B;QAD1B,iBAAY,GAAZ,YAAY,CAAyB;QACrC,aAAQ,GAAR,QAAQ,CAAkB;QAdpC,aAAQ,GAAY,KAAK,CAAC;QAEjB,cAAS,GAAG,CAAC,OAA0D,EAAE,EAAE;YAC3F,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBACtE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,CAAC;QACF,CAAC,CAAC;QAsBK,aAAQ,GAAY,KAAK,CAAC;QAbhC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC;QAE5D,IAAA,iBAAM,EACL,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAC5D,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAE3C,wEAAwE;QACxE,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC1E,CAAC;IAGM,OAAO;QACb,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO;QACR,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD;AAxCD,wCAwCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions\";\n\n/** @see CatchUpMonitor for usage */\ntype CaughtUpListener = () => void;\n\n/** Monitor that emits an event when a Container has caught up to a given point in the op stream */\nexport type ICatchUpMonitor = IDisposable;\n\n/**\n * Monitors a Container's DeltaManager, notifying listeners when all ops have been processed\n * that were known at the time the monitor was created.\n */\nexport class CatchUpMonitor implements ICatchUpMonitor {\n\tprivate readonly targetSeqNumber: number;\n\tprivate caughtUp: boolean = false;\n\n\tprivate readonly opHandler = (message: Pick<ISequencedDocumentMessage, \"sequenceNumber\">) => {\n\t\tif (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {\n\t\t\tthis.caughtUp = true;\n\t\t\tthis.listener();\n\t\t}\n\t};\n\n\t/**\n\t * Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.\n\t */\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManager<any, any>,\n\t\tprivate readonly listener: CaughtUpListener,\n\t) {\n\t\tthis.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;\n\n\t\tassert(\n\t\t\tthis.targetSeqNumber >= this.deltaManager.lastSequenceNumber,\n\t\t\t0x37c /* Cannot wait for seqNumber below last processed sequence number */,\n\t\t);\n\n\t\tthis.deltaManager.on(\"op\", this.opHandler);\n\n\t\t// Simulate the last processed op to set caughtUp in case we already are\n\t\tthis.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });\n\t}\n\n\tpublic disposed: boolean = false;\n\tpublic dispose() {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis.disposed = true;\n\n\t\tthis.deltaManager.off(\"op\", this.opHandler);\n\t}\n}\n"]}
1
+ {"version":3,"file":"catchUpMonitor.js","sourceRoot":"","sources":["../src/catchUpMonitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA6D;AAS7D;;;GAGG;AACH,MAAa,cAAc;IAeR;IACA;IAfD,eAAe,CAAS;IACjC,QAAQ,GAAY,KAAK,CAAC;IAEjB,SAAS,GAAG,CAAC,OAA0D,EAAE,EAAE;QAC3F,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACtE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACjB,CAAC;IACF,CAAC,CAAC;IAEF;;OAEG;IACH,YACkB,YAAqC,EACrC,QAA0B;QAD1B,iBAAY,GAAZ,YAAY,CAAyB;QACrC,aAAQ,GAAR,QAAQ,CAAkB;QAE3C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC;QAE5D,IAAA,iBAAM,EACL,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAC5D,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAE3C,wEAAwE;QACxE,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC1E,CAAC;IAEM,QAAQ,GAAY,KAAK,CAAC;IAC1B,OAAO;QACb,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO;QACR,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD;AAxCD,wCAwCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\n\n/** @see CatchUpMonitor for usage */\ntype CaughtUpListener = () => void;\n\n/** Monitor that emits an event when a Container has caught up to a given point in the op stream */\nexport type ICatchUpMonitor = IDisposable;\n\n/**\n * Monitors a Container's DeltaManager, notifying listeners when all ops have been processed\n * that were known at the time the monitor was created.\n */\nexport class CatchUpMonitor implements ICatchUpMonitor {\n\tprivate readonly targetSeqNumber: number;\n\tprivate caughtUp: boolean = false;\n\n\tprivate readonly opHandler = (message: Pick<ISequencedDocumentMessage, \"sequenceNumber\">) => {\n\t\tif (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {\n\t\t\tthis.caughtUp = true;\n\t\t\tthis.listener();\n\t\t}\n\t};\n\n\t/**\n\t * Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.\n\t */\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManager<any, any>,\n\t\tprivate readonly listener: CaughtUpListener,\n\t) {\n\t\tthis.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;\n\n\t\tassert(\n\t\t\tthis.targetSeqNumber >= this.deltaManager.lastSequenceNumber,\n\t\t\t0x37c /* Cannot wait for seqNumber below last processed sequence number */,\n\t\t);\n\n\t\tthis.deltaManager.on(\"op\", this.opHandler);\n\n\t\t// Simulate the last processed op to set caughtUp in case we already are\n\t\tthis.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });\n\t}\n\n\tpublic disposed: boolean = false;\n\tpublic dispose() {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis.disposed = true;\n\n\t\tthis.deltaManager.off(\"op\", this.opHandler);\n\t}\n}\n"]}
@@ -5,8 +5,8 @@
5
5
  import { ICriticalContainerError } from "@fluidframework/container-definitions";
6
6
  import { IDeltaQueue, ReadOnlyInfo } from "@fluidframework/container-definitions/internal";
7
7
  import { ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
8
- import { ConnectionMode, IClient, IClientDetails, ISequencedDocumentMessage } from "@fluidframework/driver-definitions";
9
- import { IDocumentService, IClientConfiguration, IDocumentMessage } from "@fluidframework/driver-definitions/internal";
8
+ import { ConnectionMode, IClient, IClientDetails } from "@fluidframework/driver-definitions";
9
+ import { IDocumentService, IClientConfiguration, IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
10
10
  import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
11
11
  import { IConnectionDetailsInternal, IConnectionManager, IConnectionManagerFactoryArgs, IConnectionStateChangeReason, ReconnectMode } from "./contracts.js";
12
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAe,wBAAwB,EAAY,MAAM,iCAAiC,CAAC;AAElG,OAAO,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,yBAAyB,EAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAGN,gBAAgB,EAGhB,oBAAoB,EACpB,gBAAgB,EAQhB,MAAM,6CAA6C,CAAC;AAUrD,OAAO,EACN,mBAAmB,EAOnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACN,0BAA0B,EAC1B,kBAAkB,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,aAAa,EACb,MAAM,gBAAgB,CAAC;AAiIxB;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IA6L1D,OAAO,CAAC,QAAQ,CAAC,eAAe;aAChB,cAAc,EAAE,MAAM,OAAO;IAC7C,OAAO,CAAC,QAAQ,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C,QAAQ,CAAC,WAAW,CAkB1B;IAGF,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAIxC;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAE3B;CACF"}
@@ -38,6 +38,26 @@ const clientNoDeltaStream = {
38
38
  };
39
39
  const clientIdNoDeltaStream = "storage-only client";
40
40
  class NoDeltaStream extends client_utils_1.TypedEventEmitter {
41
+ storageOnlyReason;
42
+ readonlyConnectionReason;
43
+ clientId = clientIdNoDeltaStream;
44
+ claims = {
45
+ scopes: [internal_2.ScopeType.DocRead],
46
+ };
47
+ mode = "read";
48
+ existing = true;
49
+ maxMessageSize = 0;
50
+ version = "";
51
+ initialMessages = [];
52
+ initialSignals = [];
53
+ initialClients = [
54
+ { client: clientNoDeltaStream, clientId: clientIdNoDeltaStream },
55
+ ];
56
+ serviceConfiguration = {
57
+ maxMessageSize: 0,
58
+ blockSize: 0,
59
+ };
60
+ checkpointSequenceNumber = undefined;
41
61
  /**
42
62
  * Connection which is not connected to socket.
43
63
  * @param storageOnlyReason - Reason on why the connection to delta stream is not allowed.
@@ -47,25 +67,6 @@ class NoDeltaStream extends client_utils_1.TypedEventEmitter {
47
67
  super();
48
68
  this.storageOnlyReason = storageOnlyReason;
49
69
  this.readonlyConnectionReason = readonlyConnectionReason;
50
- this.clientId = clientIdNoDeltaStream;
51
- this.claims = {
52
- scopes: [internal_2.ScopeType.DocRead],
53
- };
54
- this.mode = "read";
55
- this.existing = true;
56
- this.maxMessageSize = 0;
57
- this.version = "";
58
- this.initialMessages = [];
59
- this.initialSignals = [];
60
- this.initialClients = [
61
- { client: clientNoDeltaStream, clientId: clientIdNoDeltaStream },
62
- ];
63
- this.serviceConfiguration = {
64
- maxMessageSize: 0,
65
- blockSize: 0,
66
- };
67
- this.checkpointSequenceNumber = undefined;
68
- this._disposed = false;
69
70
  }
70
71
  submit(messages) {
71
72
  this.emit("nack", this.clientId, messages.map((operation) => {
@@ -81,6 +82,7 @@ class NoDeltaStream extends client_utils_1.TypedEventEmitter {
81
82
  content: { message: "Cannot submit signal with storage-only connection", code: 403 },
82
83
  });
83
84
  }
85
+ _disposed = false;
84
86
  get disposed() {
85
87
  return this._disposed;
86
88
  }
@@ -109,9 +111,47 @@ const waitForOnline = async () => {
109
111
  * Exposes various controls to influence this process, including manual reconnects, forced read-only mode, etc.
110
112
  */
111
113
  class ConnectionManager {
114
+ serviceProvider;
115
+ containerDirty;
116
+ client;
117
+ logger;
118
+ props;
119
+ /** Connection mode used when reconnecting on error or disconnect. */
120
+ defaultReconnectionMode;
121
+ /**
122
+ * Tracks the current in-progress connection attempt. Undefined if there is none.
123
+ * Note: Once the connection attempt fires and the code becomes asynchronous, its possible that a new connection
124
+ * attempt was fired and this.pendingConnection was overwritten to reflect the new attempt.
125
+ */
126
+ pendingConnection;
127
+ connection;
128
+ /** Details about connection. undefined if there is no active connection. */
129
+ _connectionDetails;
130
+ /** file ACL - whether user has only read-only access to a file */
131
+ _readonlyPermissions;
132
+ /** tracks host requiring read-only mode. */
133
+ _forceReadonly = false;
134
+ /**
135
+ * Controls whether the DeltaManager will automatically reconnect to the delta stream after receiving a disconnect.
136
+ */
137
+ _reconnectMode;
138
+ /** True if there is pending (async) reconnection from "read" to "write" */
139
+ pendingReconnect = false;
140
+ clientSequenceNumber = 0;
141
+ clientSequenceNumberObserved = 0;
142
+ /** Counts the number of non-runtime ops sent by the client which may not be acked. */
143
+ localOpsToIgnore = 0;
144
+ /** track clientId used last time when we sent any ops */
145
+ lastSubmittedClientId;
146
+ connectFirstConnection = true;
147
+ _connectionVerboseProps = {};
148
+ _connectionProps = {};
149
+ _disposed = false;
150
+ _outbound;
112
151
  get connectionVerboseProps() {
113
152
  return this._connectionVerboseProps;
114
153
  }
154
+ clientDetails;
115
155
  /**
116
156
  * The current connection mode, initially read.
117
157
  */
@@ -232,50 +272,6 @@ class ConnectionManager {
232
272
  this.client = client;
233
273
  this.logger = logger;
234
274
  this.props = props;
235
- /** tracks host requiring read-only mode. */
236
- this._forceReadonly = false;
237
- /** True if there is pending (async) reconnection from "read" to "write" */
238
- this.pendingReconnect = false;
239
- this.clientSequenceNumber = 0;
240
- this.clientSequenceNumberObserved = 0;
241
- /** Counts the number of non-runtime ops sent by the client which may not be acked. */
242
- this.localOpsToIgnore = 0;
243
- this.connectFirstConnection = true;
244
- this._connectionVerboseProps = {};
245
- this._connectionProps = {};
246
- this._disposed = false;
247
- this.opHandler = (documentId, messagesArg) => {
248
- const messages = Array.isArray(messagesArg) ? messagesArg : [messagesArg];
249
- this.props.incomingOpHandler(messages, "opHandler");
250
- };
251
- this.signalHandler = (signalsArg) => {
252
- const signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];
253
- this.props.signalHandler(signals);
254
- };
255
- // Always connect in write mode after getting nacked.
256
- this.nackHandler = (documentId, messages) => {
257
- const message = messages[0];
258
- if (this._readonlyPermissions === true) {
259
- this.props.closeHandler((0, internal_3.createWriteError)("writeOnReadOnlyDocument", { driverVersion: undefined }));
260
- return;
261
- }
262
- const reconnectInfo = getNackReconnectInfo(message.content);
263
- // If the nack indicates we cannot retry, then close the container outright
264
- if (!reconnectInfo.canRetry) {
265
- this.props.closeHandler(reconnectInfo);
266
- return;
267
- }
268
- this.reconnectOnError("write", reconnectInfo);
269
- };
270
- // Connection mode is always read on disconnect/error unless the system mode was write.
271
- this.disconnectHandlerInternal = (disconnectReason) => {
272
- // Note: we might get multiple disconnect calls on same socket, as early disconnect notification
273
- // ("server_disconnect", ODSP-specific) is mapped to "disconnect"
274
- this.reconnectOnError(this.defaultReconnectionMode, disconnectReason);
275
- };
276
- this.errorHandler = (error) => {
277
- this.reconnectOnError(this.defaultReconnectionMode, error);
278
- };
279
275
  this.clientDetails = this.client.details;
280
276
  this.defaultReconnectionMode = this.client.mode;
281
277
  this._reconnectMode = reconnectAllowed ? contracts_js_1.ReconnectMode.Enabled : contracts_js_1.ReconnectMode.Never;
@@ -884,6 +880,38 @@ class ConnectionManager {
884
880
  }
885
881
  }
886
882
  }
883
+ opHandler = (documentId, messagesArg) => {
884
+ const messages = Array.isArray(messagesArg) ? messagesArg : [messagesArg];
885
+ this.props.incomingOpHandler(messages, "opHandler");
886
+ };
887
+ signalHandler = (signalsArg) => {
888
+ const signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];
889
+ this.props.signalHandler(signals);
890
+ };
891
+ // Always connect in write mode after getting nacked.
892
+ nackHandler = (documentId, messages) => {
893
+ const message = messages[0];
894
+ if (this._readonlyPermissions === true) {
895
+ this.props.closeHandler((0, internal_3.createWriteError)("writeOnReadOnlyDocument", { driverVersion: undefined }));
896
+ return;
897
+ }
898
+ const reconnectInfo = getNackReconnectInfo(message.content);
899
+ // If the nack indicates we cannot retry, then close the container outright
900
+ if (!reconnectInfo.canRetry) {
901
+ this.props.closeHandler(reconnectInfo);
902
+ return;
903
+ }
904
+ this.reconnectOnError("write", reconnectInfo);
905
+ };
906
+ // Connection mode is always read on disconnect/error unless the system mode was write.
907
+ disconnectHandlerInternal = (disconnectReason) => {
908
+ // Note: we might get multiple disconnect calls on same socket, as early disconnect notification
909
+ // ("server_disconnect", ODSP-specific) is mapped to "disconnect"
910
+ this.reconnectOnError(this.defaultReconnectionMode, disconnectReason);
911
+ };
912
+ errorHandler = (error) => {
913
+ this.reconnectOnError(this.defaultReconnectionMode, error);
914
+ };
887
915
  }
888
916
  exports.ConnectionManager = ConnectionManager;
889
917
  //# sourceMappingURL=connectionManager.js.map