@fluidframework/container-runtime 2.0.0-internal.7.3.0 → 2.0.0-internal.7.4.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 (264) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/api-extractor-lint.json +13 -0
  3. package/api-extractor.json +9 -1
  4. package/api-report/container-runtime.api.md +124 -107
  5. package/dist/blobManager.d.ts +4 -4
  6. package/dist/blobManager.d.ts.map +1 -1
  7. package/dist/blobManager.js.map +1 -1
  8. package/dist/container-runtime-alpha.d.ts +1473 -0
  9. package/dist/container-runtime-beta.d.ts +300 -0
  10. package/dist/container-runtime-public.d.ts +300 -0
  11. package/dist/container-runtime-untrimmed.d.ts +1836 -0
  12. package/dist/containerRuntime.d.ts +30 -30
  13. package/dist/containerRuntime.d.ts.map +1 -1
  14. package/dist/containerRuntime.js +62 -40
  15. package/dist/containerRuntime.js.map +1 -1
  16. package/dist/dataStoreRegistry.d.ts +1 -1
  17. package/dist/dataStoreRegistry.js +1 -1
  18. package/dist/dataStoreRegistry.js.map +1 -1
  19. package/dist/dataStores.d.ts +10 -15
  20. package/dist/dataStores.d.ts.map +1 -1
  21. package/dist/dataStores.js +77 -40
  22. package/dist/dataStores.js.map +1 -1
  23. package/dist/gc/garbageCollection.d.ts +41 -13
  24. package/dist/gc/garbageCollection.d.ts.map +1 -1
  25. package/dist/gc/garbageCollection.js +215 -78
  26. package/dist/gc/garbageCollection.js.map +1 -1
  27. package/dist/gc/gcConfigs.d.ts.map +1 -1
  28. package/dist/gc/gcConfigs.js +34 -37
  29. package/dist/gc/gcConfigs.js.map +1 -1
  30. package/dist/gc/gcDefinitions.d.ts +121 -46
  31. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  32. package/dist/gc/gcDefinitions.js +26 -18
  33. package/dist/gc/gcDefinitions.js.map +1 -1
  34. package/dist/gc/gcHelpers.d.ts +18 -25
  35. package/dist/gc/gcHelpers.d.ts.map +1 -1
  36. package/dist/gc/gcHelpers.js +29 -45
  37. package/dist/gc/gcHelpers.js.map +1 -1
  38. package/dist/gc/gcTelemetry.d.ts +0 -5
  39. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  40. package/dist/gc/gcTelemetry.js +14 -42
  41. package/dist/gc/gcTelemetry.js.map +1 -1
  42. package/dist/gc/gcUnreferencedStateTracker.d.ts +11 -5
  43. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
  44. package/dist/gc/gcUnreferencedStateTracker.js +43 -19
  45. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  46. package/dist/gc/index.d.ts +1 -1
  47. package/dist/gc/index.d.ts.map +1 -1
  48. package/dist/gc/index.js +4 -5
  49. package/dist/gc/index.js.map +1 -1
  50. package/dist/index.d.ts +14 -2
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +16 -5
  53. package/dist/index.js.map +1 -1
  54. package/dist/messageTypes.d.ts +15 -7
  55. package/dist/messageTypes.d.ts.map +1 -1
  56. package/dist/messageTypes.js +6 -1
  57. package/dist/messageTypes.js.map +1 -1
  58. package/dist/opLifecycle/definitions.d.ts +1 -1
  59. package/dist/opLifecycle/definitions.js.map +1 -1
  60. package/dist/packageVersion.d.ts +1 -1
  61. package/dist/packageVersion.js +1 -1
  62. package/dist/packageVersion.js.map +1 -1
  63. package/dist/pendingStateManager.d.ts +1 -0
  64. package/dist/pendingStateManager.d.ts.map +1 -1
  65. package/dist/pendingStateManager.js +1 -0
  66. package/dist/pendingStateManager.js.map +1 -1
  67. package/dist/summary/orderedClientElection.d.ts +1 -1
  68. package/dist/summary/orderedClientElection.js.map +1 -1
  69. package/dist/summary/runWhileConnectedCoordinator.d.ts +2 -2
  70. package/dist/summary/runWhileConnectedCoordinator.js +1 -1
  71. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  72. package/dist/summary/summarizer.d.ts +1 -1
  73. package/dist/summary/summarizer.js +1 -1
  74. package/dist/summary/summarizer.js.map +1 -1
  75. package/dist/summary/summarizerTypes.d.ts +30 -30
  76. package/dist/summary/summarizerTypes.js.map +1 -1
  77. package/dist/summary/summaryCollection.d.ts +10 -10
  78. package/dist/summary/summaryCollection.js +1 -1
  79. package/dist/summary/summaryCollection.js.map +1 -1
  80. package/dist/summary/summaryFormat.d.ts +3 -3
  81. package/dist/summary/summaryFormat.js.map +1 -1
  82. package/lib/blobManager.d.ts +4 -4
  83. package/lib/blobManager.d.ts.map +1 -1
  84. package/lib/blobManager.js.map +1 -1
  85. package/lib/container-runtime-alpha.d.ts +1473 -0
  86. package/lib/container-runtime-beta.d.ts +300 -0
  87. package/lib/container-runtime-public.d.ts +300 -0
  88. package/lib/container-runtime-untrimmed.d.ts +1836 -0
  89. package/lib/containerRuntime.d.ts +30 -30
  90. package/lib/containerRuntime.d.ts.map +1 -1
  91. package/lib/containerRuntime.js +64 -42
  92. package/lib/containerRuntime.js.map +1 -1
  93. package/lib/dataStoreRegistry.d.ts +1 -1
  94. package/lib/dataStoreRegistry.js +1 -1
  95. package/lib/dataStoreRegistry.js.map +1 -1
  96. package/lib/dataStores.d.ts +10 -15
  97. package/lib/dataStores.d.ts.map +1 -1
  98. package/lib/dataStores.js +80 -43
  99. package/lib/dataStores.js.map +1 -1
  100. package/lib/gc/garbageCollection.d.ts +41 -13
  101. package/lib/gc/garbageCollection.d.ts.map +1 -1
  102. package/lib/gc/garbageCollection.js +217 -80
  103. package/lib/gc/garbageCollection.js.map +1 -1
  104. package/lib/gc/gcConfigs.d.ts.map +1 -1
  105. package/lib/gc/gcConfigs.js +37 -40
  106. package/lib/gc/gcConfigs.js.map +1 -1
  107. package/lib/gc/gcDefinitions.d.ts +121 -46
  108. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  109. package/lib/gc/gcDefinitions.js +25 -17
  110. package/lib/gc/gcDefinitions.js.map +1 -1
  111. package/lib/gc/gcHelpers.d.ts +18 -25
  112. package/lib/gc/gcHelpers.d.ts.map +1 -1
  113. package/lib/gc/gcHelpers.js +27 -43
  114. package/lib/gc/gcHelpers.js.map +1 -1
  115. package/lib/gc/gcTelemetry.d.ts +0 -5
  116. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  117. package/lib/gc/gcTelemetry.js +15 -43
  118. package/lib/gc/gcTelemetry.js.map +1 -1
  119. package/lib/gc/gcUnreferencedStateTracker.d.ts +11 -5
  120. package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
  121. package/lib/gc/gcUnreferencedStateTracker.js +43 -19
  122. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  123. package/lib/gc/index.d.ts +1 -1
  124. package/lib/gc/index.d.ts.map +1 -1
  125. package/lib/gc/index.js +1 -1
  126. package/lib/gc/index.js.map +1 -1
  127. package/lib/index.d.ts +14 -2
  128. package/lib/index.d.ts.map +1 -1
  129. package/lib/index.js +15 -1
  130. package/lib/index.js.map +1 -1
  131. package/lib/messageTypes.d.ts +15 -7
  132. package/lib/messageTypes.d.ts.map +1 -1
  133. package/lib/messageTypes.js +6 -1
  134. package/lib/messageTypes.js.map +1 -1
  135. package/lib/opLifecycle/definitions.d.ts +1 -1
  136. package/lib/opLifecycle/definitions.js.map +1 -1
  137. package/lib/packageVersion.d.ts +1 -1
  138. package/lib/packageVersion.js +1 -1
  139. package/lib/packageVersion.js.map +1 -1
  140. package/lib/pendingStateManager.d.ts +1 -0
  141. package/lib/pendingStateManager.d.ts.map +1 -1
  142. package/lib/pendingStateManager.js +1 -0
  143. package/lib/pendingStateManager.js.map +1 -1
  144. package/lib/summary/orderedClientElection.d.ts +1 -1
  145. package/lib/summary/orderedClientElection.js.map +1 -1
  146. package/lib/summary/runWhileConnectedCoordinator.d.ts +2 -2
  147. package/lib/summary/runWhileConnectedCoordinator.js +1 -1
  148. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  149. package/lib/summary/summarizer.d.ts +1 -1
  150. package/lib/summary/summarizer.js +1 -1
  151. package/lib/summary/summarizer.js.map +1 -1
  152. package/lib/summary/summarizerTypes.d.ts +30 -30
  153. package/lib/summary/summarizerTypes.js.map +1 -1
  154. package/lib/summary/summaryCollection.d.ts +10 -10
  155. package/lib/summary/summaryCollection.js +1 -1
  156. package/lib/summary/summaryCollection.js.map +1 -1
  157. package/lib/summary/summaryFormat.d.ts +3 -3
  158. package/lib/summary/summaryFormat.js.map +1 -1
  159. package/package.json +42 -19
  160. package/src/blobManager.ts +5 -5
  161. package/src/containerRuntime.ts +86 -56
  162. package/src/dataStoreRegistry.ts +1 -1
  163. package/src/dataStores.ts +140 -69
  164. package/src/gc/garbageCollection.md +14 -15
  165. package/src/gc/garbageCollection.ts +256 -96
  166. package/src/gc/gcConfigs.ts +50 -52
  167. package/src/gc/gcDefinitions.ts +137 -52
  168. package/src/gc/gcHelpers.ts +31 -52
  169. package/src/gc/gcTelemetry.ts +16 -57
  170. package/src/gc/gcUnreferencedStateTracker.ts +61 -22
  171. package/src/gc/index.ts +6 -4
  172. package/src/index.ts +19 -1
  173. package/src/messageTypes.ts +19 -4
  174. package/src/opLifecycle/definitions.ts +1 -1
  175. package/src/packageVersion.ts +1 -1
  176. package/src/pendingStateManager.ts +1 -0
  177. package/src/summary/orderedClientElection.ts +1 -1
  178. package/src/summary/runWhileConnectedCoordinator.ts +2 -2
  179. package/src/summary/summarizer.ts +1 -1
  180. package/src/summary/summarizerTypes.ts +30 -30
  181. package/src/summary/summaryCollection.ts +10 -10
  182. package/src/summary/summaryFormat.ts +3 -3
  183. package/dist/id-compressor/appendOnlySortedMap.d.ts +0 -124
  184. package/dist/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
  185. package/dist/id-compressor/appendOnlySortedMap.js +0 -318
  186. package/dist/id-compressor/appendOnlySortedMap.js.map +0 -1
  187. package/dist/id-compressor/finalSpace.d.ts +0 -29
  188. package/dist/id-compressor/finalSpace.d.ts.map +0 -1
  189. package/dist/id-compressor/finalSpace.js +0 -62
  190. package/dist/id-compressor/finalSpace.js.map +0 -1
  191. package/dist/id-compressor/idCompressor.d.ts +0 -54
  192. package/dist/id-compressor/idCompressor.d.ts.map +0 -1
  193. package/dist/id-compressor/idCompressor.js +0 -495
  194. package/dist/id-compressor/idCompressor.js.map +0 -1
  195. package/dist/id-compressor/identifiers.d.ts +0 -32
  196. package/dist/id-compressor/identifiers.d.ts.map +0 -1
  197. package/dist/id-compressor/identifiers.js +0 -15
  198. package/dist/id-compressor/identifiers.js.map +0 -1
  199. package/dist/id-compressor/index.d.ts +0 -13
  200. package/dist/id-compressor/index.d.ts.map +0 -1
  201. package/dist/id-compressor/index.js +0 -32
  202. package/dist/id-compressor/index.js.map +0 -1
  203. package/dist/id-compressor/persistanceUtilities.d.ts +0 -22
  204. package/dist/id-compressor/persistanceUtilities.d.ts.map +0 -1
  205. package/dist/id-compressor/persistanceUtilities.js +0 -43
  206. package/dist/id-compressor/persistanceUtilities.js.map +0 -1
  207. package/dist/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
  208. package/dist/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
  209. package/dist/id-compressor/sessionSpaceNormalizer.js +0 -80
  210. package/dist/id-compressor/sessionSpaceNormalizer.js.map +0 -1
  211. package/dist/id-compressor/sessions.d.ts +0 -115
  212. package/dist/id-compressor/sessions.d.ts.map +0 -1
  213. package/dist/id-compressor/sessions.js +0 -305
  214. package/dist/id-compressor/sessions.js.map +0 -1
  215. package/dist/id-compressor/utilities.d.ts +0 -52
  216. package/dist/id-compressor/utilities.d.ts.map +0 -1
  217. package/dist/id-compressor/utilities.js +0 -169
  218. package/dist/id-compressor/utilities.js.map +0 -1
  219. package/lib/id-compressor/appendOnlySortedMap.d.ts +0 -124
  220. package/lib/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
  221. package/lib/id-compressor/appendOnlySortedMap.js +0 -314
  222. package/lib/id-compressor/appendOnlySortedMap.js.map +0 -1
  223. package/lib/id-compressor/finalSpace.d.ts +0 -29
  224. package/lib/id-compressor/finalSpace.d.ts.map +0 -1
  225. package/lib/id-compressor/finalSpace.js +0 -58
  226. package/lib/id-compressor/finalSpace.js.map +0 -1
  227. package/lib/id-compressor/idCompressor.d.ts +0 -54
  228. package/lib/id-compressor/idCompressor.d.ts.map +0 -1
  229. package/lib/id-compressor/idCompressor.js +0 -491
  230. package/lib/id-compressor/idCompressor.js.map +0 -1
  231. package/lib/id-compressor/identifiers.d.ts +0 -32
  232. package/lib/id-compressor/identifiers.d.ts.map +0 -1
  233. package/lib/id-compressor/identifiers.js +0 -11
  234. package/lib/id-compressor/identifiers.js.map +0 -1
  235. package/lib/id-compressor/index.d.ts +0 -13
  236. package/lib/id-compressor/index.d.ts.map +0 -1
  237. package/lib/id-compressor/index.js +0 -13
  238. package/lib/id-compressor/index.js.map +0 -1
  239. package/lib/id-compressor/persistanceUtilities.d.ts +0 -22
  240. package/lib/id-compressor/persistanceUtilities.d.ts.map +0 -1
  241. package/lib/id-compressor/persistanceUtilities.js +0 -34
  242. package/lib/id-compressor/persistanceUtilities.js.map +0 -1
  243. package/lib/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
  244. package/lib/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
  245. package/lib/id-compressor/sessionSpaceNormalizer.js +0 -76
  246. package/lib/id-compressor/sessionSpaceNormalizer.js.map +0 -1
  247. package/lib/id-compressor/sessions.d.ts +0 -115
  248. package/lib/id-compressor/sessions.d.ts.map +0 -1
  249. package/lib/id-compressor/sessions.js +0 -290
  250. package/lib/id-compressor/sessions.js.map +0 -1
  251. package/lib/id-compressor/utilities.d.ts +0 -52
  252. package/lib/id-compressor/utilities.d.ts.map +0 -1
  253. package/lib/id-compressor/utilities.js +0 -151
  254. package/lib/id-compressor/utilities.js.map +0 -1
  255. package/src/id-compressor/README.md +0 -3
  256. package/src/id-compressor/appendOnlySortedMap.ts +0 -366
  257. package/src/id-compressor/finalSpace.ts +0 -67
  258. package/src/id-compressor/idCompressor.ts +0 -630
  259. package/src/id-compressor/identifiers.ts +0 -42
  260. package/src/id-compressor/index.ts +0 -26
  261. package/src/id-compressor/persistanceUtilities.ts +0 -58
  262. package/src/id-compressor/sessionSpaceNormalizer.ts +0 -83
  263. package/src/id-compressor/sessions.ts +0 -405
  264. package/src/id-compressor/utilities.ts +0 -190
