@fluid-experimental/tree 0.59.2001 → 0.59.3000

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 (258) hide show
  1. package/.eslintrc.js +2 -0
  2. package/.vscode/SharedTree.code-workspace +15 -0
  3. package/.vscode/settings.json +6 -0
  4. package/dist/ChangeCompression.js +9 -9
  5. package/dist/ChangeCompression.js.map +1 -1
  6. package/dist/ChangeTypes.d.ts +1 -6
  7. package/dist/ChangeTypes.d.ts.map +1 -1
  8. package/dist/ChangeTypes.js +5 -5
  9. package/dist/ChangeTypes.js.map +1 -1
  10. package/dist/Checkout.js +14 -14
  11. package/dist/Checkout.js.map +1 -1
  12. package/dist/Common.d.ts +21 -3
  13. package/dist/Common.d.ts.map +1 -1
  14. package/dist/Common.js +29 -4
  15. package/dist/Common.js.map +1 -1
  16. package/dist/EditLog.js +26 -25
  17. package/dist/EditLog.js.map +1 -1
  18. package/dist/EditUtilities.js +17 -17
  19. package/dist/EditUtilities.js.map +1 -1
  20. package/dist/Forest.js +31 -31
  21. package/dist/Forest.js.map +1 -1
  22. package/dist/HistoryEditFactory.js +9 -9
  23. package/dist/HistoryEditFactory.js.map +1 -1
  24. package/dist/IdConversion.js +9 -9
  25. package/dist/IdConversion.js.map +1 -1
  26. package/dist/Identifiers.d.ts +4 -0
  27. package/dist/Identifiers.d.ts.map +1 -1
  28. package/dist/Identifiers.js.map +1 -1
  29. package/dist/LogViewer.d.ts +1 -5
  30. package/dist/LogViewer.d.ts.map +1 -1
  31. package/dist/LogViewer.js +11 -19
  32. package/dist/LogViewer.js.map +1 -1
  33. package/dist/MergeHealth.js +2 -2
  34. package/dist/MergeHealth.js.map +1 -1
  35. package/dist/NodeIdUtilities.js +2 -2
  36. package/dist/NodeIdUtilities.js.map +1 -1
  37. package/dist/PayloadUtilities.js +1 -1
  38. package/dist/PayloadUtilities.js.map +1 -1
  39. package/dist/RevisionValueCache.d.ts +13 -10
  40. package/dist/RevisionValueCache.d.ts.map +1 -1
  41. package/dist/RevisionValueCache.js +14 -11
  42. package/dist/RevisionValueCache.js.map +1 -1
  43. package/dist/RevisionView.js +4 -4
  44. package/dist/RevisionView.js.map +1 -1
  45. package/dist/SerializationUtilities.js +4 -4
  46. package/dist/SerializationUtilities.js.map +1 -1
  47. package/dist/SharedTree.d.ts +93 -31
  48. package/dist/SharedTree.d.ts.map +1 -1
  49. package/dist/SharedTree.js +160 -131
  50. package/dist/SharedTree.js.map +1 -1
  51. package/dist/SharedTreeEncoder.d.ts +3 -3
  52. package/dist/SharedTreeEncoder.d.ts.map +1 -1
  53. package/dist/SharedTreeEncoder.js +36 -36
  54. package/dist/SharedTreeEncoder.js.map +1 -1
  55. package/dist/StringInterner.js +1 -1
  56. package/dist/StringInterner.js.map +1 -1
  57. package/dist/Summary.js +1 -1
  58. package/dist/Summary.js.map +1 -1
  59. package/dist/SummaryBackCompatibility.js +8 -8
  60. package/dist/SummaryBackCompatibility.js.map +1 -1
  61. package/dist/Transaction.js +1 -1
  62. package/dist/Transaction.js.map +1 -1
  63. package/dist/TransactionInternal.js +17 -17
  64. package/dist/TransactionInternal.js.map +1 -1
  65. package/dist/TreeCompressor.d.ts.map +1 -1
  66. package/dist/TreeCompressor.js +6 -8
  67. package/dist/TreeCompressor.js.map +1 -1
  68. package/dist/TreeNodeHandle.js +4 -4
  69. package/dist/TreeNodeHandle.js.map +1 -1
  70. package/dist/TreeView.js +7 -7
  71. package/dist/TreeView.js.map +1 -1
  72. package/dist/TreeViewUtilities.js +2 -2
  73. package/dist/TreeViewUtilities.js.map +1 -1
  74. package/dist/UndoRedoHandler.js +1 -1
  75. package/dist/UndoRedoHandler.js.map +1 -1
  76. package/dist/UuidUtilities.d.ts +30 -0
  77. package/dist/UuidUtilities.d.ts.map +1 -0
  78. package/dist/UuidUtilities.js +106 -0
  79. package/dist/UuidUtilities.js.map +1 -0
  80. package/dist/id-compressor/AppendOnlySortedMap.d.ts +52 -28
  81. package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
  82. package/dist/id-compressor/AppendOnlySortedMap.js +167 -90
  83. package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
  84. package/dist/id-compressor/IdCompressor.d.ts +43 -42
  85. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  86. package/dist/id-compressor/IdCompressor.js +179 -177
  87. package/dist/id-compressor/IdCompressor.js.map +1 -1
  88. package/dist/id-compressor/IdRange.js +1 -1
  89. package/dist/id-compressor/IdRange.js.map +1 -1
  90. package/dist/id-compressor/NumericUuid.d.ts +6 -14
  91. package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
  92. package/dist/id-compressor/NumericUuid.js +15 -76
  93. package/dist/id-compressor/NumericUuid.js.map +1 -1
  94. package/dist/id-compressor/SessionIdNormalizer.d.ts +122 -0
  95. package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
  96. package/dist/id-compressor/SessionIdNormalizer.js +418 -0
  97. package/dist/id-compressor/SessionIdNormalizer.js.map +1 -0
  98. package/dist/id-compressor/persisted-types/0.0.1.d.ts +6 -13
  99. package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  100. package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
  101. package/dist/index.d.ts +2 -2
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js.map +1 -1
  104. package/dist/persisted-types/0.1.1.d.ts +1 -6
  105. package/dist/persisted-types/0.1.1.d.ts.map +1 -1
  106. package/dist/persisted-types/0.1.1.js +3 -3
  107. package/dist/persisted-types/0.1.1.js.map +1 -1
  108. package/lib/ChangeTypes.d.ts +1 -6
  109. package/lib/ChangeTypes.d.ts.map +1 -1
  110. package/lib/Checkout.js.map +1 -1
  111. package/lib/Common.d.ts +21 -3
  112. package/lib/Common.d.ts.map +1 -1
  113. package/lib/Common.js +25 -3
  114. package/lib/Common.js.map +1 -1
  115. package/lib/EditLog.js +2 -1
  116. package/lib/EditLog.js.map +1 -1
  117. package/lib/EditUtilities.js.map +1 -1
  118. package/lib/Forest.js.map +1 -1
  119. package/lib/HistoryEditFactory.js.map +1 -1
  120. package/lib/Identifiers.d.ts +4 -0
  121. package/lib/Identifiers.d.ts.map +1 -1
  122. package/lib/Identifiers.js.map +1 -1
  123. package/lib/LogViewer.d.ts +1 -5
  124. package/lib/LogViewer.d.ts.map +1 -1
  125. package/lib/LogViewer.js +5 -13
  126. package/lib/LogViewer.js.map +1 -1
  127. package/lib/MergeHealth.js.map +1 -1
  128. package/lib/NodeIdUtilities.js.map +1 -1
  129. package/lib/RevisionValueCache.d.ts +13 -10
  130. package/lib/RevisionValueCache.d.ts.map +1 -1
  131. package/lib/RevisionValueCache.js +10 -7
  132. package/lib/RevisionValueCache.js.map +1 -1
  133. package/lib/RevisionView.js.map +1 -1
  134. package/lib/SharedTree.d.ts +93 -31
  135. package/lib/SharedTree.d.ts.map +1 -1
  136. package/lib/SharedTree.js +107 -78
  137. package/lib/SharedTree.js.map +1 -1
  138. package/lib/SharedTreeEncoder.d.ts +3 -3
  139. package/lib/SharedTreeEncoder.d.ts.map +1 -1
  140. package/lib/SharedTreeEncoder.js +4 -4
  141. package/lib/SharedTreeEncoder.js.map +1 -1
  142. package/lib/StringInterner.js.map +1 -1
  143. package/lib/Summary.js.map +1 -1
  144. package/lib/TreeCompressor.d.ts.map +1 -1
  145. package/lib/TreeCompressor.js +1 -3
  146. package/lib/TreeCompressor.js.map +1 -1
  147. package/lib/TreeNodeHandle.js.map +1 -1
  148. package/lib/TreeView.js.map +1 -1
  149. package/lib/TreeViewUtilities.js.map +1 -1
  150. package/lib/UuidUtilities.d.ts +30 -0
  151. package/lib/UuidUtilities.d.ts.map +1 -0
  152. package/lib/UuidUtilities.js +98 -0
  153. package/lib/UuidUtilities.js.map +1 -0
  154. package/lib/id-compressor/AppendOnlySortedMap.d.ts +52 -28
  155. package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
  156. package/lib/id-compressor/AppendOnlySortedMap.js +165 -88
  157. package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
  158. package/lib/id-compressor/IdCompressor.d.ts +43 -42
  159. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  160. package/lib/id-compressor/IdCompressor.js +97 -95
  161. package/lib/id-compressor/IdCompressor.js.map +1 -1
  162. package/lib/id-compressor/NumericUuid.d.ts +6 -14
  163. package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
  164. package/lib/id-compressor/NumericUuid.js +11 -70
  165. package/lib/id-compressor/NumericUuid.js.map +1 -1
  166. package/lib/id-compressor/SessionIdNormalizer.d.ts +122 -0
  167. package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
  168. package/lib/id-compressor/SessionIdNormalizer.js +414 -0
  169. package/lib/id-compressor/SessionIdNormalizer.js.map +1 -0
  170. package/lib/id-compressor/persisted-types/0.0.1.d.ts +6 -13
  171. package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  172. package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
  173. package/lib/index.d.ts +2 -2
  174. package/lib/index.d.ts.map +1 -1
  175. package/lib/index.js.map +1 -1
  176. package/lib/persisted-types/0.1.1.d.ts +1 -6
  177. package/lib/persisted-types/0.1.1.d.ts.map +1 -1
  178. package/lib/persisted-types/0.1.1.js.map +1 -1
  179. package/lib/test/AppendOnlySortedMap.perf.tests.d.ts +6 -0
  180. package/lib/test/AppendOnlySortedMap.perf.tests.d.ts.map +1 -0
  181. package/lib/test/AppendOnlySortedMap.perf.tests.js +49 -0
  182. package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -0
  183. package/lib/test/AppendOnlySortedMap.tests.js +56 -14
  184. package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
  185. package/lib/test/Checkout.tests.js +2 -2
  186. package/lib/test/Checkout.tests.js.map +1 -1
  187. package/lib/test/Forest.tests.js.map +1 -1
  188. package/lib/test/IdCompressor.perf.tests.js +8 -2
  189. package/lib/test/IdCompressor.perf.tests.js.map +1 -1
  190. package/lib/test/IdCompressor.tests.js +75 -24
  191. package/lib/test/IdCompressor.tests.js.map +1 -1
  192. package/lib/test/LogViewer.tests.js +3 -5
  193. package/lib/test/LogViewer.tests.js.map +1 -1
  194. package/lib/test/NumericUuid.perf.tests.js +4 -4
  195. package/lib/test/NumericUuid.perf.tests.js.map +1 -1
  196. package/lib/test/NumericUuid.tests.js +5 -4
  197. package/lib/test/NumericUuid.tests.js.map +1 -1
  198. package/lib/test/RevisionValueCache.tests.js.map +1 -1
  199. package/lib/test/RevisionView.tests.js.map +1 -1
  200. package/lib/test/SessionIdNormalizer.tests.d.ts +6 -0
  201. package/lib/test/SessionIdNormalizer.tests.d.ts.map +1 -0
  202. package/lib/test/SessionIdNormalizer.tests.js +299 -0
  203. package/lib/test/SessionIdNormalizer.tests.js.map +1 -0
  204. package/lib/test/Summary.tests.js +1 -1
  205. package/lib/test/Summary.tests.js.map +1 -1
  206. package/lib/test/TreeCompression.tests.js +1 -1
  207. package/lib/test/TreeCompression.tests.js.map +1 -1
  208. package/lib/test/Virtualization.tests.js +1 -1
  209. package/lib/test/Virtualization.tests.js.map +1 -1
  210. package/lib/test/fuzz/Generators.d.ts +3 -14
  211. package/lib/test/fuzz/Generators.d.ts.map +1 -1
  212. package/lib/test/fuzz/Generators.js +60 -151
  213. package/lib/test/fuzz/Generators.js.map +1 -1
  214. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +10 -7
  215. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
  216. package/lib/test/fuzz/SharedTreeFuzzTests.js +94 -104
  217. package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
  218. package/lib/test/fuzz/Types.d.ts +2 -9
  219. package/lib/test/fuzz/Types.d.ts.map +1 -1
  220. package/lib/test/fuzz/Types.js +1 -1
  221. package/lib/test/fuzz/Types.js.map +1 -1
  222. package/lib/test/utilities/IdCompressorTestUtilities.d.ts +57 -11
  223. package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
  224. package/lib/test/utilities/IdCompressorTestUtilities.js +112 -98
  225. package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
  226. package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
  227. package/lib/test/utilities/PendingLocalStateTests.js +2 -1
  228. package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
  229. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  230. package/lib/test/utilities/SharedTreeTests.js +30 -1
  231. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  232. package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
  233. package/lib/test/utilities/SharedTreeVersioningTests.js +20 -0
  234. package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
  235. package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -1
  236. package/lib/test/utilities/SummaryLoadPerfTests.js +6 -3
  237. package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
  238. package/lib/test/utilities/TestNode.js.map +1 -1
  239. package/lib/test/utilities/TestUtilities.d.ts +9 -1
  240. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  241. package/lib/test/utilities/TestUtilities.js +27 -13
  242. package/lib/test/utilities/TestUtilities.js.map +1 -1
  243. package/package.json +19 -17
  244. package/src/Common.ts +42 -4
  245. package/src/EditLog.ts +1 -1
  246. package/src/Identifiers.ts +5 -0
  247. package/src/LogViewer.ts +4 -20
  248. package/src/RevisionValueCache.ts +11 -8
  249. package/src/SharedTree.ts +222 -75
  250. package/src/SharedTreeEncoder.ts +17 -11
  251. package/src/TreeCompressor.ts +2 -4
  252. package/src/UuidUtilities.ts +123 -0
  253. package/src/id-compressor/AppendOnlySortedMap.ts +183 -94
  254. package/src/id-compressor/IdCompressor.ts +144 -132
  255. package/src/id-compressor/NumericUuid.ts +11 -80
  256. package/src/id-compressor/SessionIdNormalizer.ts +497 -0
  257. package/src/id-compressor/persisted-types/0.0.1.ts +12 -15
  258. package/src/index.ts +5 -0
