@fluid-experimental/tree 1.2.7 → 2.0.0-dev.1.3.0.96595
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.
- package/.mocharc.js +12 -0
- package/.prettierignore +6 -0
- package/README.md +1 -1
- package/dist/Checkout.d.ts +9 -4
- package/dist/Checkout.d.ts.map +1 -1
- package/dist/Checkout.js +34 -25
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +31 -18
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +33 -22
- package/dist/Common.js.map +1 -1
- package/dist/EditLog.js +2 -2
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.d.ts +5 -0
- package/dist/EditUtilities.d.ts.map +1 -1
- package/dist/EditUtilities.js +4 -3
- package/dist/EditUtilities.js.map +1 -1
- package/dist/EventTypes.d.ts +11 -6
- package/dist/EventTypes.d.ts.map +1 -1
- package/dist/EventTypes.js +11 -6
- package/dist/EventTypes.js.map +1 -1
- package/dist/HistoryEditFactory.d.ts +5 -3
- package/dist/HistoryEditFactory.d.ts.map +1 -1
- package/dist/HistoryEditFactory.js +25 -6
- package/dist/HistoryEditFactory.js.map +1 -1
- package/dist/LogViewer.d.ts +12 -6
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js.map +1 -1
- package/dist/RevisionValueCache.d.ts +8 -4
- package/dist/RevisionValueCache.d.ts.map +1 -1
- package/dist/RevisionValueCache.js +4 -2
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/SharedTree.d.ts +22 -11
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +25 -19
- package/dist/SharedTree.js.map +1 -1
- package/dist/StringInterner.d.ts +4 -3
- package/dist/StringInterner.d.ts.map +1 -1
- package/dist/StringInterner.js +4 -3
- package/dist/StringInterner.js.map +1 -1
- package/dist/Transaction.d.ts +2 -2
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +3 -2
- package/dist/Transaction.js.map +1 -1
- package/dist/TransactionInternal.d.ts.map +1 -1
- package/dist/TransactionInternal.js +1 -0
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts +14 -8
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +14 -8
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/NumericUuid.d.ts +4 -0
- package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
- package/dist/id-compressor/NumericUuid.js +13 -3
- package/dist/id-compressor/NumericUuid.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.d.ts +8 -3
- package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.js +8 -3
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/lib/Checkout.d.ts +9 -4
- package/lib/Checkout.d.ts.map +1 -1
- package/lib/Checkout.js +36 -27
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +31 -18
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +31 -21
- package/lib/Common.js.map +1 -1
- package/lib/EditLog.js +2 -2
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.d.ts +5 -0
- package/lib/EditUtilities.d.ts.map +1 -1
- package/lib/EditUtilities.js +4 -3
- package/lib/EditUtilities.js.map +1 -1
- package/lib/EventTypes.d.ts +11 -6
- package/lib/EventTypes.d.ts.map +1 -1
- package/lib/EventTypes.js +11 -6
- package/lib/EventTypes.js.map +1 -1
- package/lib/HistoryEditFactory.d.ts +5 -3
- package/lib/HistoryEditFactory.d.ts.map +1 -1
- package/lib/HistoryEditFactory.js +25 -6
- package/lib/HistoryEditFactory.js.map +1 -1
- package/lib/LogViewer.d.ts +12 -6
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js.map +1 -1
- package/lib/RevisionValueCache.d.ts +8 -4
- package/lib/RevisionValueCache.d.ts.map +1 -1
- package/lib/RevisionValueCache.js +4 -2
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/SharedTree.d.ts +22 -11
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +26 -20
- package/lib/SharedTree.js.map +1 -1
- package/lib/StringInterner.d.ts +4 -3
- package/lib/StringInterner.d.ts.map +1 -1
- package/lib/StringInterner.js +4 -3
- package/lib/StringInterner.js.map +1 -1
- package/lib/Transaction.d.ts +2 -2
- package/lib/Transaction.d.ts.map +1 -1
- package/lib/Transaction.js +3 -2
- package/lib/Transaction.js.map +1 -1
- package/lib/TransactionInternal.d.ts.map +1 -1
- package/lib/TransactionInternal.js +1 -0
- package/lib/TransactionInternal.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts +14 -8
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +14 -8
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/NumericUuid.d.ts +4 -0
- package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
- package/lib/id-compressor/NumericUuid.js +13 -3
- package/lib/id-compressor/NumericUuid.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.d.ts +8 -3
- package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.js +8 -3
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -1
- package/lib/test/Checkout.tests.d.ts.map +1 -1
- package/lib/test/Checkout.tests.js +39 -10
- package/lib/test/Checkout.tests.js.map +1 -1
- package/lib/test/Common.tests.js +20 -1
- package/lib/test/Common.tests.js.map +1 -1
- package/lib/test/HistoryEditFactory.tests.js +48 -9
- package/lib/test/HistoryEditFactory.tests.js.map +1 -1
- package/lib/test/SessionIdNormalizer.tests.js +3 -2
- package/lib/test/SessionIdNormalizer.tests.js.map +1 -1
- package/lib/test/fuzz/Generators.d.ts.map +1 -1
- package/lib/test/fuzz/Generators.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +2 -3
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/utilities/MockTransaction.d.ts.map +1 -1
- package/lib/test/utilities/MockTransaction.js +1 -0
- package/lib/test/utilities/MockTransaction.js.map +1 -1
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +35 -26
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js +7 -0
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts +5 -0
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +4 -3
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/lib/test/utilities/UndoRedoTests.js +3 -2
- package/lib/test/utilities/UndoRedoTests.js.map +1 -1
- package/package.json +28 -23
- package/src/Checkout.ts +56 -14
- package/src/Common.ts +39 -21
- package/src/EditLog.ts +2 -2
- package/src/EditUtilities.ts +3 -3
- package/src/EventTypes.ts +12 -6
- package/src/HistoryEditFactory.ts +31 -6
- package/src/LogViewer.ts +12 -6
- package/src/RevisionValueCache.ts +8 -4
- package/src/SharedTree.ts +39 -26
- package/src/StringInterner.ts +4 -3
- package/src/Transaction.ts +5 -4
- package/src/TransactionInternal.ts +1 -0
- package/src/id-compressor/IdCompressor.ts +27 -17
- package/src/id-compressor/NumericUuid.ts +17 -3
- package/src/id-compressor/SessionIdNormalizer.ts +8 -3
- package/src/id-compressor/persisted-types/0.0.1.ts +1 -0
- package/src/index.ts +1 -1
package/.mocharc.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const getFluidTestMochaConfig = require('@fluidframework/mocha-test-setup/mocharc-common');
|
|
9
|
+
|
|
10
|
+
const packageDir = __dirname;
|
|
11
|
+
const config = getFluidTestMochaConfig(packageDir);
|
|
12
|
+
module.exports = config;
|
package/.prettierignore
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# Common ignore patterns for packages using prettier.
|
|
2
|
+
# This can be referenced by using the `--ignore-path` cli argument and providing the relative path to this file.
|
|
3
|
+
# If your package requires other local exceptions, you can specify a local `.prettierignore` file with the appropriate
|
|
4
|
+
# settings, and not specify the `--ignore-path` argument in the formatting scripts.
|
|
5
|
+
# Note that you will (unfortunately) have to redundantly specify the below as applicable in that file.
|
|
6
|
+
|
|
1
7
|
# Coverage
|
|
2
8
|
nyc
|
|
3
9
|
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ The definition of a node conveys the node's semantic meaning. It is typically us
|
|
|
33
33
|
|
|
34
34
|
### Identifier
|
|
35
35
|
|
|
36
|
-
A node's identifier is a unique key associated with that node. The identifier can be used to retrieve a node from
|
|
36
|
+
A node's identifier is a unique key associated with that node. The identifier can be used to retrieve a node from the current view of a SharedTree, and provides a way to refer to existing nodes when performing edits to the tree.
|
|
37
37
|
|
|
38
38
|
### Traits
|
|
39
39
|
|
package/dist/Checkout.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ export declare abstract class Checkout extends EventEmitterWithErrorHandling<ICh
|
|
|
99
99
|
* operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.
|
|
100
100
|
*/
|
|
101
101
|
private currentEdit?;
|
|
102
|
+
private readonly logger;
|
|
102
103
|
disposed: boolean;
|
|
103
104
|
protected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler);
|
|
104
105
|
/**
|
|
@@ -142,24 +143,28 @@ export declare abstract class Checkout extends EventEmitterWithErrorHandling<ICh
|
|
|
142
143
|
* Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).
|
|
143
144
|
* `changes` must be well-formed and valid: it is an error if they do not apply cleanly.
|
|
144
145
|
*/
|
|
145
|
-
applyChanges(
|
|
146
|
+
applyChanges(changes: readonly Change[]): void;
|
|
147
|
+
applyChanges(...changes: readonly Change[]): void;
|
|
146
148
|
/**
|
|
147
149
|
* Applies the supplied changes to the tree and emits a change event.
|
|
148
150
|
* Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).
|
|
149
151
|
* `changes` must be well-formed and valid: it is an error if they do not apply cleanly.
|
|
150
152
|
*/
|
|
151
|
-
protected tryApplyChangesInternal(
|
|
153
|
+
protected tryApplyChangesInternal(changes: readonly ChangeInternal[]): EditStatus;
|
|
154
|
+
protected tryApplyChangesInternal(...changes: readonly ChangeInternal[]): EditStatus;
|
|
152
155
|
/**
|
|
153
156
|
* Convenience helper for applying an edit containing the given changes.
|
|
154
157
|
* Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).
|
|
155
158
|
*/
|
|
156
|
-
applyEdit(
|
|
159
|
+
applyEdit(changes: readonly Change[]): EditId;
|
|
160
|
+
applyEdit(...changes: readonly Change[]): EditId;
|
|
157
161
|
/**
|
|
158
162
|
* Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).
|
|
159
163
|
* If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.
|
|
160
164
|
* @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.
|
|
161
165
|
*/
|
|
162
|
-
tryApplyEdit(
|
|
166
|
+
tryApplyEdit(changes: readonly Change[]): EditId | undefined;
|
|
167
|
+
tryApplyEdit(...changes: readonly Change[]): EditId | undefined;
|
|
163
168
|
/**
|
|
164
169
|
* Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.
|
|
165
170
|
* If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current
|
package/dist/Checkout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,WAAW,EAA0C,MAAM,oCAAoC,CAAC;AAEtH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAA2C,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;;GAGG;AACH,oBAAY,aAAa;IACxB;;;OAGG;IACH,UAAU,eAAe;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,WA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
69
|
});
|
|
70
70
|
this.disposed = false;
|
|
71
71
|
this.tree = tree;
|
|
72
|
+
this.logger = telemetry_utils_1.ChildLogger.create(this.tree.logger, 'Checkout');
|
|
72
73
|
if (tree.logViewer instanceof LogViewer_1.CachingLogViewer) {
|
|
73
74
|
this.cachingLogViewer = tree.logViewer;
|
|
74
75
|
}
|
|
@@ -113,7 +114,30 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
113
114
|
(0, Common_1.assert)(currentEdit !== undefined, 'An edit is not open.');
|
|
114
115
|
this.currentEdit = undefined;
|
|
115
116
|
const editingResult = currentEdit.close();
|
|
116
|
-
|
|
117
|
+
if (editingResult.status !== persisted_types_1.EditStatus.Applied) {
|
|
118
|
+
const { failure } = editingResult;
|
|
119
|
+
const additionalProps = {};
|
|
120
|
+
switch (failure.kind) {
|
|
121
|
+
case TransactionInternal_1.TransactionInternal.FailureKind.BadPlace:
|
|
122
|
+
additionalProps.placeFailure = failure.placeFailure;
|
|
123
|
+
break;
|
|
124
|
+
case TransactionInternal_1.TransactionInternal.FailureKind.BadRange: {
|
|
125
|
+
const { rangeFailure } = failure;
|
|
126
|
+
if (typeof rangeFailure === 'string') {
|
|
127
|
+
additionalProps.rangeFailure = rangeFailure;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
additionalProps.rangeFailure = rangeFailure.kind;
|
|
131
|
+
additionalProps.rangeEndpointFailure = rangeFailure.placeFailure;
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
default:
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
this.logger.sendErrorEvent(Object.assign({ eventName: 'FailedLocalEdit', status: editingResult.status === 0 ? 'Malformed' : 'Invalid', failureKind: editingResult.failure.kind }, additionalProps));
|
|
139
|
+
(0, Common_1.fail)('Locally constructed edits must be well-formed and valid');
|
|
140
|
+
}
|
|
117
141
|
const id = (0, EditUtilities_1.newEditId)();
|
|
118
142
|
this.handleNewEdit(id, editingResult);
|
|
119
143
|
return id;
|
|
@@ -141,48 +165,33 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
141
165
|
// (which processLocalEdit will do, including invalidation).
|
|
142
166
|
this.tree.applyEditInternal(edit);
|
|
143
167
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Applies the supplied changes to the tree and emits a change event.
|
|
146
|
-
* Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).
|
|
147
|
-
* `changes` must be well-formed and valid: it is an error if they do not apply cleanly.
|
|
148
|
-
*/
|
|
149
168
|
applyChanges(...changes) {
|
|
150
169
|
(0, Common_1.assert)(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
|
|
151
|
-
const
|
|
170
|
+
const changeArray = (0, Common_1.unwrapRestOrArray)(changes);
|
|
171
|
+
const { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));
|
|
152
172
|
(0, Common_1.assert)(status === persisted_types_1.EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');
|
|
153
173
|
this.emitChange();
|
|
154
174
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Applies the supplied changes to the tree and emits a change event.
|
|
157
|
-
* Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).
|
|
158
|
-
* `changes` must be well-formed and valid: it is an error if they do not apply cleanly.
|
|
159
|
-
*/
|
|
160
175
|
tryApplyChangesInternal(...changes) {
|
|
161
176
|
(0, Common_1.assert)(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
|
|
162
|
-
const
|
|
177
|
+
const changeArray = (0, Common_1.unwrapRestOrArray)(changes);
|
|
178
|
+
const { status } = this.currentEdit.applyChanges(changeArray);
|
|
163
179
|
if (status === persisted_types_1.EditStatus.Applied) {
|
|
164
180
|
this.emitChange();
|
|
165
181
|
}
|
|
166
182
|
return status;
|
|
167
183
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Convenience helper for applying an edit containing the given changes.
|
|
170
|
-
* Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).
|
|
171
|
-
*/
|
|
172
184
|
applyEdit(...changes) {
|
|
173
185
|
this.openEdit();
|
|
174
|
-
|
|
186
|
+
const changeArray = (0, Common_1.unwrapRestOrArray)(changes);
|
|
187
|
+
this.applyChanges(changeArray);
|
|
175
188
|
return this.closeEdit();
|
|
176
189
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).
|
|
179
|
-
* If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.
|
|
180
|
-
* @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.
|
|
181
|
-
*/
|
|
182
190
|
tryApplyEdit(...changes) {
|
|
183
191
|
this.openEdit();
|
|
184
192
|
(0, Common_1.assert)(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');
|
|
185
|
-
const
|
|
193
|
+
const changeArray = (0, Common_1.unwrapRestOrArray)(changes);
|
|
194
|
+
const { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));
|
|
186
195
|
if (status === persisted_types_1.EditStatus.Applied) {
|
|
187
196
|
this.emitChange();
|
|
188
197
|
return this.closeEdit();
|
|
@@ -254,7 +263,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
254
263
|
const before = this.tree.logViewer.getRevisionViewInSession(index);
|
|
255
264
|
const changes = this.tree.revertChanges(edit.changes, before);
|
|
256
265
|
if (changes !== undefined) {
|
|
257
|
-
this.tryApplyChangesInternal(
|
|
266
|
+
this.tryApplyChangesInternal(changes);
|
|
258
267
|
}
|
|
259
268
|
}
|
|
260
269
|
/**
|
package/dist/Checkout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAgF;A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5C,6GAA6G;YAC7G,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACvD;IACF,CAAC;IAaD;;;OAGG;IACI,OAAO,CAAC,KAAa;QAC3B,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACP;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,6BAA6B;QAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzE,CAAC;CACD;AAzSD,4BAySC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent } from '@fluidframework/common-definitions';\nimport { assert } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 'An edit is already open.');\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or theEdit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tconst editingResult = currentEdit.close();\n\t\tassert(editingResult.status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid');\n\n\t\tconst id: EditId = newEditId();\n\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(...changes: Change[]): void {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes.map((c) => this.tree.internalizeChange(c)));\n\t\tassert(status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(...changes: ChangeInternal[]): EditStatus {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(...changes: Change[]): EditId {\n\t\tthis.openEdit();\n\t\tthis.applyChanges(...changes);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(...changes: Change[]): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst { status } = this.currentEdit.applyChanges(changes.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 'An edit is not open.');\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 'Local edits should always be valid.');\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t'Malformed changes should have been caught on original application.'\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassert(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit = this.tree.edits.getEditInSessionAtIndex(index);\n\t\tconst before = this.tree.logViewer.getRevisionViewInSession(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(...changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAA6F;AAE7F,qCAAwE;AAExE,2CAA+C;AAI/C,+DAAoG;AACpG,uDAAqE;AACrE,6CAA+C;AAC/C,mDAA4C;AAG5C;;;GAGG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACxB;;;OAGG;IACH,0CAAyB,CAAA;AAC1B,CAAC,EANW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAMxB;AASD;;;GAGG;AACH,IAAY,oBAiBX;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C,GAAG,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzE,CAAC;CACD;AAnVD,4BAmVC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChildLogger, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent, ITelemetryLogger, ITelemetryProperties } from '@fluidframework/common-definitions';\nimport { assert, fail, RestOrArray, unwrapRestOrArray } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tprivate readonly logger: ITelemetryLogger;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tthis.logger = ChildLogger.create(this.tree.logger, 'Checkout');\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 'An edit is already open.');\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or theEdit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tconst editingResult = currentEdit.close();\n\t\tif (editingResult.status !== EditStatus.Applied) {\n\t\t\tconst { failure } = editingResult;\n\t\t\tconst additionalProps: ITelemetryProperties = {};\n\t\t\tswitch (failure.kind) {\n\t\t\t\tcase TransactionInternal.FailureKind.BadPlace:\n\t\t\t\t\tadditionalProps.placeFailure = failure.placeFailure;\n\t\t\t\t\tbreak;\n\t\t\t\tcase TransactionInternal.FailureKind.BadRange: {\n\t\t\t\t\tconst { rangeFailure } = failure;\n\t\t\t\t\tif (typeof rangeFailure === 'string') {\n\t\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure.kind;\n\t\t\t\t\t\tadditionalProps.rangeEndpointFailure = rangeFailure.placeFailure;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: 'FailedLocalEdit',\n\t\t\t\tstatus: editingResult.status === 0 ? 'Malformed' : 'Invalid',\n\t\t\t\tfailureKind: editingResult.failure.kind,\n\t\t\t\t...additionalProps,\n\t\t\t});\n\t\t\tfail('Locally constructed edits must be well-formed and valid');\n\t\t}\n\n\t\tconst id: EditId = newEditId();\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: RestOrArray<Change>): void {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tassert(status === EditStatus.Applied, 'Locally constructed edits must be well-formed and valid.');\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: RestOrArray<ChangeInternal>): EditStatus {\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: RestOrArray<Change>): EditId {\n\t\tthis.openEdit();\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tthis.applyChanges(changeArray);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: RestOrArray<Change>): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit, 'Changes must be applied as part of an ongoing edit.');\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 'An edit is not open.');\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 'Local edits should always be valid.');\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t'Malformed changes should have been caught on original application.'\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 'An edit is not open.');\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassert(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit = this.tree.edits.getEditInSessionAtIndex(index);\n\t\tconst before = this.tree.logViewer.getRevisionViewInSession(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
|
package/dist/Common.d.ts
CHANGED
|
@@ -81,15 +81,15 @@ export declare function fail(message?: string, containsPII?: boolean): never;
|
|
|
81
81
|
export declare function assertNotUndefined<T>(value: T | undefined, message?: string): T;
|
|
82
82
|
/**
|
|
83
83
|
* Asserts an array contains a single value and returns the value.
|
|
84
|
-
* @param array -
|
|
84
|
+
* @param array - Array to assert contains a single value.
|
|
85
85
|
* @param message - Message to be printed if assertion fails.
|
|
86
86
|
*/
|
|
87
87
|
export declare function assertArrayOfOne<T>(array: readonly T[], message?: string): T;
|
|
88
88
|
/**
|
|
89
89
|
* Assign a property and value to a given object.
|
|
90
|
-
* @param object -
|
|
91
|
-
* @param property -
|
|
92
|
-
* @param value -
|
|
90
|
+
* @param object - The object to add the property to
|
|
91
|
+
* @param property - The property key
|
|
92
|
+
* @param value - The value of the property
|
|
93
93
|
* @returns `object` after assigning `value` to the property `property`.
|
|
94
94
|
*/
|
|
95
95
|
export declare function assign<T, K extends keyof never, V>(object: T, property: K, value: V): With<T, K, V>;
|
|
@@ -106,9 +106,9 @@ export declare function assign<T, K extends keyof never, V>(object: T, property:
|
|
|
106
106
|
* }
|
|
107
107
|
* }
|
|
108
108
|
* ```
|
|
109
|
-
* @param object -
|
|
110
|
-
* @param propName -
|
|
111
|
-
* @param value -
|
|
109
|
+
* @param object - The object containing the property
|
|
110
|
+
* @param propName - The name of the property on the object
|
|
111
|
+
* @param value - The value of the property
|
|
112
112
|
*/
|
|
113
113
|
export declare function memoizeGetter<T, K extends keyof T>(object: T, propName: K, value: T[K]): T[K];
|
|
114
114
|
/**
|
|
@@ -129,32 +129,32 @@ export declare function reduce<T>(sequence: Iterable<T>, reduce: (previous: T, c
|
|
|
129
129
|
export declare function find<T>(sequence: Iterable<T>, find: (t: T) => boolean): T | undefined;
|
|
130
130
|
/**
|
|
131
131
|
* Iterate through two iterables and return true if they yield equivalent elements in the same order.
|
|
132
|
-
* @param iterableA -
|
|
133
|
-
* @param iterableB -
|
|
134
|
-
* @param elementComparator -
|
|
132
|
+
* @param iterableA - The first iterable to compare
|
|
133
|
+
* @param iterableB - The second iterable to compare
|
|
134
|
+
* @param elementComparator - The function used to check if two `T`s are equivalent.
|
|
135
135
|
* Defaults to `Object.is()` equality (a shallow compare)
|
|
136
136
|
*/
|
|
137
137
|
export declare function compareIterables<T>(iterableA: Iterable<T>, iterableB: Iterable<T>, elementComparator?: (a: T, b: T) => boolean): boolean;
|
|
138
138
|
/**
|
|
139
139
|
* Compare two arrays and return true if their elements are equivalent and in the same order.
|
|
140
|
-
* @param arrayA -
|
|
141
|
-
* @param arrayB -
|
|
142
|
-
* @param elementComparator -
|
|
140
|
+
* @param arrayA - The first array to compare
|
|
141
|
+
* @param arrayB - The second array to compare
|
|
142
|
+
* @param elementComparator - The function used to check if two `T`s are equivalent.
|
|
143
143
|
* Defaults to `Object.is()` equality (a shallow compare)
|
|
144
144
|
*/
|
|
145
145
|
export declare function compareArrays<T>(arrayA: readonly T[], arrayB: readonly T[], elementComparator?: (a: T, b: T) => boolean): boolean;
|
|
146
146
|
/**
|
|
147
147
|
* Compare two maps and return true if their contents are equivalent.
|
|
148
|
-
* @param mapA -
|
|
149
|
-
* @param mapB -
|
|
150
|
-
* @param elementComparator -
|
|
148
|
+
* @param mapA - The first array to compare
|
|
149
|
+
* @param mapB - The second array to compare
|
|
150
|
+
* @param elementComparator - The function used to check if two `T`s are equivalent.
|
|
151
151
|
* Defaults to `Object.is()` equality (a shallow compare)
|
|
152
152
|
*/
|
|
153
153
|
export declare function compareMaps<K, V>(mapA: ReadonlyMap<K, V>, mapB: ReadonlyMap<K, V>, elementComparator?: (a: V, b: V) => boolean): boolean;
|
|
154
154
|
/**
|
|
155
155
|
* Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.
|
|
156
|
-
* @param map -
|
|
157
|
-
* @param key -
|
|
156
|
+
* @param map - The map to query/update
|
|
157
|
+
* @param key - The key to lookup in the map
|
|
158
158
|
* @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists
|
|
159
159
|
* @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)
|
|
160
160
|
*/
|
|
@@ -296,5 +296,18 @@ export declare function hasExactlyLength<T, Len extends TakeWholeNumbers<16>>(ar
|
|
|
296
296
|
* Fails if `array` does not have at least `length` elements
|
|
297
297
|
*/
|
|
298
298
|
export declare function hasLength<T, Len extends TakeWholeNumbers<16>>(array: readonly T[], length: Len): array is [...ArrayOfLength<T, Len>, ...T[]];
|
|
299
|
+
/**
|
|
300
|
+
* Type for a rest parameter which can accept many values, or a single array.
|
|
301
|
+
* Since a callee cannot modify an array passed as a rest parameter with the spread operator,
|
|
302
|
+
* an array passed directly should be readonly for consistency (caller retains ownership).
|
|
303
|
+
*/
|
|
304
|
+
export declare type RestOrArray<T> = readonly T[] | [readonly T[]];
|
|
305
|
+
/**
|
|
306
|
+
* When value is a one-element array containing another array, unwraps and returns the inner array.
|
|
307
|
+
* Otherwise, returns the provided array.
|
|
308
|
+
* Useful for implementing functions with a `RestOrArray` parameter.
|
|
309
|
+
* T must not be implemented with an array (`Array.isArray(t)` must return false)
|
|
310
|
+
*/
|
|
311
|
+
export declare function unwrapRestOrArray<T>(value: [any[]] extends [T] ? never : RestOrArray<T>): readonly T[];
|
|
299
312
|
export {};
|
|
300
313
|
//# sourceMappingURL=Common.d.ts.map
|
package/dist/Common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.d.ts","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,KAAK,MAAM,cAAc,CAAC;AAIjC;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,wBAAwB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IAC1E,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC;CACjC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAErE;AAgBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEjF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAEnE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,OAAO,CAAC,SAA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AAS,CAAC,EAAE,CAEtG"}
|
package/dist/Common.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.hasLength = exports.hasExactlyLength = exports.Result = exports.backmap = exports.compareBtrees = exports.setPropertyIfDefined = exports.copyPropertyIfDefined = exports.identity = exports.noop = exports.getOrCreate = exports.compareMaps = exports.compareArrays = exports.compareIterables = exports.find = exports.reduce = exports.filter = exports.map = exports.memoizeGetter = exports.assign = exports.assertArrayOfOne = exports.assertNotUndefined = exports.fail = exports.assert = exports.compareStrings = exports.compareFiniteNumbersReversed = exports.compareFiniteNumbers = exports.isSharedTreeEvent = exports.sharedTreeAssertionErrorType = void 0;
|
|
7
|
+
exports.unwrapRestOrArray = exports.hasLength = exports.hasExactlyLength = exports.Result = exports.backmap = exports.compareBtrees = exports.setPropertyIfDefined = exports.copyPropertyIfDefined = exports.identity = exports.noop = exports.getOrCreate = exports.compareMaps = exports.compareArrays = exports.compareIterables = exports.find = exports.reduce = exports.filter = exports.map = exports.memoizeGetter = exports.assign = exports.assertArrayOfOne = exports.assertNotUndefined = exports.fail = exports.assert = exports.compareStrings = exports.compareFiniteNumbersReversed = exports.compareFiniteNumbers = exports.isSharedTreeEvent = exports.sharedTreeAssertionErrorType = void 0;
|
|
8
8
|
const defaultFailMessage = 'Assertion failed';
|
|
9
9
|
/**
|
|
10
10
|
* Assertion failures in SharedTree will throw an exception containing this value as an `errorType`. The Fluid runtime propagates this field
|
|
@@ -119,7 +119,7 @@ function assertNotUndefined(value, message = 'value must not be undefined') {
|
|
|
119
119
|
exports.assertNotUndefined = assertNotUndefined;
|
|
120
120
|
/**
|
|
121
121
|
* Asserts an array contains a single value and returns the value.
|
|
122
|
-
* @param array -
|
|
122
|
+
* @param array - Array to assert contains a single value.
|
|
123
123
|
* @param message - Message to be printed if assertion fails.
|
|
124
124
|
*/
|
|
125
125
|
function assertArrayOfOne(array, message = 'array value must contain exactly one item') {
|
|
@@ -129,9 +129,9 @@ function assertArrayOfOne(array, message = 'array value must contain exactly one
|
|
|
129
129
|
exports.assertArrayOfOne = assertArrayOfOne;
|
|
130
130
|
/**
|
|
131
131
|
* Assign a property and value to a given object.
|
|
132
|
-
* @param object -
|
|
133
|
-
* @param property -
|
|
134
|
-
* @param value -
|
|
132
|
+
* @param object - The object to add the property to
|
|
133
|
+
* @param property - The property key
|
|
134
|
+
* @param value - The value of the property
|
|
135
135
|
* @returns `object` after assigning `value` to the property `property`.
|
|
136
136
|
*/
|
|
137
137
|
function assign(object, property, value) {
|
|
@@ -151,9 +151,9 @@ exports.assign = assign;
|
|
|
151
151
|
* }
|
|
152
152
|
* }
|
|
153
153
|
* ```
|
|
154
|
-
* @param object -
|
|
155
|
-
* @param propName -
|
|
156
|
-
* @param value -
|
|
154
|
+
* @param object - The object containing the property
|
|
155
|
+
* @param propName - The name of the property on the object
|
|
156
|
+
* @param value - The value of the property
|
|
157
157
|
*/
|
|
158
158
|
function memoizeGetter(object, propName, value) {
|
|
159
159
|
Object.defineProperty(object, propName, {
|
|
@@ -219,9 +219,9 @@ function find(sequence, find) {
|
|
|
219
219
|
exports.find = find;
|
|
220
220
|
/**
|
|
221
221
|
* Iterate through two iterables and return true if they yield equivalent elements in the same order.
|
|
222
|
-
* @param iterableA -
|
|
223
|
-
* @param iterableB -
|
|
224
|
-
* @param elementComparator -
|
|
222
|
+
* @param iterableA - The first iterable to compare
|
|
223
|
+
* @param iterableB - The second iterable to compare
|
|
224
|
+
* @param elementComparator - The function used to check if two `T`s are equivalent.
|
|
225
225
|
* Defaults to `Object.is()` equality (a shallow compare)
|
|
226
226
|
*/
|
|
227
227
|
function compareIterables(iterableA, iterableB, elementComparator = Object.is) {
|
|
@@ -230,9 +230,9 @@ function compareIterables(iterableA, iterableB, elementComparator = Object.is) {
|
|
|
230
230
|
exports.compareIterables = compareIterables;
|
|
231
231
|
/**
|
|
232
232
|
* Iterate through two iterators and return true if they yield equivalent elements in the same order.
|
|
233
|
-
* @param iteratorA -
|
|
234
|
-
* @param iteratorB -
|
|
235
|
-
* @param elementComparator -
|
|
233
|
+
* @param iteratorA - The first iterator to compare
|
|
234
|
+
* @param iteratorB - The second iterator to compare
|
|
235
|
+
* @param elementComparator - The function used to check if two `T`s are equivalent.
|
|
236
236
|
* Defaults to `Object.is()` equality (a shallow compare)
|
|
237
237
|
*/
|
|
238
238
|
function compareIterators(iteratorA, iteratorB, elementComparator = Object.is) {
|
|
@@ -252,9 +252,9 @@ function compareIterators(iteratorA, iteratorB, elementComparator = Object.is) {
|
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
254
|
* Compare two arrays and return true if their elements are equivalent and in the same order.
|
|
255
|
-
* @param arrayA -
|
|
256
|
-
* @param arrayB -
|
|
257
|
-
* @param elementComparator -
|
|
255
|
+
* @param arrayA - The first array to compare
|
|
256
|
+
* @param arrayB - The second array to compare
|
|
257
|
+
* @param elementComparator - The function used to check if two `T`s are equivalent.
|
|
258
258
|
* Defaults to `Object.is()` equality (a shallow compare)
|
|
259
259
|
*/
|
|
260
260
|
function compareArrays(arrayA, arrayB, elementComparator = Object.is) {
|
|
@@ -271,9 +271,9 @@ function compareArrays(arrayA, arrayB, elementComparator = Object.is) {
|
|
|
271
271
|
exports.compareArrays = compareArrays;
|
|
272
272
|
/**
|
|
273
273
|
* Compare two maps and return true if their contents are equivalent.
|
|
274
|
-
* @param mapA -
|
|
275
|
-
* @param mapB -
|
|
276
|
-
* @param elementComparator -
|
|
274
|
+
* @param mapA - The first array to compare
|
|
275
|
+
* @param mapB - The second array to compare
|
|
276
|
+
* @param elementComparator - The function used to check if two `T`s are equivalent.
|
|
277
277
|
* Defaults to `Object.is()` equality (a shallow compare)
|
|
278
278
|
*/
|
|
279
279
|
function compareMaps(mapA, mapB, elementComparator = Object.is) {
|
|
@@ -291,8 +291,8 @@ function compareMaps(mapA, mapB, elementComparator = Object.is) {
|
|
|
291
291
|
exports.compareMaps = compareMaps;
|
|
292
292
|
/**
|
|
293
293
|
* Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.
|
|
294
|
-
* @param map -
|
|
295
|
-
* @param key -
|
|
294
|
+
* @param map - The map to query/update
|
|
295
|
+
* @param key - The key to lookup in the map
|
|
296
296
|
* @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists
|
|
297
297
|
* @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)
|
|
298
298
|
*/
|
|
@@ -374,6 +374,7 @@ function backmap(forwardmap) {
|
|
|
374
374
|
return new Map(map(forwardmap, ([key, value]) => [value, key]));
|
|
375
375
|
}
|
|
376
376
|
exports.backmap = backmap;
|
|
377
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
377
378
|
var Result;
|
|
378
379
|
(function (Result) {
|
|
379
380
|
/**
|
|
@@ -453,4 +454,14 @@ function hasLength(array, length) {
|
|
|
453
454
|
return array.length >= length;
|
|
454
455
|
}
|
|
455
456
|
exports.hasLength = hasLength;
|
|
457
|
+
/**
|
|
458
|
+
* When value is a one-element array containing another array, unwraps and returns the inner array.
|
|
459
|
+
* Otherwise, returns the provided array.
|
|
460
|
+
* Useful for implementing functions with a `RestOrArray` parameter.
|
|
461
|
+
* T must not be implemented with an array (`Array.isArray(t)` must return false)
|
|
462
|
+
*/
|
|
463
|
+
function unwrapRestOrArray(value) {
|
|
464
|
+
return value.length === 1 && Array.isArray(value[0]) ? value[0] : value;
|
|
465
|
+
}
|
|
466
|
+
exports.unwrapRestOrArray = unwrapRestOrArray;
|
|
456
467
|
//# sourceMappingURL=Common.js.map
|