@@ -1,305 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.lastFinalizedLocal = exports.lastAllocatedLocal = exports.lastFinalizedFinal = exports.lastAllocatedFinal = exports.getAlignedLocal = exports.getAlignedFinal = exports.clustersEqual = exports.Session = exports.Sessions = void 0;
11
- const sorted_btree_1 = __importDefault(require("sorted-btree"));
12
- const core_utils_1 = require("@fluidframework/core-utils");
13
- const utilities_1 = require("./utilities");
14
- /**
15
- * A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).
16
- * This collection of all sessions comprises a distributed document's IDs.
17
- */
18
- class Sessions {
19
- constructor(sessions) {
20
- // A range-queryable store of all sessions. A btree is used as it solves the predecessor problem for any given UUID, allowing
21
- // us to quickly find the session that may have produced it.
22
- this.uuidSpace = new sorted_btree_1.default(undefined, utilities_1.compareBigints);
23
- // A fast lookup table from session ID to the session object, used to avoid accessing the slower btree
24
- this.sessionCache = new Map();
25
- if (sessions !== undefined) {
26
- // bulk load path
27
- for (const [numeric, session] of sessions) {
28
- this.sessionCache.set((0, utilities_1.stableIdFromNumericUuid)(numeric), session);
29
- }
30
- this.uuidSpace = new sorted_btree_1.default(sessions, utilities_1.compareBigints);
31
- if (this.sessionCache.size !== sessions.length ||
32
- sessions.length !== this.uuidSpace.size) {
33
- throw new Error("Cannot resume existing session.");
34
- }
35
- }
36
- }
37
- sessions() {
38
- return this.sessionCache.values();
39
- }
40
- getOrCreate(sessionId) {
41
- const existing = this.sessionCache.get(sessionId);
42
- if (existing !== undefined) {
43
- return existing;
44
- }
45
- const session = new Session(sessionId);
46
- (0, core_utils_1.assert)(this.uuidSpace.set(session.sessionUuid, session), 0x760 /* Duplicate session in map. */);
47
- this.sessionCache.set(sessionId, session);
48
- return session;
49
- }
50
- get(sessionId) {
51
- return this.sessionCache.get(sessionId);
52
- }
53
- getContainingCluster(query) {
54
- const numericStable = (0, utilities_1.numericUuidFromStableId)(query);
55
- const possibleMatch = this.uuidSpace.getPairOrNextLower(numericStable);
56
- if (possibleMatch === undefined) {
57
- return undefined;
58
- }
59
- const [_, session] = possibleMatch;
60
- const numericDelta = (0, utilities_1.subtractNumericUuids)(numericStable, session.sessionUuid);
61
- if (numericDelta > Number.MAX_SAFE_INTEGER) {
62
- return undefined;
63
- }
64
- const alignedLocal = (0, utilities_1.localIdFromGenCount)(Number(numericDelta) + 1);
65
- const containingCluster = session.getClusterByLocal(alignedLocal, true);
66
- if (containingCluster === undefined) {
67
- return undefined;
68
- }
69
- return [containingCluster, alignedLocal];
70
- }
71
- clusterCollides(cluster) {
72
- const { session: owningSession, baseLocalId, capacity } = cluster;
73
- const clusterBaseNumeric = (0, utilities_1.offsetNumericUuid)(owningSession.sessionUuid, (0, utilities_1.genCountFromLocalId)(baseLocalId) - 1);
74
- const clusterMaxNumeric = (0, utilities_1.offsetNumericUuid)(clusterBaseNumeric, capacity - 1);
75
- let closestMatch = this.uuidSpace.getPairOrNextLower(clusterMaxNumeric);
76
- // Find the first session that is not the owner of this new cluster.
77
- // Once we have that, check to see if its cluster chain overlaps with the new cluster.
78
- // Consider the following diagram of UUID space:
79
- // Cluster chain A: |----------------------|
80
- // Cluster chain B: |----------|
81
- // Cluster chain C: |-------|
82
- // While it is true that when adding a cluster to chain C, we would find
83
- // the next lower session (which is B) and erroneously determine we do not collide
84
- // with any other session, but this situation is impossible to get into as B would
85
- // have detected that it collided with A (or the other way around, depending on ordering).
86
- while (closestMatch !== undefined && closestMatch[1] === owningSession) {
87
- closestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);
88
- }
89
- if (closestMatch === undefined) {
90
- return false;
91
- }
92
- const [_, session] = closestMatch;
93
- (0, core_utils_1.assert)(session !== owningSession, 0x761 /* Failed to attempt to detect collisions. */);
94
- const lastCluster = session.getLastCluster();
95
- if (lastCluster === undefined) {
96
- // If the closest session is empty (the local session), then it is guaranteed (probabilistically) that there are no
97
- // non-empty sessions that have a cluster chain that starts prior to the empty session and collides with the cluster
98
- // we are checking, so we can return false.
99
- return false;
100
- }
101
- const lastAllocatedNumeric = (0, utilities_1.offsetNumericUuid)(session.sessionUuid, (0, utilities_1.genCountFromLocalId)(lastAllocatedLocal(lastCluster)) - 1);
102
- return lastAllocatedNumeric >= clusterBaseNumeric;
103
- }
104
- equals(other, includeLocalState) {
105
- const checkIsSubset = (sessionsA, sessionsB) => {
106
- const first = sessionsA.sessions().next();
107
- const firstSessionThis = first.done ? undefined : first.value;
108
- for (const [stableId, session] of sessionsA.sessionCache.entries()) {
109
- const otherSession = sessionsB.sessionCache.get(stableId);
110
- if (otherSession === undefined) {
111
- if (!session.isEmpty() || includeLocalState) {
112
- return false;
113
- }
114
- (0, core_utils_1.assert)(session === firstSessionThis, 0x762 /* The only non-empty session must be the local session. */);
115
- }
116
- else if (!session.equals(otherSession)) {
117
- return false;
118
- }
119
- }
120
- return true;
121
- };
122
- return checkIsSubset(this, other) && checkIsSubset(other, this);
123
- }
124
- }
125
- exports.Sessions = Sessions;
126
- /**
127
- * The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.
128
- */
129
- class Session {
130
- constructor(sessionId) {
131
- // All clusters created by this session, in creation order (thus sorted by base final and local ID).
132
- this.clusterChain = [];
133
- this.sessionUuid =
134
- typeof sessionId === "string" ? (0, utilities_1.numericUuidFromStableId)(sessionId) : sessionId;
135
- }
136
- /**
137
- * Adds a new empty cluster to the cluster chain of this session.
138
- */
139
- addNewCluster(baseFinalId, capacity, count) {
140
- const lastCluster = this.getLastCluster();
141
- const newCluster = {
142
- session: this,
143
- baseFinalId,
144
- baseLocalId: (lastCluster === undefined
145
- ? -1
146
- : lastAllocatedLocal(lastCluster) - 1),
147
- capacity,
148
- count,
149
- };
150
- this.clusterChain.push(newCluster);
151
- return newCluster;
152
- }
153
- isEmpty() {
154
- return this.clusterChain.length === 0;
155
- }
156
- /**
157
- * Returns the last cluster in this session's cluster chain, if any.
158
- */
159
- getLastCluster() {
160
- return this.clusterChain[this.clusterChain.length - 1];
161
- }
162
- /**
163
- * Converts the local ID from this session to a final ID, if possible.
164
- * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.
165
- */
166
- tryConvertToFinal(searchLocal, includeAllocated) {
167
- const containingCluster = this.getClusterByLocal(searchLocal, includeAllocated);
168
- if (containingCluster === undefined) {
169
- return undefined;
170
- }
171
- return getAlignedFinal(containingCluster, searchLocal);
172
- }
173
- /**
174
- * Returns the cluster containing the supplied local ID, if possible.
175
- * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.
176
- */
177
- getClusterByLocal(localId, includeAllocated) {
178
- const lastValidLocal = includeAllocated
179
- ? lastAllocatedLocal
180
- : lastFinalizedLocal;
181
- const matchedCluster = Session.binarySearch(localId, this.clusterChain, (local, cluster) => {
182
- const lastLocal = lastValidLocal(cluster);
183
- if (local < lastLocal) {
184
- return 1;
185
- }
186
- else if (local > cluster.baseLocalId) {
187
- return -1;
188
- }
189
- else {
190
- return 0;
191
- }
192
- });
193
- return matchedCluster;
194
- }
195
- /**
196
- * Returns the cluster containing the supplied final ID, if possible.
197
- */
198
- getClusterByAllocatedFinal(final) {
199
- return Session.getContainingCluster(final, this.clusterChain);
200
- }
201
- /**
202
- * Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.
203
- * `clusterChain` must be sorted by final/local base ID.
204
- */
205
- static getContainingCluster(finalId, clusterChain) {
206
- return Session.binarySearch(finalId, clusterChain, (final, cluster) => {
207
- const lastFinal = lastAllocatedFinal(cluster);
208
- if (final < cluster.baseFinalId) {
209
- return -1;
210
- }
211
- else if (final > lastFinal) {
212
- return 1;
213
- }
214
- else {
215
- return 0;
216
- }
217
- });
218
- }
219
- static binarySearch(search, arr, comparator) {
220
- let left = 0;
221
- let right = arr.length - 1;
222
- while (left <= right) {
223
- const mid = Math.floor((left + right) / 2);
224
- const c = comparator(search, arr[mid]);
225
- if (c === 0) {
226
- return arr[mid]; // Found the target, return its index.
227
- }
228
- else if (c > 0) {
229
- left = mid + 1; // Continue search on right half.
230
- }
231
- else {
232
- right = mid - 1; // Continue search on left half.
233
- }
234
- }
235
- return undefined; // If we reach here, target is not in array.
236
- }
237
- equals(other) {
238
- for (let i = 0; i < this.clusterChain.length; i++) {
239
- if (!clustersEqual(this.clusterChain[i], other.clusterChain[i])) {
240
- return false;
241
- }
242
- }
243
- return this.sessionUuid === other.sessionUuid;
244
- }
245
- }
246
- exports.Session = Session;
247
- function clustersEqual(a, b) {
248
- return (a.session.sessionUuid === b.session.sessionUuid &&
249
- a.baseFinalId === b.baseFinalId &&
250
- a.baseLocalId === b.baseLocalId &&
251
- a.capacity === b.capacity &&
252
- a.count === b.count);
253
- }
254
- exports.clustersEqual = clustersEqual;
255
- /**
256
- * Returns the final ID that is aligned with the supplied local ID within a cluster.
257
- * Includes allocated IDs.
258
- */
259
- function getAlignedFinal(cluster, localWithin) {
260
- const clusterOffset = (0, utilities_1.genCountFromLocalId)(localWithin) - (0, utilities_1.genCountFromLocalId)(cluster.baseLocalId);
261
- if (clusterOffset < cluster.capacity) {
262
- return (cluster.baseFinalId + clusterOffset);
263
- }
264
- return undefined;
265
- }
266
- exports.getAlignedFinal = getAlignedFinal;
267
- /**
268
- * Returns the local ID that is aligned with the supplied final ID within a cluster.
269
- * Fails if the supplied ID does not fall within the cluster bounds.
270
- */
271
- function getAlignedLocal(cluster, finalWithin) {
272
- (0, core_utils_1.assert)(finalWithin >= cluster.baseFinalId && finalWithin <= lastAllocatedFinal(cluster), 0x763 /* Supplied ID is not within the cluster. */);
273
- const finalDelta = finalWithin - cluster.baseFinalId;
274
- return (cluster.baseLocalId - finalDelta);
275
- }
276
- exports.getAlignedLocal = getAlignedLocal;
277
- /**
278
- * Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster
279
- */
280
- function lastAllocatedFinal(cluster) {
281
- return (cluster.baseFinalId + (cluster.capacity - 1));
282
- }
283
- exports.lastAllocatedFinal = lastAllocatedFinal;
284
- /**
285
- * Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster
286
- */
287
- function lastFinalizedFinal(cluster) {
288
- return (cluster.baseFinalId + (cluster.count - 1));
289
- }
290
- exports.lastFinalizedFinal = lastFinalizedFinal;
291
- /**
292
- * Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster
293
- */
294
- function lastAllocatedLocal(cluster) {
295
- return (cluster.baseLocalId - (cluster.capacity - 1));
296
- }
297
- exports.lastAllocatedLocal = lastAllocatedLocal;
298
- /**
299
- * Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster
300
- */
301
- function lastFinalizedLocal(cluster) {
302
- return (cluster.baseLocalId - (cluster.count - 1));
303
- }
304
- exports.lastFinalizedLocal = lastFinalizedLocal;
305
- //# sourceMappingURL=sessions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/id-compressor/sessions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gEAAiC;AAEjC,2DAAoD;AACpD,2CAQqB;AAGrB;;;GAGG;AACH,MAAa,QAAQ;IAOpB,YAAmB,QAAyD;QAN5E,6HAA6H;QAC7H,4DAA4D;QAC3C,cAAS,GAAG,IAAI,sBAAK,CAAuB,SAAS,EAAE,0BAAc,CAAC,CAAC;QACxF,sGAAsG;QACrF,iBAAY,GAAG,IAAI,GAAG,EAAsB,CAAC;QAG7D,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3B,iBAAiB;YACjB,KAAK,MAAM,C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AkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAsB,CAAC;AACxF,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAsB,CAAC;AACxF,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAkB;IACpD,OAAO,CAAE,OAAO,CAAC,WAAsB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAsB,CAAC;AACrF,CAAC;AAFD,gDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport BTree from \"sorted-btree\";\nimport { SessionId, StableId } from \"@fluidframework/runtime-definitions\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tcompareBigints,\n\tlocalIdFromGenCount,\n\tgenCountFromLocalId,\n\tnumericUuidFromStableId,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n\toffsetNumericUuid,\n} from \"./utilities\";\nimport { FinalCompressedId, LocalCompressedId, NumericUuid } from \"./identifiers\";\n\n/**\n * A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).\n * This collection of all sessions comprises a distributed document's IDs.\n */\nexport class Sessions {\n\t// A range-queryable store of all sessions. A btree is used as it solves the predecessor problem for any given UUID, allowing\n\t// us to quickly find the session that may have produced it.\n\tprivate readonly uuidSpace = new BTree<NumericUuid, Session>(undefined, compareBigints);\n\t// A fast lookup table from session ID to the session object, used to avoid accessing the slower btree\n\tprivate readonly sessionCache = new Map<SessionId, Session>();\n\n\tpublic constructor(sessions?: [sessionBase: NumericUuid, session: Session][]) {\n\t\tif (sessions !== undefined) {\n\t\t\t// bulk load path\n\t\t\tfor (const [numeric, session] of sessions) {\n\t\t\t\tthis.sessionCache.set(stableIdFromNumericUuid(numeric) as SessionId, session);\n\t\t\t}\n\t\t\tthis.uuidSpace = new BTree(sessions, compareBigints);\n\t\t\tif (\n\t\t\t\tthis.sessionCache.size !== sessions.length ||\n\t\t\t\tsessions.length !== this.uuidSpace.size\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cannot resume existing session.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic sessions(): IterableIterator<Session> {\n\t\treturn this.sessionCache.values();\n\t}\n\n\tpublic getOrCreate(sessionId: SessionId): Session {\n\t\tconst existing = this.sessionCache.get(sessionId);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\t\tconst session = new Session(sessionId);\n\t\tassert(\n\t\t\tthis.uuidSpace.set(session.sessionUuid, session),\n\t\t\t0x760 /* Duplicate session in map. */,\n\t\t);\n\t\tthis.sessionCache.set(sessionId, session);\n\t\treturn session;\n\t}\n\n\tpublic get(sessionId: SessionId): Session | undefined {\n\t\treturn this.sessionCache.get(sessionId);\n\t}\n\n\tpublic getContainingCluster(\n\t\tquery: StableId,\n\t): [cluster: IdCluster, alignedLocal: LocalCompressedId] | undefined {\n\t\tconst numericStable = numericUuidFromStableId(query);\n\t\tconst possibleMatch = this.uuidSpace.getPairOrNextLower(numericStable);\n\t\tif (possibleMatch === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [_, session] = possibleMatch;\n\t\tconst numericDelta = subtractNumericUuids(numericStable, session.sessionUuid);\n\t\tif (numericDelta > Number.MAX_SAFE_INTEGER) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst alignedLocal = localIdFromGenCount(Number(numericDelta) + 1);\n\t\tconst containingCluster = session.getClusterByLocal(alignedLocal, true);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [containingCluster, alignedLocal];\n\t}\n\n\tpublic clusterCollides(cluster: IdCluster): boolean {\n\t\tconst { session: owningSession, baseLocalId, capacity } = cluster;\n\t\tconst clusterBaseNumeric = offsetNumericUuid(\n\t\t\towningSession.sessionUuid,\n\t\t\tgenCountFromLocalId(baseLocalId) - 1,\n\t\t);\n\t\tconst clusterMaxNumeric = offsetNumericUuid(clusterBaseNumeric, capacity - 1);\n\t\tlet closestMatch: [NumericUuid, Session] | undefined =\n\t\t\tthis.uuidSpace.getPairOrNextLower(clusterMaxNumeric);\n\t\t// Find the first session that is not the owner of this new cluster.\n\t\t// Once we have that, check to see if its cluster chain overlaps with the new cluster.\n\t\t// Consider the following diagram of UUID space:\n\t\t// Cluster chain A: |----------------------|\n\t\t// Cluster chain B: |----------|\n\t\t// Cluster chain C: |-------|\n\t\t// While it is true that when adding a cluster to chain C, we would find\n\t\t// the next lower session (which is B) and erroneously determine we do not collide\n\t\t// with any other session, but this situation is impossible to get into as B would\n\t\t// have detected that it collided with A (or the other way around, depending on ordering).\n\t\twhile (closestMatch !== undefined && closestMatch[1] === owningSession) {\n\t\t\tclosestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);\n\t\t}\n\t\tif (closestMatch === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst [_, session] = closestMatch;\n\t\tassert(session !== owningSession, 0x761 /* Failed to attempt to detect collisions. */);\n\t\tconst lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// If the closest session is empty (the local session), then it is guaranteed (probabilistically) that there are no\n\t\t\t// non-empty sessions that have a cluster chain that starts prior to the empty session and collides with the cluster\n\t\t\t// we are checking, so we can return false.\n\t\t\treturn false;\n\t\t}\n\t\tconst lastAllocatedNumeric = offsetNumericUuid(\n\t\t\tsession.sessionUuid,\n\t\t\tgenCountFromLocalId(lastAllocatedLocal(lastCluster)) - 1,\n\t\t);\n\t\treturn lastAllocatedNumeric >= clusterBaseNumeric;\n\t}\n\n\tpublic equals(other: Sessions, includeLocalState: boolean): boolean {\n\t\tconst checkIsSubset = (sessionsA: Sessions, sessionsB: Sessions) => {\n\t\t\tconst first = sessionsA.sessions().next();\n\t\t\tconst firstSessionThis = first.done ? undefined : first.value;\n\t\t\tfor (const [stableId, session] of sessionsA.sessionCache.entries()) {\n\t\t\t\tconst otherSession = sessionsB.sessionCache.get(stableId);\n\t\t\t\tif (otherSession === undefined) {\n\t\t\t\t\tif (!session.isEmpty() || includeLocalState) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsession === firstSessionThis,\n\t\t\t\t\t\t0x762 /* The only non-empty session must be the local session. */,\n\t\t\t\t\t);\n\t\t\t\t} else if (!session.equals(otherSession)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\t\treturn checkIsSubset(this, other) && checkIsSubset(other, this);\n\t}\n}\n\n/**\n * The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.\n */\nexport class Session {\n\t// All clusters created by this session, in creation order (thus sorted by base final and local ID).\n\tprivate readonly clusterChain: IdCluster[] = [];\n\t// The numeric form of the SessionId\n\tpublic readonly sessionUuid: NumericUuid;\n\n\tpublic constructor(sessionId: SessionId | NumericUuid) {\n\t\tthis.sessionUuid =\n\t\t\ttypeof sessionId === \"string\" ? numericUuidFromStableId(sessionId) : sessionId;\n\t}\n\n\t/**\n\t * Adds a new empty cluster to the cluster chain of this session.\n\t */\n\tpublic addNewCluster(\n\t\tbaseFinalId: FinalCompressedId,\n\t\tcapacity: number,\n\t\tcount: number,\n\t): IdCluster {\n\t\tconst lastCluster = this.getLastCluster();\n\t\tconst newCluster: IdCluster = {\n\t\t\tsession: this,\n\t\t\tbaseFinalId,\n\t\t\tbaseLocalId: (lastCluster === undefined\n\t\t\t\t? -1\n\t\t\t\t: lastAllocatedLocal(lastCluster) - 1) as LocalCompressedId,\n\t\t\tcapacity,\n\t\t\tcount,\n\t\t};\n\t\tthis.clusterChain.push(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.clusterChain.length === 0;\n\t}\n\n\t/**\n\t * Returns the last cluster in this session's cluster chain, if any.\n\t */\n\tpublic getLastCluster(): IdCluster | undefined {\n\t\treturn this.clusterChain[this.clusterChain.length - 1];\n\t}\n\n\t/**\n\t * Converts the local ID from this session to a final ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic tryConvertToFinal(\n\t\tsearchLocal: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): FinalCompressedId | undefined {\n\t\tconst containingCluster = this.getClusterByLocal(searchLocal, includeAllocated);\n\t\tif (containingCluster === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getAlignedFinal(containingCluster, searchLocal);\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied local ID, if possible.\n\t * @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.\n\t */\n\tpublic getClusterByLocal(\n\t\tlocalId: LocalCompressedId,\n\t\tincludeAllocated: boolean,\n\t): IdCluster | undefined {\n\t\tconst lastValidLocal: (cluster: IdCluster) => LocalCompressedId = includeAllocated\n\t\t\t? lastAllocatedLocal\n\t\t\t: lastFinalizedLocal;\n\t\tconst matchedCluster = Session.binarySearch(\n\t\t\tlocalId,\n\t\t\tthis.clusterChain,\n\t\t\t(local, cluster): number => {\n\t\t\t\tconst lastLocal = lastValidLocal(cluster);\n\t\t\t\tif (local < lastLocal) {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (local > cluster.baseLocalId) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t\treturn matchedCluster;\n\t}\n\n\t/**\n\t * Returns the cluster containing the supplied final ID, if possible.\n\t */\n\tpublic getClusterByAllocatedFinal(final: FinalCompressedId): IdCluster | undefined {\n\t\treturn Session.getContainingCluster(final, this.clusterChain);\n\t}\n\n\t/**\n\t * Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.\n\t * `clusterChain` must be sorted by final/local base ID.\n\t */\n\tpublic static getContainingCluster(\n\t\tfinalId: FinalCompressedId,\n\t\tclusterChain: readonly IdCluster[],\n\t): IdCluster | undefined {\n\t\treturn Session.binarySearch(finalId, clusterChain, (final, cluster) => {\n\t\t\tconst lastFinal = lastAllocatedFinal(cluster);\n\t\t\tif (final < cluster.baseFinalId) {\n\t\t\t\treturn -1;\n\t\t\t} else if (final > lastFinal) {\n\t\t\t\treturn 1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic binarySearch<S, T>(\n\t\tsearch: S,\n\t\tarr: readonly T[],\n\t\tcomparator: (a: S, b: T) => number,\n\t): T | undefined {\n\t\tlet left = 0;\n\t\tlet right = arr.length - 1;\n\t\twhile (left <= right) {\n\t\t\tconst mid = Math.floor((left + right) / 2);\n\t\t\tconst c = comparator(search, arr[mid]);\n\t\t\tif (c === 0) {\n\t\t\t\treturn arr[mid]; // Found the target, return its index.\n\t\t\t} else if (c > 0) {\n\t\t\t\tleft = mid + 1; // Continue search on right half.\n\t\t\t} else {\n\t\t\t\tright = mid - 1; // Continue search on left half.\n\t\t\t}\n\t\t}\n\t\treturn undefined; // If we reach here, target is not in array.\n\t}\n\n\tpublic equals(other: Session): boolean {\n\t\tfor (let i = 0; i < this.clusterChain.length; i++) {\n\t\t\tif (!clustersEqual(this.clusterChain[i], other.clusterChain[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn this.sessionUuid === other.sessionUuid;\n\t}\n}\n\n/**\n * A cluster of final (sequenced via consensus), sequentially allocated compressed IDs.\n * A final ID in a cluster decompresses to a sequentially allocated UUID that is the result of adding its offset within\n * the cluster to base UUID for the session that created it.\n */\nexport interface IdCluster {\n\t/**\n\t * The session that created this cluster.\n\t */\n\treadonly session: Session;\n\n\t/**\n\t * The first final ID in the cluster.\n\t */\n\treadonly baseFinalId: FinalCompressedId;\n\n\t/**\n\t * The local ID aligned with `baseFinalId`.\n\t */\n\treadonly baseLocalId: LocalCompressedId;\n\n\t/**\n\t * The total number of final IDs reserved for allocation in the cluster.\n\t * Clusters are reserved in blocks as a performance optimization.\n\t */\n\tcapacity: number;\n\n\t/**\n\t * The number of final IDs currently allocated in the cluster.\n\t */\n\tcount: number;\n}\n\nexport function clustersEqual(a: IdCluster, b: IdCluster): boolean {\n\treturn (\n\t\ta.session.sessionUuid === b.session.sessionUuid &&\n\t\ta.baseFinalId === b.baseFinalId &&\n\t\ta.baseLocalId === b.baseLocalId &&\n\t\ta.capacity === b.capacity &&\n\t\ta.count === b.count\n\t);\n}\n\n/**\n * Returns the final ID that is aligned with the supplied local ID within a cluster.\n * Includes allocated IDs.\n */\nexport function getAlignedFinal(\n\tcluster: IdCluster,\n\tlocalWithin: LocalCompressedId,\n): FinalCompressedId | undefined {\n\tconst clusterOffset =\n\t\tgenCountFromLocalId(localWithin) - genCountFromLocalId(cluster.baseLocalId);\n\tif (clusterOffset < cluster.capacity) {\n\t\treturn ((cluster.baseFinalId as number) + clusterOffset) as FinalCompressedId;\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns the local ID that is aligned with the supplied final ID within a cluster.\n * Fails if the supplied ID does not fall within the cluster bounds.\n */\nexport function getAlignedLocal(\n\tcluster: IdCluster,\n\tfinalWithin: FinalCompressedId,\n): LocalCompressedId {\n\tassert(\n\t\tfinalWithin >= cluster.baseFinalId && finalWithin <= lastAllocatedFinal(cluster),\n\t\t0x763 /* Supplied ID is not within the cluster. */,\n\t);\n\tconst finalDelta = finalWithin - cluster.baseFinalId;\n\treturn (cluster.baseLocalId - finalDelta) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster\n */\nexport function lastAllocatedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.capacity - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster\n */\nexport function lastFinalizedFinal(cluster: IdCluster): FinalCompressedId {\n\treturn ((cluster.baseFinalId as number) + (cluster.count - 1)) as FinalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster\n */\nexport function lastAllocatedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.capacity - 1)) as LocalCompressedId;\n}\n\n/**\n * Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster\n */\nexport function lastFinalizedLocal(cluster: IdCluster): LocalCompressedId {\n\treturn ((cluster.baseLocalId as number) - (cluster.count - 1)) as LocalCompressedId;\n}\n"]}
@@ -1,52 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { SessionId, StableId } from "@fluidframework/runtime-definitions";
6
- import { LocalCompressedId, NumericUuid } from "./identifiers";
7
- /**
8
- * Generate a random session ID
9
- */
10
- export declare function createSessionId(): SessionId;
11
- /**
12
- * Asserts that the given string is a stable ID.
13
- * @public
14
- */
15
- export declare function assertIsStableId(stableId: string): StableId;
16
- /**
17
- * Asserts that the given string is a stable ID.
18
- */
19
- export declare function assertIsSessionId(stableId: string): SessionId;
20
- /**
21
- * Generate a random stable ID
22
- * @public
23
- */
24
- export declare function generateStableId(): StableId;
25
- /**
26
- * Returns true iff the given string is a valid Version 4, variant 2 UUID
27
- * 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'
28
- * @public
29
- */
30
- export declare function isStableId(str: string): str is StableId;
31
- /**
32
- * A numeric comparator used for sorting in ascending order.
33
- *
34
- * Handles +/-0 like Map: -0 is equal to +0.
35
- */
36
- export declare function compareFiniteNumbers<T extends number>(a: T, b: T): number;
37
- /**
38
- * Compares strings lexically to form a strict partial ordering.
39
- */
40
- export declare function compareStrings<T extends string>(a: T, b: T): number;
41
- /**
42
- * Compares bigints to form a strict partial ordering.
43
- */
44
- export declare function compareBigints<T extends bigint>(a: T, b: T): number;
45
- export declare function genCountFromLocalId(localId: LocalCompressedId): number;
46
- export declare function localIdFromGenCount(genCount: number): LocalCompressedId;
47
- export declare function numericUuidFromStableId(stableId: StableId): NumericUuid;
48
- export declare function stableIdFromNumericUuid(numericUuid: NumericUuid): StableId;
49
- export declare function offsetNumericUuid(numericUuid: NumericUuid, offset: number): NumericUuid;
50
- export declare function subtractNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid;
51
- export declare function addNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid;
52
- //# sourceMappingURL=utilities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/id-compressor/utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAmB/D;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAG3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAG7D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,QAAQ,CAuCvD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEnE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAEtE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAEvE;AAeD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAWvE;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,QAAQ,CAY1E;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAGvF;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,WAAW,CAEhF;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,WAAW,CAG3E"}
@@ -1,169 +0,0 @@
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.addNumericUuids = exports.subtractNumericUuids = exports.offsetNumericUuid = exports.stableIdFromNumericUuid = exports.numericUuidFromStableId = exports.localIdFromGenCount = exports.genCountFromLocalId = exports.compareBigints = exports.compareStrings = exports.compareFiniteNumbers = exports.isStableId = exports.generateStableId = exports.assertIsSessionId = exports.assertIsStableId = exports.createSessionId = void 0;
8
- /* eslint-disable no-bitwise */
9
- const core_utils_1 = require("@fluidframework/core-utils");
10
- const uuid_1 = require("uuid");
11
- const hexadecimalCharCodes = Array.from("09afAF").map((c) => c.charCodeAt(0));
12
- function isHexadecimalCharacter(charCode) {
13
- return ((charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||
14
- (charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||
15
- (charCode >= hexadecimalCharCodes[4] && charCode <= hexadecimalCharCodes[5]));
16
- }
17
- /**
18
- * Generate a random session ID
19
- */
20
- function createSessionId() {
21
- return assertIsStableId((0, uuid_1.v4)());
22
- }
23
- exports.createSessionId = createSessionId;
24
- /**
25
- * Asserts that the given string is a stable ID.
26
- * @public
27
- */
28
- function assertIsStableId(stableId) {
29
- (0, core_utils_1.assert)(isStableId(stableId), 0x4a3 /* Expected a StableId */);
30
- return stableId;
31
- }
32
- exports.assertIsStableId = assertIsStableId;
33
- /**
34
- * Asserts that the given string is a stable ID.
35
- */
36
- function assertIsSessionId(stableId) {
37
- assertIsStableId(stableId);
38
- return stableId;
39
- }
40
- exports.assertIsSessionId = assertIsSessionId;
41
- /**
42
- * Generate a random stable ID
43
- * @public
44
- */
45
- function generateStableId() {
46
- return assertIsStableId((0, uuid_1.v4)());
47
- }
48
- exports.generateStableId = generateStableId;
49
- /**
50
- * Returns true iff the given string is a valid Version 4, variant 2 UUID
51
- * 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'
52
- * @public
53
- */
54
- function isStableId(str) {
55
- if (str.length !== 36) {
56
- return false;
57
- }
58
- for (let i = 0; i < str.length; i++) {
59
- switch (i) {
60
- case 8:
61
- case 13:
62
- case 18:
63
- case 23:
64
- if (str.charAt(i) !== "-") {
65
- return false;
66
- }
67
- break;
68
- case 14:
69
- if (str.charAt(i) !== "4") {
70
- return false;
71
- }
72
- break;
73
- case 19: {
74
- const char = str.charAt(i);
75
- if (char !== "8" && char !== "9" && char !== "a" && char !== "b") {
76
- return false;
77
- }
78
- break;
79
- }
80
- default:
81
- if (!isHexadecimalCharacter(str.charCodeAt(i))) {
82
- return false;
83
- }
84
- break;
85
- }
86
- }
87
- return true;
88
- }
89
- exports.isStableId = isStableId;
90
- /**
91
- * A numeric comparator used for sorting in ascending order.
92
- *
93
- * Handles +/-0 like Map: -0 is equal to +0.
94
- */
95
- function compareFiniteNumbers(a, b) {
96
- return a - b;
97
- }
98
- exports.compareFiniteNumbers = compareFiniteNumbers;
99
- /**
100
- * Compares strings lexically to form a strict partial ordering.
101
- */
102
- function compareStrings(a, b) {
103
- return a > b ? 1 : a === b ? 0 : -1;
104
- }
105
- exports.compareStrings = compareStrings;
106
- /**
107
- * Compares bigints to form a strict partial ordering.
108
- */
109
- function compareBigints(a, b) {
110
- return a > b ? 1 : a === b ? 0 : -1;
111
- }
112
- exports.compareBigints = compareBigints;
113
- function genCountFromLocalId(localId) {
114
- return -localId;
115
- }
116
- exports.genCountFromLocalId = genCountFromLocalId;
117
- function localIdFromGenCount(genCount) {
118
- return -genCount;
119
- }
120
- exports.localIdFromGenCount = localIdFromGenCount;
121
- // xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
122
- const versionMask = 0x4n << (19n * 4n); // Version 4
123
- const variantMask = 0x8n << (15n * 4n); // Variant RFC4122 (1 0 x x)
124
- const upperMask = 0xffffffffffffn << (20n * 4n);
125
- // Upper mask when version/variant bits are removed
126
- const strippedUpperMask = upperMask >> 6n;
127
- const middieBittiesMask = 0xfffn << (16n * 4n);
128
- // Middie mask when version/variant bits are removed
129
- const strippedMiddieBittiesMask = middieBittiesMask >> 2n;
130
- // Note: leading character should be 3 to mask at 0011
131
- // The more-significant half of the N nibble is used to denote the variant (10xx)
132
- const lowerMask = 0x3fffffffffffffffn;
133
- function numericUuidFromStableId(stableId) {
134
- const uuidU128 = BigInt(`0x${stableId.replace(/-/g, "")}`);
135
- const upperMasked = uuidU128 & upperMask;
136
- const middieBittiesMasked = uuidU128 & middieBittiesMask;
137
- const lowerMasked = uuidU128 & lowerMask;
138
- const upperMaskedPlaced = upperMasked >> 6n;
139
- const middieBittiesMaskedPlaced = middieBittiesMasked >> 2n;
140
- const id = upperMaskedPlaced | middieBittiesMaskedPlaced | lowerMasked;
141
- return id;
142
- }
143
- exports.numericUuidFromStableId = numericUuidFromStableId;
144
- function stableIdFromNumericUuid(numericUuid) {
145
- // bitwise reverse transform
146
- const upperMasked = (numericUuid & strippedUpperMask) << 6n;
147
- const middieBittiesMasked = (numericUuid & strippedMiddieBittiesMask) << 2n;
148
- const lowerMasked = numericUuid & lowerMask;
149
- const uuidU128 = upperMasked | versionMask | middieBittiesMasked | variantMask | lowerMasked;
150
- // Pad to 32 characters, inserting leading zeroes if needed
151
- const uuidString = uuidU128.toString(16).padStart(32, "0");
152
- return `${uuidString.substring(0, 8)}-${uuidString.substring(8, 12)}-${uuidString.substring(12, 16)}-${uuidString.substring(16, 20)}-${uuidString.substring(20, 32)}`;
153
- }
154
- exports.stableIdFromNumericUuid = stableIdFromNumericUuid;
155
- function offsetNumericUuid(numericUuid, offset) {
156
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
157
- return (numericUuid + BigInt(offset));
158
- }
159
- exports.offsetNumericUuid = offsetNumericUuid;
160
- function subtractNumericUuids(a, b) {
161
- return (a - b);
162
- }
163
- exports.subtractNumericUuids = subtractNumericUuids;
164
- function addNumericUuids(a, b) {
165
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
166
- return (a + b);
167
- }
168
- exports.addNumericUuids = addNumericUuids;
169
- //# sourceMappingURL=utilities.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/id-compressor/utilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAC/B,2DAAoD;AAEpD,+BAA0B;AAG1B,MAAM,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CA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AFD,oDAEC;AAED,SAAgB,eAAe,CAAC,CAAc,EAAE,CAAc;IAC7D,qEAAqE;IACrE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAgB,CAAC;AAC/B,CAAC;AAHD,0CAGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\nimport { assert } from \"@fluidframework/core-utils\";\nimport { SessionId, StableId } from \"@fluidframework/runtime-definitions\";\nimport { v4 } from \"uuid\";\nimport { LocalCompressedId, NumericUuid } from \"./identifiers\";\n\nconst hexadecimalCharCodes = Array.from(\"09afAF\").map((c) => c.charCodeAt(0)) as [\n\tzero: number,\n\tnine: number,\n\ta: number,\n\tf: number,\n\tA: number,\n\tF: number,\n];\n\nfunction isHexadecimalCharacter(charCode: number): boolean {\n\treturn (\n\t\t(charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||\n\t\t(charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||\n\t\t(charCode >= hexadecimalCharCodes[4] && charCode <= hexadecimalCharCodes[5])\n\t);\n}\n\n/**\n * Generate a random session ID\n */\nexport function createSessionId(): SessionId {\n\treturn assertIsStableId(v4()) as SessionId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n * @public\n */\nexport function assertIsStableId(stableId: string): StableId {\n\tassert(isStableId(stableId), 0x4a3 /* Expected a StableId */);\n\treturn stableId;\n}\n\n/**\n * Asserts that the given string is a stable ID.\n */\nexport function assertIsSessionId(stableId: string): SessionId {\n\tassertIsStableId(stableId);\n\treturn stableId as SessionId;\n}\n\n/**\n * Generate a random stable ID\n * @public\n */\nexport function generateStableId(): StableId {\n\treturn assertIsStableId(v4());\n}\n\n/**\n * Returns true iff the given string is a valid Version 4, variant 2 UUID\n * 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'\n * @public\n */\nexport function isStableId(str: string): str is StableId {\n\tif (str.length !== 36) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tswitch (i) {\n\t\t\tcase 8:\n\t\t\tcase 13:\n\t\t\tcase 18:\n\t\t\tcase 23:\n\t\t\t\tif (str.charAt(i) !== \"-\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 14:\n\t\t\t\tif (str.charAt(i) !== \"4\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 19: {\n\t\t\t\tconst char = str.charAt(i);\n\t\t\t\tif (char !== \"8\" && char !== \"9\" && char !== \"a\" && char !== \"b\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tif (!isHexadecimalCharacter(str.charCodeAt(i))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * A numeric comparator used for sorting in ascending order.\n *\n * Handles +/-0 like Map: -0 is equal to +0.\n */\nexport function compareFiniteNumbers<T extends number>(a: T, b: T): number {\n\treturn a - b;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\n/**\n * Compares bigints to form a strict partial ordering.\n */\nexport function compareBigints<T extends bigint>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\nexport function genCountFromLocalId(localId: LocalCompressedId): number {\n\treturn -localId;\n}\n\nexport function localIdFromGenCount(genCount: number): LocalCompressedId {\n\treturn -genCount as LocalCompressedId;\n}\n\n// xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx\nconst versionMask = 0x4n << (19n * 4n); // Version 4\nconst variantMask = 0x8n << (15n * 4n); // Variant RFC4122 (1 0 x x)\nconst upperMask = 0xffffffffffffn << (20n * 4n);\n// Upper mask when version/variant bits are removed\nconst strippedUpperMask = upperMask >> 6n;\nconst middieBittiesMask = 0xfffn << (16n * 4n);\n// Middie mask when version/variant bits are removed\nconst strippedMiddieBittiesMask = middieBittiesMask >> 2n;\n// Note: leading character should be 3 to mask at 0011\n// The more-significant half of the N nibble is used to denote the variant (10xx)\nconst lowerMask = 0x3fffffffffffffffn;\n\nexport function numericUuidFromStableId(stableId: StableId): NumericUuid {\n\tconst uuidU128 = BigInt(`0x${stableId.replace(/-/g, \"\")}`);\n\tconst upperMasked = uuidU128 & upperMask;\n\tconst middieBittiesMasked = uuidU128 & middieBittiesMask;\n\tconst lowerMasked = uuidU128 & lowerMask;\n\n\tconst upperMaskedPlaced = upperMasked >> 6n;\n\tconst middieBittiesMaskedPlaced = middieBittiesMasked >> 2n;\n\n\tconst id = upperMaskedPlaced | middieBittiesMaskedPlaced | lowerMasked;\n\treturn id as NumericUuid;\n}\n\nexport function stableIdFromNumericUuid(numericUuid: NumericUuid): StableId {\n\t// bitwise reverse transform\n\tconst upperMasked = (numericUuid & strippedUpperMask) << 6n;\n\tconst middieBittiesMasked = (numericUuid & strippedMiddieBittiesMask) << 2n;\n\tconst lowerMasked = numericUuid & lowerMask;\n\tconst uuidU128 = upperMasked | versionMask | middieBittiesMasked | variantMask | lowerMasked;\n\t// Pad to 32 characters, inserting leading zeroes if needed\n\tconst uuidString = uuidU128.toString(16).padStart(32, \"0\");\n\treturn `${uuidString.substring(0, 8)}-${uuidString.substring(8, 12)}-${uuidString.substring(\n\t\t12,\n\t\t16,\n\t)}-${uuidString.substring(16, 20)}-${uuidString.substring(20, 32)}` as StableId;\n}\n\nexport function offsetNumericUuid(numericUuid: NumericUuid, offset: number): NumericUuid {\n\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\treturn (numericUuid + BigInt(offset)) as NumericUuid;\n}\n\nexport function subtractNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\treturn (a - b) as NumericUuid;\n}\n\nexport function addNumericUuids(a: NumericUuid, b: NumericUuid): NumericUuid {\n\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\treturn (a + b) as NumericUuid;\n}\n"]}