@fluidframework/container-loader 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.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.
Files changed (146) hide show
  1. package/.eslintrc.js +18 -21
  2. package/.mocharc.js +2 -2
  3. package/README.md +45 -43
  4. package/api-extractor.json +2 -2
  5. package/closeAndGetPendingLocalState.md +51 -0
  6. package/dist/audience.d.ts.map +1 -1
  7. package/dist/audience.js.map +1 -1
  8. package/dist/catchUpMonitor.d.ts.map +1 -1
  9. package/dist/catchUpMonitor.js.map +1 -1
  10. package/dist/collabWindowTracker.d.ts.map +1 -1
  11. package/dist/collabWindowTracker.js.map +1 -1
  12. package/dist/connectionManager.d.ts +2 -2
  13. package/dist/connectionManager.d.ts.map +1 -1
  14. package/dist/connectionManager.js +50 -23
  15. package/dist/connectionManager.js.map +1 -1
  16. package/dist/connectionState.d.ts.map +1 -1
  17. package/dist/connectionState.js.map +1 -1
  18. package/dist/connectionStateHandler.d.ts.map +1 -1
  19. package/dist/connectionStateHandler.js +35 -16
  20. package/dist/connectionStateHandler.js.map +1 -1
  21. package/dist/container.d.ts.map +1 -1
  22. package/dist/container.js +96 -46
  23. package/dist/container.js.map +1 -1
  24. package/dist/containerContext.d.ts.map +1 -1
  25. package/dist/containerContext.js +6 -2
  26. package/dist/containerContext.js.map +1 -1
  27. package/dist/containerStorageAdapter.d.ts.map +1 -1
  28. package/dist/containerStorageAdapter.js +2 -4
  29. package/dist/containerStorageAdapter.js.map +1 -1
  30. package/dist/contracts.d.ts.map +1 -1
  31. package/dist/contracts.js.map +1 -1
  32. package/dist/deltaManager.d.ts +3 -3
  33. package/dist/deltaManager.d.ts.map +1 -1
  34. package/dist/deltaManager.js +56 -27
  35. package/dist/deltaManager.js.map +1 -1
  36. package/dist/deltaManagerProxy.d.ts.map +1 -1
  37. package/dist/deltaManagerProxy.js.map +1 -1
  38. package/dist/deltaQueue.d.ts.map +1 -1
  39. package/dist/deltaQueue.js +4 -2
  40. package/dist/deltaQueue.js.map +1 -1
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/loader.d.ts +3 -3
  45. package/dist/loader.d.ts.map +1 -1
  46. package/dist/loader.js +16 -8
  47. package/dist/loader.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.d.ts.map +1 -1
  52. package/dist/protocol.js +2 -1
  53. package/dist/protocol.js.map +1 -1
  54. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  55. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  56. package/dist/quorum.d.ts.map +1 -1
  57. package/dist/quorum.js.map +1 -1
  58. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  59. package/dist/retriableDocumentStorageService.js +6 -2
  60. package/dist/retriableDocumentStorageService.js.map +1 -1
  61. package/dist/utils.d.ts.map +1 -1
  62. package/dist/utils.js +6 -4
  63. package/dist/utils.js.map +1 -1
  64. package/lib/audience.d.ts.map +1 -1
  65. package/lib/audience.js.map +1 -1
  66. package/lib/catchUpMonitor.d.ts.map +1 -1
  67. package/lib/catchUpMonitor.js.map +1 -1
  68. package/lib/collabWindowTracker.d.ts.map +1 -1
  69. package/lib/collabWindowTracker.js.map +1 -1
  70. package/lib/connectionManager.d.ts +2 -2
  71. package/lib/connectionManager.d.ts.map +1 -1
  72. package/lib/connectionManager.js +52 -25
  73. package/lib/connectionManager.js.map +1 -1
  74. package/lib/connectionState.d.ts.map +1 -1
  75. package/lib/connectionState.js.map +1 -1
  76. package/lib/connectionStateHandler.d.ts.map +1 -1
  77. package/lib/connectionStateHandler.js +35 -16
  78. package/lib/connectionStateHandler.js.map +1 -1
  79. package/lib/container.d.ts.map +1 -1
  80. package/lib/container.js +100 -50
  81. package/lib/container.js.map +1 -1
  82. package/lib/containerContext.d.ts.map +1 -1
  83. package/lib/containerContext.js +6 -2
  84. package/lib/containerContext.js.map +1 -1
  85. package/lib/containerStorageAdapter.d.ts.map +1 -1
  86. package/lib/containerStorageAdapter.js +2 -4
  87. package/lib/containerStorageAdapter.js.map +1 -1
  88. package/lib/contracts.d.ts.map +1 -1
  89. package/lib/contracts.js.map +1 -1
  90. package/lib/deltaManager.d.ts +3 -3
  91. package/lib/deltaManager.d.ts.map +1 -1
  92. package/lib/deltaManager.js +58 -29
  93. package/lib/deltaManager.js.map +1 -1
  94. package/lib/deltaManagerProxy.d.ts.map +1 -1
  95. package/lib/deltaManagerProxy.js.map +1 -1
  96. package/lib/deltaQueue.d.ts.map +1 -1
  97. package/lib/deltaQueue.js +4 -2
  98. package/lib/deltaQueue.js.map +1 -1
  99. package/lib/index.d.ts +1 -1
  100. package/lib/index.d.ts.map +1 -1
  101. package/lib/index.js.map +1 -1
  102. package/lib/loader.d.ts +3 -3
  103. package/lib/loader.d.ts.map +1 -1
  104. package/lib/loader.js +16 -8
  105. package/lib/loader.js.map +1 -1
  106. package/lib/packageVersion.d.ts +1 -1
  107. package/lib/packageVersion.js +1 -1
  108. package/lib/packageVersion.js.map +1 -1
  109. package/lib/protocol.d.ts.map +1 -1
  110. package/lib/protocol.js +2 -1
  111. package/lib/protocol.js.map +1 -1
  112. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  113. package/lib/protocolTreeDocumentStorageService.js.map +1 -1
  114. package/lib/quorum.d.ts.map +1 -1
  115. package/lib/quorum.js.map +1 -1
  116. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  117. package/lib/retriableDocumentStorageService.js +6 -2
  118. package/lib/retriableDocumentStorageService.js.map +1 -1
  119. package/lib/utils.d.ts.map +1 -1
  120. package/lib/utils.js +6 -4
  121. package/lib/utils.js.map +1 -1
  122. package/package.json +115 -114
  123. package/prettier.config.cjs +1 -1
  124. package/src/audience.ts +51 -46
  125. package/src/catchUpMonitor.ts +39 -37
  126. package/src/collabWindowTracker.ts +75 -70
  127. package/src/connectionManager.ts +1006 -943
  128. package/src/connectionState.ts +19 -19
  129. package/src/connectionStateHandler.ts +544 -465
  130. package/src/container.ts +2056 -1895
  131. package/src/containerContext.ts +350 -340
  132. package/src/containerStorageAdapter.ts +163 -153
  133. package/src/contracts.ts +155 -153
  134. package/src/deltaManager.ts +1069 -992
  135. package/src/deltaManagerProxy.ts +143 -137
  136. package/src/deltaQueue.ts +155 -151
  137. package/src/index.ts +14 -17
  138. package/src/loader.ts +408 -403
  139. package/src/packageVersion.ts +1 -1
  140. package/src/protocol.ts +93 -87
  141. package/src/protocolTreeDocumentStorageService.ts +30 -33
  142. package/src/quorum.ts +34 -34
  143. package/src/retriableDocumentStorageService.ts +118 -102
  144. package/src/utils.ts +89 -82
  145. package/tsconfig.esnext.json +6 -6
  146. package/tsconfig.json +8 -12
