@fluidframework/container-runtime 2.0.0-internal.6.3.3 → 2.0.0-internal.7.0.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 (286) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/dist/blobManager.d.ts +4 -3
  3. package/dist/blobManager.d.ts.map +1 -1
  4. package/dist/blobManager.js +35 -31
  5. package/dist/blobManager.js.map +1 -1
  6. package/dist/containerHandleContext.js +3 -3
  7. package/dist/containerHandleContext.js.map +1 -1
  8. package/dist/containerRuntime.d.ts +21 -78
  9. package/dist/containerRuntime.d.ts.map +1 -1
  10. package/dist/containerRuntime.js +378 -412
  11. package/dist/containerRuntime.js.map +1 -1
  12. package/dist/dataStore.js +9 -9
  13. package/dist/dataStore.js.map +1 -1
  14. package/dist/dataStoreContext.d.ts +1 -3
  15. package/dist/dataStoreContext.d.ts.map +1 -1
  16. package/dist/dataStoreContext.js +54 -56
  17. package/dist/dataStoreContext.js.map +1 -1
  18. package/dist/dataStoreRegistry.js +3 -3
  19. package/dist/dataStoreRegistry.js.map +1 -1
  20. package/dist/dataStores.d.ts +1 -1
  21. package/dist/dataStores.js +3 -3
  22. package/dist/dataStores.js.map +1 -1
  23. package/dist/deltaManagerProxyBase.js +4 -4
  24. package/dist/deltaManagerProxyBase.js.map +1 -1
  25. package/dist/deltaManagerSummarizerProxy.js +6 -6
  26. package/dist/deltaManagerSummarizerProxy.js.map +1 -1
  27. package/dist/deltaScheduler.js.map +1 -1
  28. package/dist/gc/garbageCollection.d.ts +6 -3
  29. package/dist/gc/garbageCollection.d.ts.map +1 -1
  30. package/dist/gc/garbageCollection.js +19 -16
  31. package/dist/gc/garbageCollection.js.map +1 -1
  32. package/dist/gc/gcDefinitions.d.ts +17 -17
  33. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  34. package/dist/gc/gcDefinitions.js +14 -15
  35. package/dist/gc/gcDefinitions.js.map +1 -1
  36. package/dist/gc/gcHelpers.d.ts +0 -9
  37. package/dist/gc/gcHelpers.d.ts.map +1 -1
  38. package/dist/gc/gcHelpers.js +1 -13
  39. package/dist/gc/gcHelpers.js.map +1 -1
  40. package/dist/gc/gcTelemetry.d.ts +1 -1
  41. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  42. package/dist/gc/gcTelemetry.js +1 -4
  43. package/dist/gc/gcTelemetry.js.map +1 -1
  44. package/dist/gc/gcUnreferencedStateTracker.js +3 -3
  45. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  46. package/dist/gc/index.d.ts +2 -2
  47. package/dist/gc/index.d.ts.map +1 -1
  48. package/dist/gc/index.js +3 -4
  49. package/dist/gc/index.js.map +1 -1
  50. package/dist/id-compressor/appendOnlySortedMap.js.map +1 -1
  51. package/dist/id-compressor/idCompressor.js.map +1 -1
  52. package/dist/id-compressor/identifiers.d.ts +3 -3
  53. package/dist/id-compressor/identifiers.d.ts.map +1 -1
  54. package/dist/index.d.ts +2 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +3 -2
  57. package/dist/index.js.map +1 -1
  58. package/dist/messageTypes.d.ts +134 -0
  59. package/dist/messageTypes.d.ts.map +1 -0
  60. package/dist/messageTypes.js +29 -0
  61. package/dist/messageTypes.js.map +1 -0
  62. package/dist/opLifecycle/batchManager.js +6 -6
  63. package/dist/opLifecycle/batchManager.js.map +1 -1
  64. package/dist/opLifecycle/definitions.d.ts +4 -3
  65. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  66. package/dist/opLifecycle/definitions.js.map +1 -1
  67. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  68. package/dist/opLifecycle/opDecompressor.js +0 -4
  69. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  70. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  71. package/dist/opLifecycle/opGroupingManager.js +4 -2
  72. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  73. package/dist/opLifecycle/opSplitter.js +3 -3
  74. package/dist/opLifecycle/opSplitter.js.map +1 -1
  75. package/dist/opLifecycle/remoteMessageProcessor.d.ts +17 -3
  76. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  77. package/dist/opLifecycle/remoteMessageProcessor.js +38 -25
  78. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  79. package/dist/packageVersion.d.ts +1 -1
  80. package/dist/packageVersion.js +1 -1
  81. package/dist/packageVersion.js.map +1 -1
  82. package/dist/pendingStateManager.d.ts +4 -20
  83. package/dist/pendingStateManager.d.ts.map +1 -1
  84. package/dist/pendingStateManager.js +33 -45
  85. package/dist/pendingStateManager.js.map +1 -1
  86. package/dist/summary/orderedClientElection.d.ts +3 -3
  87. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  88. package/dist/summary/orderedClientElection.js +54 -54
  89. package/dist/summary/orderedClientElection.js.map +1 -1
  90. package/dist/summary/runWhileConnectedCoordinator.js +6 -6
  91. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  92. package/dist/summary/runningSummarizer.d.ts +1 -1
  93. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  94. package/dist/summary/runningSummarizer.js +41 -39
  95. package/dist/summary/runningSummarizer.js.map +1 -1
  96. package/dist/summary/summarizer.d.ts +2 -2
  97. package/dist/summary/summarizer.d.ts.map +1 -1
  98. package/dist/summary/summarizer.js +10 -8
  99. package/dist/summary/summarizer.js.map +1 -1
  100. package/dist/summary/summarizerClientElection.js +6 -6
  101. package/dist/summary/summarizerClientElection.js.map +1 -1
  102. package/dist/summary/summarizerHeuristics.js +9 -9
  103. package/dist/summary/summarizerHeuristics.js.map +1 -1
  104. package/dist/summary/summarizerNode/summarizerNode.d.ts +1 -1
  105. package/dist/summary/summarizerNode/summarizerNode.js +8 -8
  106. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  107. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +1 -1
  108. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  109. package/dist/summary/summarizerNode/summarizerNodeUtils.js +3 -3
  110. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  111. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +2 -2
  112. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  113. package/dist/summary/summarizerTypes.d.ts +14 -13
  114. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  115. package/dist/summary/summarizerTypes.js.map +1 -1
  116. package/dist/summary/summaryCollection.d.ts +2 -2
  117. package/dist/summary/summaryCollection.d.ts.map +1 -1
  118. package/dist/summary/summaryCollection.js +21 -21
  119. package/dist/summary/summaryCollection.js.map +1 -1
  120. package/dist/summary/summaryFormat.d.ts +8 -5
  121. package/dist/summary/summaryFormat.d.ts.map +1 -1
  122. package/dist/summary/summaryFormat.js +3 -0
  123. package/dist/summary/summaryFormat.js.map +1 -1
  124. package/dist/summary/summaryGenerator.d.ts +3 -3
  125. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  126. package/dist/summary/summaryManager.js +7 -7
  127. package/dist/summary/summaryManager.js.map +1 -1
  128. package/dist/throttler.js +16 -16
  129. package/dist/throttler.js.map +1 -1
  130. package/dist/tsdoc-metadata.json +1 -1
  131. package/lib/blobManager.d.ts +4 -3
  132. package/lib/blobManager.d.ts.map +1 -1
  133. package/lib/blobManager.js +36 -32
  134. package/lib/blobManager.js.map +1 -1
  135. package/lib/containerHandleContext.js +3 -3
  136. package/lib/containerHandleContext.js.map +1 -1
  137. package/lib/containerRuntime.d.ts +21 -78
  138. package/lib/containerRuntime.d.ts.map +1 -1
  139. package/lib/containerRuntime.js +339 -375
  140. package/lib/containerRuntime.js.map +1 -1
  141. package/lib/dataStore.js +9 -9
  142. package/lib/dataStore.js.map +1 -1
  143. package/lib/dataStoreContext.d.ts +1 -3
  144. package/lib/dataStoreContext.d.ts.map +1 -1
  145. package/lib/dataStoreContext.js +54 -56
  146. package/lib/dataStoreContext.js.map +1 -1
  147. package/lib/dataStoreRegistry.js +3 -3
  148. package/lib/dataStoreRegistry.js.map +1 -1
  149. package/lib/dataStores.d.ts +1 -1
  150. package/lib/dataStores.js +4 -4
  151. package/lib/dataStores.js.map +1 -1
  152. package/lib/deltaManagerProxyBase.js +4 -4
  153. package/lib/deltaManagerProxyBase.js.map +1 -1
  154. package/lib/deltaManagerSummarizerProxy.js +6 -6
  155. package/lib/deltaManagerSummarizerProxy.js.map +1 -1
  156. package/lib/deltaScheduler.js.map +1 -1
  157. package/lib/gc/garbageCollection.d.ts +6 -3
  158. package/lib/gc/garbageCollection.d.ts.map +1 -1
  159. package/lib/gc/garbageCollection.js +19 -16
  160. package/lib/gc/garbageCollection.js.map +1 -1
  161. package/lib/gc/gcDefinitions.d.ts +17 -17
  162. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  163. package/lib/gc/gcDefinitions.js +13 -14
  164. package/lib/gc/gcDefinitions.js.map +1 -1
  165. package/lib/gc/gcHelpers.d.ts +0 -9
  166. package/lib/gc/gcHelpers.d.ts.map +1 -1
  167. package/lib/gc/gcHelpers.js +0 -11
  168. package/lib/gc/gcHelpers.js.map +1 -1
  169. package/lib/gc/gcTelemetry.d.ts +1 -1
  170. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  171. package/lib/gc/gcTelemetry.js +1 -4
  172. package/lib/gc/gcTelemetry.js.map +1 -1
  173. package/lib/gc/gcUnreferencedStateTracker.js +3 -3
  174. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  175. package/lib/gc/index.d.ts +2 -2
  176. package/lib/gc/index.d.ts.map +1 -1
  177. package/lib/gc/index.js +2 -2
  178. package/lib/gc/index.js.map +1 -1
  179. package/lib/id-compressor/appendOnlySortedMap.js.map +1 -1
  180. package/lib/id-compressor/idCompressor.js.map +1 -1
  181. package/lib/id-compressor/identifiers.d.ts +3 -3
  182. package/lib/id-compressor/identifiers.d.ts.map +1 -1
  183. package/lib/index.d.ts +2 -1
  184. package/lib/index.d.ts.map +1 -1
  185. package/lib/index.js +2 -1
  186. package/lib/index.js.map +1 -1
  187. package/lib/messageTypes.d.ts +134 -0
  188. package/lib/messageTypes.d.ts.map +1 -0
  189. package/lib/messageTypes.js +26 -0
  190. package/lib/messageTypes.js.map +1 -0
  191. package/lib/opLifecycle/batchManager.js +6 -6
  192. package/lib/opLifecycle/batchManager.js.map +1 -1
  193. package/lib/opLifecycle/definitions.d.ts +4 -3
  194. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  195. package/lib/opLifecycle/definitions.js.map +1 -1
  196. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  197. package/lib/opLifecycle/opDecompressor.js +0 -4
  198. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  199. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  200. package/lib/opLifecycle/opGroupingManager.js +4 -2
  201. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  202. package/lib/opLifecycle/opSplitter.js +1 -1
  203. package/lib/opLifecycle/opSplitter.js.map +1 -1
  204. package/lib/opLifecycle/remoteMessageProcessor.d.ts +17 -3
  205. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  206. package/lib/opLifecycle/remoteMessageProcessor.js +37 -24
  207. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  208. package/lib/packageVersion.d.ts +1 -1
  209. package/lib/packageVersion.js +1 -1
  210. package/lib/packageVersion.js.map +1 -1
  211. package/lib/pendingStateManager.d.ts +4 -20
  212. package/lib/pendingStateManager.d.ts.map +1 -1
  213. package/lib/pendingStateManager.js +32 -44
  214. package/lib/pendingStateManager.js.map +1 -1
  215. package/lib/summary/orderedClientElection.d.ts +3 -3
  216. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  217. package/lib/summary/orderedClientElection.js +54 -54
  218. package/lib/summary/orderedClientElection.js.map +1 -1
  219. package/lib/summary/runWhileConnectedCoordinator.js +6 -6
  220. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  221. package/lib/summary/runningSummarizer.d.ts +1 -1
  222. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  223. package/lib/summary/runningSummarizer.js +41 -39
  224. package/lib/summary/runningSummarizer.js.map +1 -1
  225. package/lib/summary/summarizer.d.ts +2 -2
  226. package/lib/summary/summarizer.d.ts.map +1 -1
  227. package/lib/summary/summarizer.js +10 -8
  228. package/lib/summary/summarizer.js.map +1 -1
  229. package/lib/summary/summarizerClientElection.js +6 -6
  230. package/lib/summary/summarizerClientElection.js.map +1 -1
  231. package/lib/summary/summarizerHeuristics.js +9 -9
  232. package/lib/summary/summarizerHeuristics.js.map +1 -1
  233. package/lib/summary/summarizerNode/summarizerNode.d.ts +1 -1
  234. package/lib/summary/summarizerNode/summarizerNode.js +8 -8
  235. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  236. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +1 -1
  237. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  238. package/lib/summary/summarizerNode/summarizerNodeUtils.js +3 -3
  239. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  240. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +2 -2
  241. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  242. package/lib/summary/summarizerTypes.d.ts +14 -13
  243. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  244. package/lib/summary/summarizerTypes.js.map +1 -1
  245. package/lib/summary/summaryCollection.d.ts +2 -2
  246. package/lib/summary/summaryCollection.d.ts.map +1 -1
  247. package/lib/summary/summaryCollection.js +21 -21
  248. package/lib/summary/summaryCollection.js.map +1 -1
  249. package/lib/summary/summaryFormat.d.ts +8 -5
  250. package/lib/summary/summaryFormat.d.ts.map +1 -1
  251. package/lib/summary/summaryFormat.js +3 -0
  252. package/lib/summary/summaryFormat.js.map +1 -1
  253. package/lib/summary/summaryGenerator.d.ts +3 -3
  254. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  255. package/lib/summary/summaryManager.js +6 -6
  256. package/lib/summary/summaryManager.js.map +1 -1
  257. package/lib/throttler.js +16 -16
  258. package/lib/throttler.js.map +1 -1
  259. package/package.json +57 -22
  260. package/src/blobManager.ts +38 -28
  261. package/src/containerRuntime.ts +210 -278
  262. package/src/dataStore.ts +1 -1
  263. package/src/dataStoreContext.ts +4 -7
  264. package/src/dataStores.ts +4 -4
  265. package/src/gc/garbageCollection.md +53 -5
  266. package/src/gc/garbageCollection.ts +6 -3
  267. package/src/gc/gcDefinitions.ts +14 -27
  268. package/src/gc/gcEarlyAdoption.md +145 -0
  269. package/src/gc/gcHelpers.ts +0 -12
  270. package/src/gc/gcTelemetry.ts +1 -4
  271. package/src/gc/index.ts +2 -3
  272. package/src/index.ts +7 -4
  273. package/src/messageTypes.ts +225 -0
  274. package/src/opLifecycle/README.md +40 -40
  275. package/src/opLifecycle/definitions.ts +2 -1
  276. package/src/opLifecycle/opDecompressor.ts +0 -8
  277. package/src/opLifecycle/opGroupingManager.ts +7 -6
  278. package/src/opLifecycle/opSplitter.ts +2 -2
  279. package/src/opLifecycle/remoteMessageProcessor.ts +54 -33
  280. package/src/packageVersion.ts +1 -1
  281. package/src/pendingStateManager.ts +30 -52
  282. package/src/summary/runningSummarizer.ts +4 -2
  283. package/src/summary/summarizer.ts +5 -3
  284. package/src/summary/summarizerNode/summarizerNode.ts +1 -1
  285. package/src/summary/summarizerTypes.ts +2 -1
  286. package/src/summary/summaryFormat.ts +3 -0
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../../src/id-compressor/idCompressor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+DAA8E;AAC9E,6EAY6C;AAE7C,qEAAyF;AACzF,+CAA6F;AAC7F,2CAQqB;AACrB,iEAQgC;AAChC,yCAOoB;AACpB,qEAAkE;AAClE,6CAA0C;AAE1C;;;GAGG;AACH,MAAM,qBAAqB,GAAG,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KAAK,CAAC,CAAC,CAAC;aAC1E;SACD;QAED,IAAA,mBAAM,EACL,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,WAAW,CAAC,MAAM,EACxC,KAAK,CAAC,kDAAkD,CACxD,CAAC;QACF,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,KAAmB,EAAE,iBAA0B;QAC5D,IACC,iBAAiB;YACjB,CAAC,IAAI,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;gBAC5C,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;gBAC7C,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;gBACzC,IAAI,CAAC,qBAAqB,KAAK,KAAK,CAAC,qBAAqB;gBAC1D,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,CAAC,EAC3C;YACD,OAAO,KAAK,CAAC;SACb;QACD,OAAO,CACN,IAAI,CAAC,kBAAkB,KAAK,KAAK,CAAC,kBAAkB;YACpD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,iBAAiB,CAAC;YACvD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CACxC,CAAC;IACH,CAAC;;AAvjBF,oCAwjBC;AAvjBA;;GAEG;AACoB,2BAAc,GAAG,CAAC,IAAI,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport {\n\tIdCreationRange,\n\tIIdCompressor,\n\tIIdCompressorCore,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n\tinitialClusterCapacity,\n} from \"@fluidframework/runtime-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ITelemetryLoggerExt, createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { FinalCompressedId, isFinalId, LocalCompressedId, NumericUuid } from \"./identifiers\";\nimport {\n\tcreateSessionId,\n\tlocalIdFromGenCount,\n\tgenCountFromLocalId,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities\";\nimport {\n\tIndex,\n\treadBoolean,\n\treadNumber,\n\treadNumericUuid,\n\twriteBoolean,\n\twriteNumber,\n\twriteNumericUuid,\n} from \"./persistanceUtilities\";\nimport {\n\tgetAlignedLocal,\n\tgetAlignedFinal,\n\tIdCluster,\n\tlastFinalizedLocal,\n\tSession,\n\tSessions,\n} from \"./sessions\";\nimport { SessionSpaceNormalizer } from \"./sessionSpaceNormalizer\";\nimport { FinalSpace } from \"./finalSpace\";\n\n/**\n * The version of IdCompressor that is currently persisted.\n * This should not be changed without careful consideration to compatibility.\n */\nconst currentWrittenVersion = 1;\n\n/**\n * See {@link IIdCompressor} and {@link IIdCompressorCore}\n */\nexport class IdCompressor implements IIdCompressor, IIdCompressorCore {\n\t/**\n\t * Max allowed initial cluster size.\n\t */\n\tpublic static readonly maxClusterSize = 2 ** 20;\n\n\t// ----- Local state -----\n\n\tpublic readonly localSessionId: SessionId;\n\tprivate readonly localSession: Session;\n\tprivate readonly normalizer = new SessionSpaceNormalizer();\n\t// The number of IDs generated by the local session\n\tprivate localGenCount = 0;\n\n\t// -----------------------\n\n\t// ----- Final state -----\n\n\t// The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.\n\t// This is updated to be equal to `generatedIdCount` + 1 each time it is called.\n\tprivate nextRangeBaseGenCount = 1;\n\t// The capacity of the next cluster to be created\n\tprivate newClusterCapacity = initialClusterCapacity;\n\tprivate readonly sessions = new Sessions();\n\tprivate readonly finalSpace = new FinalSpace();\n\n\t// -----------------------\n\n\t// ----- Telemetry state -----\n\n\t// The number of local IDs generated since the last telemetry was sent.\n\tprivate telemetryLocalIdCount = 0;\n\t// The number of eager final IDs generated since the last telemetry was sent.\n\tprivate telemetryEagerFinalIdCount = 0;\n\n\t// -----------------------\n\n\tprivate constructor(\n\t\tlocalSessionIdOrDeserialized: SessionId | Sessions,\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t) {\n\t\tif (typeof localSessionIdOrDeserialized === \"string\") {\n\t\t\tthis.localSessionId = localSessionIdOrDeserialized;\n\t\t\tthis.localSession = this.sessions.getOrCreate(localSessionIdOrDeserialized);\n\t\t} else {\n\t\t\t// Deserialize case\n\t\t\tthis.sessions = localSessionIdOrDeserialized;\n\t\t\t// As policy, the first session is always the local session. Preserve this invariant\n\t\t\t// during deserialization.\n\t\t\tconst firstSession = localSessionIdOrDeserialized.sessions().next();\n\t\t\tassert(!firstSession.done, 0x754 /* First session must be present. */);\n\t\t\tthis.localSession = firstSession.value;\n\t\t\tthis.localSessionId = stableIdFromNumericUuid(\n\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t) as SessionId;\n\t\t}\n\t}\n\n\tpublic static create(logger?: ITelemetryBaseLogger): IdCompressor;\n\tpublic static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IdCompressor;\n\tpublic static create(\n\t\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\t\tloggerOrUndefined?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\tlet localSessionId: SessionId;\n\t\tlet logger: ITelemetryBaseLogger | undefined;\n\t\tif (sessionIdOrLogger === undefined) {\n\t\t\tlocalSessionId = createSessionId();\n\t\t} else {\n\t\t\tif (typeof sessionIdOrLogger === \"string\") {\n\t\t\t\tlocalSessionId = sessionIdOrLogger;\n\t\t\t\tlogger = loggerOrUndefined;\n\t\t\t} else {\n\t\t\t\tlocalSessionId = createSessionId();\n\t\t\t\tlogger = loggerOrUndefined;\n\t\t\t}\n\t\t}\n\t\tconst compressor = new IdCompressor(\n\t\t\tlocalSessionId,\n\t\t\tlogger === undefined ? undefined : createChildLogger({ logger }),\n\t\t);\n\t\treturn compressor;\n\t}\n\n\t/**\n\t * The size of each newly created ID cluster.\n\t */\n\tpublic get clusterCapacity(): number {\n\t\treturn this.newClusterCapacity;\n\t}\n\n\t/**\n\t * Must only be set with a value upon which consensus has been reached. Value must be greater than zero and less than\n\t * `IdCompressor.maxClusterSize`.\n\t */\n\tpublic set clusterCapacity(value: number) {\n\t\tif (value <= 0) {\n\t\t\tthrow new Error(\"Clusters must have a positive capacity.\");\n\t\t}\n\t\tif (value > IdCompressor.maxClusterSize) {\n\t\t\tthrow new Error(\"Clusters must not exceed max cluster size.\");\n\t\t}\n\t\tthis.newClusterCapacity = value;\n\t}\n\n\tpublic generateCompressedId(): SessionSpaceCompressedId {\n\t\tthis.localGenCount++;\n\t\tconst lastCluster = this.localSession.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\tthis.telemetryLocalIdCount++;\n\t\t\treturn this.generateNextLocalId();\n\t\t}\n\n\t\t// If there exists a cluster of final IDs already claimed by the local session that still has room in it,\n\t\t// it is known prior to range sequencing what a local ID's corresponding final ID will be.\n\t\t// In this case, it is safe to return the final ID immediately. This is guaranteed to be safe because\n\t\t// any op that the local session sends that contains one of those final IDs are guaranteed to arrive to\n\t\t// collaborators *after* the one containing the creation range.\n\t\tconst clusterOffset = this.localGenCount - genCountFromLocalId(lastCluster.baseLocalId);\n\t\tif (lastCluster.capacity > clusterOffset) {\n\t\t\tthis.telemetryEagerFinalIdCount++;\n\t\t\t// Space in the cluster: eager final\n\t\t\treturn ((lastCluster.baseFinalId as number) +\n\t\t\t\tclusterOffset) as SessionSpaceCompressedId;\n\t\t}\n\t\t// No space in the cluster, return next local\n\t\tthis.telemetryLocalIdCount++;\n\t\treturn this.generateNextLocalId();\n\t}\n\n\tprivate generateNextLocalId(): LocalCompressedId {\n\t\t// Must tell the normalizer that we generated a local ID\n\t\tthis.normalizer.addLocalRange(this.localGenCount, 1);\n\t\treturn localIdFromGenCount(this.localGenCount);\n\t}\n\n\tpublic takeNextCreationRange(): IdCreationRange {\n\t\tconst count = this.localGenCount - (this.nextRangeBaseGenCount - 1);\n\t\tif (count === 0) {\n\t\t\treturn {\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t};\n\t\t}\n\t\tconst range: IdCreationRange = {\n\t\t\tsessionId: this.localSessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: this.nextRangeBaseGenCount,\n\t\t\t\tcount,\n\t\t\t},\n\t\t};\n\t\tthis.nextRangeBaseGenCount = this.localGenCount + 1;\n\t\treturn range;\n\t}\n\n\tpublic finalizeCreationRange(range: IdCreationRange): void {\n\t\t// Check if the range has IDs\n\t\tif (range.ids === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(range.ids.count > 0, 0x755 /* Malformed ID Range. */);\n\t\tconst { sessionId, ids } = range;\n\t\tconst { count, firstGenCount } = ids;\n\t\tconst session = this.sessions.getOrCreate(sessionId);\n\t\tconst isLocal = session === this.localSession;\n\t\tconst rangeBaseLocal = localIdFromGenCount(firstGenCount);\n\t\tlet lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// This is the first cluster in the session space\n\t\t\tif (rangeBaseLocal !== -1) {\n\t\t\t\tthrow new Error(\"Ranges finalized out of order.\");\n\t\t\t}\n\t\t\tlastCluster = this.addEmptyCluster(session, this.clusterCapacity + count);\n\t\t\tif (isLocal) {\n\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: \"RuntimeIdCompressor:FirstCluster\",\n\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst remainingCapacity = lastCluster.capacity - lastCluster.count;\n\t\tif (lastCluster.baseLocalId - lastCluster.count !== rangeBaseLocal) {\n\t\t\tthrow new Error(\"Ranges finalized out of order.\");\n\t\t}\n\n\t\tif (remainingCapacity >= count) {\n\t\t\t// The current range fits in the existing cluster\n\t\t\tlastCluster.count += count;\n\t\t} else {\n\t\t\tconst overflow = count - remainingCapacity;\n\t\t\tconst newClaimedFinalCount = overflow + this.clusterCapacity;\n\t\t\tif (lastCluster === this.finalSpace.getLastCluster()) {\n\t\t\t\t// The last cluster in the sessions chain is the last cluster globally, so it can be expanded.\n\t\t\t\tlastCluster.capacity += newClaimedFinalCount;\n\t\t\t\tlastCluster.count += count;\n\t\t\t\tassert(\n\t\t\t\t\t!this.sessions.clusterCollides(lastCluster),\n\t\t\t\t\t0x756 /* Cluster collision detected. */,\n\t\t\t\t);\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:ClusterExpansion\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t\tpreviousCapacity: lastCluster.capacity - newClaimedFinalCount,\n\t\t\t\t\t\tnewCapacity: lastCluster.capacity,\n\t\t\t\t\t\toverflow,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// The last cluster in the sessions chain is *not* the last cluster globally. Fill and overflow to new.\n\t\t\t\tlastCluster.count = lastCluster.capacity;\n\t\t\t\tconst newCluster = this.addEmptyCluster(session, newClaimedFinalCount);\n\t\t\t\tnewCluster.count += overflow;\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:NewCluster\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isLocal) {\n\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\teventName: \"RuntimeIdCompressor:IdCompressorStatus\",\n\t\t\t\teagerFinalIdCount: this.telemetryEagerFinalIdCount,\n\t\t\t\tlocalIdCount: this.telemetryLocalIdCount,\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t});\n\t\t\tthis.telemetryEagerFinalIdCount = 0;\n\t\t\tthis.telemetryLocalIdCount = 0;\n\t\t}\n\n\t\tassert(!session.isEmpty(), 0x757 /* Empty sessions should not be created. */);\n\t}\n\n\tprivate addEmptyCluster(session: Session, capacity: number): IdCluster {\n\t\tconst newCluster = session.addNewCluster(\n\t\t\tthis.finalSpace.getAllocatedIdLimit(),\n\t\t\tcapacity,\n\t\t\t0,\n\t\t);\n\t\tassert(!this.sessions.clusterCollides(newCluster), 0x758 /* Cluster collision detected. */);\n\t\tthis.finalSpace.addCluster(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\treturn id;\n\t\t} else {\n\t\t\tconst local = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(local)) {\n\t\t\t\tthrow new Error(\"Invalid ID to normalize.\");\n\t\t\t}\n\t\t\tconst finalForm = this.localSession.tryConvertToFinal(local, true);\n\t\t\treturn finalForm === undefined\n\t\t\t\t? (local as unknown as OpSpaceCompressedId)\n\t\t\t\t: (finalForm as OpSpaceCompressedId);\n\t\t}\n\t}\n\n\tpublic normalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = this.localSession.getClusterByAllocatedFinal(id);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\t// Does not exist in local cluster chain\n\t\t\t\tif (id >= this.finalSpace.getFinalizedIdLimit()) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tif (genCountFromLocalId(alignedLocal) > this.localGenCount) {\n\t\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t\t}\n\t\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst localToNormalize = id as unknown as LocalCompressedId;\n\t\t\tif (originSessionId === this.localSessionId) {\n\t\t\t\tif (this.normalizer.contains(localToNormalize)) {\n\t\t\t\t\treturn localToNormalize;\n\t\t\t\t} else {\n\t\t\t\t\t// We never generated this local ID, so fail\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// LocalId from a remote session\n\t\t\t\tconst remoteSession = this.sessions.get(originSessionId);\n\t\t\t\tif (remoteSession === undefined) {\n\t\t\t\t\tthrow new Error(\"No IDs have ever been finalized by the supplied session.\");\n\t\t\t\t}\n\t\t\t\tconst correspondingFinal = remoteSession.tryConvertToFinal(localToNormalize, false);\n\t\t\t\tif (correspondingFinal === undefined) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn correspondingFinal as unknown as SessionSpaceCompressedId;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic decompress(id: SessionSpaceCompressedId): StableId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = Session.getContainingCluster(id, this.finalSpace.clusters);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\tconst alignedGenCount = genCountFromLocalId(alignedLocal);\n\t\t\tconst lastFinalizedGenCount = genCountFromLocalId(\n\t\t\t\tlastFinalizedLocal(containingCluster),\n\t\t\t);\n\t\t\tif (alignedGenCount > lastFinalizedGenCount) {\n\t\t\t\t// should be an eager final id generated by the local session\n\t\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!this.normalizer.contains(alignedLocal),\n\t\t\t\t\t\t0x759 /* Normalizer out of sync. */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(containingCluster.session.sessionUuid, alignedGenCount - 1),\n\t\t\t);\n\t\t} else {\n\t\t\tconst localToDecompress = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(localToDecompress)) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(\n\t\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t\t\tgenCountFromLocalId(localToDecompress) - 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic recompress(uncompressed: StableId): SessionSpaceCompressedId {\n\t\tconst recompressed = this.tryRecompress(uncompressed);\n\t\tif (recompressed === undefined) {\n\t\t\tthrow new Error(\"Could not recompress.\");\n\t\t}\n\t\treturn recompressed;\n\t}\n\n\tpublic tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined {\n\t\tconst match = this.sessions.getContainingCluster(uncompressed);\n\t\tif (match === undefined) {\n\t\t\tconst numericUncompressed = numericUuidFromStableId(uncompressed);\n\t\t\tconst offset = subtractNumericUuids(numericUncompressed, this.localSession.sessionUuid);\n\t\t\tif (offset < Number.MAX_SAFE_INTEGER) {\n\t\t\t\tconst genCountEquivalent = Number(offset) + 1;\n\t\t\t\tconst localEquivalent = localIdFromGenCount(genCountEquivalent);\n\t\t\t\tif (this.normalizer.contains(localEquivalent)) {\n\t\t\t\t\treturn localEquivalent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\tconst [containingCluster, alignedLocal] = match;\n\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t// Local session\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tgenCountFromLocalId(alignedLocal) <= this.localGenCount,\n\t\t\t\t\t\t0x75a /* Clusters out of sync. */,\n\t\t\t\t\t);\n\t\t\t\t\t// Id is an eager final\n\t\t\t\t\treturn getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t| undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Not the local session\n\t\t\t\treturn genCountFromLocalId(alignedLocal) >= lastFinalizedLocal(containingCluster)\n\t\t\t\t\t? (getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t\t| undefined)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\tpublic serialize(withSession: false): SerializedIdCompressorWithNoSession;\n\tpublic serialize(hasLocalState: boolean): SerializedIdCompressor {\n\t\tconst { normalizer, finalSpace, sessions } = this;\n\t\tconst sessionIndexMap = new Map<Session, number>();\n\t\tlet sessionIndex = 0;\n\t\tfor (const session of sessions.sessions()) {\n\t\t\t// Filter empty sessions to prevent them accumulating in the serialized state\n\t\t\tif (!session.isEmpty() || hasLocalState) {\n\t\t\t\tsessionIndexMap.set(session, sessionIndex);\n\t\t\t\tsessionIndex++;\n\t\t\t}\n\t\t}\n\t\tconst localStateSize = hasLocalState\n\t\t\t? 1 + // generated ID count\n\t\t\t 1 + // next range base genCount\n\t\t\t 1 + // count of normalizer pairs\n\t\t\t this.normalizer.idRanges.size * 2 // pairs\n\t\t\t: 0;\n\t\t// Layout size, in 8 byte increments\n\t\tconst totalSize =\n\t\t\t1 + // version\n\t\t\t1 + // hasLocalState\n\t\t\t1 + // cluster capacity\n\t\t\t1 + // session count\n\t\t\t1 + // cluster count\n\t\t\tsessionIndexMap.size * 2 + // session IDs\n\t\t\tfinalSpace.clusters.length * 3 + // clusters: (sessionIndex, capacity, count)[]\n\t\t\tlocalStateSize; // local state, if present\n\n\t\tconst serializedFloat = new Float64Array(totalSize);\n\t\tconst serializedUint = new BigUint64Array(serializedFloat.buffer);\n\t\tlet index = 0;\n\t\tindex = writeNumber(serializedFloat, index, currentWrittenVersion);\n\t\tindex = writeBoolean(serializedFloat, index, hasLocalState);\n\t\tindex = writeNumber(serializedFloat, index, this.clusterCapacity);\n\t\tindex = writeNumber(serializedFloat, index, sessionIndexMap.size);\n\t\tindex = writeNumber(serializedFloat, index, finalSpace.clusters.length);\n\n\t\tfor (const [session] of sessionIndexMap.entries()) {\n\t\t\tindex = writeNumericUuid(serializedUint, index, session.sessionUuid);\n\t\t}\n\n\t\tfinalSpace.clusters.forEach((cluster) => {\n\t\t\tindex = writeNumber(\n\t\t\t\tserializedFloat,\n\t\t\t\tindex,\n\t\t\t\tsessionIndexMap.get(cluster.session) as number,\n\t\t\t);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.capacity);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.count);\n\t\t});\n\n\t\tif (hasLocalState) {\n\t\t\tindex = writeNumber(serializedFloat, index, this.localGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, this.nextRangeBaseGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, normalizer.idRanges.size);\n\t\t\tfor (const [leadingGenCount, count] of normalizer.idRanges.entries()) {\n\t\t\t\tindex = writeNumber(serializedFloat, index, leadingGenCount);\n\t\t\t\tindex = writeNumber(serializedFloat, index, count);\n\t\t\t}\n\t\t}\n\n\t\tassert(index === totalSize, 0x75b /* Serialized size was incorrectly calculated. */);\n\t\tthis.logger?.sendTelemetryEvent({\n\t\t\teventName: \"RuntimeIdCompressor:SerializedIdCompressorSize\",\n\t\t\tsize: serializedFloat.byteLength,\n\t\t\tclusterCount: finalSpace.clusters.length,\n\t\t\tsessionCount: sessionIndexMap.size,\n\t\t});\n\n\t\treturn bufferToString(serializedFloat.buffer, \"base64\") as SerializedIdCompressor;\n\t}\n\n\tpublic static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;\n\tpublic static deserialize(\n\t\tserialized: SerializedIdCompressorWithNoSession,\n\t\tnewSessionId: SessionId,\n\t): IdCompressor;\n\tpublic static deserialize(\n\t\tserialized: SerializedIdCompressor,\n\t\tsessionId?: SessionId,\n\t): IdCompressor {\n\t\tconst buffer = stringToBuffer(serialized, \"base64\");\n\t\tconst index: Index = {\n\t\t\tindex: 0,\n\t\t\tbufferFloat: new Float64Array(buffer),\n\t\t\tbufferUint: new BigUint64Array(buffer),\n\t\t};\n\t\tconst version = readNumber(index);\n\t\tassert(version === currentWrittenVersion, 0x75c /* Unknown serialized version. */);\n\t\tconst hasLocalState = readBoolean(index);\n\t\tconst clusterCapacity = readNumber(index);\n\t\tconst sessionCount = readNumber(index);\n\t\tconst clusterCount = readNumber(index);\n\n\t\t// Sessions\n\t\tlet sessionOffset = 0;\n\t\tconst sessions: [NumericUuid, Session][] = [];\n\t\tif (!hasLocalState) {\n\t\t\t// If !hasLocalState, there won't be a serialized local session ID so insert one at the beginning\n\t\t\tassert(sessionId !== undefined, 0x75d /* Local session ID is undefined. */);\n\t\t\tconst localSessionNumeric = numericUuidFromStableId(sessionId);\n\t\t\tsessions.push([localSessionNumeric, new Session(localSessionNumeric)]);\n\t\t\tsessionOffset = 1;\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tsessionId === undefined,\n\t\t\t\t0x75e /* Local state should not exist in serialized form. */,\n\t\t\t);\n\t\t}\n\n\t\tfor (let i = 0; i < sessionCount; i++) {\n\t\t\tconst numeric = readNumericUuid(index);\n\t\t\tsessions.push([numeric, new Session(numeric)]);\n\t\t}\n\n\t\tconst compressor = new IdCompressor(new Sessions(sessions));\n\t\tcompressor.clusterCapacity = clusterCapacity;\n\n\t\t// Clusters\n\t\tlet baseFinalId = 0;\n\t\tfor (let i = 0; i < clusterCount; i++) {\n\t\t\tconst sessionIndex = readNumber(index);\n\t\t\tconst session = sessions[sessionIndex + sessionOffset][1];\n\t\t\tconst capacity = readNumber(index);\n\t\t\tconst count = readNumber(index);\n\t\t\tconst cluster = session.addNewCluster(\n\t\t\t\tbaseFinalId as FinalCompressedId,\n\t\t\t\tcapacity,\n\t\t\t\tcount,\n\t\t\t);\n\t\t\tcompressor.finalSpace.addCluster(cluster);\n\t\t\tbaseFinalId += capacity;\n\t\t}\n\n\t\t// Local state\n\t\tif (hasLocalState) {\n\t\t\tcompressor.localGenCount = readNumber(index);\n\t\t\tcompressor.nextRangeBaseGenCount = readNumber(index);\n\t\t\tconst normalizerCount = readNumber(index);\n\t\t\tfor (let i = 0; i < normalizerCount; i++) {\n\t\t\t\tcompressor.normalizer.addLocalRange(readNumber(index), readNumber(index));\n\t\t\t}\n\t\t}\n\n\t\tassert(\n\t\t\tindex.index === index.bufferFloat.length,\n\t\t\t0x75f /* Failed to read entire serialized compressor. */,\n\t\t);\n\t\treturn compressor;\n\t}\n\n\tpublic equals(other: IdCompressor, includeLocalState: boolean): boolean {\n\t\tif (\n\t\t\tincludeLocalState &&\n\t\t\t(this.localSessionId !== other.localSessionId ||\n\t\t\t\t!this.localSession.equals(other.localSession) ||\n\t\t\t\t!this.normalizer.equals(other.normalizer) ||\n\t\t\t\tthis.nextRangeBaseGenCount !== other.nextRangeBaseGenCount ||\n\t\t\t\tthis.localGenCount !== other.localGenCount)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\tthis.newClusterCapacity === other.newClusterCapacity &&\n\t\t\tthis.sessions.equals(other.sessions, includeLocalState) &&\n\t\t\tthis.finalSpace.equals(other.finalSpace)\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../../src/id-compressor/idCompressor.ts"],"names":[],"mappings":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AC,KAAK,CAAC,CAAC;YAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,EAAE,EAAE;gBACzC,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,IAAA,iCAAU,EAAC,KAAK,CAAC,EAAE,IAAA,iCAAU,EAAC,KAAK,CAAC,CAAC,CAAC;aAC1E;SACD;QAED,IAAA,mBAAM,EACL,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,WAAW,CAAC,MAAM,EACxC,KAAK,CAAC,kDAAkD,CACxD,CAAC;QACF,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,KAAmB,EAAE,iBAA0B;QAC5D,IACC,iBAAiB;YACjB,CAAC,IAAI,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;gBAC5C,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;gBAC7C,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;gBACzC,IAAI,CAAC,qBAAqB,KAAK,KAAK,CAAC,qBAAqB;gBAC1D,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,CAAC,EAC3C;YACD,OAAO,KAAK,CAAC;SACb;QACD,OAAO,CACN,IAAI,CAAC,kBAAkB,KAAK,KAAK,CAAC,kBAAkB;YACpD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,iBAAiB,CAAC;YACvD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CACxC,CAAC;IACH,CAAC;;AAvjBF,oCAwjBC;AAvjBA;;GAEG;AACoB,2BAAc,GAAG,CAAC,IAAI,EAAE,AAAV,CAAW","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport {\n\tIdCreationRange,\n\tIIdCompressor,\n\tIIdCompressorCore,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n\tinitialClusterCapacity,\n} from \"@fluidframework/runtime-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ITelemetryLoggerExt, createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { FinalCompressedId, isFinalId, LocalCompressedId, NumericUuid } from \"./identifiers\";\nimport {\n\tcreateSessionId,\n\tlocalIdFromGenCount,\n\tgenCountFromLocalId,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities\";\nimport {\n\tIndex,\n\treadBoolean,\n\treadNumber,\n\treadNumericUuid,\n\twriteBoolean,\n\twriteNumber,\n\twriteNumericUuid,\n} from \"./persistanceUtilities\";\nimport {\n\tgetAlignedLocal,\n\tgetAlignedFinal,\n\tIdCluster,\n\tlastFinalizedLocal,\n\tSession,\n\tSessions,\n} from \"./sessions\";\nimport { SessionSpaceNormalizer } from \"./sessionSpaceNormalizer\";\nimport { FinalSpace } from \"./finalSpace\";\n\n/**\n * The version of IdCompressor that is currently persisted.\n * This should not be changed without careful consideration to compatibility.\n */\nconst currentWrittenVersion = 1;\n\n/**\n * See {@link IIdCompressor} and {@link IIdCompressorCore}\n */\nexport class IdCompressor implements IIdCompressor, IIdCompressorCore {\n\t/**\n\t * Max allowed initial cluster size.\n\t */\n\tpublic static readonly maxClusterSize = 2 ** 20;\n\n\t// ----- Local state -----\n\n\tpublic readonly localSessionId: SessionId;\n\tprivate readonly localSession: Session;\n\tprivate readonly normalizer = new SessionSpaceNormalizer();\n\t// The number of IDs generated by the local session\n\tprivate localGenCount = 0;\n\n\t// -----------------------\n\n\t// ----- Final state -----\n\n\t// The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.\n\t// This is updated to be equal to `generatedIdCount` + 1 each time it is called.\n\tprivate nextRangeBaseGenCount = 1;\n\t// The capacity of the next cluster to be created\n\tprivate newClusterCapacity = initialClusterCapacity;\n\tprivate readonly sessions = new Sessions();\n\tprivate readonly finalSpace = new FinalSpace();\n\n\t// -----------------------\n\n\t// ----- Telemetry state -----\n\n\t// The number of local IDs generated since the last telemetry was sent.\n\tprivate telemetryLocalIdCount = 0;\n\t// The number of eager final IDs generated since the last telemetry was sent.\n\tprivate telemetryEagerFinalIdCount = 0;\n\n\t// -----------------------\n\n\tprivate constructor(\n\t\tlocalSessionIdOrDeserialized: SessionId | Sessions,\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t) {\n\t\tif (typeof localSessionIdOrDeserialized === \"string\") {\n\t\t\tthis.localSessionId = localSessionIdOrDeserialized;\n\t\t\tthis.localSession = this.sessions.getOrCreate(localSessionIdOrDeserialized);\n\t\t} else {\n\t\t\t// Deserialize case\n\t\t\tthis.sessions = localSessionIdOrDeserialized;\n\t\t\t// As policy, the first session is always the local session. Preserve this invariant\n\t\t\t// during deserialization.\n\t\t\tconst firstSession = localSessionIdOrDeserialized.sessions().next();\n\t\t\tassert(!firstSession.done, 0x754 /* First session must be present. */);\n\t\t\tthis.localSession = firstSession.value;\n\t\t\tthis.localSessionId = stableIdFromNumericUuid(\n\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t) as SessionId;\n\t\t}\n\t}\n\n\tpublic static create(logger?: ITelemetryBaseLogger): IdCompressor;\n\tpublic static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IdCompressor;\n\tpublic static create(\n\t\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\t\tloggerOrUndefined?: ITelemetryBaseLogger,\n\t): IdCompressor {\n\t\tlet localSessionId: SessionId;\n\t\tlet logger: ITelemetryBaseLogger | undefined;\n\t\tif (sessionIdOrLogger === undefined) {\n\t\t\tlocalSessionId = createSessionId();\n\t\t} else {\n\t\t\tif (typeof sessionIdOrLogger === \"string\") {\n\t\t\t\tlocalSessionId = sessionIdOrLogger;\n\t\t\t\tlogger = loggerOrUndefined;\n\t\t\t} else {\n\t\t\t\tlocalSessionId = createSessionId();\n\t\t\t\tlogger = loggerOrUndefined;\n\t\t\t}\n\t\t}\n\t\tconst compressor = new IdCompressor(\n\t\t\tlocalSessionId,\n\t\t\tlogger === undefined ? undefined : createChildLogger({ logger }),\n\t\t);\n\t\treturn compressor;\n\t}\n\n\t/**\n\t * The size of each newly created ID cluster.\n\t */\n\tpublic get clusterCapacity(): number {\n\t\treturn this.newClusterCapacity;\n\t}\n\n\t/**\n\t * Must only be set with a value upon which consensus has been reached. Value must be greater than zero and less than\n\t * `IdCompressor.maxClusterSize`.\n\t */\n\tpublic set clusterCapacity(value: number) {\n\t\tif (value <= 0) {\n\t\t\tthrow new Error(\"Clusters must have a positive capacity.\");\n\t\t}\n\t\tif (value > IdCompressor.maxClusterSize) {\n\t\t\tthrow new Error(\"Clusters must not exceed max cluster size.\");\n\t\t}\n\t\tthis.newClusterCapacity = value;\n\t}\n\n\tpublic generateCompressedId(): SessionSpaceCompressedId {\n\t\tthis.localGenCount++;\n\t\tconst lastCluster = this.localSession.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\tthis.telemetryLocalIdCount++;\n\t\t\treturn this.generateNextLocalId();\n\t\t}\n\n\t\t// If there exists a cluster of final IDs already claimed by the local session that still has room in it,\n\t\t// it is known prior to range sequencing what a local ID's corresponding final ID will be.\n\t\t// In this case, it is safe to return the final ID immediately. This is guaranteed to be safe because\n\t\t// any op that the local session sends that contains one of those final IDs are guaranteed to arrive to\n\t\t// collaborators *after* the one containing the creation range.\n\t\tconst clusterOffset = this.localGenCount - genCountFromLocalId(lastCluster.baseLocalId);\n\t\tif (lastCluster.capacity > clusterOffset) {\n\t\t\tthis.telemetryEagerFinalIdCount++;\n\t\t\t// Space in the cluster: eager final\n\t\t\treturn ((lastCluster.baseFinalId as number) +\n\t\t\t\tclusterOffset) as SessionSpaceCompressedId;\n\t\t}\n\t\t// No space in the cluster, return next local\n\t\tthis.telemetryLocalIdCount++;\n\t\treturn this.generateNextLocalId();\n\t}\n\n\tprivate generateNextLocalId(): LocalCompressedId {\n\t\t// Must tell the normalizer that we generated a local ID\n\t\tthis.normalizer.addLocalRange(this.localGenCount, 1);\n\t\treturn localIdFromGenCount(this.localGenCount);\n\t}\n\n\tpublic takeNextCreationRange(): IdCreationRange {\n\t\tconst count = this.localGenCount - (this.nextRangeBaseGenCount - 1);\n\t\tif (count === 0) {\n\t\t\treturn {\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t};\n\t\t}\n\t\tconst range: IdCreationRange = {\n\t\t\tsessionId: this.localSessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: this.nextRangeBaseGenCount,\n\t\t\t\tcount,\n\t\t\t},\n\t\t};\n\t\tthis.nextRangeBaseGenCount = this.localGenCount + 1;\n\t\treturn range;\n\t}\n\n\tpublic finalizeCreationRange(range: IdCreationRange): void {\n\t\t// Check if the range has IDs\n\t\tif (range.ids === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(range.ids.count > 0, 0x755 /* Malformed ID Range. */);\n\t\tconst { sessionId, ids } = range;\n\t\tconst { count, firstGenCount } = ids;\n\t\tconst session = this.sessions.getOrCreate(sessionId);\n\t\tconst isLocal = session === this.localSession;\n\t\tconst rangeBaseLocal = localIdFromGenCount(firstGenCount);\n\t\tlet lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// This is the first cluster in the session space\n\t\t\tif (rangeBaseLocal !== -1) {\n\t\t\t\tthrow new Error(\"Ranges finalized out of order.\");\n\t\t\t}\n\t\t\tlastCluster = this.addEmptyCluster(session, this.clusterCapacity + count);\n\t\t\tif (isLocal) {\n\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: \"RuntimeIdCompressor:FirstCluster\",\n\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst remainingCapacity = lastCluster.capacity - lastCluster.count;\n\t\tif (lastCluster.baseLocalId - lastCluster.count !== rangeBaseLocal) {\n\t\t\tthrow new Error(\"Ranges finalized out of order.\");\n\t\t}\n\n\t\tif (remainingCapacity >= count) {\n\t\t\t// The current range fits in the existing cluster\n\t\t\tlastCluster.count += count;\n\t\t} else {\n\t\t\tconst overflow = count - remainingCapacity;\n\t\t\tconst newClaimedFinalCount = overflow + this.clusterCapacity;\n\t\t\tif (lastCluster === this.finalSpace.getLastCluster()) {\n\t\t\t\t// The last cluster in the sessions chain is the last cluster globally, so it can be expanded.\n\t\t\t\tlastCluster.capacity += newClaimedFinalCount;\n\t\t\t\tlastCluster.count += count;\n\t\t\t\tassert(\n\t\t\t\t\t!this.sessions.clusterCollides(lastCluster),\n\t\t\t\t\t0x756 /* Cluster collision detected. */,\n\t\t\t\t);\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:ClusterExpansion\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t\tpreviousCapacity: lastCluster.capacity - newClaimedFinalCount,\n\t\t\t\t\t\tnewCapacity: lastCluster.capacity,\n\t\t\t\t\t\toverflow,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// The last cluster in the sessions chain is *not* the last cluster globally. Fill and overflow to new.\n\t\t\t\tlastCluster.count = lastCluster.capacity;\n\t\t\t\tconst newCluster = this.addEmptyCluster(session, newClaimedFinalCount);\n\t\t\t\tnewCluster.count += overflow;\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:NewCluster\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isLocal) {\n\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\teventName: \"RuntimeIdCompressor:IdCompressorStatus\",\n\t\t\t\teagerFinalIdCount: this.telemetryEagerFinalIdCount,\n\t\t\t\tlocalIdCount: this.telemetryLocalIdCount,\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t});\n\t\t\tthis.telemetryEagerFinalIdCount = 0;\n\t\t\tthis.telemetryLocalIdCount = 0;\n\t\t}\n\n\t\tassert(!session.isEmpty(), 0x757 /* Empty sessions should not be created. */);\n\t}\n\n\tprivate addEmptyCluster(session: Session, capacity: number): IdCluster {\n\t\tconst newCluster = session.addNewCluster(\n\t\t\tthis.finalSpace.getAllocatedIdLimit(),\n\t\t\tcapacity,\n\t\t\t0,\n\t\t);\n\t\tassert(!this.sessions.clusterCollides(newCluster), 0x758 /* Cluster collision detected. */);\n\t\tthis.finalSpace.addCluster(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\treturn id;\n\t\t} else {\n\t\t\tconst local = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(local)) {\n\t\t\t\tthrow new Error(\"Invalid ID to normalize.\");\n\t\t\t}\n\t\t\tconst finalForm = this.localSession.tryConvertToFinal(local, true);\n\t\t\treturn finalForm === undefined\n\t\t\t\t? (local as unknown as OpSpaceCompressedId)\n\t\t\t\t: (finalForm as OpSpaceCompressedId);\n\t\t}\n\t}\n\n\tpublic normalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = this.localSession.getClusterByAllocatedFinal(id);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\t// Does not exist in local cluster chain\n\t\t\t\tif (id >= this.finalSpace.getFinalizedIdLimit()) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tif (genCountFromLocalId(alignedLocal) > this.localGenCount) {\n\t\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t\t}\n\t\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst localToNormalize = id as unknown as LocalCompressedId;\n\t\t\tif (originSessionId === this.localSessionId) {\n\t\t\t\tif (this.normalizer.contains(localToNormalize)) {\n\t\t\t\t\treturn localToNormalize;\n\t\t\t\t} else {\n\t\t\t\t\t// We never generated this local ID, so fail\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// LocalId from a remote session\n\t\t\t\tconst remoteSession = this.sessions.get(originSessionId);\n\t\t\t\tif (remoteSession === undefined) {\n\t\t\t\t\tthrow new Error(\"No IDs have ever been finalized by the supplied session.\");\n\t\t\t\t}\n\t\t\t\tconst correspondingFinal = remoteSession.tryConvertToFinal(localToNormalize, false);\n\t\t\t\tif (correspondingFinal === undefined) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn correspondingFinal as unknown as SessionSpaceCompressedId;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic decompress(id: SessionSpaceCompressedId): StableId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = Session.getContainingCluster(id, this.finalSpace.clusters);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\tconst alignedGenCount = genCountFromLocalId(alignedLocal);\n\t\t\tconst lastFinalizedGenCount = genCountFromLocalId(\n\t\t\t\tlastFinalizedLocal(containingCluster),\n\t\t\t);\n\t\t\tif (alignedGenCount > lastFinalizedGenCount) {\n\t\t\t\t// should be an eager final id generated by the local session\n\t\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!this.normalizer.contains(alignedLocal),\n\t\t\t\t\t\t0x759 /* Normalizer out of sync. */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(containingCluster.session.sessionUuid, alignedGenCount - 1),\n\t\t\t);\n\t\t} else {\n\t\t\tconst localToDecompress = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(localToDecompress)) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(\n\t\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t\t\tgenCountFromLocalId(localToDecompress) - 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic recompress(uncompressed: StableId): SessionSpaceCompressedId {\n\t\tconst recompressed = this.tryRecompress(uncompressed);\n\t\tif (recompressed === undefined) {\n\t\t\tthrow new Error(\"Could not recompress.\");\n\t\t}\n\t\treturn recompressed;\n\t}\n\n\tpublic tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined {\n\t\tconst match = this.sessions.getContainingCluster(uncompressed);\n\t\tif (match === undefined) {\n\t\t\tconst numericUncompressed = numericUuidFromStableId(uncompressed);\n\t\t\tconst offset = subtractNumericUuids(numericUncompressed, this.localSession.sessionUuid);\n\t\t\tif (offset < Number.MAX_SAFE_INTEGER) {\n\t\t\t\tconst genCountEquivalent = Number(offset) + 1;\n\t\t\t\tconst localEquivalent = localIdFromGenCount(genCountEquivalent);\n\t\t\t\tif (this.normalizer.contains(localEquivalent)) {\n\t\t\t\t\treturn localEquivalent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\tconst [containingCluster, alignedLocal] = match;\n\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t// Local session\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tgenCountFromLocalId(alignedLocal) <= this.localGenCount,\n\t\t\t\t\t\t0x75a /* Clusters out of sync. */,\n\t\t\t\t\t);\n\t\t\t\t\t// Id is an eager final\n\t\t\t\t\treturn getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t| undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Not the local session\n\t\t\t\treturn genCountFromLocalId(alignedLocal) >= lastFinalizedLocal(containingCluster)\n\t\t\t\t\t? (getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t\t| undefined)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\tpublic serialize(withSession: false): SerializedIdCompressorWithNoSession;\n\tpublic serialize(hasLocalState: boolean): SerializedIdCompressor {\n\t\tconst { normalizer, finalSpace, sessions } = this;\n\t\tconst sessionIndexMap = new Map<Session, number>();\n\t\tlet sessionIndex = 0;\n\t\tfor (const session of sessions.sessions()) {\n\t\t\t// Filter empty sessions to prevent them accumulating in the serialized state\n\t\t\tif (!session.isEmpty() || hasLocalState) {\n\t\t\t\tsessionIndexMap.set(session, sessionIndex);\n\t\t\t\tsessionIndex++;\n\t\t\t}\n\t\t}\n\t\tconst localStateSize = hasLocalState\n\t\t\t? 1 + // generated ID count\n\t\t\t 1 + // next range base genCount\n\t\t\t 1 + // count of normalizer pairs\n\t\t\t this.normalizer.idRanges.size * 2 // pairs\n\t\t\t: 0;\n\t\t// Layout size, in 8 byte increments\n\t\tconst totalSize =\n\t\t\t1 + // version\n\t\t\t1 + // hasLocalState\n\t\t\t1 + // cluster capacity\n\t\t\t1 + // session count\n\t\t\t1 + // cluster count\n\t\t\tsessionIndexMap.size * 2 + // session IDs\n\t\t\tfinalSpace.clusters.length * 3 + // clusters: (sessionIndex, capacity, count)[]\n\t\t\tlocalStateSize; // local state, if present\n\n\t\tconst serializedFloat = new Float64Array(totalSize);\n\t\tconst serializedUint = new BigUint64Array(serializedFloat.buffer);\n\t\tlet index = 0;\n\t\tindex = writeNumber(serializedFloat, index, currentWrittenVersion);\n\t\tindex = writeBoolean(serializedFloat, index, hasLocalState);\n\t\tindex = writeNumber(serializedFloat, index, this.clusterCapacity);\n\t\tindex = writeNumber(serializedFloat, index, sessionIndexMap.size);\n\t\tindex = writeNumber(serializedFloat, index, finalSpace.clusters.length);\n\n\t\tfor (const [session] of sessionIndexMap.entries()) {\n\t\t\tindex = writeNumericUuid(serializedUint, index, session.sessionUuid);\n\t\t}\n\n\t\tfinalSpace.clusters.forEach((cluster) => {\n\t\t\tindex = writeNumber(\n\t\t\t\tserializedFloat,\n\t\t\t\tindex,\n\t\t\t\tsessionIndexMap.get(cluster.session) as number,\n\t\t\t);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.capacity);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.count);\n\t\t});\n\n\t\tif (hasLocalState) {\n\t\t\tindex = writeNumber(serializedFloat, index, this.localGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, this.nextRangeBaseGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, normalizer.idRanges.size);\n\t\t\tfor (const [leadingGenCount, count] of normalizer.idRanges.entries()) {\n\t\t\t\tindex = writeNumber(serializedFloat, index, leadingGenCount);\n\t\t\t\tindex = writeNumber(serializedFloat, index, count);\n\t\t\t}\n\t\t}\n\n\t\tassert(index === totalSize, 0x75b /* Serialized size was incorrectly calculated. */);\n\t\tthis.logger?.sendTelemetryEvent({\n\t\t\teventName: \"RuntimeIdCompressor:SerializedIdCompressorSize\",\n\t\t\tsize: serializedFloat.byteLength,\n\t\t\tclusterCount: finalSpace.clusters.length,\n\t\t\tsessionCount: sessionIndexMap.size,\n\t\t});\n\n\t\treturn bufferToString(serializedFloat.buffer, \"base64\") as SerializedIdCompressor;\n\t}\n\n\tpublic static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;\n\tpublic static deserialize(\n\t\tserialized: SerializedIdCompressorWithNoSession,\n\t\tnewSessionId: SessionId,\n\t): IdCompressor;\n\tpublic static deserialize(\n\t\tserialized: SerializedIdCompressor,\n\t\tsessionId?: SessionId,\n\t): IdCompressor {\n\t\tconst buffer = stringToBuffer(serialized, \"base64\");\n\t\tconst index: Index = {\n\t\t\tindex: 0,\n\t\t\tbufferFloat: new Float64Array(buffer),\n\t\t\tbufferUint: new BigUint64Array(buffer),\n\t\t};\n\t\tconst version = readNumber(index);\n\t\tassert(version === currentWrittenVersion, 0x75c /* Unknown serialized version. */);\n\t\tconst hasLocalState = readBoolean(index);\n\t\tconst clusterCapacity = readNumber(index);\n\t\tconst sessionCount = readNumber(index);\n\t\tconst clusterCount = readNumber(index);\n\n\t\t// Sessions\n\t\tlet sessionOffset = 0;\n\t\tconst sessions: [NumericUuid, Session][] = [];\n\t\tif (!hasLocalState) {\n\t\t\t// If !hasLocalState, there won't be a serialized local session ID so insert one at the beginning\n\t\t\tassert(sessionId !== undefined, 0x75d /* Local session ID is undefined. */);\n\t\t\tconst localSessionNumeric = numericUuidFromStableId(sessionId);\n\t\t\tsessions.push([localSessionNumeric, new Session(localSessionNumeric)]);\n\t\t\tsessionOffset = 1;\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tsessionId === undefined,\n\t\t\t\t0x75e /* Local state should not exist in serialized form. */,\n\t\t\t);\n\t\t}\n\n\t\tfor (let i = 0; i < sessionCount; i++) {\n\t\t\tconst numeric = readNumericUuid(index);\n\t\t\tsessions.push([numeric, new Session(numeric)]);\n\t\t}\n\n\t\tconst compressor = new IdCompressor(new Sessions(sessions));\n\t\tcompressor.clusterCapacity = clusterCapacity;\n\n\t\t// Clusters\n\t\tlet baseFinalId = 0;\n\t\tfor (let i = 0; i < clusterCount; i++) {\n\t\t\tconst sessionIndex = readNumber(index);\n\t\t\tconst session = sessions[sessionIndex + sessionOffset][1];\n\t\t\tconst capacity = readNumber(index);\n\t\t\tconst count = readNumber(index);\n\t\t\tconst cluster = session.addNewCluster(\n\t\t\t\tbaseFinalId as FinalCompressedId,\n\t\t\t\tcapacity,\n\t\t\t\tcount,\n\t\t\t);\n\t\t\tcompressor.finalSpace.addCluster(cluster);\n\t\t\tbaseFinalId += capacity;\n\t\t}\n\n\t\t// Local state\n\t\tif (hasLocalState) {\n\t\t\tcompressor.localGenCount = readNumber(index);\n\t\t\tcompressor.nextRangeBaseGenCount = readNumber(index);\n\t\t\tconst normalizerCount = readNumber(index);\n\t\t\tfor (let i = 0; i < normalizerCount; i++) {\n\t\t\t\tcompressor.normalizer.addLocalRange(readNumber(index), readNumber(index));\n\t\t\t}\n\t\t}\n\n\t\tassert(\n\t\t\tindex.index === index.bufferFloat.length,\n\t\t\t0x75f /* Failed to read entire serialized compressor. */,\n\t\t);\n\t\treturn compressor;\n\t}\n\n\tpublic equals(other: IdCompressor, includeLocalState: boolean): boolean {\n\t\tif (\n\t\t\tincludeLocalState &&\n\t\t\t(this.localSessionId !== other.localSessionId ||\n\t\t\t\t!this.localSession.equals(other.localSession) ||\n\t\t\t\t!this.normalizer.equals(other.normalizer) ||\n\t\t\t\tthis.nextRangeBaseGenCount !== other.nextRangeBaseGenCount ||\n\t\t\t\tthis.localGenCount !== other.localGenCount)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\tthis.newClusterCapacity === other.newClusterCapacity &&\n\t\t\tthis.sessions.equals(other.sessions, includeLocalState) &&\n\t\t\tthis.finalSpace.equals(other.finalSpace)\n\t\t);\n\t}\n}\n"]}
@@ -7,7 +7,7 @@ import { OpSpaceCompressedId, SessionSpaceCompressedId } from "@fluidframework/r
7
7
  * A compressed ID that is stable and unique within the scope of network of compressors (i.e. a document).