@@ -27,25 +27,15 @@ const ChangeTypes_1 = require("./ChangeTypes");
27
27
  const id_compressor_1 = require("./id-compressor");
28
28
  const IdConversion_1 = require("./IdConversion");
29
29
  const StringInterner_1 = require("./StringInterner");
30
+ const UuidUtilities_1 = require("./UuidUtilities");
30
31
  /**
31
32
  * Factory for SharedTree.
32
33
  * Includes history in the summary.
33
34
  * @public
34
35
  */
35
36
  class SharedTreeFactory {
36
- /**
37
- * Get a factory for SharedTree to register with the data store.
38
- * @param writeFormat - Determines the format version the SharedTree will write ops and summaries in. See [the write format
39
- * documentation](../docs/Write-Format.md) for more information.
40
- * @param summarizeHistory - Determines if the history is included in summaries and if edit chunks are uploaded when they are full.
41
- * See the [breaking change migration documentation](docs/Breaking-Change-Migration) for more details on this scheme.
42
- * @param expensiveValidation - Enables expensive asserts on SharedTree.
43
- * @returns A factory that creates `SharedTree`s and loads them from storage.
44
- */
45
- constructor(writeFormat, summarizeHistory = false, expensiveValidation = false) {
46
- this.writeFormat = writeFormat;
47
- this.summarizeHistory = summarizeHistory;
48
- this.expensiveValidation = expensiveValidation;
37
+ constructor(...args) {
38
+ this.args = args;
49
39
  }
50
40
  /**
51
41
  * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory."type"}
@@ -72,15 +62,21 @@ class SharedTreeFactory {
72
62
  * @param runtime - data store runtime that owns the new SharedTree
73
63
  * @param id - optional name for the SharedTree
74
64
  */
75
- create(runtime, id, expensiveValidation = false) {
76
- this.expensiveValidation = expensiveValidation;
65
+ create(runtime, id) {
77
66
  const sharedTree = this.createSharedTree(runtime, id);
78
67
  sharedTree.initializeLocal();
79
68
  return sharedTree;
80
69
  }
81
70
  createSharedTree(runtime, id) {
82
- const sharedTree = new SharedTree(runtime, id, this.writeFormat, this.summarizeHistory, this.expensiveValidation);
83
- return sharedTree;
71
+ const [writeFormat] = this.args;
72
+ switch (writeFormat) {
73
+ case persisted_types_1.WriteFormat.v0_0_2:
74
+ return new SharedTree(runtime, id, ...this.args);
75
+ case persisted_types_1.WriteFormat.v0_1_1:
76
+ return new SharedTree(runtime, id, ...this.args);
77
+ default:
78
+ (0, Common_1.fail)('Unknown write format');
79
+ }
84
80
  }
85
81
  }
86
82
  exports.SharedTreeFactory = SharedTreeFactory;
@@ -110,20 +106,9 @@ const sharedTreeTelemetryProperties = { all: { isSharedTreeEvent: true } };
110
106
  * @public
111
107
  */
112
108
  class SharedTree extends shared_object_base_1.SharedObject {
113
- /**
114
- * Create a new SharedTreeFactory.
115
- * @param runtime - The runtime the SharedTree will be associated with
116
- * @param id - Unique ID for the SharedTree
117
- * @param writeFormat - Determines the format version the SharedTree will write ops and summaries in. See [the write format
118
- * documentation](../docs/Write-Format.md) for more information.
119
- * @param summarizeHistory - Determines if the history is included in summaries and if edit chunks are uploaded when they are full.
120
- * @param expensiveValidation - Enable expensive asserts.
121
- */
122
- constructor(runtime, id, writeFormat, summarizeHistory = false, expensiveValidation = false) {
109
+ constructor(runtime, id, writeFormat, options = {}) {
123
110
  super(id, runtime, SharedTreeFactory.Attributes);
124
111
  this.writeFormat = writeFormat;
125
- this.expensiveValidation = expensiveValidation;
126
- this.idCompressor = new id_compressor_1.IdCompressor(id_compressor_1.createSessionId(), persisted_types_1.reservedIdCount);
127
112
  this.idNormalizer = {
128
113
  tree: this,
129
114
  get localSessionId() {
@@ -166,8 +151,9 @@ class SharedTree extends shared_object_base_1.SharedObject {
166
151
  }
167
152
  }
168
153
  };
169
- this.summarizeHistory = summarizeHistory === false ? false : true;
170
- this.uploadEditChunks = summarizeHistory === false ? false : summarizeHistory.uploadEditChunks;
154
+ const historyPolicy = this.getHistoryPolicy(options);
155
+ this.summarizeHistory = historyPolicy.summarizeHistory;
156
+ this.uploadEditChunks = historyPolicy.uploadEditChunks;
171
157
  // This code is somewhat duplicated from OldestClientObserver because it currently depends on the container runtime
172
158
  // which SharedTree does not have access to.
173
159
  // TODO:#55900: Get rid of copy-pasted OldestClientObserver code
@@ -179,11 +165,12 @@ class SharedTree extends shared_object_base_1.SharedObject {
179
165
  runtime.on('disconnected', this.updateOldest);
180
166
  this.logger = telemetry_utils_1.ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);
181
167
  this.sequencedEditAppliedLogger = telemetry_utils_1.ChildLogger.create(this.logger, 'SequencedEditApplied', sharedTreeTelemetryProperties);
168
+ const attributionId = options.attributionId;
169
+ this.idCompressor = new id_compressor_1.IdCompressor((0, id_compressor_1.createSessionId)(), persisted_types_1.reservedIdCount, attributionId);
182
170
  const { editLog, cachingLogViewer } = this.initializeNewEditLogFromSummary({
183
171
  editChunks: [],
184
172
  editIds: [],
185
- }, undefined, this.idCompressor, // TODO: Attribution info
186
- this.processEditResult, this.processSequencedEditResult, persisted_types_1.WriteFormat.v0_1_1);
173
+ }, undefined, this.idCompressor, this.processEditResult, this.processSequencedEditResult, persisted_types_1.WriteFormat.v0_1_1);
187
174
  this.editLog = editLog;
188
175
  this.cachingLogViewer = cachingLogViewer;
189
176
  this.encoder_0_0_2 = new SharedTreeEncoder_1.SharedTreeEncoder_0_0_2(this.summarizeHistory);
@@ -195,31 +182,39 @@ class SharedTree extends shared_object_base_1.SharedObject {
195
182
  static create(runtime, id) {
196
183
  return runtime.createChannel(id, SharedTreeFactory.Type);
197
184
  }
198
- /**
199
- * Get a factory for SharedTree to register with the data store.
200
- * @param summarizeHistory - Determines if the history is included in summaries and if edit chunks are uploaded when they are full.
201
- *
202
- * On 0.1.1 documents, due to current code limitations, this parameter is only impactful for newly created documents.
203
- * `SharedTree`s which load existing documents will summarize history if and only if the loaded summary included history.
204
- *
205
- * The technical limitations here relate to clients with mixed versions collaborating.
206
- * In the future we may allow modification of whether or not a particular document saves history, but only via a consensus mechanism.
207
- * See the skipped test in SharedTreeFuzzTests.ts for more details on this issue.
208
- * See docs/Breaking-Change-Migration for more details on the consensus scheme.
209
- * @param writeFormat - Determines the format version the SharedTree will write ops and summaries in.
210
- * This format may be updated to a newer (supported) version at runtime if a collaborating shared-tree
211
- * that was initialized with a newer write version connects to the session. Care must be taken when changing this value,
212
- * as a staged rollout must of occurred such that all collaborating clients must have the code to read at least the version
213
- * written.
214
- * See [the write format documentation](../docs/Write-Format.md) for more information.
215
- * @returns A factory that creates `SharedTree`s and loads them from storage.
216
- */
217
- static getFactory(writeFormat, summarizeHistory = false) {
185
+ static getFactory(...args) {
186
+ const [writeFormat] = args;
218
187
  // On 0.1.1 documents, due to current code limitations, all clients MUST agree on the value of `summarizeHistory`.
219
188
  // Note that this means staged rollout changing this value should not be attempted.
220
189
  // It is possible to update shared-tree to correctly handle such a staged rollout, but that hasn't been implemented.
221
190
  // See the skipped test in SharedTreeFuzzTests.ts for more details on this issue.
222
- return new SharedTreeFactory(writeFormat, summarizeHistory);
191
+ switch (writeFormat) {
192
+ case persisted_types_1.WriteFormat.v0_0_2:
193
+ return new SharedTreeFactory(...args);
194
+ case persisted_types_1.WriteFormat.v0_1_1:
195
+ return new SharedTreeFactory(...args);
196
+ default:
197
+ (0, Common_1.fail)('Unknown write format');
198
+ }
199
+ }
200
+ /**
201
+ * The UUID used for attribution of nodes created by this SharedTree. All shared trees with a write format of 0.1.1 or
202
+ * greater have a unique attribution ID which may be configured in the constructor. All other shared trees (i.e. those
203
+ * with a write format of 0.0.2) use the nil UUID as their attribution ID.
204
+ * @public
205
+ */
206
+ get attributionId() {
207
+ switch (this.writeFormat) {
208
+ case persisted_types_1.WriteFormat.v0_0_2:
209
+ return UuidUtilities_1.nilUuid;
210
+ default: {
211
+ const { attributionId } = this.idCompressor;
212
+ if (attributionId === persisted_types_1.ghostSessionId) {
213
+ return UuidUtilities_1.nilUuid;
214
+ }
215
+ return attributionId;
216
+ }
217
+ }
223
218
  }
224
219
  /**
225
220
  * Viewer for trees defined by editLog. This allows access to views of the tree at different revisions (various points in time).
@@ -227,6 +222,27 @@ class SharedTree extends shared_object_base_1.SharedObject {
227
222
  get logViewer() {
228
223
  return this.cachingLogViewer;
229
224
  }
225
+ getHistoryPolicy(options) {
226
+ var _a;
227
+ const noCompatOptions = options;
228
+ if (typeof noCompatOptions.summarizeHistory === 'object') {
229
+ return {
230
+ summarizeHistory: true,
231
+ uploadEditChunks: noCompatOptions.summarizeHistory.uploadEditChunks,
232
+ };
233
+ }
234
+ else {
235
+ return {
236
+ summarizeHistory: (_a = noCompatOptions.summarizeHistory) !== null && _a !== void 0 ? _a : false,
237
+ uploadEditChunks: false,
238
+ };
239
+ }
240
+ }
241
+ /**
242
+ * The write format version currently used by this `SharedTree`. This is always initialized to the write format
243
+ * passed to the tree's constructor, but it may automatically upgrade over time (e.g. when connected to another
244
+ * SharedTree with a higher write format, or when loading a summary with a higher write format).
245
+ */
230
246
  getWriteFormat() {
231
247
  return this.writeFormat;
232
248
  }
@@ -243,7 +259,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
243
259
  if (!this.runtime.connected) {
244
260
  return false;
245
261
  }
246
- Common_1.assert(this.runtime.clientId !== undefined, 'Client id should be set if connected.');
262
+ (0, Common_1.assert)(this.runtime.clientId !== undefined, 'Client id should be set if connected.');
247
263
  const quorum = this.runtime.getQuorum();
248
264
  const selfSequencedClient = quorum.getMember(this.runtime.clientId);
249
265
  // When in readonly mode our clientId will not be present in the quorum.
@@ -289,7 +305,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
289
305
  */
290
306
  convertToStableNodeId(id) {
291
307
  var _a;
292
- return (_a = this.idCompressor.tryDecompress(id)) !== null && _a !== void 0 ? _a : Common_1.fail('Node id is not known to this SharedTree');
308
+ return (_a = this.idCompressor.tryDecompress(id)) !== null && _a !== void 0 ? _a : (0, Common_1.fail)('Node id is not known to this SharedTree');
293
309
  }
294
310
  /**
295
311
  * Given a NodeId, attempt to return the corresponding stable ID.
@@ -311,7 +327,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
311
327
  */
312
328
  convertToNodeId(id) {
313
329
  var _a;
314
- return ((_a = this.idCompressor.tryRecompress(id)) !== null && _a !== void 0 ? _a : Common_1.fail('Stable node id is not known to this SharedTree'));
330
+ return ((_a = this.idCompressor.tryRecompress(id)) !== null && _a !== void 0 ? _a : (0, Common_1.fail)('Stable node id is not known to this SharedTree'));
315
331
  }
316
332
  /**
317
333
  * Given a stable ID, return the corresponding NodeId or return undefined if the supplied stable ID was never generated with this tree,
@@ -323,6 +339,25 @@ class SharedTree extends shared_object_base_1.SharedObject {
323
339
  tryConvertToNodeId(id) {
324
340
  return this.idCompressor.tryRecompress(id);
325
341
  }
342
+ /**
343
+ * Returns the attribution ID associated with the SharedTree that generated the given node ID. This is generally only useful for clients
344
+ * with a write format of 0.1.1 or greater since older clients cannot be given an attribution ID and will always use the default
345
+ * `attributionId` of the tree.
346
+ * @public
347
+ */
348
+ attributeNodeId(id) {
349
+ switch (this.writeFormat) {
350
+ case persisted_types_1.WriteFormat.v0_0_2:
351
+ return UuidUtilities_1.nilUuid;
352
+ default: {
353
+ const attributionId = this.idCompressor.attributeId(id);
354
+ if (attributionId === persisted_types_1.ghostSessionId) {
355
+ return UuidUtilities_1.nilUuid;
356
+ }
357
+ return attributionId;
358
+ }
359
+ }
360
+ }
326
361
  /**
327
362
  * @returns the edit history of the tree.
328
363
  * @public
@@ -332,28 +367,33 @@ class SharedTree extends shared_object_base_1.SharedObject {
332
367
  }
333
368
  deserializeHandle(serializedHandle) {
334
369
  const deserializeHandle = this.serializer.parse(serializedHandle);
335
- Common_1.assert(typeof deserializeHandle === 'object');
370
+ (0, Common_1.assert)(typeof deserializeHandle === 'object');
336
371
  return deserializeHandle;
337
372
  }
338
373
  /**
339
- * Uploads the edit chunk and sends the chunk starting revision along with the resulting handle as an op.
374
+ * Uploads the edit chunk and submits a `SharedTreeHandleOp`.
375
+ * This method is fire-and-forget and will swallow any errors that occur during upload or the `onUploadComplete` hook.
376
+ * If the upload or op submission does fail then a future client will attempt the submission instead.
340
377
  */
341
- async uploadEditChunk(edits, startRevision) {
378
+ uploadEditChunk(edits, startRevision, onUploadComplete) {
379
+ this.uploadEditChunkAsync(edits, startRevision).then(onUploadComplete).catch(Common_1.noop);
380
+ }
381
+ async uploadEditChunkAsync(edits, startRevision) {
342
382
  var _a;
343
- Common_1.assert(this.writeFormat !== persisted_types_1.WriteFormat.v0_0_2, 'Edit chunking is not supported in v0_0_2');
383
+ (0, Common_1.assert)(this.writeFormat !== persisted_types_1.WriteFormat.v0_0_2, 'Edit chunking is not supported in v0_0_2');
344
384
  // SPO attachment blob upload limit is set here:
345
385
  // https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=%2Fsts%2Fstsom%2FPrague%2FSPPragueProtocolConfig.cs&version=GBmaster&line=82&lineEnd=82&lineStartColumn=29&lineEndColumn=116&lineStyle=plain&_a=contents
346
386
  // TODO:#59754: Create chunks based on data buffer size instead of number of edits
347
387
  const blobUploadSizeLimit = 4194304;
348
388
  try {
349
- const chunkContents = this.encoder_0_1_1.encodeEditChunk(edits, NodeIdUtilities_1.sequencedIdNormalizer(this.idNormalizer), this.interner);
350
- const serializedContents = shared_object_base_1.serializeHandles(chunkContents, this.serializer, this.handle);
389
+ const chunkContents = this.encoder_0_1_1.encodeEditChunk(edits, (0, NodeIdUtilities_1.sequencedIdNormalizer)(this.idNormalizer), this.interner);
390
+ const serializedContents = (0, shared_object_base_1.serializeHandles)(chunkContents, this.serializer, this.handle);
351
391
  const buffer = common_utils_1.IsoBuffer.from(serializedContents);
352
392
  const bufferSize = buffer.byteLength;
353
- Common_1.assert(bufferSize <= blobUploadSizeLimit, `Edit chunk size ${bufferSize} is larger than blob upload size limit of ${blobUploadSizeLimit} bytes.`);
393
+ (0, Common_1.assert)(bufferSize <= blobUploadSizeLimit, `Edit chunk size ${bufferSize} is larger than blob upload size limit of ${blobUploadSizeLimit} bytes.`);
354
394
  const editHandle = await this.runtime.uploadBlob(buffer);
355
395
  const handleOp = {
356
- editHandle: (_a = shared_object_base_1.serializeHandles(editHandle, this.serializer, this.handle)) !== null && _a !== void 0 ? _a : Common_1.fail('Edit chunk handle could not be serialized.'),
396
+ editHandle: (_a = (0, shared_object_base_1.serializeHandles)(editHandle, this.serializer, this.handle)) !== null && _a !== void 0 ? _a : (0, Common_1.fail)('Edit chunk handle could not be serialized.'),
357
397
  startRevision,
358
398
  type: persisted_types_1.SharedTreeOpType.Handle,
359
399
  version: this.writeFormat,
@@ -372,7 +412,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
372
412
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
373
413
  */
374
414
  summarizeCore(serializer) {
375
- return shared_object_base_1.createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));
415
+ return (0, shared_object_base_1.createSingleBlobSummary)(snapshotFileName, this.saveSerializedSummary({ serializer }));
376
416
  }
377
417
  /**
378
418
  * Saves this SharedTree into a serialized summary. This is used for testing.
@@ -382,7 +422,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
382
422
  */
383
423
  saveSerializedSummary(options) {
384
424
  const { serializer } = options || {};
385
- return Summary_1.serialize(this.saveSummary(), serializer !== null && serializer !== void 0 ? serializer : this.serializer, this.handle);
425
+ return (0, Summary_1.serialize)(this.saveSummary(), serializer !== null && serializer !== void 0 ? serializer : this.serializer, this.handle);
386
426
  }
387
427
  /**
388
428
  * Initialize shared tree with a serialized summary. This is used for testing.
@@ -390,9 +430,9 @@ class SharedTree extends shared_object_base_1.SharedObject {
390
430
  * @internal
391
431
  */
392
432
  loadSerializedSummary(blobData) {
393
- const summary = SummaryBackCompatibility_1.deserialize(blobData, this.serializer);
433
+ const summary = (0, SummaryBackCompatibility_1.deserialize)(blobData, this.serializer);
394
434
  this.loadSummary(summary);
395
- return SummaryBackCompatibility_1.getSummaryStatistics(summary);
435
+ return (0, SummaryBackCompatibility_1.getSummaryStatistics)(summary);
396
436
  }
397
437
  /**
398
438
  * Saves this SharedTree into a deserialized summary.
@@ -405,7 +445,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
405
445
  // ever invoked on a DataObject containing local changes when it is attached for the first time. In post-attach flows, an extra
406
446
  // instance of the DataObject is created for generating summaries and will never have local edits.
407
447
  if (this.editLog.numberOfLocalEdits > 0) {
408
- Common_1.assert(this.runtime.attachState !== container_definitions_1.AttachState.Attached, 'Summarizing should not occur with local edits except on first attach.');
448
+ (0, Common_1.assert)(this.runtime.attachState !== container_definitions_1.AttachState.Attached, 'Summarizing should not occur with local edits except on first attach.');
409
449
  if (this.writeFormat === persisted_types_1.WriteFormat.v0_1_1) {
410
450
  // Since we're the first client to attach, we can safely finalize ourselves since we're the only ones who have made IDs.
411
451
  this.idCompressor.finalizeCreationRange(this.idCompressor.takeNextCreationRange());
@@ -415,7 +455,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
415
455
  }
416
456
  this.editLog.sequenceLocalEdits();
417
457
  }
418
- Common_1.assert(this.editLog.numberOfLocalEdits === 0, 'generateSummary must not be called with local edits');
458
+ (0, Common_1.assert)(this.editLog.numberOfLocalEdits === 0, 'generateSummary must not be called with local edits');
419
459
  return this.generateSummary();
420
460
  }
421
461
  /**
@@ -431,7 +471,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
431
471
  case persisted_types_1.WriteFormat.v0_1_1:
432
472
  return this.encoder_0_1_1.encodeSummary(this.editLog, this.currentView, this, this.idNormalizer, this.interner, this.idCompressor.serialize(false));
433
473
  default:
434
- Common_1.fail('Unknown version');
474
+ (0, Common_1.fail)('Unknown version');
435
475
  }
436
476
  }
437
477
  catch (error) {
@@ -460,11 +500,11 @@ class SharedTree extends shared_object_base_1.SharedObject {
460
500
  // Write whatever format the loaded summary uses (this is the current agreed-upon format: it may be updated by an update op)
461
501
  this.changeWriteFormat(loadedSummaryVersion);
462
502
  }
463
- Common_1.assert(this.idCompressor.getAllIdsFromLocalSession().next().done === true, 'Summary load should not be executed after local state is created.');
503
+ (0, Common_1.assert)(this.idCompressor.getAllIdsFromLocalSession().next().done === true, 'Summary load should not be executed after local state is created.');
464
504
  let convertedSummary;
465
505
  switch (loadedSummaryVersion) {
466
506
  case persisted_types_1.WriteFormat.v0_0_2:
467
- convertedSummary = this.encoder_0_0_2.decodeSummary(summary);
507
+ convertedSummary = this.encoder_0_0_2.decodeSummary(summary, this.attributionId);
468
508
  break;
469
509
  case persisted_types_1.WriteFormat.v0_1_1: {
470
510
  const typedSummary = summary;
@@ -475,11 +515,11 @@ class SharedTree extends shared_object_base_1.SharedObject {
475
515
  this.uploadEditChunks = loadedSummaryIncludesHistory;
476
516
  this.encoder_0_1_1 = new SharedTreeEncoder_1.SharedTreeEncoder_0_1_1(this.summarizeHistory);
477
517
  }
478
- convertedSummary = this.encoder_0_1_1.decodeSummary(summary);
518
+ convertedSummary = this.encoder_0_1_1.decodeSummary(summary, this.attributionId);
479
519
  break;
480
520
  }
481
521
  default:
482
- Common_1.fail('Unknown version');
522
+ (0, Common_1.fail)('Unknown version');
483
523
  }
484
524
  const { editHistory, currentTree, idCompressor, interner } = convertedSummary;
485
525
  this.interner = interner;
@@ -491,7 +531,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
491
531
  formatVersion: persisted_types_1.WriteFormat.v0_1_1,
492
532
  historySize: editIds.length,
493
533
  totalNumberOfChunks: editChunks.length,
494
- uploadedChunks: EditLog_1.getNumberOfHandlesFromEditLogSummary(editHistory),
534
+ uploadedChunks: (0, EditLog_1.getNumberOfHandlesFromEditLogSummary)(editHistory),
495
535
  });
496
536
  }
497
537
  this.initializeNewEditLogFromSummary(editHistory, currentTree, idCompressor, this.processEditResult, this.processSequencedEditResult, summary.version);
@@ -556,7 +596,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
556
596
  // TODO:#47830: Store multiple checkpoints in summary.
557
597
  knownRevisions = [[editLog.length, { view: currentView }]];
558
598
  }
559
- const logViewer = new LogViewer_1.CachingLogViewer(editLog, RevisionView_1.RevisionView.fromTree(InitialTree_1.initialTree, this), knownRevisions, this.expensiveValidation, editStatusCallback, sequencedEditResultCallback, 0);
599
+ const logViewer = new LogViewer_1.CachingLogViewer(editLog, RevisionView_1.RevisionView.fromTree(InitialTree_1.initialTree, this), knownRevisions, editStatusCallback, sequencedEditResultCallback, 0);
560
600
  this.editLog = editLog;
561
601
  this.cachingLogViewer = logViewer;
562
602
  return { editLog, cachingLogViewer: logViewer };
@@ -567,14 +607,10 @@ class SharedTree extends shared_object_base_1.SharedObject {
567
607
  uploadCatchUpBlobs() {
568
608
  if (this.writeFormat !== persisted_types_1.WriteFormat.v0_0_2 && this.uploadEditChunks) {
569
609
  for (const [startRevision, chunk] of this.editLog.getEditChunksReadyForUpload()) {
570
- this.uploadEditChunk(chunk, startRevision)
571
- .then(() => {
610
+ this.uploadEditChunk(chunk, startRevision, () => {
572
611
  this.emit(EventTypes_1.SharedTreeDiagnosticEvent.CatchUpBlobUploaded);
573
612
  this.logger.sendTelemetryEvent({ eventName: 'CatchUpBlobUpload', chunkSize: chunk.length });
574
- })
575
- // It is safe to swallow errors from edit chunk upload because the next summary load will
576
- // do another attempt to upload the edit chunks that couldn't previously be uploaded
577
- .catch((error) => { });
613
+ });
578
614
  }
579
615
  }
580
616
  }
@@ -593,7 +629,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
593
629
  * @internal
594
630
  * */
595
631
  equals(sharedTree) {
596
- if (!EditUtilities_1.areRevisionViewsSemanticallyEqual(this.currentView, this, sharedTree.currentView, sharedTree)) {
632
+ if (!(0, EditUtilities_1.areRevisionViewsSemanticallyEqual)(this.currentView, this, sharedTree.currentView, sharedTree)) {
597
633
  return false;
598
634
  }
599
635
  return this.editLog.equals(sharedTree.editLog);
@@ -605,7 +641,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
605
641
  const summaryLoadPerformanceEvent = telemetry_utils_1.PerformanceEvent.start(this.logger, { eventName: 'SummaryLoad' });
606
642
  try {
607
643
  const newBlob = await storage.readBlob(snapshotFileName);
608
- const blobData = common_utils_1.bufferToString(newBlob, 'utf8');
644
+ const blobData = (0, common_utils_1.bufferToString)(newBlob, 'utf8');
609
645
  const stats = this.loadSerializedSummary(blobData);
610
646
  summaryLoadPerformanceEvent.end(stats);
611
647
  }
@@ -634,7 +670,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
634
670
  get: async () => {
635
671
  const contents = await baseHandle.get();
636
672
  const parsedContents = JSON.parse(common_utils_1.IsoBuffer.from(contents).toString());
637
- return this.encoder_0_1_1.decodeEditChunk(parsedContents, NodeIdUtilities_1.sequencedIdNormalizer(this.idNormalizer), this.interner);
673
+ return this.encoder_0_1_1.decodeEditChunk(parsedContents, (0, NodeIdUtilities_1.sequencedIdNormalizer)(this.idNormalizer), this.interner);
638
674
  },
639
675
  baseHandle,
640
676
  };
@@ -642,10 +678,8 @@ class SharedTree extends shared_object_base_1.SharedObject {
642
678
  }
643
679
  else if (type === persisted_types_1.SharedTreeOpType.Edit) {
644
680
  if (op.version === persisted_types_1.WriteFormat.v0_1_1) {
645
- // TODO: This cast can be removed on typescript 4.6
646
681
  this.idCompressor.finalizeCreationRange(op.idRange);
647
682
  }
648
- // TODO: This cast can be removed on typescript 4.6
649
683
  const edit = this.parseSequencedEdit(op);
650
684
  if (op.version === persisted_types_1.WriteFormat.v0_1_1) {
651
685
  this.internStringsFromEdit(edit);
@@ -663,7 +697,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
663
697
  this.logger.sendErrorEvent({
664
698
  eventName: 'UnexpectedNewerOpVersion',
665
699
  }, error);
666
- Common_1.fail(error);
700
+ (0, Common_1.fail)(error);
667
701
  }
668
702
  }
669
703
  /**
@@ -689,7 +723,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
689
723
  case persisted_types_1.WriteFormat.v0_1_1:
690
724
  return this.encoder_0_1_1.decodeEditOp(op, this.encodeSemiSerializedEdit.bind(this), this.idNormalizer, this.interner);
691
725
  default:
692
- Common_1.fail('Unknown op version');
726
+ (0, Common_1.fail)('Unknown op version');
693
727
  }
694
728
  }
695
729
  encodeSemiSerializedEdit(semiSerializedEdit) {
@@ -719,18 +753,14 @@ class SharedTree extends shared_object_base_1.SharedObject {
719
753
  const lastPair = this.editLog.getLastEditChunk();
720
754
  if (lastPair !== undefined) {
721
755
  const [startRevision, chunk] = lastPair;
722
- const edits = Common_1.assertNotUndefined(chunk.edits);
756
+ const edits = (0, Common_1.assertNotUndefined)(chunk.edits);
723
757
  if (edits.length === this.editLog.editsPerChunk) {
724
- this.uploadEditChunk(edits, startRevision)
725
- .then(() => {
758
+ this.uploadEditChunk(edits, startRevision, () => {
726
759
  this.logger.sendTelemetryEvent({
727
760
  eventName: 'EditChunkUpload',
728
761
  chunkSize: edits.length,
729
762
  });
730
- })
731
- // It is safe to swallow errors from edit chunk upload because the next summary load will
732
- // do another attempt to upload the edit chunks that couldn't previously be uploaded
733
- .catch((error) => { });
763
+ });
734
764
  }
735
765
  }
736
766
  }
@@ -773,8 +803,8 @@ class SharedTree extends shared_object_base_1.SharedObject {
773
803
  this.interner = new StringInterner_1.MutableStringInterner([InitialTree_1.initialTree.definition]);
774
804
  const oldIdCompressor = this.idCompressor;
775
805
  // Create the IdCompressor that will be used after the upgrade
776
- const newIdCompressor = new id_compressor_1.IdCompressor(id_compressor_1.createSessionId(), persisted_types_1.reservedIdCount); // TODO: attribution info
777
- const newContext = NodeIdUtilities_1.getNodeIdContext(newIdCompressor);
806
+ const newIdCompressor = new id_compressor_1.IdCompressor((0, id_compressor_1.createSessionId)(), persisted_types_1.reservedIdCount, this.attributionId);
807
+ const newContext = (0, NodeIdUtilities_1.getNodeIdContext)(newIdCompressor);
778
808
  // Generate all local IDs in the new compressor that were in the old compressor and preserve their UUIDs.
779
809
  // This will allow the client to continue to use local IDs that were allocated pre-upgrade
780
810
  for (const localId of oldIdCompressor.getAllIdsFromLocalSession()) {
@@ -783,12 +813,12 @@ class SharedTree extends shared_object_base_1.SharedObject {
783
813
  const unifyHistoricalIds = (context) => {
784
814
  for (let i = 0; i < this.editLog.numberOfSequencedEdits; i++) {
785
815
  const edit = this.editLog.getEditInSessionAtIndex(i);
786
- IdConversion_1.convertEditIds(edit, (id) => context.generateNodeId(this.convertToStableNodeId(id)));
816
+ (0, IdConversion_1.convertEditIds)(edit, (id) => context.generateNodeId(this.convertToStableNodeId(id)));
787
817
  }
788
818
  };
789
819
  // Construct a temporary "ghost" compressor which is used to generate final IDs that will be consistent across all upgrading clients
790
- const ghostIdCompressor = new id_compressor_1.IdCompressor(persisted_types_1.ghostSessionId, persisted_types_1.reservedIdCount); // TODO: attribution info
791
- const ghostContext = NodeIdUtilities_1.getNodeIdContext(ghostIdCompressor);
820
+ const ghostIdCompressor = new id_compressor_1.IdCompressor(persisted_types_1.ghostSessionId, persisted_types_1.reservedIdCount);
821
+ const ghostContext = (0, NodeIdUtilities_1.getNodeIdContext)(ghostIdCompressor);
792
822
  if (this.summarizeHistory) {
793
823
  // All clients have the full history, and can therefore all "generate" the same final IDs for every ID in the history
794
824
  // via the ghost compressor.
@@ -818,7 +848,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
818
848
  }
819
849
  applyEdit(headOrChanges, ...tail) {
820
850
  const changes = Array.isArray(headOrChanges) ? headOrChanges : [headOrChanges, ...tail];
821
- const id = EditUtilities_1.newEditId();
851
+ const id = (0, EditUtilities_1.newEditId)();
822
852
  const internalEdit = {
823
853
  id,
824
854
  changes: changes.map((c) => this.internalizeChange(c)),
@@ -844,7 +874,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
844
874
  const convertedStableId = (_a = stableIdRemapper === null || stableIdRemapper === void 0 ? void 0 : stableIdRemapper(stableId)) !== null && _a !== void 0 ? _a : stableId;
845
875
  return this.generateNodeId(convertedStableId);
846
876
  };
847
- return Array.from(edits, (edit) => this.applyEditInternal(IdConversion_1.convertEditIds(edit, (id) => idConverter(id))).id);
877
+ return Array.from(edits, (edit) => this.applyEditInternal((0, IdConversion_1.convertEditIds)(edit, (id) => idConverter(id))).id);
848
878
  }
849
879
  /**
850
880
  * Applies a set of internal changes to this tree. The result will be reflected in `SharedTree.currentView`.
@@ -856,7 +886,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
856
886
  applyEditInternal(editOrChanges) {
857
887
  let edit;
858
888
  if (Array.isArray(editOrChanges)) {
859
- const id = EditUtilities_1.newEditId();
889
+ const id = (0, EditUtilities_1.newEditId)();
860
890
  edit = { id, changes: editOrChanges };
861
891
  }
862
892
  else {
@@ -876,20 +906,20 @@ class SharedTree extends shared_object_base_1.SharedObject {
876
906
  case ChangeTypes_1.ChangeType.Insert:
877
907
  return {
878
908
  source: change.source,
879
- destination: EditUtilities_1.deepCloneStablePlace(change.destination),
909
+ destination: (0, EditUtilities_1.deepCloneStablePlace)(change.destination),
880
910
  type: persisted_types_1.ChangeTypeInternal.Insert,
881
911
  };
882
912
  case ChangeTypes_1.ChangeType.Detach: {
883
913
  const detach = {
884
- source: EditUtilities_1.deepCloneStableRange(change.source),
914
+ source: (0, EditUtilities_1.deepCloneStableRange)(change.source),
885
915
  type: persisted_types_1.ChangeTypeInternal.Detach,
886
916
  };
887
- Common_1.copyPropertyIfDefined(change, detach, 'destination');
917
+ (0, Common_1.copyPropertyIfDefined)(change, detach, 'destination');
888
918
  return detach;
889
919
  }
890
920
  case ChangeTypes_1.ChangeType.Build: {
891
921
  if (isTreeNodeSequence(change.source)) {
892
- const source = change.source.map((buildNode) => EditUtilities_1.convertTreeNodes(buildNode, (nodeData) => EditUtilities_1.internalizeBuildNode(nodeData, this), (x) => typeof x === 'number'));
922
+ const source = change.source.map((buildNode) => (0, EditUtilities_1.convertTreeNodes)(buildNode, (nodeData) => (0, EditUtilities_1.internalizeBuildNode)(nodeData, this), (x) => typeof x === 'number'));
893
923
  return {
894
924
  source,
895
925
  destination: change.destination,
@@ -897,7 +927,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
897
927
  };
898
928
  }
899
929
  else {
900
- const source = EditUtilities_1.convertTreeNodes(change.source, (nodeData) => EditUtilities_1.internalizeBuildNode(nodeData, this), (x) => typeof x === 'number');
930
+ const source = (0, EditUtilities_1.convertTreeNodes)(change.source, (nodeData) => (0, EditUtilities_1.internalizeBuildNode)(nodeData, this), (x) => typeof x === 'number');
901
931
  return {
902
932
  source: [source],
903
933
  destination: change.destination,
@@ -917,21 +947,20 @@ class SharedTree extends shared_object_base_1.SharedObject {
917
947
  toConstrain: change.toConstrain,
918
948
  type: persisted_types_1.ChangeTypeInternal.Constraint,
919
949
  };
920
- Common_1.copyPropertyIfDefined(change, constraint, 'contentHash');
921
- Common_1.copyPropertyIfDefined(change, constraint, 'identityHash');
922
- Common_1.copyPropertyIfDefined(change, constraint, 'label');
923
- Common_1.copyPropertyIfDefined(change, constraint, 'length');
924
- Common_1.copyPropertyIfDefined(change, constraint, 'parentNode');
950
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'contentHash');
951
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'identityHash');
952
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'label');
953
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'length');
954
+ (0, Common_1.copyPropertyIfDefined)(change, constraint, 'parentNode');
925
955
  return constraint;
926
956
  }
927
957
  default:
928
- Common_1.fail('unexpected change type');
958
+ (0, Common_1.fail)('unexpected change type');
929
959
  }
930
960
  }
931
961
  applyEditLocally(edit, message) {
932
962
  const isSequenced = message !== undefined;
933
963
  if (isSequenced) {
934
- // TODO: This cast can be removed on typescript 4.6
935
964
  this.editLog.addSequencedEdit(edit, message);
936
965
  }
937
966
  else {
@@ -968,7 +997,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
968
997
  * @internal
969
998
  */
970
999
  revertChanges(changes, before) {
971
- return HistoryEditFactory_1.revert(changes, before);
1000
+ return (0, HistoryEditFactory_1.revert)(changes, before);
972
1001
  }
973
1002
  /**
974
1003
  * Submits an edit by the local client to the runtime.
@@ -985,7 +1014,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
985
1014
  this.submitOp(this.encoder_0_1_1.encodeEditOp(edit, this.serializeEdit.bind(this), this.idCompressor.takeNextCreationRange(), this.idNormalizer, this.interner));
986
1015
  break;
987
1016
  default:
988
- Common_1.fail('Unknown version');
1017
+ (0, Common_1.fail)('Unknown version');
989
1018
  }
990
1019
  }
991
1020
  }
@@ -994,7 +1023,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
994
1023
  }
995
1024
  /** A type-safe `submitLocalMessage` wrapper to enforce op format */
996
1025
  submitOp(content, localOpMetadata = undefined) {
997
- Common_1.assert(compareSummaryFormatVersions(content.version, this.writeFormat) === 0, 'Attempted to submit op of wrong version');
1026
+ (0, Common_1.assert)(compareSummaryFormatVersions(content.version, this.writeFormat) === 0, 'Attempted to submit op of wrong version');
998
1027
  this.submitLocalMessage(content, localOpMetadata);
999
1028
  }
1000
1029
  getRuntime() {
@@ -1024,24 +1053,24 @@ class SharedTree extends shared_object_base_1.SharedObject {
1024
1053
  }
1025
1054
  case persisted_types_1.WriteFormat.v0_1_1:
1026
1055
  // TODO:#74390: Implement
1027
- Common_1.fail('Received stashed op 0.1.1 before upgrade');
1056
+ (0, Common_1.fail)('Received stashed op 0.1.1 before upgrade');
1028
1057
  default:
1029
- Common_1.fail('Unknown version');
1058
+ (0, Common_1.fail)('Unknown version');
1030
1059
  }
1031
1060
  break;
1032
1061
  case persisted_types_1.WriteFormat.v0_1_1:
1033
1062
  switch (sharedTreeOp.version) {
1034
1063
  case persisted_types_1.WriteFormat.v0_0_2:
1035
1064
  // TODO:#74390: Implement
1036
- Common_1.fail('v0.1.1 does not support stashed ops.');
1065
+ (0, Common_1.fail)('v0.1.1 does not support stashed ops.');
1037
1066
  case persisted_types_1.WriteFormat.v0_1_1:
1038
1067
  // TODO:#74390: Implement
1039
- Common_1.fail('v0.1.1 does not support stashed ops.');
1068
+ (0, Common_1.fail)('v0.1.1 does not support stashed ops.');
1040
1069
  default:
1041
- Common_1.fail('Unknown version');
1070
+ (0, Common_1.fail)('Unknown version');
1042
1071
  }
1043
1072
  default:
1044
- Common_1.fail('Unknown version');
1073
+ (0, Common_1.fail)('Unknown version');
1045
1074
  }
1046
1075
  break;
1047
1076
  }
@@ -1051,7 +1080,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
1051
1080
  case persisted_types_1.SharedTreeOpType.NoOp:
1052
1081
  break;
1053
1082
  default:
1054
- Common_1.fail('Unrecognized op');
1083
+ (0, Common_1.fail)('Unrecognized op');
1055
1084
  }
1056
1085
  }
1057
1086
  changeWriteFormat(newFormat) {
@@ -1067,7 +1096,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
1067
1096
  for (const change of edit.changes) {
1068
1097
  if (change.type === persisted_types_1.ChangeTypeInternal.Build) {
1069
1098
  for (const root of change.source) {
1070
- EditUtilities_1.walkTree(root, (node) => {
1099
+ (0, EditUtilities_1.walkTree)(root, (node) => {
1071
1100
  this.interner.getOrCreateInternedId(node.definition);
1072
1101
  for (const trait of Object.keys(node.traits)) {
1073
1102
  this.interner.getOrCreateInternedId(trait);
@@ -1093,7 +1122,7 @@ function compareSummaryFormatVersions(versionA, versionB) {
1093
1122
  const versionAIndex = sortedWriteVersions.indexOf(versionA);
1094
1123
  const versionBIndex = sortedWriteVersions.indexOf(versionB);
1095
1124
  if (versionAIndex === -1 || versionBIndex === -1) {
1096
- Common_1.fail('Summary version being compared cannot be read.');
1125
+ (0, Common_1.fail)('Summary version being compared cannot be read.');
1097
1126
  }
1098
1127
  if (versionAIndex < versionBIndex) {
1099
1128
  return -1;
@@ -1111,7 +1140,7 @@ function compareSummaryFormatVersions(versionA, versionB) {
1111
1140
  function isUpdateRequired(oldVersion, newVersion) {
1112
1141
  const newVersionIndex = sortedWriteVersions.indexOf(newVersion);
1113
1142
  if (newVersionIndex === -1) {
1114
- Common_1.fail('New write version is invalid.');
1143
+ (0, Common_1.fail)('New write version is invalid.');
1115
1144
  }
1116
1145
  return compareSummaryFormatVersions(oldVersion, newVersion) === -1 ? true : false;
1117
1146
  }