package/src/contracts.ts CHANGED
@@ -3,31 +3,29 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { ITelemetryProperties } from "@fluidframework/common-definitions";
6
7
  import {
7
- ITelemetryProperties,
8
- } from "@fluidframework/common-definitions";
9
- import {
10
- IDeltaQueue,
11
- ReadOnlyInfo,
12
- IConnectionDetails,
13
- ICriticalContainerError,
14
- IFluidCodeDetails,
15
- isFluidPackage,
8
+ IDeltaQueue,
9
+ ReadOnlyInfo,
10
+ IConnectionDetails,
11
+ ICriticalContainerError,
12
+ IFluidCodeDetails,
13
+ isFluidPackage,
16
14
  } from "@fluidframework/container-definitions";
17
15
  import {
18
- ConnectionMode,
19
- IDocumentMessage,
20
- ISequencedDocumentMessage,
21
- IClientConfiguration,
22
- IClientDetails,
23
- ISignalMessage,
16
+ ConnectionMode,
17
+ IDocumentMessage,
18
+ ISequencedDocumentMessage,
19
+ IClientConfiguration,
20
+ IClientDetails,
21
+ ISignalMessage,
24
22
  } from "@fluidframework/protocol-definitions";
25
23
  import { IContainerPackageInfo } from "@fluidframework/driver-definitions";