8
8
  * It can only be used/decompressed in the context of the originating document.
9
9
  */
10
- export declare type FinalCompressedId = number & {
10
+ export type FinalCompressedId = number & {
11
11
  readonly FinalCompressedId: "5d83d1e2-98b7-4e4e-a889-54c855cfa73d";
12
12
  readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
13
13
  };
@@ -16,7 +16,7 @@ export declare type FinalCompressedId = number & {
16
16
  * Internally, it should not be persisted outside a scope annotated with the originating SessionId in order to be unambiguous.
17
17
  * If external persistence is needed (e.g. by a client), a StableId should be used instead.
18
18
  */
19
- export declare type LocalCompressedId = number & {
19
+ export type LocalCompressedId = number & {
20
20
  readonly LocalCompressedId: "6fccb42f-e2a4-4243-bd29-f13d12b9c6d1";
21
21
  } & SessionSpaceCompressedId;
22
22
  /**
@@ -26,7 +26,7 @@ export declare function isFinalId(id: SessionSpaceCompressedId | OpSpaceCompress
26
26
  /**
27
27
  * A StableId which is suitable for use as a session identifier
28
28
  */
29
- export declare type NumericUuid = bigint & {
29
+ export type NumericUuid = bigint & {
30
30
  readonly NumericUuid: "be04dd4d-9d7e-4337-a833-eec64c61aa46";
31
31
  };
32
32
  //# sourceMappingURL=identifiers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../../src/id-compressor/identifiers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAEpG;;;GAGG;AACH,oBAAY,iBAAiB,GAAG,MAAM,GAAG;IACxC,QAAQ,CAAC,iBAAiB,EAAE,sCAAsC,CAAC;IAGnE,QAAQ,CAAC,YAAY,EAAE,sCAAsC,CAAC;CAC9D,CAAC;AAEF;;;;GAIG;AACH,oBAAY,iBAAiB,GAAG,MAAM,GAAG;IACxC,QAAQ,CAAC,iBAAiB,EAAE,sCAAsC,CAAC;CACnE,GAAG,wBAAwB,CAAC;AAE7B;;GAEG;AACH,wBAAgB,SAAS,CACxB,EAAE,EAAE,wBAAwB,GAAG,mBAAmB,GAChD,EAAE,IAAI,iBAAiB,CAEzB;AAED;;GAEG;AACH,oBAAY,WAAW,GAAG,MAAM,GAAG;IAClC,QAAQ,CAAC,WAAW,EAAE,sCAAsC,CAAC;CAC7D,CAAC"}
1
+ {"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../../src/id-compressor/identifiers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAEpG;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IACxC,QAAQ,CAAC,iBAAiB,EAAE,sCAAsC,CAAC;IAGnE,QAAQ,CAAC,YAAY,EAAE,sCAAsC,CAAC;CAC9D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IACxC,QAAQ,CAAC,iBAAiB,EAAE,sCAAsC,CAAC;CACnE,GAAG,wBAAwB,CAAC;AAE7B;;GAEG;AACH,wBAAgB,SAAS,CACxB,EAAE,EAAE,wBAAwB,GAAG,mBAAmB,GAChD,EAAE,IAAI,iBAAiB,CAEzB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAClC,QAAQ,CAAC,WAAW,EAAE,sCAAsC,CAAC;CAC7D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { ContainerMessageType, ContainerRuntimeMessage, IContainerRuntimeMessageCompatDetails, CompatModeBehavior, ISummaryRuntimeOptions, ISummaryBaseConfiguration, ISummaryConfigurationHeuristics, ISummaryConfigurationDisableSummarizer, ISummaryConfigurationDisableHeuristics, IContainerRuntimeOptions, isRuntimeMessage, RuntimeMessage, agentSchedulerId, ContainerRuntime, RuntimeHeaders, AllowTombstoneRequestHeaderKey, AllowInactiveRequestHeaderKey, TombstoneResponseHeaderKey, InactiveResponseHeaderKey, ISummaryConfiguration, DefaultSummaryConfiguration, ICompressionRuntimeOptions, CompressionAlgorithms, } from "./containerRuntime";
5
+ export { ISummaryRuntimeOptions, ISummaryBaseConfiguration, ISummaryConfigurationHeuristics, ISummaryConfigurationDisableSummarizer, ISummaryConfigurationDisableHeuristics, IContainerRuntimeOptions, isRuntimeMessage, RuntimeMessage, agentSchedulerId, ContainerRuntime, RuntimeHeaders, AllowTombstoneRequestHeaderKey, AllowInactiveRequestHeaderKey, TombstoneResponseHeaderKey, InactiveResponseHeaderKey, ISummaryConfiguration, DefaultSummaryConfiguration, ICompressionRuntimeOptions, CompressionAlgorithms, } from "./containerRuntime";
6
+ export { ContainerMessageType, ContainerRuntimeMessage, IContainerRuntimeMessageCompatDetails, CompatModeBehavior, RecentlyAddedContainerRuntimeMessageDetails, } from "./messageTypes";
6
7
  export { FluidDataStoreRegistry } from "./dataStoreRegistry";
7
8
  export { IGCRuntimeOptions, IGCStats } from "./gc";
8
9
  export { IAckedSummary, ISummarizer, ISummarizeResults, ISummaryCancellationToken, neverCancelledSummaryToken, Summarizer, SummarizerStopReason, SummaryCollection, EnqueueSummarizeResult, IAckSummaryResult, IBaseSummarizeResult, IBroadcastSummaryResult, ICancellationToken, IConnectableRuntime, IEnqueueSummarizeOptions, IGenerateSummaryTreeResult, IGeneratedSummaryStats, INackSummaryResult, IOnDemandSummarizeOptions, IRefreshSummaryAckOptions, ISubmitSummaryOpResult, ISubmitSummaryOptions, ISummarizeOptions, ISummarizerEvents, ISummarizerInternalsProvider, ISummarizerRuntime, ISummarizingWarning, IUploadSummaryResult, SubmitSummaryResult, SummarizeResultPart, IClientSummaryWatcher, ISummary, ISummaryCollectionOpEvents, ISummaryAckMessage, ISummaryNackMessage, ISummaryOpMessage, OpActionEventListener, OpActionEventName, ICancellableSummarizerController, SubmitSummaryFailureData, SummaryStage, IRetriableFailureResult, ISummarizeEventProps, } from "./summary";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EACvB,qCAAqC,EACrC,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,+BAA+B,EAC/B,sCAAsC,EACtC,sCAAsC,EACtC,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EACN,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,yBAAyB,EACzB,0BAA0B,EAC1B,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,EAClB,mBA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BAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,QAAQ,EACR,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,gCAAgC,EAChC,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -4,9 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.unpackRuntimeMessage = exports.assertIsStableId = exports.generateStableId = exports.isStableId = exports.SummaryCollection = exports.Summarizer = exports.neverCancelledSummaryToken = exports.FluidDataStoreRegistry = exports.CompressionAlgorithms = exports.DefaultSummaryConfiguration = exports.InactiveResponseHeaderKey = exports.TombstoneResponseHeaderKey = exports.AllowInactiveRequestHeaderKey = exports.AllowTombstoneRequestHeaderKey = exports.RuntimeHeaders = exports.ContainerRuntime = exports.agentSchedulerId = exports.RuntimeMessage = exports.isRuntimeMessage = exports.ContainerMessageType = void 0;
7
+ exports.unpackRuntimeMessage = exports.assertIsStableId = exports.generateStableId = exports.isStableId = exports.SummaryCollection = exports.Summarizer = exports.neverCancelledSummaryToken = exports.FluidDataStoreRegistry = exports.ContainerMessageType = exports.CompressionAlgorithms = exports.DefaultSummaryConfiguration = exports.InactiveResponseHeaderKey = exports.TombstoneResponseHeaderKey = exports.AllowInactiveRequestHeaderKey = exports.AllowTombstoneRequestHeaderKey = exports.RuntimeHeaders = exports.ContainerRuntime = exports.agentSchedulerId = exports.RuntimeMessage = exports.isRuntimeMessage = void 0;
8
8
  var containerRuntime_1 = require("./containerRuntime");
9
- Object.defineProperty(exports, "ContainerMessageType", { enumerable: true, get: function () { return containerRuntime_1.ContainerMessageType; } });
10
9
  Object.defineProperty(exports, "isRuntimeMessage", { enumerable: true, get: function () { return containerRuntime_1.isRuntimeMessage; } });
11
10
  Object.defineProperty(exports, "RuntimeMessage", { enumerable: true, get: function () { return containerRuntime_1.RuntimeMessage; } });
12
11
  Object.defineProperty(exports, "agentSchedulerId", { enumerable: true, get: function () { return containerRuntime_1.agentSchedulerId; } });
@@ -18,6 +17,8 @@ Object.defineProperty(exports, "TombstoneResponseHeaderKey", { enumerable: true,
18
17
  Object.defineProperty(exports, "InactiveResponseHeaderKey", { enumerable: true, get: function () { return containerRuntime_1.InactiveResponseHeaderKey; } });
19
18
  Object.defineProperty(exports, "DefaultSummaryConfiguration", { enumerable: true, get: function () { return containerRuntime_1.DefaultSummaryConfiguration; } });
20
19
  Object.defineProperty(exports, "CompressionAlgorithms", { enumerable: true, get: function () { return containerRuntime_1.CompressionAlgorithms; } });
20
+ var messageTypes_1 = require("./messageTypes");
21
+ Object.defineProperty(exports, "ContainerMessageType", { enumerable: true, get: function () { return messageTypes_1.ContainerMessageType; } });
21
22
  var dataStoreRegistry_1 = require("./dataStoreRegistry");
22
23
  Object.defineProperty(exports, "FluidDataStoreRegistry", { enumerable: true, get: function () { return dataStoreRegistry_1.FluidDataStoreRegistry; } });
23
24
  var summary_1 = require("./summary");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAwB4B;AAvB3B,wHAAA,oBAAoB,OAAA;AAUpB,oHAAA,gBAAgB,OAAA;AAChB,kHAAA,cAAc,OAAA;AACd,oHAAA,gBAAgB,OAAA;AAChB,oHAAA,gBAAgB,OAAA;AAChB,kHAAA,cAAc,OAAA;AACd,kIAAA,8BAA8B,OAAA;AAC9B,iIAAA,6BAA6B,OAAA;AAC7B,8HAAA,0BAA0B,OAAA;AAC1B,6HAAA,yBAAyB,OAAA;AAEzB,+HAAA,2BAA2B,OAAA;AAE3B,yHAAA,qBAAqB,OAAA;AAEtB,yDAA6D;AAApD,2HAAA,sBAAsB,OAAA;AAE/B,qCA4CmB;AAvClB,qHAAA,0BAA0B,OAAA;AAC1B,qGAAA,UAAU,OAAA;AAEV,4GAAA,iBAAiB,OAAA;AAqClB,iDAAiF;AAAxE,2GAAA,UAAU,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AACvD,6CAAiE;AAA5C,mHAAA,oBAAoB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tContainerMessageType,\n\tContainerRuntimeMessage,\n\tIContainerRuntimeMessageCompatDetails,\n\tCompatModeBehavior,\n\tISummaryRuntimeOptions,\n\tISummaryBaseConfiguration,\n\tISummaryConfigurationHeuristics,\n\tISummaryConfigurationDisableSummarizer,\n\tISummaryConfigurationDisableHeuristics,\n\tIContainerRuntimeOptions,\n\tisRuntimeMessage,\n\tRuntimeMessage,\n\tagentSchedulerId,\n\tContainerRuntime,\n\tRuntimeHeaders,\n\tAllowTombstoneRequestHeaderKey,\n\tAllowInactiveRequestHeaderKey,\n\tTombstoneResponseHeaderKey,\n\tInactiveResponseHeaderKey,\n\tISummaryConfiguration,\n\tDefaultSummaryConfiguration,\n\tICompressionRuntimeOptions,\n\tCompressionAlgorithms,\n} from \"./containerRuntime\";\nexport { FluidDataStoreRegistry } from \"./dataStoreRegistry\";\nexport { IGCRuntimeOptions, IGCStats } from \"./gc\";\nexport {\n\tIAckedSummary,\n\tISummarizer,\n\tISummarizeResults,\n\tISummaryCancellationToken,\n\tneverCancelledSummaryToken,\n\tSummarizer,\n\tSummarizerStopReason,\n\tSummaryCollection,\n\tEnqueueSummarizeResult,\n\tIAckSummaryResult,\n\tIBaseSummarizeResult,\n\tIBroadcastSummaryResult,\n\tICancellationToken,\n\tIConnectableRuntime,\n\tIEnqueueSummarizeOptions,\n\tIGenerateSummaryTreeResult,\n\tIGeneratedSummaryStats,\n\tINackSummaryResult,\n\tIOnDemandSummarizeOptions,\n\tIRefreshSummaryAckOptions,\n\tISubmitSummaryOpResult,\n\tISubmitSummaryOptions,\n\tISummarizeOptions,\n\tISummarizerEvents,\n\tISummarizerInternalsProvider,\n\tISummarizerRuntime,\n\tISummarizingWarning,\n\tIUploadSummaryResult,\n\tSubmitSummaryResult,\n\tSummarizeResultPart,\n\tIClientSummaryWatcher,\n\tISummary,\n\tISummaryCollectionOpEvents,\n\tISummaryAckMessage,\n\tISummaryNackMessage,\n\tISummaryOpMessage,\n\tOpActionEventListener,\n\tOpActionEventName,\n\tICancellableSummarizerController,\n\tSubmitSummaryFailureData,\n\tSummaryStage,\n\tIRetriableFailureResult,\n\tISummarizeEventProps,\n} from \"./summary\";\nexport { isStableId, generateStableId, assertIsStableId } from \"./id-compressor\";\nexport { IChunkedOp, unpackRuntimeMessage } from \"./opLifecycle\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAoB4B;AAb3B,oHAAA,gBAAgB,OAAA;AAChB,kHAAA,cAAc,OAAA;AACd,oHAAA,gBAAgB,OAAA;AAChB,oHAAA,gBAAgB,OAAA;AAChB,kHAAA,cAAc,OAAA;AACd,kIAAA,8BAA8B,OAAA;AAC9B,iIAAA,6BAA6B,OAAA;AAC7B,8HAAA,0BAA0B,OAAA;AAC1B,6HAAA,yBAAyB,OAAA;AAEzB,+HAAA,2BAA2B,OAAA;AAE3B,yHAAA,qBAAqB,OAAA;AAEtB,+CAMwB;AALvB,oHAAA,oBAAoB,OAAA;AAMrB,yDAA6D;AAApD,2HAAA,sBAAsB,OAAA;AAE/B,qCA4CmB;AAvClB,qHAAA,0BAA0B,OAAA;AAC1B,qGAAA,UAAU,OAAA;AAEV,4GAAA,iBAAiB,OAAA;AAqClB,iDAAiF;AAAxE,2GAAA,UAAU,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AACvD,6CAAiE;AAA5C,mHAAA,oBAAoB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tISummaryRuntimeOptions,\n\tISummaryBaseConfiguration,\n\tISummaryConfigurationHeuristics,\n\tISummaryConfigurationDisableSummarizer,\n\tISummaryConfigurationDisableHeuristics,\n\tIContainerRuntimeOptions,\n\tisRuntimeMessage,\n\tRuntimeMessage,\n\tagentSchedulerId,\n\tContainerRuntime,\n\tRuntimeHeaders,\n\tAllowTombstoneRequestHeaderKey,\n\tAllowInactiveRequestHeaderKey,\n\tTombstoneResponseHeaderKey,\n\tInactiveResponseHeaderKey,\n\tISummaryConfiguration,\n\tDefaultSummaryConfiguration,\n\tICompressionRuntimeOptions,\n\tCompressionAlgorithms,\n} from \"./containerRuntime\";\nexport {\n\tContainerMessageType,\n\tContainerRuntimeMessage,\n\tIContainerRuntimeMessageCompatDetails,\n\tCompatModeBehavior,\n\tRecentlyAddedContainerRuntimeMessageDetails,\n} from \"./messageTypes\";\nexport { FluidDataStoreRegistry } from \"./dataStoreRegistry\";\nexport { IGCRuntimeOptions, IGCStats } from \"./gc\";\nexport {\n\tIAckedSummary,\n\tISummarizer,\n\tISummarizeResults,\n\tISummaryCancellationToken,\n\tneverCancelledSummaryToken,\n\tSummarizer,\n\tSummarizerStopReason,\n\tSummaryCollection,\n\tEnqueueSummarizeResult,\n\tIAckSummaryResult,\n\tIBaseSummarizeResult,\n\tIBroadcastSummaryResult,\n\tICancellationToken,\n\tIConnectableRuntime,\n\tIEnqueueSummarizeOptions,\n\tIGenerateSummaryTreeResult,\n\tIGeneratedSummaryStats,\n\tINackSummaryResult,\n\tIOnDemandSummarizeOptions,\n\tIRefreshSummaryAckOptions,\n\tISubmitSummaryOpResult,\n\tISubmitSummaryOptions,\n\tISummarizeOptions,\n\tISummarizerEvents,\n\tISummarizerInternalsProvider,\n\tISummarizerRuntime,\n\tISummarizingWarning,\n\tIUploadSummaryResult,\n\tSubmitSummaryResult,\n\tSummarizeResultPart,\n\tIClientSummaryWatcher,\n\tISummary,\n\tISummaryCollectionOpEvents,\n\tISummaryAckMessage,\n\tISummaryNackMessage,\n\tISummaryOpMessage,\n\tOpActionEventListener,\n\tOpActionEventName,\n\tICancellableSummarizerController,\n\tSubmitSummaryFailureData,\n\tSummaryStage,\n\tIRetriableFailureResult,\n\tISummarizeEventProps,\n} from \"./summary\";\nexport { isStableId, generateStableId, assertIsStableId } from \"./id-compressor\";\nexport { IChunkedOp, unpackRuntimeMessage } from \"./opLifecycle\";\n"]}
@@ -0,0 +1,134 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
6
+ import { IEnvelope, InboundAttachMessage, IAttachMessage, IdCreationRangeWithStashedState, IdCreationRange } from "@fluidframework/runtime-definitions";
7
+ import { IDataStoreAliasMessage } from "./dataStore";
8
+ import { IChunkedOp } from "./opLifecycle";
9
+ export declare enum ContainerMessageType {
10
+ FluidDataStoreOp = "component",
11
+ Attach = "attach",
12
+ ChunkedOp = "chunkedOp",
13
+ BlobAttach = "blobAttach",
14
+ Rejoin = "rejoin",
15
+ Alias = "alias",
16
+ /**
17
+ * An op containing an IdRange of Ids allocated using the runtime's IdCompressor since
18
+ * the last allocation op was sent.
19
+ * See the [IdCompressor README](./id-compressor/README.md) for more details.
20
+ */
21
+ IdAllocation = "idAllocation"
22
+ }
23
+ /**
24
+ * How should an older client handle an unrecognized remote op type?
25
+ *
26
+ * @internal
27
+ */
28
+ export type CompatModeBehavior =
29
+ /** Ignore the op. It won't be persisted if this client summarizes */
30
+ "Ignore"
31
+ /** Fail processing immediately. (The container will close) */
32
+ | "FailToProcess";
33
+ /**
34
+ * All the info an older client would need to know how to handle an unrecognized remote op type
35
+ *
36
+ * @internal
37
+ */
38
+ export interface IContainerRuntimeMessageCompatDetails {
39
+ /** How should an older client handle an unrecognized remote op type? */
40
+ behavior: CompatModeBehavior;
41
+ }
42
+ /**
43
+ * The unpacked runtime message / details to be handled or dispatched by the ContainerRuntime.
44
+ * Message type are differentiated via a `type` string and contain different contents depending on their type.
45
+ *
46
+ * IMPORTANT: when creating one to be serialized, set the properties in the order they appear here.
47
+ * This way stringified values can be compared.
48
+ */
49
+ interface TypedContainerRuntimeMessage<TType extends ContainerMessageType, TContents> {
50
+ /** Type of the op, within the ContainerRuntime's domain */
51
+ type: TType;
52
+ /** Domain-specific contents, interpreted according to the type */
53
+ contents: TContents;
54
+ }
55
+ /**
56
+ * Additional details expected for any recently added message.
57
+ * @internal
58
+ */
59
+ export interface RecentlyAddedContainerRuntimeMessageDetails {
60
+ /** Info describing how to handle this op in case the type is unrecognized (default: fail to process) */
61
+ compatDetails: IContainerRuntimeMessageCompatDetails;
62
+ }
63
+ export type ContainerRuntimeDataStoreOpMessage = TypedContainerRuntimeMessage<ContainerMessageType.FluidDataStoreOp, IEnvelope>;
64
+ export type InboundContainerRuntimeAttachMessage = TypedContainerRuntimeMessage<ContainerMessageType.Attach, InboundAttachMessage>;
65
+ export type OutboundContainerRuntimeAttachMessage = TypedContainerRuntimeMessage<ContainerMessageType.Attach, IAttachMessage>;
66
+ export type ContainerRuntimeChunkedOpMessage = TypedContainerRuntimeMessage<ContainerMessageType.ChunkedOp, IChunkedOp>;
67
+ export type ContainerRuntimeBlobAttachMessage = TypedContainerRuntimeMessage<ContainerMessageType.BlobAttach, undefined>;
68
+ export type ContainerRuntimeRejoinMessage = TypedContainerRuntimeMessage<ContainerMessageType.Rejoin, undefined>;
69
+ export type ContainerRuntimeAliasMessage = TypedContainerRuntimeMessage<ContainerMessageType.Alias, IDataStoreAliasMessage>;
70
+ export type LocalContainerRuntimeIdAllocationMessage = TypedContainerRuntimeMessage<ContainerMessageType.IdAllocation, IdCreationRangeWithStashedState>;
71
+ export type ContainerRuntimeIdAllocationMessage = TypedContainerRuntimeMessage<ContainerMessageType.IdAllocation, IdCreationRange & {
72
+ stashedState?: never;
73
+ }>;
74
+ /**
75
+ * Represents an unrecognized {@link TypedContainerRuntimeMessage}, e.g. a message from a future version of the container runtime.
76
+ * @internal
77
+ */
78
+ export interface UnknownContainerRuntimeMessage extends Partial<RecentlyAddedContainerRuntimeMessageDetails> {
79
+ /** Invalid type of the op, within the ContainerRuntime's domain. This value should never exist at runtime.
80
+ * This is useful for type narrowing but should never be used as an actual message type at runtime.
81
+ * Actual value will not be "__unknown...", but the type `Exclude<string, ContainerMessageType>` is not supported.
82
+ */
83
+ type: "__unknown_container_message_type__never_use_as_value__";
84
+ /** Domain-specific contents, but not decipherable by an unknown op. */
85
+ contents: unknown;
86
+ }
87
+ /**
88
+ * A {@link TypedContainerRuntimeMessage} that is received from the server and will be processed by the container runtime.
89
+ */
90
+ export type InboundContainerRuntimeMessage = ContainerRuntimeDataStoreOpMessage | InboundContainerRuntimeAttachMessage | ContainerRuntimeChunkedOpMessage | ContainerRuntimeBlobAttachMessage | ContainerRuntimeRejoinMessage | ContainerRuntimeAliasMessage | ContainerRuntimeIdAllocationMessage | UnknownContainerRuntimeMessage;
91
+ /** A {@link TypedContainerRuntimeMessage} that has been generated by the container runtime but is not yet being sent to the server. */
92
+ export type LocalContainerRuntimeMessage = ContainerRuntimeDataStoreOpMessage | OutboundContainerRuntimeAttachMessage | ContainerRuntimeChunkedOpMessage | ContainerRuntimeBlobAttachMessage | ContainerRuntimeRejoinMessage | ContainerRuntimeAliasMessage | LocalContainerRuntimeIdAllocationMessage | UnknownContainerRuntimeMessage;
93
+ /** A {@link TypedContainerRuntimeMessage} that is being sent to the server from the container runtime. */
94
+ export type OutboundContainerRuntimeMessage = ContainerRuntimeDataStoreOpMessage | OutboundContainerRuntimeAttachMessage | ContainerRuntimeChunkedOpMessage | ContainerRuntimeBlobAttachMessage | ContainerRuntimeRejoinMessage | ContainerRuntimeAliasMessage | ContainerRuntimeIdAllocationMessage;
95
+ /**
96
+ * An unpacked ISequencedDocumentMessage with the inner TypedContainerRuntimeMessage type/contents/etc
97
+ * promoted up to the outer object
98
+ */
99
+ export type InboundSequencedContainerRuntimeMessage = Omit<ISequencedDocumentMessage, "type" | "contents"> & InboundContainerRuntimeMessage;
100
+ /** Essentially ISequencedDocumentMessage except that `type` is not `string` to enable narrowing
101
+ * as `Exclude<string, InboundContainerRuntimeMessage['type']>` is not supported.
102
+ * There should never be a runtime value of "__not_a_...".
103
+ * Currently additionally replaces `contents` type until protocol-definitions update is taken with `unknown` instead of `any`.
104
+ */
105
+ type InboundSequencedNonContainerRuntimeMessage = Omit<ISequencedDocumentMessage, "type" | "contents"> & {
106
+ type: "__not_a_container_runtime_message_type__";
107
+ contents: unknown;
108
+ };
109
+ export type InboundSequencedContainerRuntimeMessageOrSystemMessage = InboundSequencedContainerRuntimeMessage | InboundSequencedNonContainerRuntimeMessage;
110
+ /** A [loose] InboundSequencedContainerRuntimeMessage that is recent and may contain compat details.
111
+ * It exists solely to to provide access to those details.
112
+ */
113
+ export type InboundSequencedRecentlyAddedContainerRuntimeMessage = ISequencedDocumentMessage & Partial<RecentlyAddedContainerRuntimeMessageDetails>;
114
+ /**
115
+ * The unpacked runtime message / details to be handled or dispatched by the ContainerRuntime
116
+ *
117
+ * IMPORTANT: when creating one to be serialized, set the properties in the order they appear here.
118
+ * This way stringified values can be compared.
119
+ *
120
+ * @deprecated - this is an internal type which should not be used outside of the package.
121
+ * Internally, it is superseded by `TypedContainerRuntimeMessage`.
122
+ *
123
+ * @internal
124
+ */
125
+ export interface ContainerRuntimeMessage {
126
+ /** Type of the op, within the ContainerRuntime's domain */
127
+ type: ContainerMessageType;
128
+ /** Domain-specific contents, interpreted according to the type */
129
+ contents: any;
130
+ /** Info describing how to handle this op in case the type is unrecognized (default: fail to process) */
131
+ compatDetails?: IContainerRuntimeMessageCompatDetails;
132
+ }
133
+ export {};
134
+ //# sourceMappingURL=messageTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../src/messageTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,SAAS,EACT,oBAAoB,EACpB,cAAc,EACd,+BAA+B,EAC/B,eAAe,EACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,oBAAY,oBAAoB;IAE/B,gBAAgB,cAAc;IAG9B,MAAM,WAAW;IAGjB,SAAS,cAAc;IAGvB,UAAU,eAAe;IAGzB,MAAM,WAAW;IAGjB,KAAK,UAAU;IAEf;;;;OAIG;IACH,YAAY,iBAAiB;CAC7B;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB;AAC7B,qEAAqE;AACnE,QAAQ;AACV,8DAA8D;GAC5D,eAAe,CAAC;AAEnB;;;;GAIG;AACH,MAAM,WAAW,qCAAqC;IACrD,wEAAwE;IACxE,QAAQ,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,UAAU,4BAA4B,CAAC,KAAK,SAAS,oBAAoB,EAAE,SAAS;IACnF,2DAA2D;IAC3D,IAAI,EAAE,KAAK,CAAC;IACZ,kEAAkE;IAClE,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,2CAA2C;IAC3D,wGAAwG;IACxG,aAAa,EAAE,qCAAqC,CAA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AAuI;AACvI,MAAM,MAAM,4BAA4B,GACrC,kCAAkC,GAClC,qCAAqC,GACrC,gCAAgC,GAChC,iCAAiC,GACjC,6BAA6B,GAC7B,4BAA4B,GAC5B,wCAAwC,GAExC,8BAA8B,CAAC;AAElC,0GAA0G;AAC1G,MAAM,MAAM,+BAA+B,GACxC,kCAAkC,GAClC,qCAAqC,GACrC,gCAAgC,GAChC,iCAAiC,GACjC,6BAA6B,GAC7B,4BAA4B,GAC5B,mCAAmC,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,uCAAuC,GAAG,IAAI,CACzD,yBAAyB,EACzB,MAAM,GAAG,UAAU,CACnB,GACA,8BAA8B,CAAC;AAEhC;;;;GAIG;AACH,KAAK,0CAA0C,GAAG,IAAI,CACrD,yBAAyB,EACzB,MAAM,GAAG,UAAU,CACnB,GAAG;IAAE,IAAI,EAAE,0CAA0C,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5E,MAAM,MAAM,sDAAsD,GAC/D,uCAAuC,GACvC,0CAA0C,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,oDAAoD,GAAG,yBAAyB,GAC3F,OAAO,CAAC,2CAA2C,CAAC,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,uBAAuB;IACvC,2DAA2D;IAC3D,IAAI,EAAE,oBAAoB,CAAC;IAC3B,kEAAkE;IAClE,QAAQ,EAAE,GAAG,CAAC;IACd,wGAAwG;IACxG,aAAa,CAAC,EAAE,qCAAqC,CAAC;CACtD"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ContainerMessageType = void 0;
8
+ var ContainerMessageType;
9
+ (function (ContainerMessageType) {
10
+ // An op to be delivered to store
11
+ ContainerMessageType["FluidDataStoreOp"] = "component";
12
+ // Creates a new store
13
+ ContainerMessageType["Attach"] = "attach";
14
+ // Chunked operation.
15
+ ContainerMessageType["ChunkedOp"] = "chunkedOp";
16
+ // Signifies that a blob has been attached and should not be garbage collected by storage
17
+ ContainerMessageType["BlobAttach"] = "blobAttach";
18
+ // Ties our new clientId to our old one on reconnect
19
+ ContainerMessageType["Rejoin"] = "rejoin";
20
+ // Sets the alias of a root data store
21
+ ContainerMessageType["Alias"] = "alias";
22
+ /**
23
+ * An op containing an IdRange of Ids allocated using the runtime's IdCompressor since
24
+ * the last allocation op was sent.
25
+ * See the [IdCompressor README](./id-compressor/README.md) for more details.
26
+ */
27
+ ContainerMessageType["IdAllocation"] = "idAllocation";
28
+ })(ContainerMessageType || (exports.ContainerMessageType = ContainerMessageType = {}));
29
+ //# sourceMappingURL=messageTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageTypes.js","sourceRoot":"","sources":["../src/messageTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAaH,IAAY,oBAyBX;AAzBD,WAAY,oBAAoB;IAC/B,iCAAiC;IACjC,sDAA8B,CAAA;IAE9B,sBAAsB;IACtB,yCAAiB,CAAA;IAEjB,qBAAqB;IACrB,+CAAuB,CAAA;IAEvB,yFAAyF;IACzF,iDAAyB,CAAA;IAEzB,oDAAoD;IACpD,yCAAiB,CAAA;IAEjB,sCAAsC;IACtC,uCAAe,CAAA;IAEf;;;;OAIG;IACH,qDAA6B,CAAA;AAC9B,CAAC,EAzBW,oBAAoB,oCAApB,oBAAoB,QAyB/B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIEnvelope,\n\tInboundAttachMessage,\n\tIAttachMessage,\n\tIdCreationRangeWithStashedState,\n\tIdCreationRange,\n} from \"@fluidframework/runtime-definitions\";\nimport { IDataStoreAliasMessage } from \"./dataStore\";\nimport { IChunkedOp } from \"./opLifecycle\";\n\nexport enum ContainerMessageType {\n\t// An op to be delivered to store\n\tFluidDataStoreOp = \"component\",\n\n\t// Creates a new store\n\tAttach = \"attach\",\n\n\t// Chunked operation.\n\tChunkedOp = \"chunkedOp\",\n\n\t// Signifies that a blob has been attached and should not be garbage collected by storage\n\tBlobAttach = \"blobAttach\",\n\n\t// Ties our new clientId to our old one on reconnect\n\tRejoin = \"rejoin\",\n\n\t// Sets the alias of a root data store\n\tAlias = \"alias\",\n\n\t/**\n\t * An op containing an IdRange of Ids allocated using the runtime's IdCompressor since\n\t * the last allocation op was sent.\n\t * See the [IdCompressor README](./id-compressor/README.md) for more details.\n\t */\n\tIdAllocation = \"idAllocation\",\n}\n\n/**\n * How should an older client handle an unrecognized remote op type?\n *\n * @internal\n */\nexport type CompatModeBehavior =\n\t/** Ignore the op. It won't be persisted if this client summarizes */\n\t| \"Ignore\"\n\t/** Fail processing immediately. (The container will close) */\n\t| \"FailToProcess\";\n\n/**\n * All the info an older client would need to know how to handle an unrecognized remote op type\n *\n * @internal\n */\nexport interface IContainerRuntimeMessageCompatDetails {\n\t/** How should an older client handle an unrecognized remote op type? */\n\tbehavior: CompatModeBehavior;\n}\n\n/**\n * The unpacked runtime message / details to be handled or dispatched by the ContainerRuntime.\n * Message type are differentiated via a `type` string and contain different contents depending on their type.\n *\n * IMPORTANT: when creating one to be serialized, set the properties in the order they appear here.\n * This way stringified values can be compared.\n */\ninterface TypedContainerRuntimeMessage<TType extends ContainerMessageType, TContents> {\n\t/** Type of the op, within the ContainerRuntime's domain */\n\ttype: TType;\n\t/** Domain-specific contents, interpreted according to the type */\n\tcontents: TContents;\n}\n\n/**\n * Additional details expected for any recently added message.\n * @internal\n */\nexport interface RecentlyAddedContainerRuntimeMessageDetails {\n\t/** Info describing how to handle this op in case the type is unrecognized (default: fail to process) */\n\tcompatDetails: IContainerRuntimeMessageCompatDetails;\n}\n\nexport type ContainerRuntimeDataStoreOpMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.FluidDataStoreOp,\n\tIEnvelope\n>;\nexport type InboundContainerRuntimeAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Attach,\n\tInboundAttachMessage\n>;\nexport type OutboundContainerRuntimeAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Attach,\n\tIAttachMessage\n>;\nexport type ContainerRuntimeChunkedOpMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.ChunkedOp,\n\tIChunkedOp\n>;\nexport type ContainerRuntimeBlobAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.BlobAttach,\n\tundefined\n>;\nexport type ContainerRuntimeRejoinMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Rejoin,\n\tundefined\n>;\nexport type ContainerRuntimeAliasMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Alias,\n\tIDataStoreAliasMessage\n>;\nexport type LocalContainerRuntimeIdAllocationMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.IdAllocation,\n\tIdCreationRangeWithStashedState\n>;\nexport type ContainerRuntimeIdAllocationMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.IdAllocation,\n\tIdCreationRange & { stashedState?: never }\n>;\n\n/**\n * Represents an unrecognized {@link TypedContainerRuntimeMessage}, e.g. a message from a future version of the container runtime.\n * @internal\n */\nexport interface UnknownContainerRuntimeMessage\n\textends Partial<RecentlyAddedContainerRuntimeMessageDetails> {\n\t/** Invalid type of the op, within the ContainerRuntime's domain. This value should never exist at runtime.\n\t * This is useful for type narrowing but should never be used as an actual message type at runtime.\n\t * Actual value will not be \"__unknown...\", but the type `Exclude<string, ContainerMessageType>` is not supported.\n\t */\n\ttype: \"__unknown_container_message_type__never_use_as_value__\";\n\n\t/** Domain-specific contents, but not decipherable by an unknown op. */\n\tcontents: unknown;\n}\n\n/**\n * A {@link TypedContainerRuntimeMessage} that is received from the server and will be processed by the container runtime.\n */\nexport type InboundContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| InboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeChunkedOpMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| ContainerRuntimeIdAllocationMessage\n\t// Inbound messages may include unknown types from other clients, so we include that as a special case here\n\t| UnknownContainerRuntimeMessage;\n\n/** A {@link TypedContainerRuntimeMessage} that has been generated by the container runtime but is not yet being sent to the server. */\nexport type LocalContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| OutboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeChunkedOpMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| LocalContainerRuntimeIdAllocationMessage\n\t// In rare cases (e.g. related to stashed ops) we could have a local message of an unknown type\n\t| UnknownContainerRuntimeMessage;\n\n/** A {@link TypedContainerRuntimeMessage} that is being sent to the server from the container runtime. */\nexport type OutboundContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| OutboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeChunkedOpMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| ContainerRuntimeIdAllocationMessage;\n\n/**\n * An unpacked ISequencedDocumentMessage with the inner TypedContainerRuntimeMessage type/contents/etc\n * promoted up to the outer object\n */\nexport type InboundSequencedContainerRuntimeMessage = Omit<\n\tISequencedDocumentMessage,\n\t\"type\" | \"contents\"\n> &\n\tInboundContainerRuntimeMessage;\n\n/** Essentially ISequencedDocumentMessage except that `type` is not `string` to enable narrowing\n * as `Exclude<string, InboundContainerRuntimeMessage['type']>` is not supported.\n * There should never be a runtime value of \"__not_a_...\".\n * Currently additionally replaces `contents` type until protocol-definitions update is taken with `unknown` instead of `any`.\n */\ntype InboundSequencedNonContainerRuntimeMessage = Omit<\n\tISequencedDocumentMessage,\n\t\"type\" | \"contents\"\n> & { type: \"__not_a_container_runtime_message_type__\"; contents: unknown };\n\nexport type InboundSequencedContainerRuntimeMessageOrSystemMessage =\n\t| InboundSequencedContainerRuntimeMessage\n\t| InboundSequencedNonContainerRuntimeMessage;\n\n/** A [loose] InboundSequencedContainerRuntimeMessage that is recent and may contain compat details.\n * It exists solely to to provide access to those details.\n */\nexport type InboundSequencedRecentlyAddedContainerRuntimeMessage = ISequencedDocumentMessage &\n\tPartial<RecentlyAddedContainerRuntimeMessageDetails>;\n\n/**\n * The unpacked runtime message / details to be handled or dispatched by the ContainerRuntime\n *\n * IMPORTANT: when creating one to be serialized, set the properties in the order they appear here.\n * This way stringified values can be compared.\n *\n * @deprecated - this is an internal type which should not be used outside of the package.\n * Internally, it is superseded by `TypedContainerRuntimeMessage`.\n *\n * @internal\n */\nexport interface ContainerRuntimeMessage {\n\t/** Type of the op, within the ContainerRuntime's domain */\n\ttype: ContainerMessageType;\n\t/** Domain-specific contents, interpreted according to the type */\n\tcontents: any;\n\t/** Info describing how to handle this op in case the type is unrecognized (default: fail to process) */\n\tcompatDetails?: IContainerRuntimeMessageCompatDetails;\n}\n"]}
@@ -14,12 +14,6 @@ const opOverhead = 200;
14
14
  * Helper class that manages partial batch & rollback.
15
15
  */
16
16
  class BatchManager {
17
- constructor(options) {
18
- this.options = options;
19
- this.pendingBatch = [];
20
- this.batchContentSize = 0;
21
- this.hasReentrantOps = false;
22
- }
23
17
  get length() {
24
18
  return this.pendingBatch.length;
25
19
  }
@@ -37,6 +31,12 @@ class BatchManager {
37
31
  ? undefined
38
32
  : this.pendingBatch[this.pendingBatch.length - 1].referenceSequenceNumber;
39
33
  }
34
+ constructor(options) {
35
+ this.options = options;
36
+ this.pendingBatch = [];
37
+ this.batchContentSize = 0;
38
+ this.hasReentrantOps = false;
39
+ }
40
40
  push(message, reentrant, currentClientSequenceNumber) {
41
41
  const contentSize = this.batchContentSize + (message.contents?.length ?? 0);
42
42
  const opCount = this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AC;AAFW,QAAA,kBAAkB,sBAE7B;AAEK,MAAM,oBAAoB,GAAG,CACnC,OAA6B,EAC7B,YAAkC,EACxB,EAAE;IACZ,OAAO,CACN,CAAC,OAAO,CAAC,uBAAuB,KAAK,SAAS;QAC7C,YAAY,CAAC,uBAAuB,KAAK,SAAS;QAClD,OAAO,CAAC,uBAAuB,KAAK,YAAY,CAAC,uBAAuB,CAAC;QAC1E,CAAC,OAAO,CAAC,oBAAoB,KAAK,SAAS;YAC1C,YAAY,CAAC,oBAAoB,KAAK,SAAS;YAC/C,OAAO,CAAC,oBAAoB,KAAK,YAAY,CAAC,oBAAoB,CAAC,CACpE,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICompressionRuntimeOptions } from \"../containerRuntime\";\nimport { BatchMessage, IBatch, IBatchCheckpoint } from \"./definitions\";\n\nexport interface IBatchManagerOptions {\n\treadonly hardLimit: number;\n\treadonly softLimit?: number;\n\treadonly compressionOptions?: ICompressionRuntimeOptions;\n}\n\nexport interface BatchSequenceNumbers {\n\treferenceSequenceNumber?: number;\n\tclientSequenceNumber?: number;\n}\n\n/**\n * Estimated size of the stringification overhead for an op accumulated\n * from runtime to loader to the service.\n */\nconst opOverhead = 200;\n\n/**\n * Helper class that manages partial batch & rollback.\n */\nexport class BatchManager {\n\tprivate pendingBatch: BatchMessage[] = [];\n\tprivate batchContentSize = 0;\n\tprivate hasReentrantOps = false;\n\n\tpublic get length() {\n\t\treturn this.pendingBatch.length;\n\t}\n\tpublic get contentSizeInBytes() {\n\t\treturn this.batchContentSize;\n\t}\n\n\tpublic get sequenceNumbers(): BatchSequenceNumbers {\n\t\treturn {\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\tclientSequenceNumber: this.clientSequenceNumber,\n\t\t};\n\t}\n\n\tprivate get referenceSequenceNumber(): number | undefined {\n\t\treturn this.pendingBatch.length === 0\n\t\t\t? undefined\n\t\t\t: this.pendingBatch[this.pendingBatch.length - 1].referenceSequenceNumber;\n\t}\n\n\tprivate clientSequenceNumber: number | undefined;\n\n\tconstructor(public readonly options: IBatchManagerOptions) {}\n\n\tpublic push(\n\t\tmessage: BatchMessage,\n\t\treentrant: boolean,\n\t\tcurrentClientSequenceNumber?: number,\n\t): boolean {\n\t\tconst contentSize = this.batchContentSize + (message.contents?.length ?? 0);\n\t\tconst opCount = this.pendingBatch.length;\n\t\tthis.hasReentrantOps = this.hasReentrantOps || reentrant;\n\n\t\t// Attempt to estimate batch size, aka socket message size.\n\t\t// Each op has pretty large envelope, estimating to be 200 bytes.\n\t\t// Also content will be strigified, and that adds a lot of overhead due to a lot of escape characters.\n\t\t// Not taking it into account, as compression work should help there - compressed payload will be\n\t\t// initially stored as base64, and that requires only 2 extra escape characters.\n\t\tconst socketMessageSize = contentSize + opOverhead * opCount;\n\n\t\t// If we were provided soft limit, check for exceeding it.\n\t\t// But only if we have any ops, as the intention here is to flush existing ops (on exceeding this limit)\n\t\t// and start over. That's not an option if we have no ops.\n\t\t// If compression is enabled, the soft and hard limit are ignored and the message will be pushed anyways.\n\t\t// Cases where the message is still too large will be handled by the maxConsecutiveReconnects path.\n\t\tif (\n\t\t\tthis.options.softLimit !== undefined &&\n\t\t\tthis.length > 0 &&\n\t\t\tsocketMessageSize >= this.options.softLimit\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (socketMessageSize >= this.options.hardLimit) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (this.pendingBatch.length === 0) {\n\t\t\tthis.clientSequenceNumber = currentClientSequenceNumber;\n\t\t}\n\n\t\tthis.batchContentSize = contentSize;\n\t\tthis.pendingBatch.push(message);\n\t\treturn true;\n\t}\n\n\tpublic get empty() {\n\t\treturn this.pendingBatch.length === 0;\n\t}\n\n\tpublic popBatch(): IBatch {\n\t\tconst batch: IBatch = {\n\t\t\tcontent: this.pendingBatch,\n\t\t\tcontentSizeInBytes: this.batchContentSize,\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\thasReentrantOps: this.hasReentrantOps,\n\t\t};\n\n\t\tthis.pendingBatch = [];\n\t\tthis.batchContentSize = 0;\n\t\tthis.clientSequenceNumber = undefined;\n\t\tthis.hasReentrantOps = false;\n\n\t\treturn addBatchMetadata(batch);\n\t}\n\n\t/**\n\t * Capture the pending state at this point\n\t */\n\tpublic checkpoint(): IBatchCheckpoint {\n\t\tconst startPoint = this.pendingBatch.length;\n\t\treturn {\n\t\t\trollback: (process: (message: BatchMessage) => void) => {\n\t\t\t\tfor (let i = this.pendingBatch.length; i > startPoint; ) {\n\t\t\t\t\ti--;\n\t\t\t\t\tconst message = this.pendingBatch[i];\n\t\t\t\t\tthis.batchContentSize -= message.contents?.length ?? 0;\n\t\t\t\t\tprocess(message);\n\t\t\t\t}\n\n\t\t\t\tthis.pendingBatch.length = startPoint;\n\t\t\t},\n\t\t};\n\t}\n}\n\nconst addBatchMetadata = (batch: IBatch): IBatch => {\n\tif (batch.content.length > 1) {\n\t\tbatch.content[0].metadata = {\n\t\t\t...batch.content[0].metadata,\n\t\t\tbatch: true,\n\t\t};\n\t\tbatch.content[batch.content.length - 1].metadata = {\n\t\t\t...batch.content[batch.content.length - 1].metadata,\n\t\t\tbatch: false,\n\t\t};\n\t}\n\n\treturn batch;\n};\n\n/**\n * Estimates the real size in bytes on the socket for a given batch. It assumes that\n * the envelope size (and the size of an empty op) is 200 bytes, taking into account\n * extra overhead from stringification.\n *\n * @param batch - the batch to inspect\n * @returns An estimate of the payload size in bytes which will be produced when the batch is sent over the wire\n */\nexport const estimateSocketSize = (batch: IBatch): number => {\n\treturn batch.contentSizeInBytes + opOverhead * batch.content.length;\n};\n\nexport const sequenceNumbersMatch = (\n\tseqNums: BatchSequenceNumbers,\n\totherSeqNums: BatchSequenceNumbers,\n): boolean => {\n\treturn (\n\t\t(seqNums.referenceSequenceNumber === undefined ||\n\t\t\totherSeqNums.referenceSequenceNumber === undefined ||\n\t\t\tseqNums.referenceSequenceNumber === otherSeqNums.referenceSequenceNumber) &&\n\t\t(seqNums.clientSequenceNumber === undefined ||\n\t\t\totherSeqNums.clientSequenceNumber === undefined ||\n\t\t\tseqNums.clientSequenceNumber === otherSeqNums.clientSequenceNumber)\n\t);\n};\n"]}
1
+ {"version":3,"file":"batchManager.js","sourceRoot":"","sources":["../../src/opLifecycle/batchManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH;;;GAGG;AACH,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;GAEG;AACH,MAAa,YAAY;IAKxB,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;IAED,IAAW,eAAe;QACzB,OAAO;YACN,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;SAC/C,CAAC;IACH,CAAC;IAED,IAAY,uBAAuB;QAClC,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC;YACpC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,uBAAuB,CAAC;IAC5E,CAAC;IAID,YAA4B,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;QA1BjD,iBAAY,GAAmB,EAAE,CAAC;QAClC,qBAAgB,GAAG,CAAC,CAAC;QACrB,oBAAe,GAAG,KAAK,CAAC;IAwB4B,CAAC;IAEtD,IAAI,CACV,OAAqB,EACrB,SAAkB,EAClB,2BAAoC;QAEpC,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,C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KAAK,CAAC;AACd,CAAC,CAAC;AAEF;;;;;;;GAOG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3D,OAAO,KAAK,CAAC,kBAAkB,GAAG,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;AACrE,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEK,MAAM,oBAAoB,GAAG,CACnC,OAA6B,EAC7B,YAAkC,EACxB,EAAE;IACZ,OAAO,CACN,CAAC,OAAO,CAAC,uBAAuB,KAAK,SAAS;QAC7C,YAAY,CAAC,uBAAuB,KAAK,SAAS;QAClD,OAAO,CAAC,uBAAuB,KAAK,YAAY,CAAC,uBAAuB,CAAC;QAC1E,CAAC,OAAO,CAAC,oBAAoB,KAAK,SAAS;YAC1C,YAAY,CAAC,oBAAoB,KAAK,SAAS;YAC/C,OAAO,CAAC,oBAAoB,KAAK,YAAY,CAAC,oBAAoB,CAAC,CACpE,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICompressionRuntimeOptions } from \"../containerRuntime\";\nimport { BatchMessage, IBatch, IBatchCheckpoint } from \"./definitions\";\n\nexport interface IBatchManagerOptions {\n\treadonly hardLimit: number;\n\treadonly softLimit?: number;\n\treadonly compressionOptions?: ICompressionRuntimeOptions;\n}\n\nexport interface BatchSequenceNumbers {\n\treferenceSequenceNumber?: number;\n\tclientSequenceNumber?: number;\n}\n\n/**\n * Estimated size of the stringification overhead for an op accumulated\n * from runtime to loader to the service.\n */\nconst opOverhead = 200;\n\n/**\n * Helper class that manages partial batch & rollback.\n */\nexport class BatchManager {\n\tprivate pendingBatch: BatchMessage[] = [];\n\tprivate batchContentSize = 0;\n\tprivate hasReentrantOps = false;\n\n\tpublic get length() {\n\t\treturn this.pendingBatch.length;\n\t}\n\tpublic get contentSizeInBytes() {\n\t\treturn this.batchContentSize;\n\t}\n\n\tpublic get sequenceNumbers(): BatchSequenceNumbers {\n\t\treturn {\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\tclientSequenceNumber: this.clientSequenceNumber,\n\t\t};\n\t}\n\n\tprivate get referenceSequenceNumber(): number | undefined {\n\t\treturn this.pendingBatch.length === 0\n\t\t\t? undefined\n\t\t\t: this.pendingBatch[this.pendingBatch.length - 1].referenceSequenceNumber;\n\t}\n\n\tprivate clientSequenceNumber: number | undefined;\n\n\tconstructor(public readonly options: IBatchManagerOptions) {}\n\n\tpublic push(\n\t\tmessage: BatchMessage,\n\t\treentrant: boolean,\n\t\tcurrentClientSequenceNumber?: number,\n\t): boolean {\n\t\tconst contentSize = this.batchContentSize + (message.contents?.length ?? 0);\n\t\tconst opCount = this.pendingBatch.length;\n\t\tthis.hasReentrantOps = this.hasReentrantOps || reentrant;\n\n\t\t// Attempt to estimate batch size, aka socket message size.\n\t\t// Each op has pretty large envelope, estimating to be 200 bytes.\n\t\t// Also content will be strigified, and that adds a lot of overhead due to a lot of escape characters.\n\t\t// Not taking it into account, as compression work should help there - compressed payload will be\n\t\t// initially stored as base64, and that requires only 2 extra escape characters.\n\t\tconst socketMessageSize = contentSize + opOverhead * opCount;\n\n\t\t// If we were provided soft limit, check for exceeding it.\n\t\t// But only if we have any ops, as the intention here is to flush existing ops (on exceeding this limit)\n\t\t// and start over. That's not an option if we have no ops.\n\t\t// If compression is enabled, the soft and hard limit are ignored and the message will be pushed anyways.\n\t\t// Cases where the message is still too large will be handled by the maxConsecutiveReconnects path.\n\t\tif (\n\t\t\tthis.options.softLimit !== undefined &&\n\t\t\tthis.length > 0 &&\n\t\t\tsocketMessageSize >= this.options.softLimit\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (socketMessageSize >= this.options.hardLimit) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (this.pendingBatch.length === 0) {\n\t\t\tthis.clientSequenceNumber = currentClientSequenceNumber;\n\t\t}\n\n\t\tthis.batchContentSize = contentSize;\n\t\tthis.pendingBatch.push(message);\n\t\treturn true;\n\t}\n\n\tpublic get empty() {\n\t\treturn this.pendingBatch.length === 0;\n\t}\n\n\tpublic popBatch(): IBatch {\n\t\tconst batch: IBatch = {\n\t\t\tcontent: this.pendingBatch,\n\t\t\tcontentSizeInBytes: this.batchContentSize,\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\thasReentrantOps: this.hasReentrantOps,\n\t\t};\n\n\t\tthis.pendingBatch = [];\n\t\tthis.batchContentSize = 0;\n\t\tthis.clientSequenceNumber = undefined;\n\t\tthis.hasReentrantOps = false;\n\n\t\treturn addBatchMetadata(batch);\n\t}\n\n\t/**\n\t * Capture the pending state at this point\n\t */\n\tpublic checkpoint(): IBatchCheckpoint {\n\t\tconst startPoint = this.pendingBatch.length;\n\t\treturn {\n\t\t\trollback: (process: (message: BatchMessage) => void) => {\n\t\t\t\tfor (let i = this.pendingBatch.length; i > startPoint; ) {\n\t\t\t\t\ti--;\n\t\t\t\t\tconst message = this.pendingBatch[i];\n\t\t\t\t\tthis.batchContentSize -= message.contents?.length ?? 0;\n\t\t\t\t\tprocess(message);\n\t\t\t\t}\n\n\t\t\t\tthis.pendingBatch.length = startPoint;\n\t\t\t},\n\t\t};\n\t}\n}\n\nconst addBatchMetadata = (batch: IBatch): IBatch => {\n\tif (batch.content.length > 1) {\n\t\tbatch.content[0].metadata = {\n\t\t\t...batch.content[0].metadata,\n\t\t\tbatch: true,\n\t\t};\n\t\tbatch.content[batch.content.length - 1].metadata = {\n\t\t\t...batch.content[batch.content.length - 1].metadata,\n\t\t\tbatch: false,\n\t\t};\n\t}\n\n\treturn batch;\n};\n\n/**\n * Estimates the real size in bytes on the socket for a given batch. It assumes that\n * the envelope size (and the size of an empty op) is 200 bytes, taking into account\n * extra overhead from stringification.\n *\n * @param batch - the batch to inspect\n * @returns An estimate of the payload size in bytes which will be produced when the batch is sent over the wire\n */\nexport const estimateSocketSize = (batch: IBatch): number => {\n\treturn batch.contentSizeInBytes + opOverhead * batch.content.length;\n};\n\nexport const sequenceNumbersMatch = (\n\tseqNums: BatchSequenceNumbers,\n\totherSeqNums: BatchSequenceNumbers,\n): boolean => {\n\treturn (\n\t\t(seqNums.referenceSequenceNumber === undefined ||\n\t\t\totherSeqNums.referenceSequenceNumber === undefined ||\n\t\t\tseqNums.referenceSequenceNumber === otherSeqNums.referenceSequenceNumber) &&\n\t\t(seqNums.clientSequenceNumber === undefined ||\n\t\t\totherSeqNums.clientSequenceNumber === undefined ||\n\t\t\tseqNums.clientSequenceNumber === otherSeqNums.clientSequenceNumber)\n\t);\n};\n"]}
@@ -4,11 +4,12 @@
4
4
  */
5
5
  import { IBatchMessage } from "@fluidframework/container-definitions";
6
6
  import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
7
- import { CompressionAlgorithms, ContainerMessageType } from "..";
7
+ import { CompressionAlgorithms } from "..";
8
+ import { ContainerMessageType } from "../messageTypes";
8
9
  /**
9
10
  * Batch message type used internally by the runtime
10
11
  */
11
- export declare type BatchMessage = IBatchMessage & {
12
+ export type BatchMessage = IBatchMessage & {
12
13
  localOpMetadata: unknown;
13
14
  type: ContainerMessageType;
14
15
  referenceSequenceNumber: number;
@@ -61,7 +62,7 @@ export interface IChunkedOp {
61
62
  * `Accepted` - the message was processed partially. Eventually, a message
62
63
  * will make the processor return `Processed`.
63
64
  */
64
- export declare type ProcessingState = "Processed" | "Skipped" | "Accepted";
65
+ export type ProcessingState = "Processed" | "Skipped" | "Accepted";
65
66
  /**
66
67
  * Return type for functions which process remote messages
67
68
  */
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/opLifecycle/definitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,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