26
24
 
27
25
  export enum ReconnectMode {
28
- Never = "Never",
29
- Disabled = "Disabled",
30
- Enabled = "Enabled",
26
+ Never = "Never",
27
+ Disabled = "Disabled",
28
+ Enabled = "Enabled",
31
29
  }
32
30
 
33
31
  /**
@@ -35,74 +33,76 @@ export enum ReconnectMode {
35
33
  * to relay service.
36
34
  */
37
35
  export interface IConnectionManager {
38
- readonly connected: boolean;
39
-
40
- readonly clientId: string | undefined;
41
-
42
- /** The queue of outbound delta messages */
43
- readonly outbound: IDeltaQueue<IDocumentMessage[]>;
44
-
45
- /** Details of client */
46
- readonly clientDetails: IClientDetails;
47
-
48
- /** Protocol version being used to communicate with the service */
49
- readonly version: string;
50
-
51
- /** Max message size allowed to the delta manager */
52
- readonly maxMessageSize: number;
53
-
54
- /** Service configuration provided by the service. */
55
- readonly serviceConfiguration: IClientConfiguration | undefined;
56
-
57
- readonly readOnlyInfo: ReadOnlyInfo;
58
-
59
- // Various connectivity properties for telemetry describing type of current connection
60
- // Things like connection mode, service info, etc.
61
- // Called when connection state changes (connect / disconnect)
62
- readonly connectionProps: ITelemetryProperties;
63
-
64
- // Verbose information about connection logged to telemetry in case of issues with
65
- // maintaining healthy connection, including op gaps, not receiving join op in time, etc.
66
- // Contains details information, like sequence numbers at connection time, initial ops info, etc.
67
- readonly connectionVerboseProps: ITelemetryProperties;
68
-
69
- /**
70
- * Prepares message to be sent. Fills in clientSequenceNumber.
71
- * Called only when active connection is present.
72
- */
73
- prepareMessageToSend(message: Omit<IDocumentMessage, "clientSequenceNumber">): IDocumentMessage | undefined;
74
-
75
- /**
76
- * Called before incoming message is processed. Incoming messages can be combing from connection,
77
- * but also could come from storage.
78
- * This call allows connection manager to adjust knowledge about acked ops sent on previous connection.
79
- * Can be called at any time, including when there is no active connection.
80
- */
81
- beforeProcessingIncomingOp(message: ISequencedDocumentMessage): void;
82
-
83
- /**
84
- * Submits signal to relay service.
85
- * Called only when active connection is present.
86
- */
87
- submitSignal(content: any): void;
88
-
89
- /**
90
- * Submits messages to relay service.
91
- * Called only when active connection is present.
92
- */
93
- sendMessages(messages: IDocumentMessage[]): void;
94
-
95
- /**
96
- * Initiates connection to relay service (noop if already connected).
97
- */
98
- connect(connectionMode?: ConnectionMode): void;
99
-
100
- /**
101
- * Disposed connection manager
102
- */
103
- dispose(error?: ICriticalContainerError, switchToReadonly?: boolean): void;
104
-
105
- get connectionMode(): ConnectionMode;
36
+ readonly connected: boolean;
37
+
38
+ readonly clientId: string | undefined;
39
+
40
+ /** The queue of outbound delta messages */
41
+ readonly outbound: IDeltaQueue<IDocumentMessage[]>;
42
+
43
+ /** Details of client */
44
+ readonly clientDetails: IClientDetails;
45
+
46
+ /** Protocol version being used to communicate with the service */
47
+ readonly version: string;
48
+
49
+ /** Max message size allowed to the delta manager */
50
+ readonly maxMessageSize: number;
51
+
52
+ /** Service configuration provided by the service. */
53
+ readonly serviceConfiguration: IClientConfiguration | undefined;
54
+
55
+ readonly readOnlyInfo: ReadOnlyInfo;
56
+
57
+ // Various connectivity properties for telemetry describing type of current connection
58
+ // Things like connection mode, service info, etc.
59
+ // Called when connection state changes (connect / disconnect)
60
+ readonly connectionProps: ITelemetryProperties;
61
+
62
+ // Verbose information about connection logged to telemetry in case of issues with
63
+ // maintaining healthy connection, including op gaps, not receiving join op in time, etc.
64
+ // Contains details information, like sequence numbers at connection time, initial ops info, etc.
65
+ readonly connectionVerboseProps: ITelemetryProperties;
66
+
67
+ /**
68
+ * Prepares message to be sent. Fills in clientSequenceNumber.
69
+ * Called only when active connection is present.
70
+ */
71
+ prepareMessageToSend(
72
+ message: Omit<IDocumentMessage, "clientSequenceNumber">,
73
+ ): IDocumentMessage | undefined;
74
+
75
+ /**
76
+ * Called before incoming message is processed. Incoming messages can be combing from connection,
77
+ * but also could come from storage.
78
+ * This call allows connection manager to adjust knowledge about acked ops sent on previous connection.
79
+ * Can be called at any time, including when there is no active connection.
80
+ */
81
+ beforeProcessingIncomingOp(message: ISequencedDocumentMessage): void;
82
+
83
+ /**
84
+ * Submits signal to relay service.
85
+ * Called only when active connection is present.
86
+ */
87
+ submitSignal(content: any): void;
88
+
89
+ /**
90
+ * Submits messages to relay service.
91
+ * Called only when active connection is present.
92
+ */
93
+ sendMessages(messages: IDocumentMessage[]): void;
94
+
95
+ /**
96
+ * Initiates connection to relay service (noop if already connected).
97
+ */
98
+ connect(connectionMode?: ConnectionMode): void;
99
+
100
+ /**
101
+ * Disposed connection manager
102
+ */
103
+ dispose(error?: ICriticalContainerError, switchToReadonly?: boolean): void;
104
+
105
+ get connectionMode(): ConnectionMode;
106
106
  }
107
107
 
108
108
  /**
@@ -110,63 +110,63 @@ export interface IConnectionManager {
110
110
  * IConnectionManager instance will use them to communicate to DeltaManager about various events.
111
111
  */
112
112
  export interface IConnectionManagerFactoryArgs {
113
- /**
114
- * Called by connection manager for each incoming op. Some ops maybe delivered before
115
- * connectHandler is called (initial ops on socket connection)
116
- */
117
- readonly incomingOpHandler: (messages: ISequencedDocumentMessage[], reason: string) => void;
118
-
119
- /**
120
- * Called by connection manager for each incoming signals.
121
- * Maybe called before connectHandler is called (initial signals on socket connection)
122
- */
123
- readonly signalHandler: (message: ISignalMessage) => void;
124
-
125
- /**
126
- * Called when connection manager experiences delay in connecting to relay service.
127
- * This can happen because client is offline, or service is busy and asks to not connect for some time.
128
- * Can be called many times while not connected.
129
- * Situation is considered resolved when connection is established and connectHandler is called.
130
- */
131
- readonly reconnectionDelayHandler: (delayMs: number, error: unknown) => void;
132
-
133
- /**
134
- * Called by connection manager whenever critical error happens and container should be closed.
135
- * Expects dispose() call in response to this call.
136
- */
137
- readonly closeHandler: (error?: any) => void;
138
-
139
- /**
140
- * Called whenever connection to relay service is lost.
141
- */
142
- readonly disconnectHandler: (reason: string) => void;
143
-
144
- /**
145
- * Called whenever new connection to rely service is established
146
- */
147
- readonly connectHandler: (connection: IConnectionDetails) => void;
148
-
149
- /**
150
- * Called whenever ping/pong messages are roundtripped on connection.
151
- *
152
- * @deprecated No replacement API intended.
153
- */
154
- readonly pongHandler: (latency: number) => void;
155
-
156
- /**
157
- * Called whenever connection type changes from writable to read-only or vice versa.
158
- *
159
- * @remarks
160
- *
161
- * Connection can be read-only if user has no edit permissions, or if container forced
162
- * connection to be read-only.
163
- * This should not be confused with "read" / "write"connection mode which is internal
164
- * optimization.
165
- *
166
- * @param readonly - Whether or not the container is now read-only.
167
- * `undefined` indicates that user permissions are not yet known.
168
- */
169
- readonly readonlyChangeHandler: (readonly?: boolean) => void;
113
+ /**
114
+ * Called by connection manager for each incoming op. Some ops maybe delivered before
115
+ * connectHandler is called (initial ops on socket connection)
116
+ */
117
+ readonly incomingOpHandler: (messages: ISequencedDocumentMessage[], reason: string) => void;
118
+
119
+ /**
120
+ * Called by connection manager for each incoming signals.
121
+ * Maybe called before connectHandler is called (initial signals on socket connection)
122
+ */
123
+ readonly signalHandler: (message: ISignalMessage) => void;
124
+
125
+ /**
126
+ * Called when connection manager experiences delay in connecting to relay service.
127
+ * This can happen because client is offline, or service is busy and asks to not connect for some time.
128
+ * Can be called many times while not connected.
129
+ * Situation is considered resolved when connection is established and connectHandler is called.
130
+ */
131
+ readonly reconnectionDelayHandler: (delayMs: number, error: unknown) => void;
132
+
133
+ /**
134
+ * Called by connection manager whenever critical error happens and container should be closed.
135
+ * Expects dispose() call in response to this call.
136
+ */
137
+ readonly closeHandler: (error?: any) => void;
138
+
139
+ /**
140
+ * Called whenever connection to relay service is lost.
141
+ */
142
+ readonly disconnectHandler: (reason: string) => void;
143
+
144
+ /**
145
+ * Called whenever new connection to rely service is established
146
+ */
147
+ readonly connectHandler: (connection: IConnectionDetails) => void;
148
+
149
+ /**
150
+ * Called whenever ping/pong messages are roundtripped on connection.
151
+ *
152
+ * @deprecated No replacement API intended.
153
+ */
154
+ readonly pongHandler: (latency: number) => void;
155
+
156
+ /**
157
+ * Called whenever connection type changes from writable to read-only or vice versa.
158
+ *
159
+ * @remarks
160
+ *
161
+ * Connection can be read-only if user has no edit permissions, or if container forced
162
+ * connection to be read-only.
163
+ * This should not be confused with "read" / "write"connection mode which is internal
164
+ * optimization.
165
+ *
166
+ * @param readonly - Whether or not the container is now read-only.
167
+ * `undefined` indicates that user permissions are not yet known.
168
+ */
169
+ readonly readonlyChangeHandler: (readonly?: boolean) => void;
170
170
  }
171
171
 
172
172
  /**
@@ -174,14 +174,16 @@ export interface IConnectionManagerFactoryArgs {
174
174
  * @param codeDetails- - Data structure used to describe the code to load on the Fluid document
175
175
  * @returns The name of the Fluid package
176
176
  */
177
- export const getPackageName = (codeDetails: IFluidCodeDetails | undefined): IContainerPackageInfo => {
178
- let containerPackageName;
179
- if (codeDetails && "name" in codeDetails) {
180
- containerPackageName = codeDetails;
181
- } else if (isFluidPackage(codeDetails?.package)) {
182
- containerPackageName = codeDetails?.package.name;
183
- } else {
184
- containerPackageName = codeDetails?.package;
185
- }
186
- return { name: containerPackageName };
177
+ export const getPackageName = (
178
+ codeDetails: IFluidCodeDetails | undefined,
179
+ ): IContainerPackageInfo => {
180
+ let containerPackageName;
181
+ if (codeDetails && "name" in codeDetails) {
182
+ containerPackageName = codeDetails;
183
+ } else if (isFluidPackage(codeDetails?.package)) {
184
+ containerPackageName = codeDetails?.package.name;
185
+ } else {
186
+ containerPackageName = codeDetails?.package;
187
+ }
188
+ return { name: containerPackageName };
187
189
  };