@fluid-experimental/tree 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191258
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/.eslintrc.js +1 -0
- package/CHANGELOG.md +51 -0
- package/dist/ChangeCompression.js +8 -2
- package/dist/ChangeCompression.js.map +1 -1
- package/dist/ChangeTypes.d.ts +23 -0
- package/dist/ChangeTypes.d.ts.map +1 -1
- package/dist/ChangeTypes.js +7 -3
- package/dist/ChangeTypes.js.map +1 -1
- package/dist/Checkout.d.ts +4 -3
- package/dist/Checkout.d.ts.map +1 -1
- package/dist/Checkout.js +25 -21
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +3 -9
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +6 -15
- package/dist/Common.js.map +1 -1
- package/dist/EditLog.d.ts +2 -2
- package/dist/EditLog.d.ts.map +1 -1
- package/dist/EditLog.js +21 -29
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.js +10 -15
- package/dist/EditUtilities.js.map +1 -1
- package/dist/Forest.js +42 -38
- package/dist/Forest.js.map +1 -1
- package/dist/HistoryEditFactory.js +7 -8
- package/dist/HistoryEditFactory.js.map +1 -1
- package/dist/LogViewer.d.ts +2 -2
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +34 -22
- package/dist/LogViewer.js.map +1 -1
- package/dist/MergeHealth.d.ts.map +1 -1
- package/dist/MergeHealth.js +17 -9
- package/dist/MergeHealth.js.map +1 -1
- package/dist/NodeIdUtilities.js +2 -3
- package/dist/NodeIdUtilities.js.map +1 -1
- package/dist/RevisionValueCache.js +3 -4
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.js +2 -3
- package/dist/RevisionView.js.map +1 -1
- package/dist/SerializationUtilities.js +13 -4
- package/dist/SerializationUtilities.js.map +1 -1
- package/dist/SharedTree.d.ts +1 -1
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +34 -34
- package/dist/SharedTree.js.map +1 -1
- package/dist/SharedTreeEncoder.d.ts.map +1 -1
- package/dist/SharedTreeEncoder.js +9 -9
- package/dist/SharedTreeEncoder.js.map +1 -1
- package/dist/StringInterner.js +2 -4
- package/dist/StringInterner.js.map +1 -1
- package/dist/Summary.js +1 -2
- package/dist/Summary.js.map +1 -1
- package/dist/SummaryBackCompatibility.js +2 -2
- package/dist/SummaryBackCompatibility.js.map +1 -1
- package/dist/SummaryTestUtilities.js +2 -2
- package/dist/SummaryTestUtilities.js.map +1 -1
- package/dist/Transaction.d.ts +2 -2
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +2 -2
- package/dist/Transaction.js.map +1 -1
- package/dist/TransactionInternal.js +19 -11
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/TreeCompressor.js +5 -7
- package/dist/TreeCompressor.js.map +1 -1
- package/dist/TreeNodeHandle.js +1 -2
- package/dist/TreeNodeHandle.js.map +1 -1
- package/dist/TreeView.js +10 -14
- package/dist/TreeView.js.map +1 -1
- package/dist/TreeViewUtilities.js +2 -3
- package/dist/TreeViewUtilities.js.map +1 -1
- package/dist/id-compressor/AppendOnlySortedMap.js +4 -5
- package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts +3 -3
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +72 -75
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/IdRange.js +4 -4
- package/dist/id-compressor/IdRange.js.map +1 -1
- package/dist/id-compressor/Logger.d.ts.map +1 -1
- package/dist/id-compressor/Logger.js +1 -1
- package/dist/id-compressor/Logger.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.js +17 -24
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +6 -2
- 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/persisted-types/0.1.1.d.ts +4 -0
- package/dist/persisted-types/0.1.1.d.ts.map +1 -1
- package/dist/persisted-types/0.1.1.js +8 -5
- package/dist/persisted-types/0.1.1.js.map +1 -1
- package/lib/ChangeCompression.js +8 -2
- package/lib/ChangeCompression.js.map +1 -1
- package/lib/ChangeTypes.d.ts +23 -0
- package/lib/ChangeTypes.d.ts.map +1 -1
- package/lib/ChangeTypes.js +5 -1
- package/lib/ChangeTypes.js.map +1 -1
- package/lib/Checkout.d.ts +4 -3
- package/lib/Checkout.d.ts.map +1 -1
- package/lib/Checkout.js +15 -11
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +3 -9
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +5 -13
- package/lib/Common.js.map +1 -1
- package/lib/EditLog.d.ts +2 -2
- package/lib/EditLog.d.ts.map +1 -1
- package/lib/EditLog.js +15 -23
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.js +10 -15
- package/lib/EditUtilities.js.map +1 -1
- package/lib/Forest.js +21 -17
- package/lib/Forest.js.map +1 -1
- package/lib/HistoryEditFactory.js +5 -6
- package/lib/HistoryEditFactory.js.map +1 -1
- package/lib/LogViewer.d.ts +2 -2
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +29 -17
- package/lib/LogViewer.js.map +1 -1
- package/lib/MergeHealth.d.ts.map +1 -1
- package/lib/MergeHealth.js +17 -9
- package/lib/MergeHealth.js.map +1 -1
- package/lib/NodeIdUtilities.js +2 -3
- package/lib/NodeIdUtilities.js.map +1 -1
- package/lib/RevisionValueCache.js +2 -3
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.js +2 -3
- package/lib/RevisionView.js.map +1 -1
- package/lib/SerializationUtilities.js +13 -4
- package/lib/SerializationUtilities.js.map +1 -1
- package/lib/SharedTree.d.ts +1 -1
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +28 -28
- package/lib/SharedTree.js.map +1 -1
- package/lib/SharedTreeEncoder.d.ts.map +1 -1
- package/lib/SharedTreeEncoder.js +3 -3
- package/lib/SharedTreeEncoder.js.map +1 -1
- package/lib/StringInterner.js +2 -4
- package/lib/StringInterner.js.map +1 -1
- package/lib/Summary.js +1 -2
- package/lib/Summary.js.map +1 -1
- package/lib/SummaryBackCompatibility.js +2 -2
- package/lib/SummaryBackCompatibility.js.map +1 -1
- package/lib/SummaryTestUtilities.js +1 -1
- package/lib/SummaryTestUtilities.js.map +1 -1
- package/lib/Transaction.d.ts +2 -2
- package/lib/Transaction.d.ts.map +1 -1
- package/lib/Transaction.js +1 -1
- package/lib/Transaction.js.map +1 -1
- package/lib/TransactionInternal.js +15 -7
- package/lib/TransactionInternal.js.map +1 -1
- package/lib/TreeCompressor.js +4 -6
- package/lib/TreeCompressor.js.map +1 -1
- package/lib/TreeNodeHandle.js +1 -2
- package/lib/TreeNodeHandle.js.map +1 -1
- package/lib/TreeView.js +9 -13
- package/lib/TreeView.js.map +1 -1
- package/lib/TreeViewUtilities.js +2 -3
- package/lib/TreeViewUtilities.js.map +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.js +2 -3
- package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts +3 -3
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +50 -53
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/IdRange.js +3 -3
- package/lib/id-compressor/IdRange.js.map +1 -1
- package/lib/id-compressor/Logger.d.ts.map +1 -1
- package/lib/id-compressor/Logger.js +2 -2
- package/lib/id-compressor/Logger.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.js +10 -17
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.d.ts +6 -2
- 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/persisted-types/0.1.1.d.ts +4 -0
- package/lib/persisted-types/0.1.1.d.ts.map +1 -1
- package/lib/persisted-types/0.1.1.js +6 -3
- package/lib/persisted-types/0.1.1.js.map +1 -1
- package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
- package/lib/test/ChangeCompression.tests.js +13 -4
- package/lib/test/ChangeCompression.tests.js.map +1 -1
- package/lib/test/Checkout.tests.js +12 -6
- package/lib/test/Checkout.tests.js.map +1 -1
- package/lib/test/EditLog.tests.js +5 -7
- package/lib/test/EditLog.tests.js.map +1 -1
- package/lib/test/EditUtilities.tests.js +24 -15
- package/lib/test/EditUtilities.tests.js.map +1 -1
- package/lib/test/Forest.perf.tests.js +1 -1
- package/lib/test/Forest.perf.tests.js.map +1 -1
- package/lib/test/Forest.tests.js +9 -9
- package/lib/test/Forest.tests.js.map +1 -1
- package/lib/test/IdCompressor.perf.tests.js +1 -1
- package/lib/test/IdCompressor.perf.tests.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +5 -8
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/lib/test/LogViewer.tests.js +7 -10
- package/lib/test/LogViewer.tests.js.map +1 -1
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +11 -2
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -1
- package/lib/test/NumericUuid.tests.js.map +1 -1
- package/lib/test/RevisionValueCache.tests.js +1 -2
- package/lib/test/RevisionValueCache.tests.js.map +1 -1
- package/lib/test/RevisionView.tests.js +3 -5
- package/lib/test/RevisionView.tests.js.map +1 -1
- package/lib/test/SessionIdNormalizer.tests.js +2 -3
- package/lib/test/SessionIdNormalizer.tests.js.map +1 -1
- package/lib/test/StringInterner.tests.js.map +1 -1
- package/lib/test/Summary.tests.js +6 -8
- package/lib/test/Summary.tests.js.map +1 -1
- package/lib/test/TransactionInternal.tests.js +15 -6
- package/lib/test/TransactionInternal.tests.js.map +1 -1
- package/lib/test/TreeCompression.tests.js +1 -1
- package/lib/test/TreeCompression.tests.js.map +1 -1
- package/lib/test/TreeView.tests.js +3 -3
- package/lib/test/TreeView.tests.js.map +1 -1
- package/lib/test/UndoRedoHandler.tests.js +2 -2
- package/lib/test/UndoRedoHandler.tests.js.map +1 -1
- package/lib/test/fuzz/Generators.d.ts.map +1 -1
- package/lib/test/fuzz/Generators.js +24 -18
- package/lib/test/fuzz/Generators.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +4 -5
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +2 -2
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.js +9 -11
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.js +13 -8
- package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +70 -34
- 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 +39 -14
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
- package/lib/test/utilities/SummarySizeTests.js +3 -3
- package/lib/test/utilities/SummarySizeTests.js.map +1 -1
- package/lib/test/utilities/TestNode.js +4 -4
- package/lib/test/utilities/TestNode.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +30 -26
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/lib/test/utilities/UndoRedoTests.js +3 -4
- package/lib/test/utilities/UndoRedoTests.js.map +1 -1
- package/package.json +30 -32
- package/src/ChangeTypes.ts +24 -1
- package/src/Checkout.ts +7 -6
- package/src/Common.ts +4 -13
- package/src/EditLog.ts +3 -3
- package/src/Forest.ts +1 -1
- package/src/HistoryEditFactory.ts +1 -1
- package/src/LogViewer.ts +3 -2
- package/src/MergeHealth.ts +9 -4
- package/src/RevisionValueCache.ts +1 -1
- package/src/SharedTree.ts +14 -9
- package/src/SharedTreeEncoder.ts +2 -1
- package/src/SummaryTestUtilities.ts +1 -1
- package/src/Transaction.ts +2 -2
- package/src/TransactionInternal.ts +1 -1
- package/src/TreeCompressor.ts +1 -1
- package/src/TreeView.ts +1 -1
- package/src/id-compressor/AppendOnlySortedMap.ts +1 -1
- package/src/id-compressor/IdCompressor.ts +8 -3
- package/src/id-compressor/IdRange.ts +1 -1
- package/src/id-compressor/Logger.ts +2 -2
- package/src/id-compressor/SessionIdNormalizer.ts +1 -1
- package/src/id-compressor/persisted-types/0.0.1.ts +6 -2
- package/src/persisted-types/0.1.1.ts +5 -1
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @fluid-experimental/tree
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.6.3.0
|
|
4
|
+
|
|
5
|
+
Dependency updates only.
|
|
6
|
+
|
|
7
|
+
## 2.0.0-internal.6.2.0
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- Remove use of @fluidframework/common-definitions ([#16638](https://github.com/microsoft/FluidFramework/issues/16638)) [a8c81509c9](https://github.com/microsoft/FluidFramework/commits/a8c81509c9bf09cfb2092ebcf7265205f9eb6dbf)
|
|
12
|
+
|
|
13
|
+
The **@fluidframework/common-definitions** package is being deprecated, so the following interfaces and types are now
|
|
14
|
+
imported from the **@fluidframework/core-interfaces** package:
|
|
15
|
+
|
|
16
|
+
- interface IDisposable
|
|
17
|
+
- interface IErrorEvent
|
|
18
|
+
- interface IErrorEvent
|
|
19
|
+
- interface IEvent
|
|
20
|
+
- interface IEventProvider
|
|
21
|
+
- interface ILoggingError
|
|
22
|
+
- interface ITaggedTelemetryPropertyType
|
|
23
|
+
- interface ITelemetryBaseEvent
|
|
24
|
+
- interface ITelemetryBaseLogger
|
|
25
|
+
- interface ITelemetryErrorEvent
|
|
26
|
+
- interface ITelemetryGenericEvent
|
|
27
|
+
- interface ITelemetryLogger
|
|
28
|
+
- interface ITelemetryPerformanceEvent
|
|
29
|
+
- interface ITelemetryProperties
|
|
30
|
+
- type ExtendEventProvider
|
|
31
|
+
- type IEventThisPlaceHolder
|
|
32
|
+
- type IEventTransformer
|
|
33
|
+
- type ReplaceIEventThisPlaceHolder
|
|
34
|
+
- type ReplaceIEventThisPlaceHolder
|
|
35
|
+
- type TelemetryEventCategory
|
|
36
|
+
- type TelemetryEventPropertyType
|
|
37
|
+
|
|
38
|
+
## 2.0.0-internal.6.1.0
|
|
39
|
+
|
|
40
|
+
Dependency updates only.
|
|
41
|
+
|
|
42
|
+
## 2.0.0-internal.6.0.0
|
|
43
|
+
|
|
44
|
+
### Major Changes
|
|
45
|
+
|
|
46
|
+
- Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
47
|
+
|
|
48
|
+
Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
|
|
49
|
+
|
|
50
|
+
## 2.0.0-internal.5.4.0
|
|
51
|
+
|
|
52
|
+
Dependency updates only.
|
|
53
|
+
|
|
3
54
|
## 2.0.0-internal.5.3.0
|
|
4
55
|
|
|
5
56
|
### Minor Changes
|
|
@@ -103,7 +103,10 @@ function normalizeChange(change, normalizeId) {
|
|
|
103
103
|
* untouched.
|
|
104
104
|
*/
|
|
105
105
|
function compressEdit(compressor, interner, idNormalizer, edit) {
|
|
106
|
-
return
|
|
106
|
+
return {
|
|
107
|
+
...edit,
|
|
108
|
+
changes: edit.changes.map((change) => compressor.compress(change, interner, idNormalizer)),
|
|
109
|
+
};
|
|
107
110
|
}
|
|
108
111
|
exports.compressEdit = compressEdit;
|
|
109
112
|
/**
|
|
@@ -111,7 +114,10 @@ exports.compressEdit = compressEdit;
|
|
|
111
114
|
* untouched.
|
|
112
115
|
*/
|
|
113
116
|
function decompressEdit(compressor, interner, idNormalizer, edit) {
|
|
114
|
-
return
|
|
117
|
+
return {
|
|
118
|
+
...edit,
|
|
119
|
+
changes: edit.changes.map((change) => compressor.decompress(change, interner, idNormalizer)),
|
|
120
|
+
};
|
|
115
121
|
}
|
|
116
122
|
exports.decompressEdit = decompressEdit;
|
|
117
123
|
//# sourceMappingURL=ChangeCompression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeCompression.js","sourceRoot":"","sources":["../src/ChangeCompression.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uDAY2B;AAE3B,qCAAkF;AAGlF,iDAA8E;AAE9E;;;;GAIG;AACH,MAAa,gBAAgB;IAC5B,YAAoC,cAAkD;QAAlD,mBAAc,GAAd,cAAc,CAAoC;IAAG,CAAC;IAEnF,QAAQ,CACd,MAAsB,EACtB,QAAwB,EACxB,YAAiD;QAEjD,IAAI,MAAM,CAAC,IAAI,KAAK,oCAAkB,CAAC,KAAK,EAAE;YAC7C,MAAM,MAAM,GAAyD,EAAE,CAAC;YACxE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE;gBACjC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;aACxE;YACD,MAAM,SAAS,GAAiC;gBAC/C,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,MAAM;gBACN,IAAI,EAAE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OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;KAC5F,CAAC;AACH,CAAC;AAbD,wCAaC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DetachedSequenceId, NodeId, OpSpaceNodeId } from './Identifiers';\nimport {\n\tBuildInternal,\n\tBuildNodeInternal,\n\tChangeInternal,\n\tCompressedChangeInternal,\n\tChangeTypeInternal,\n\tCompressedBuildInternal,\n\tCompressedPlaceholderTree,\n\tInsertInternal,\n\tDetachInternal,\n\tSetValueInternal,\n\tConstraintInternal,\n} from './persisted-types';\nimport { ContextualizedNodeIdNormalizer } from './NodeIdUtilities';\nimport { copyPropertyIfDefined, fail, Mutable, ReplaceRecursive } from './Common';\nimport { TreeCompressor } from './TreeCompressor';\nimport { StringInterner } from './StringInterner';\nimport { convertStablePlaceIds, convertStableRangeIds } from './IdConversion';\n\n/**\n * Encapsulates knowledge of how to compress/decompress a change into a compressed change\n * Compression and decompression each take in a {@link StringInterner} for deduplicating shared strings.\n * @internal\n */\nexport class ChangeCompressor {\n\tpublic constructor(private readonly treeCompressor: TreeCompressor<DetachedSequenceId>) {}\n\n\tpublic compress<TId extends OpSpaceNodeId>(\n\t\tchange: ChangeInternal,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): CompressedChangeInternal<TId> {\n\t\tif (change.type === ChangeTypeInternal.Build) {\n\t\t\tconst source: CompressedPlaceholderTree<TId, DetachedSequenceId>[] = [];\n\t\t\tfor (const node of change.source) {\n\t\t\t\tsource.push(this.treeCompressor.compress(node, interner, idNormalizer));\n\t\t\t}\n\t\t\tconst newChange: CompressedBuildInternal<TId> = {\n\t\t\t\tdestination: change.destination,\n\t\t\t\tsource,\n\t\t\t\ttype: ChangeTypeInternal.CompressedBuild,\n\t\t\t};\n\t\t\treturn newChange;\n\t\t} else {\n\t\t\treturn normalizeChange(change, (id) => idNormalizer.normalizeToOpSpace(id));\n\t\t}\n\t}\n\n\tpublic decompress<TId extends OpSpaceNodeId>(\n\t\tchange: CompressedChangeInternal<TId>,\n\t\tinterner: StringInterner,\n\t\tidNormalizer: ContextualizedNodeIdNormalizer<TId>\n\t): ChangeInternal {\n\t\tif (change.type === ChangeTypeInternal.CompressedBuild) {\n\t\t\tconst source: BuildNodeInternal[] = [];\n\t\t\tfor (const node of change.source) {\n\t\t\t\tsource.push(this.treeCompressor.decompress(node, interner, idNormalizer));\n\t\t\t}\n\t\t\tconst newChange: BuildInternal = {\n\t\t\t\tdestination: change.destination,\n\t\t\t\tsource,\n\t\t\t\ttype: ChangeTypeInternal.Build,\n\t\t\t};\n\t\t\treturn newChange;\n\t\t} else {\n\t\t\treturn normalizeChange(change, (id) => idNormalizer.normalizeToSessionSpace(id));\n\t\t}\n\t}\n}\n\nfunction normalizeChange<From extends NodeId | OpSpaceNodeId, To extends NodeId | OpSpaceNodeId>(\n\tchange: ReplaceRecursive<Exclude<ChangeInternal, BuildInternal>, NodeId, From>,\n\tnormalizeId: (id: From) => To\n): ReplaceRecursive<Exclude<ChangeInternal, BuildInternal>, NodeId, To> {\n\tswitch (change.type) {\n\t\tcase ChangeTypeInternal.Insert: {\n\t\t\tconst insert: ReplaceRecursive<InsertInternal, NodeId, To> = {\n\t\t\t\tsource: change.source,\n\t\t\t\tdestination: convertStablePlaceIds(change.destination, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Insert,\n\t\t\t};\n\t\t\treturn insert;\n\t\t}\n\t\tcase ChangeTypeInternal.Detach: {\n\t\t\tconst detach: ReplaceRecursive<DetachInternal, NodeId, To> = {\n\t\t\t\tsource: convertStableRangeIds(change.source, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Detach,\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(change, detach, 'destination');\n\t\t\treturn detach;\n\t\t}\n\t\tcase ChangeTypeInternal.SetValue: {\n\t\t\tconst setValue: ReplaceRecursive<SetValueInternal, NodeId, To> = {\n\t\t\t\tnodeToModify: normalizeId(change.nodeToModify),\n\t\t\t\tpayload: change.payload,\n\t\t\t\ttype: ChangeTypeInternal.SetValue,\n\t\t\t};\n\t\t\treturn setValue;\n\t\t}\n\t\tcase ChangeTypeInternal.Constraint: {\n\t\t\tconst constraint: Mutable<ReplaceRecursive<ConstraintInternal, NodeId, To>> = {\n\t\t\t\teffect: change.effect,\n\t\t\t\ttoConstrain: convertStableRangeIds(change.toConstrain, normalizeId),\n\t\t\t\ttype: ChangeTypeInternal.Constraint,\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(change, constraint, 'contentHash');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'identityHash');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'label');\n\t\t\tcopyPropertyIfDefined(change, constraint, 'length');\n\t\t\tif (change.parentNode !== undefined) {\n\t\t\t\tconstraint.parentNode = normalizeId(change.parentNode);\n\t\t\t}\n\t\t\treturn constraint;\n\t\t}\n\t\tdefault:\n\t\t\tfail('unexpected change type');\n\t}\n}\n\n/**\n * Compresses the provided edit by applying `compressor` to each change and leaving other fields\n * untouched.\n */\nexport function compressEdit<TId extends OpSpaceNodeId, TEdit extends { changes: readonly ChangeInternal[] }>(\n\tcompressor: ChangeCompressor,\n\tinterner: StringInterner,\n\tidNormalizer: ContextualizedNodeIdNormalizer<TId>,\n\tedit: TEdit\n): Omit<TEdit, 'changes'> & { changes: readonly CompressedChangeInternal<TId>[] } {\n\treturn {\n\t\t...edit,\n\t\tchanges: edit.changes.map((change) => compressor.compress(change, interner, idNormalizer)),\n\t};\n}\n\n/**\n * Decompresses the provided edit by applying `compressor` to each change and leaving other fields\n * untouched.\n */\nexport function decompressEdit<\n\tTId extends OpSpaceNodeId,\n\tTEdit extends { changes: readonly CompressedChangeInternal<TId>[] }\n>(\n\tcompressor: ChangeCompressor,\n\tinterner: StringInterner,\n\tidNormalizer: ContextualizedNodeIdNormalizer<TId>,\n\tedit: TEdit\n): Omit<TEdit, 'changes'> & { changes: readonly ChangeInternal[] } {\n\treturn {\n\t\t...edit,\n\t\tchanges: edit.changes.map((change) => compressor.decompress(change, interner, idNormalizer)),\n\t};\n}\n"]}
|
package/dist/ChangeTypes.d.ts
CHANGED
|
@@ -28,9 +28,16 @@ export declare enum ChangeType {
|
|
|
28
28
|
/**
|
|
29
29
|
* A change that composes an Edit.
|
|
30
30
|
*
|
|
31
|
+
* @remarks
|
|
32
|
+
*
|
|
31
33
|
* `Change` objects can be conveniently constructed with the helper methods exported on a constant of the same name.
|
|
34
|
+
*
|
|
32
35
|
* @example
|
|
36
|
+
*
|
|
37
|
+
* ```typescript
|
|
33
38
|
* Change.insert(sourceId, destination)
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
34
41
|
* @public
|
|
35
42
|
*/
|
|
36
43
|
export declare type Change = Insert | Detach | Build | SetValue | Constraint;
|
|
@@ -197,9 +204,14 @@ export declare const Change: {
|
|
|
197
204
|
* The anchor (`referenceSibling` or `referenceTrait`) used for a particular `StablePlace` can have an impact in collaborative scenarios.
|
|
198
205
|
*
|
|
199
206
|
* `StablePlace` objects can be conveniently constructed with the helper methods exported on a constant of the same name.
|
|
207
|
+
*
|
|
200
208
|
* @example
|
|
209
|
+
*
|
|
210
|
+
* ```typescript
|
|
201
211
|
* StablePlace.before(node)
|
|
202
212
|
* StablePlace.atStartOf(trait)
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
203
215
|
* @public
|
|
204
216
|
*/
|
|
205
217
|
export interface StablePlace {
|
|
@@ -226,9 +238,16 @@ export interface StablePlace {
|
|
|
226
238
|
*
|
|
227
239
|
* See {@link (StablePlace:interface)} for what it means for a place to be "after" another place.
|
|
228
240
|
*
|
|
241
|
+
* @remarks
|
|
242
|
+
*
|
|
229
243
|
* `StableRange` objects can be conveniently constructed with the helper methods exported on a constant of the same name.
|
|
244
|
+
*
|
|
230
245
|
* @example
|
|
246
|
+
*
|
|
247
|
+
* ```typescript
|
|
231
248
|
* StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
232
251
|
* @public
|
|
233
252
|
*/
|
|
234
253
|
export interface StableRange {
|
|
@@ -269,8 +288,12 @@ export declare const StablePlace: {
|
|
|
269
288
|
export declare const StableRange: {
|
|
270
289
|
/**
|
|
271
290
|
* Factory for producing a `StableRange` from a start `StablePlace` to an end `StablePlace`.
|
|
291
|
+
*
|
|
272
292
|
* @example
|
|
293
|
+
*
|
|
294
|
+
* ```typescript
|
|
273
295
|
* StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))
|
|
296
|
+
* ```
|
|
274
297
|
*/
|
|
275
298
|
from: (start: StablePlace) => {
|
|
276
299
|
to: (end: StablePlace) => StableRange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeTypes.d.ts","sourceRoot":"","sources":["../src/ChangeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;KACtE,CAAC;CACF;AAED;;;GAGG;AACH,oBAAY,UAAU;IACrB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,UAAU,IAAA;CACV;AAED
|
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ACU,SAAS,MAAM,CAAC,GAAG,MAAM,KAAG,WAAW;IAIpD;;;;OAIG;iBACU,aAAa,KAAG,WAAW;CAIxC,CAAC"}
|
package/dist/ChangeTypes.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.StableRange = exports.StablePlace = exports.Change = exports.ChangeType = void 0;
|
|
8
|
-
const
|
|
8
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
9
9
|
const Common_1 = require("./Common");
|
|
10
10
|
const persisted_types_1 = require("./persisted-types");
|
|
11
11
|
const NodeIdUtilities_1 = require("./NodeIdUtilities");
|
|
@@ -121,14 +121,18 @@ exports.StablePlace = {
|
|
|
121
121
|
exports.StableRange = {
|
|
122
122
|
/**
|
|
123
123
|
* Factory for producing a `StableRange` from a start `StablePlace` to an end `StablePlace`.
|
|
124
|
+
*
|
|
124
125
|
* @example
|
|
126
|
+
*
|
|
127
|
+
* ```typescript
|
|
125
128
|
* StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))
|
|
129
|
+
* ```
|
|
126
130
|
*/
|
|
127
131
|
from: (start) => ({
|
|
128
132
|
to: (end) => {
|
|
129
133
|
if (start.referenceTrait && end.referenceTrait) {
|
|
130
|
-
(0,
|
|
131
|
-
(0,
|
|
134
|
+
(0, core_utils_1.assert)(start.referenceTrait.parent === end.referenceTrait.parent, 0x5fe /* StableRange must be constructed with endpoints from the same trait */);
|
|
135
|
+
(0, core_utils_1.assert)(start.referenceTrait.label === end.referenceTrait.label, 0x5ff /* StableRange must be constructed with endpoints from the same trait */);
|
|
132
136
|
}
|
|
133
137
|
return { start, end };
|
|
134
138
|
},
|
package/dist/ChangeTypes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeTypes.js","sourceRoot":"","sources":["../src/ChangeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DA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c,EAAE,KAAK,EAAE,CAAC;IAC/F;;OAEG;IACH,OAAO,EAAE,CAAC,KAAoB,EAAe,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,sBAAI,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;CAC9F,CAAC;AAEF,oGAAoG;AACpG;;GAEG;AACU,QAAA,WAAW,GAAG;IAC1B;;;;OAIG;IACH,IAAI,EAAE,CAAC,KAAkB,EAA6C,EAAE,CAAC,CAAC;QACzE,EAAE,EAAE,CAAC,GAAgB,EAAe,EAAE;YACrC,IAAI,KAAK,CAAC,cAAc,IAAI,GAAG,CAAC,cAAc,EAAE;gBAC/C,IAAA,qBAAM,EACL,KAAK,CAAC,cAAc,CAAC,MAAM,KAAK,GAAG,CAAC,cAAc,CAAC,MAAM,EACzD,KAAK,CAAC,wEAAwE,CAC9E,CAAC;gBACF,IAAA,qBAAM,EACL,KAAK,CAAC,cAAc,CAAC,KAAK,KAAK,GAAG,CAAC,cAAc,CAAC,KAAK,EACvD,KAAK,CAAC,wEAAwE,CAC9E,CAAC;aACF;YACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QACvB,CAAC;KACD,CAAC;IACF;;;OAGG;IACH,IAAI,EAAE,CAAC,IAA+B,EAAe,EAAE,CAAC,CAAC;QACxD,KAAK,EAAE,mBAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QAC/B,GAAG,EAAE,mBAAW,CAAC,KAAK,CAAC,IAAI,CAAC;KAC5B,CAAC;IACF;;;;OAIG;IACH,GAAG,EAAE,CAAC,KAAoB,EAAe,EAAE,CAAC,CAAC;QAC5C,KAAK,EAAE,mBAAW,CAAC,SAAS,CAAC,KAAK,CAAC;QACnC,GAAG,EAAE,mBAAW,CAAC,OAAO,CAAC,KAAK,CAAC;KAC/B,CAAC;CACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/common-utils';\nimport { NodeId, TraitLabel, UuidString } from './Identifiers';\nimport { assertNotUndefined } from './Common';\nimport { ConstraintEffect, NodeData, Payload, Side, TreeNodeSequence } from './persisted-types';\nimport { TraitLocation } from './TreeView';\nimport { getNodeId } from './NodeIdUtilities';\n\n/**\n * An object which may have traits with children of the given type underneath it\n * @public\n */\nexport interface HasVariadicTraits<TChild> {\n\treadonly traits?: {\n\t\treadonly [key: string]: TChild | TreeNodeSequence<TChild> | undefined;\n\t};\n}\n\n/**\n * The type of a Change\n * @public\n */\nexport enum ChangeType {\n\tInsert,\n\tDetach,\n\tBuild,\n\tSetValue,\n\tConstraint,\n}\n\n/**\n * A change that composes an Edit.\n *\n * `Change` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * Change.insert(sourceId, destination)\n * @public\n */\nexport type Change = Insert | Detach | Build | SetValue | Constraint;\n\n/**\n * Node or a detached sequence of nodes (referred to by a detached sequence ID) for use in a Build change.\n * See `BuildTreeNode` for more.\n * @public\n */\nexport type BuildNode = BuildTreeNode | number;\n\n/**\n * Node for use in a Build change, which is composed of a definition describing what this nodes type, an identifier identifying this node\n * within the tree, and a payload containing an opaque serializable piece of data.\n * An identifier can be provided explicitly if the node must be referred to before the results of the `Change` containing this\n * BuildTreeNode can be observed. If `identifier` is not supplied, one will be generated for it in an especially efficient manner\n * that allows for compact storage and transmission and thus this property should be omitted if convenient.\n * See the SharedTree readme for more on the tree format.\n */\nexport interface BuildTreeNode extends HasVariadicTraits<BuildNode> {\n\tdefinition: string;\n\tidentifier?: NodeId;\n\tpayload?: Payload;\n}\n\n/**\n * Constructs a sequence of nodes, associates it with the supplied ID, and stores it for use in later changes.\n * Does not modify the document.\n *\n * Valid if (transitively) all DetachedSequenceId are used according to their rules (use here counts as a destination),\n * and all Nodes' identifiers are previously unused.\n *\n * @public\n */\nexport interface Build {\n\treadonly destination: number;\n\treadonly source: BuildNode | TreeNodeSequence<BuildNode>;\n\treadonly type: typeof ChangeType.Build;\n}\n\n/**\n * Inserts a sequence of nodes at the specified destination.\n * The source can be constructed either by a Build (used to insert new nodes) or a Detach (amounts to a \"move\" operation).\n * @public\n */\nexport interface Insert {\n\treadonly destination: StablePlace;\n\treadonly source: number;\n\treadonly type: typeof ChangeType.Insert;\n}\n\n/**\n * Removes a sequence of nodes from the tree.\n * If a destination is specified, the detached sequence is associated with that ID and held for possible reuse\n * by later changes in this same Edit (such as by an Insert).\n * A Detach without a destination is a deletion of the specified sequence, as is a Detach with a destination that is not used later.\n * @public\n */\nexport interface Detach {\n\treadonly destination?: number;\n\treadonly source: StableRange;\n\treadonly type: typeof ChangeType.Detach;\n}\n\n/**\n * Modifies the payload of a node.\n * @public\n */\nexport interface SetValue {\n\treadonly nodeToModify: NodeId;\n\t/**\n\t * Sets or clears the payload.\n\t * To improve ease of forwards compatibility, an explicit `null` value is used to represent the clearing of a payload.\n\t * SetValue may use `undefined` in future API versions to mean \"don't change the payload\" (which is useful if e.g. other\n\t * fields are added to SetValue that can be changed without altering the payload)\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\treadonly payload: Payload | null;\n\treadonly type: typeof ChangeType.SetValue;\n}\n\n/**\n * A set of constraints on the validity of an Edit.\n * A Constraint is used to detect when an Edit, due to other concurrent edits, may have unintended effects or merge in\n * non-semantic ways. It is processed in order like any other Change in an Edit. It can cause an edit to fail if the\n * various constraints are not met at the time of evaluation (ex: the parentNode has changed due to concurrent editing).\n * Does not modify the document.\n * @public\n */\nexport interface Constraint {\n\t/**\n\t * Selects a sequence of nodes which will be checked against the constraints specified by the optional fields.\n\t * If `toConstrain` is invalid, it will be treated like a constraint being unmet.\n\t * Depending on `effect` this may or may not make the Edit invalid.\n\t *\n\t * When a constraint is not met, the effects is specified by `effect`.\n\t */\n\treadonly toConstrain: StableRange;\n\n\t/**\n\t * Require that the identities of all the nodes in toConstrain hash to this value.\n\t * Hash is order dependent.\n\t * TODO: implement and specify exact hash function.\n\t *\n\t * This is an efficient (O(1) space) way to constrain a sequence of nodes to have specific identities.\n\t */\n\treadonly identityHash?: UuidString;\n\n\t/**\n\t * Require that the number of nodes in toConstrain is this value.\n\t */\n\treadonly length?: number;\n\n\t/**\n\t * Require that the contents of all of the nodes in toConstrain hash to this value.\n\t * Hash is an order dependant deep hash, which includes all subtree content recursively.\n\t * TODO: implement and specify exact hash function.\n\t *\n\t * This is an efficient (O(1) space) way to constrain a sequence of nodes have exact values (transitively).\n\t */\n\treadonly contentHash?: UuidString;\n\n\t/**\n\t * Require that parent under which toConstrain is located has this identifier.\n\t */\n\treadonly parentNode?: NodeId;\n\n\t/**\n\t * Require that the trait under which toConstrain is located has this label.\n\t */\n\treadonly label?: TraitLabel;\n\n\t/**\n\t * What to do if a constraint is not met.\n\t */\n\treadonly effect: ConstraintEffect;\n\n\t/**\n\t * Marker for which kind of Change this is.\n\t */\n\treadonly type: typeof ChangeType.Constraint;\n}\n\n// Note: Documentation of this constant is merged with documentation of the `Change` interface.\n/**\n * @public\n */\nexport const Change = {\n\tbuild: (source: BuildNode | TreeNodeSequence<BuildNode>, destination: number): Build => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Build,\n\t}),\n\n\tinsert: (source: number, destination: StablePlace): Insert => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Insert,\n\t}),\n\n\tdetach: (source: StableRange, destination?: number): Detach => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Detach,\n\t}),\n\n\tsetPayload: (nodeToModify: NodeId, payload: Payload): SetValue => ({\n\t\tnodeToModify,\n\t\tpayload,\n\t\ttype: ChangeType.SetValue,\n\t}),\n\n\tclearPayload: (nodeToModify: NodeId): SetValue => ({\n\t\tnodeToModify,\n\t\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface above.)\n\t\tpayload: null,\n\t\ttype: ChangeType.SetValue,\n\t}),\n\n\tconstraint: (\n\t\ttoConstrain: StableRange,\n\t\teffect: ConstraintEffect,\n\t\tidentityHash?: UuidString,\n\t\tlength?: number,\n\t\tcontentHash?: UuidString,\n\t\tparentNode?: NodeId,\n\t\tlabel?: TraitLabel\n\t): Constraint => ({\n\t\ttoConstrain,\n\t\teffect,\n\t\tidentityHash,\n\t\tlength,\n\t\tcontentHash,\n\t\tparentNode,\n\t\tlabel,\n\t\ttype: ChangeType.Constraint,\n\t}),\n\n\t/** Helpers for making high-level composite operations */\n\n\t/**\n\t * @returns a change that deletes the supplied part of the tree.\n\t */\n\tdelete: (stableRange: StableRange): Change => Change.detach(stableRange),\n\n\t/**\n\t * @returns changes that insert 'nodes' into the specified location in the tree.\n\t */\n\tinsertTree: (nodes: BuildNode | TreeNodeSequence<BuildNode>, destination: StablePlace): Change[] => {\n\t\tconst build = Change.build(nodes, 0);\n\t\treturn [build, Change.insert(build.destination, destination)];\n\t},\n\n\t/**\n\t * @returns changes that moves the specified content to a new location in the tree.\n\t */\n\tmove: (source: StableRange, destination: StablePlace): Change[] => {\n\t\tconst detach = Change.detach(source, 0);\n\t\treturn [detach, Change.insert(assertNotUndefined(detach.destination), destination)];\n\t},\n};\n\n/**\n * A location in a trait.\n * This is NOT the location of a node, but a location where a node could be inserted:\n * it is next to a sibling or at one end of the trait.\n *\n * To be well formed, either `sibling` or `trait` must be defined, but not both.\n *\n * Any given insertion location can be described by two `StablePlace` objects, one with `Side.After` and one with `Side.Before`.\n * For example, in a trait containing two strings \"foo\" and \"bar\", there are 6 different `StablePlace`s corresponding to 3 locations in the\n * trait a new node could be inserted: at the start, before \"foo\", after \"foo\", before \"bar\", after \"bar\", and at the end.\n * Neither of the two ways to specify the same location are considered to be after each other.\n *\n * The anchor (`referenceSibling` or `referenceTrait`) used for a particular `StablePlace` can have an impact in collaborative scenarios.\n *\n * `StablePlace` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * StablePlace.before(node)\n * StablePlace.atStartOf(trait)\n * @public\n */\nexport interface StablePlace {\n\t/**\n\t * Where this StablePlace is relative to the sibling (if specified), or an end of the trait (if no sibling specified).\n\t * If 'After' and there is no sibling, this StablePlace is after the front of the trait.\n\t * If 'Before' and there is no sibling, this StablePlace is before the back of the trait.\n\t */\n\treadonly side: Side;\n\n\t/**\n\t * The sibling to which this 'StablePlace' is anchored (by 'side').\n\t * If specified, referenceTrait must be unspecified.\n\t */\n\treadonly referenceSibling?: NodeId;\n\n\t/**\n\t * The trait to which this 'StablePlace' is anchored (by 'side').\n\t * If specified, referenceSibling must be unspecified.\n\t */\n\treadonly referenceTrait?: TraitLocation;\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait.\n * Valid iff start and end are valid and are within the same trait and the start does not occur after the end in the trait.\n *\n * See {@link (StablePlace:interface)} for what it means for a place to be \"after\" another place.\n *\n * `StableRange` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n * @example\n * StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))\n * @public\n */\nexport interface StableRange {\n\treadonly start: StablePlace;\n\treadonly end: StablePlace;\n}\n\n/**\n * The remainder of this file consists of ergonomic factory methods for persisted types, or common combinations thereof (e.g. \"Move\" as a\n * combination of a \"Detach\" change and an \"Insert\" change).\n *\n * None of these helpers are persisted in documents, and therefore changes to their semantics need only follow standard semantic versioning\n * practices.\n */\n\n// Note: Documentation of this constant is merged with documentation of the `StablePlace` interface.\n/**\n * @public\n */\nexport const StablePlace = {\n\t/**\n\t * @returns The location directly before `node`.\n\t */\n\tbefore: (node: NodeData<NodeId> | NodeId): StablePlace => ({\n\t\tside: Side.Before,\n\t\treferenceSibling: getNodeId(node),\n\t}),\n\t/**\n\t * @returns The location directly after `node`.\n\t */\n\tafter: (node: NodeData<NodeId> | NodeId): StablePlace => ({ side: Side.After, referenceSibling: getNodeId(node) }),\n\t/**\n\t * @returns The location at the start of `trait`.\n\t */\n\tatStartOf: (trait: TraitLocation): StablePlace => ({ side: Side.After, referenceTrait: trait }),\n\t/**\n\t * @returns The location at the end of `trait`.\n\t */\n\tatEndOf: (trait: TraitLocation): StablePlace => ({ side: Side.Before, referenceTrait: trait }),\n};\n\n// Note: Documentation of this constant is merged with documentation of the `StableRange` interface.\n/**\n * @public\n */\nexport const StableRange = {\n\t/**\n\t * Factory for producing a `StableRange` from a start `StablePlace` to an end `StablePlace`.\n\t * @example\n\t * StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))\n\t */\n\tfrom: (start: StablePlace): { to: (end: StablePlace) => StableRange } => ({\n\t\tto: (end: StablePlace): StableRange => {\n\t\t\tif (start.referenceTrait && end.referenceTrait) {\n\t\t\t\tassert(\n\t\t\t\t\tstart.referenceTrait.parent === end.referenceTrait.parent,\n\t\t\t\t\t0x5fe /* StableRange must be constructed with endpoints from the same trait */\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tstart.referenceTrait.label === end.referenceTrait.label,\n\t\t\t\t\t0x5ff /* StableRange must be constructed with endpoints from the same trait */\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { start, end };\n\t\t},\n\t}),\n\t/**\n\t * @returns a `StableRange` which contains only the provided `node`.\n\t * Both the start and end `StablePlace` objects used to anchor this `StableRange` are in terms of the passed in node.\n\t */\n\tonly: (node: NodeData<NodeId> | NodeId): StableRange => ({\n\t\tstart: StablePlace.before(node),\n\t\tend: StablePlace.after(node),\n\t}),\n\t/**\n\t * @returns a `StableRange` which contains everything in the trait.\n\t * This is anchored using the provided `trait`, and is independent of the actual contents of the trait:\n\t * it does not use sibling anchoring.\n\t */\n\tall: (trait: TraitLocation): StableRange => ({\n\t\tstart: StablePlace.atStartOf(trait),\n\t\tend: StablePlace.atEndOf(trait),\n\t}),\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ChangeTypes.js","sourceRoot":"","sources":["../src/ChangeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAEpD,qCAA8C;AAC9C,uDAAgG;AAEhG,uDAA8C;AAY9C;;;GAGG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,+CAAM,CAAA;IACN,+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MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;CAC9F,CAAC;AAEF,oGAAoG;AACpG;;GAEG;AACU,QAAA,WAAW,GAAG;IAC1B;;;;;;;;OAQG;IACH,IAAI,EAAE,CAAC,KAAkB,EAA6C,EAAE,CAAC,CAAC;QACzE,EAAE,EAAE,CAAC,GAAgB,EAAe,EAAE;YACrC,IAAI,KAAK,CAAC,cAAc,IAAI,GAAG,CAAC,cAAc,EAAE;gBAC/C,IAAA,mBAAM,EACL,KAAK,CAAC,cAAc,CAAC,MAAM,KAAK,GAAG,CAAC,cAAc,CAAC,MAAM,EACzD,KAAK,CAAC,wEAAwE,CAC9E,CAAC;gBACF,IAAA,mBAAM,EACL,KAAK,CAAC,cAAc,CAAC,KAAK,KAAK,GAAG,CAAC,cAAc,CAAC,KAAK,EACvD,KAAK,CAAC,wEAAwE,CAC9E,CAAC;aACF;YACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QACvB,CAAC;KACD,CAAC;IACF;;;OAGG;IACH,IAAI,EAAE,CAAC,IAA+B,EAAe,EAAE,CAAC,CAAC;QACxD,KAAK,EAAE,mBAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QAC/B,GAAG,EAAE,mBAAW,CAAC,KAAK,CAAC,IAAI,CAAC;KAC5B,CAAC;IACF;;;;OAIG;IACH,GAAG,EAAE,CAAC,KAAoB,EAAe,EAAE,CAAC,CAAC;QAC5C,KAAK,EAAE,mBAAW,CAAC,SAAS,CAAC,KAAK,CAAC;QACnC,GAAG,EAAE,mBAAW,CAAC,OAAO,CAAC,KAAK,CAAC;KAC/B,CAAC;CACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { NodeId, TraitLabel, UuidString } from './Identifiers';\nimport { assertNotUndefined } from './Common';\nimport { ConstraintEffect, NodeData, Payload, Side, TreeNodeSequence } from './persisted-types';\nimport { TraitLocation } from './TreeView';\nimport { getNodeId } from './NodeIdUtilities';\n\n/**\n * An object which may have traits with children of the given type underneath it\n * @public\n */\nexport interface HasVariadicTraits<TChild> {\n\treadonly traits?: {\n\t\treadonly [key: string]: TChild | TreeNodeSequence<TChild> | undefined;\n\t};\n}\n\n/**\n * The type of a Change\n * @public\n */\nexport enum ChangeType {\n\tInsert,\n\tDetach,\n\tBuild,\n\tSetValue,\n\tConstraint,\n}\n\n/**\n * A change that composes an Edit.\n *\n * @remarks\n *\n * `Change` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n *\n * @example\n *\n * ```typescript\n * Change.insert(sourceId, destination)\n * ```\n *\n * @public\n */\nexport type Change = Insert | Detach | Build | SetValue | Constraint;\n\n/**\n * Node or a detached sequence of nodes (referred to by a detached sequence ID) for use in a Build change.\n * See `BuildTreeNode` for more.\n * @public\n */\nexport type BuildNode = BuildTreeNode | number;\n\n/**\n * Node for use in a Build change, which is composed of a definition describing what this nodes type, an identifier identifying this node\n * within the tree, and a payload containing an opaque serializable piece of data.\n * An identifier can be provided explicitly if the node must be referred to before the results of the `Change` containing this\n * BuildTreeNode can be observed. If `identifier` is not supplied, one will be generated for it in an especially efficient manner\n * that allows for compact storage and transmission and thus this property should be omitted if convenient.\n * See the SharedTree readme for more on the tree format.\n */\nexport interface BuildTreeNode extends HasVariadicTraits<BuildNode> {\n\tdefinition: string;\n\tidentifier?: NodeId;\n\tpayload?: Payload;\n}\n\n/**\n * Constructs a sequence of nodes, associates it with the supplied ID, and stores it for use in later changes.\n * Does not modify the document.\n *\n * Valid if (transitively) all DetachedSequenceId are used according to their rules (use here counts as a destination),\n * and all Nodes' identifiers are previously unused.\n *\n * @public\n */\nexport interface Build {\n\treadonly destination: number;\n\treadonly source: BuildNode | TreeNodeSequence<BuildNode>;\n\treadonly type: typeof ChangeType.Build;\n}\n\n/**\n * Inserts a sequence of nodes at the specified destination.\n * The source can be constructed either by a Build (used to insert new nodes) or a Detach (amounts to a \"move\" operation).\n * @public\n */\nexport interface Insert {\n\treadonly destination: StablePlace;\n\treadonly source: number;\n\treadonly type: typeof ChangeType.Insert;\n}\n\n/**\n * Removes a sequence of nodes from the tree.\n * If a destination is specified, the detached sequence is associated with that ID and held for possible reuse\n * by later changes in this same Edit (such as by an Insert).\n * A Detach without a destination is a deletion of the specified sequence, as is a Detach with a destination that is not used later.\n * @public\n */\nexport interface Detach {\n\treadonly destination?: number;\n\treadonly source: StableRange;\n\treadonly type: typeof ChangeType.Detach;\n}\n\n/**\n * Modifies the payload of a node.\n * @public\n */\nexport interface SetValue {\n\treadonly nodeToModify: NodeId;\n\t/**\n\t * Sets or clears the payload.\n\t * To improve ease of forwards compatibility, an explicit `null` value is used to represent the clearing of a payload.\n\t * SetValue may use `undefined` in future API versions to mean \"don't change the payload\" (which is useful if e.g. other\n\t * fields are added to SetValue that can be changed without altering the payload)\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\treadonly payload: Payload | null;\n\treadonly type: typeof ChangeType.SetValue;\n}\n\n/**\n * A set of constraints on the validity of an Edit.\n * A Constraint is used to detect when an Edit, due to other concurrent edits, may have unintended effects or merge in\n * non-semantic ways. It is processed in order like any other Change in an Edit. It can cause an edit to fail if the\n * various constraints are not met at the time of evaluation (ex: the parentNode has changed due to concurrent editing).\n * Does not modify the document.\n * @public\n */\nexport interface Constraint {\n\t/**\n\t * Selects a sequence of nodes which will be checked against the constraints specified by the optional fields.\n\t * If `toConstrain` is invalid, it will be treated like a constraint being unmet.\n\t * Depending on `effect` this may or may not make the Edit invalid.\n\t *\n\t * When a constraint is not met, the effects is specified by `effect`.\n\t */\n\treadonly toConstrain: StableRange;\n\n\t/**\n\t * Require that the identities of all the nodes in toConstrain hash to this value.\n\t * Hash is order dependent.\n\t * TODO: implement and specify exact hash function.\n\t *\n\t * This is an efficient (O(1) space) way to constrain a sequence of nodes to have specific identities.\n\t */\n\treadonly identityHash?: UuidString;\n\n\t/**\n\t * Require that the number of nodes in toConstrain is this value.\n\t */\n\treadonly length?: number;\n\n\t/**\n\t * Require that the contents of all of the nodes in toConstrain hash to this value.\n\t * Hash is an order dependant deep hash, which includes all subtree content recursively.\n\t * TODO: implement and specify exact hash function.\n\t *\n\t * This is an efficient (O(1) space) way to constrain a sequence of nodes have exact values (transitively).\n\t */\n\treadonly contentHash?: UuidString;\n\n\t/**\n\t * Require that parent under which toConstrain is located has this identifier.\n\t */\n\treadonly parentNode?: NodeId;\n\n\t/**\n\t * Require that the trait under which toConstrain is located has this label.\n\t */\n\treadonly label?: TraitLabel;\n\n\t/**\n\t * What to do if a constraint is not met.\n\t */\n\treadonly effect: ConstraintEffect;\n\n\t/**\n\t * Marker for which kind of Change this is.\n\t */\n\treadonly type: typeof ChangeType.Constraint;\n}\n\n// Note: Documentation of this constant is merged with documentation of the `Change` interface.\n/**\n * @public\n */\nexport const Change = {\n\tbuild: (source: BuildNode | TreeNodeSequence<BuildNode>, destination: number): Build => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Build,\n\t}),\n\n\tinsert: (source: number, destination: StablePlace): Insert => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Insert,\n\t}),\n\n\tdetach: (source: StableRange, destination?: number): Detach => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Detach,\n\t}),\n\n\tsetPayload: (nodeToModify: NodeId, payload: Payload): SetValue => ({\n\t\tnodeToModify,\n\t\tpayload,\n\t\ttype: ChangeType.SetValue,\n\t}),\n\n\tclearPayload: (nodeToModify: NodeId): SetValue => ({\n\t\tnodeToModify,\n\t\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface above.)\n\t\tpayload: null,\n\t\ttype: ChangeType.SetValue,\n\t}),\n\n\tconstraint: (\n\t\ttoConstrain: StableRange,\n\t\teffect: ConstraintEffect,\n\t\tidentityHash?: UuidString,\n\t\tlength?: number,\n\t\tcontentHash?: UuidString,\n\t\tparentNode?: NodeId,\n\t\tlabel?: TraitLabel\n\t): Constraint => ({\n\t\ttoConstrain,\n\t\teffect,\n\t\tidentityHash,\n\t\tlength,\n\t\tcontentHash,\n\t\tparentNode,\n\t\tlabel,\n\t\ttype: ChangeType.Constraint,\n\t}),\n\n\t/** Helpers for making high-level composite operations */\n\n\t/**\n\t * @returns a change that deletes the supplied part of the tree.\n\t */\n\tdelete: (stableRange: StableRange): Change => Change.detach(stableRange),\n\n\t/**\n\t * @returns changes that insert 'nodes' into the specified location in the tree.\n\t */\n\tinsertTree: (nodes: BuildNode | TreeNodeSequence<BuildNode>, destination: StablePlace): Change[] => {\n\t\tconst build = Change.build(nodes, 0);\n\t\treturn [build, Change.insert(build.destination, destination)];\n\t},\n\n\t/**\n\t * @returns changes that moves the specified content to a new location in the tree.\n\t */\n\tmove: (source: StableRange, destination: StablePlace): Change[] => {\n\t\tconst detach = Change.detach(source, 0);\n\t\treturn [detach, Change.insert(assertNotUndefined(detach.destination), destination)];\n\t},\n};\n\n/**\n * A location in a trait.\n * This is NOT the location of a node, but a location where a node could be inserted:\n * it is next to a sibling or at one end of the trait.\n *\n * To be well formed, either `sibling` or `trait` must be defined, but not both.\n *\n * Any given insertion location can be described by two `StablePlace` objects, one with `Side.After` and one with `Side.Before`.\n * For example, in a trait containing two strings \"foo\" and \"bar\", there are 6 different `StablePlace`s corresponding to 3 locations in the\n * trait a new node could be inserted: at the start, before \"foo\", after \"foo\", before \"bar\", after \"bar\", and at the end.\n * Neither of the two ways to specify the same location are considered to be after each other.\n *\n * The anchor (`referenceSibling` or `referenceTrait`) used for a particular `StablePlace` can have an impact in collaborative scenarios.\n *\n * `StablePlace` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n *\n * @example\n *\n * ```typescript\n * StablePlace.before(node)\n * StablePlace.atStartOf(trait)\n * ```\n *\n * @public\n */\nexport interface StablePlace {\n\t/**\n\t * Where this StablePlace is relative to the sibling (if specified), or an end of the trait (if no sibling specified).\n\t * If 'After' and there is no sibling, this StablePlace is after the front of the trait.\n\t * If 'Before' and there is no sibling, this StablePlace is before the back of the trait.\n\t */\n\treadonly side: Side;\n\n\t/**\n\t * The sibling to which this 'StablePlace' is anchored (by 'side').\n\t * If specified, referenceTrait must be unspecified.\n\t */\n\treadonly referenceSibling?: NodeId;\n\n\t/**\n\t * The trait to which this 'StablePlace' is anchored (by 'side').\n\t * If specified, referenceSibling must be unspecified.\n\t */\n\treadonly referenceTrait?: TraitLocation;\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait.\n * Valid iff start and end are valid and are within the same trait and the start does not occur after the end in the trait.\n *\n * See {@link (StablePlace:interface)} for what it means for a place to be \"after\" another place.\n *\n * @remarks\n *\n * `StableRange` objects can be conveniently constructed with the helper methods exported on a constant of the same name.\n *\n * @example\n *\n * ```typescript\n * StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))\n * ```\n *\n * @public\n */\nexport interface StableRange {\n\treadonly start: StablePlace;\n\treadonly end: StablePlace;\n}\n\n/**\n * The remainder of this file consists of ergonomic factory methods for persisted types, or common combinations thereof (e.g. \"Move\" as a\n * combination of a \"Detach\" change and an \"Insert\" change).\n *\n * None of these helpers are persisted in documents, and therefore changes to their semantics need only follow standard semantic versioning\n * practices.\n */\n\n// Note: Documentation of this constant is merged with documentation of the `StablePlace` interface.\n/**\n * @public\n */\nexport const StablePlace = {\n\t/**\n\t * @returns The location directly before `node`.\n\t */\n\tbefore: (node: NodeData<NodeId> | NodeId): StablePlace => ({\n\t\tside: Side.Before,\n\t\treferenceSibling: getNodeId(node),\n\t}),\n\t/**\n\t * @returns The location directly after `node`.\n\t */\n\tafter: (node: NodeData<NodeId> | NodeId): StablePlace => ({ side: Side.After, referenceSibling: getNodeId(node) }),\n\t/**\n\t * @returns The location at the start of `trait`.\n\t */\n\tatStartOf: (trait: TraitLocation): StablePlace => ({ side: Side.After, referenceTrait: trait }),\n\t/**\n\t * @returns The location at the end of `trait`.\n\t */\n\tatEndOf: (trait: TraitLocation): StablePlace => ({ side: Side.Before, referenceTrait: trait }),\n};\n\n// Note: Documentation of this constant is merged with documentation of the `StableRange` interface.\n/**\n * @public\n */\nexport const StableRange = {\n\t/**\n\t * Factory for producing a `StableRange` from a start `StablePlace` to an end `StablePlace`.\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * StableRange.from(StablePlace.before(startNode)).to(StablePlace.after(endNode))\n\t * ```\n\t */\n\tfrom: (start: StablePlace): { to: (end: StablePlace) => StableRange } => ({\n\t\tto: (end: StablePlace): StableRange => {\n\t\t\tif (start.referenceTrait && end.referenceTrait) {\n\t\t\t\tassert(\n\t\t\t\t\tstart.referenceTrait.parent === end.referenceTrait.parent,\n\t\t\t\t\t0x5fe /* StableRange must be constructed with endpoints from the same trait */\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tstart.referenceTrait.label === end.referenceTrait.label,\n\t\t\t\t\t0x5ff /* StableRange must be constructed with endpoints from the same trait */\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { start, end };\n\t\t},\n\t}),\n\t/**\n\t * @returns a `StableRange` which contains only the provided `node`.\n\t * Both the start and end `StablePlace` objects used to anchor this `StableRange` are in terms of the passed in node.\n\t */\n\tonly: (node: NodeData<NodeId> | NodeId): StableRange => ({\n\t\tstart: StablePlace.before(node),\n\t\tend: StablePlace.after(node),\n\t}),\n\t/**\n\t * @returns a `StableRange` which contains everything in the trait.\n\t * This is anchored using the provided `trait`, and is independent of the actual contents of the trait:\n\t * it does not use sibling anchoring.\n\t */\n\tall: (trait: TraitLocation): StableRange => ({\n\t\tstart: StablePlace.atStartOf(trait),\n\t\tend: StablePlace.atEndOf(trait),\n\t}),\n};\n"]}
|
package/dist/Checkout.d.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';
|
|
6
|
-
import { IErrorEvent } from '@fluidframework/
|
|
7
|
-
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
6
|
+
import { IDisposable, IErrorEvent } from '@fluidframework/core-interfaces';
|
|
8
7
|
import { EditId } from './Identifiers';
|
|
9
8
|
import { TreeView } from './TreeView';
|
|
10
9
|
import { RevisionView } from './RevisionView';
|
|
@@ -169,6 +168,7 @@ export declare abstract class Checkout extends EventEmitterWithErrorHandling<ICh
|
|
|
169
168
|
tryApplyEdit(...changes: readonly Change[]): EditId | undefined;
|
|
170
169
|
/**
|
|
171
170
|
* Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.
|
|
171
|
+
*
|
|
172
172
|
* If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current
|
|
173
173
|
* view will reflect those changes.
|
|
174
174
|
*
|
|
@@ -176,7 +176,8 @@ export declare abstract class Checkout extends EventEmitterWithErrorHandling<ICh
|
|
|
176
176
|
* currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.
|
|
177
177
|
*
|
|
178
178
|
* Must only be called during an open edit.
|
|
179
|
-
*
|
|
179
|
+
*
|
|
180
|
+
* @returns The result of the rebase.
|
|
180
181
|
*/
|
|
181
182
|
rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid;
|
|
182
183
|
/**
|
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;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,6BAA6B,EAA0C,MAAM,iCAAiC,CAAC;AACxH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAwB,MAAM,iCAAiC,CAAC;AAEjG,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO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AIG;IACI,aAAa,IAAI,UAAU;IAQlC;;;OAGG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAYnC;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI;IAU5B;;OAEG;aACa,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAEtD;;;OAGG;aACa,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAErD;;;OAGG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;CAUnC"}
|
package/dist/Checkout.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.Checkout = exports.EditValidationResult = exports.CheckoutEvent = void 0;
|
|
8
|
-
const
|
|
8
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
9
9
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
10
10
|
const Common_1 = require("./Common");
|
|
11
11
|
const LogViewer_1 = require("./LogViewer");
|
|
@@ -70,7 +70,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
70
70
|
});
|
|
71
71
|
this.disposed = false;
|
|
72
72
|
this.tree = tree;
|
|
73
|
-
this.logger = telemetry_utils_1.
|
|
73
|
+
this.logger = (0, telemetry_utils_1.createChildLogger)({ logger: this.tree.logger, namespace: 'Checkout' });
|
|
74
74
|
if (tree.logViewer instanceof LogViewer_1.CachingLogViewer) {
|
|
75
75
|
this.cachingLogViewer = tree.logViewer;
|
|
76
76
|
}
|
|
@@ -84,8 +84,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
84
84
|
* Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.
|
|
85
85
|
*/
|
|
86
86
|
get currentView() {
|
|
87
|
-
|
|
88
|
-
return (_b = (_a = this.currentEdit) === null || _a === void 0 ? void 0 : _a.view) !== null && _b !== void 0 ? _b : this.latestCommittedView;
|
|
87
|
+
return this.currentEdit?.view ?? this.latestCommittedView;
|
|
89
88
|
}
|
|
90
89
|
/**
|
|
91
90
|
* @returns true iff there is an open edit.
|
|
@@ -99,7 +98,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
99
98
|
* Changes accumulate in the edit via calls to `applyChanges()`.
|
|
100
99
|
*/
|
|
101
100
|
openEdit() {
|
|
102
|
-
(0,
|
|
101
|
+
(0, core_utils_1.assert)(this.currentEdit === undefined, 0x600 /* An edit is already open. */);
|
|
103
102
|
this.currentEdit = TransactionInternal_1.TransactionInternal.factory(this.latestCommittedView);
|
|
104
103
|
}
|
|
105
104
|
/**
|
|
@@ -112,9 +111,9 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
112
111
|
*/
|
|
113
112
|
closeEdit() {
|
|
114
113
|
const { currentEdit } = this;
|
|
115
|
-
(0,
|
|
114
|
+
(0, core_utils_1.assert)(currentEdit !== undefined, 0x601 /* An edit is not open. */);
|
|
116
115
|
this.currentEdit = undefined;
|
|
117
|
-
(0,
|
|
116
|
+
(0, core_utils_1.assert)(currentEdit.failure === undefined, 0x66d /* Cannot close a transaction that has already failed. Use abortEdit instead. */);
|
|
118
117
|
const editingResult = currentEdit.close();
|
|
119
118
|
this.validateChangesApplied(editingResult);
|
|
120
119
|
const id = (0, EditUtilities_1.newEditId)();
|
|
@@ -145,7 +144,12 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
145
144
|
default:
|
|
146
145
|
break;
|
|
147
146
|
}
|
|
148
|
-
this.logger.sendErrorEvent(
|
|
147
|
+
this.logger.sendErrorEvent({
|
|
148
|
+
eventName: 'FailedLocalEdit',
|
|
149
|
+
status: result.status === 0 ? 'Malformed' : 'Invalid',
|
|
150
|
+
failureKind: failure.kind,
|
|
151
|
+
...additionalProps,
|
|
152
|
+
});
|
|
149
153
|
(0, Common_1.fail)('Locally constructed edits must be well-formed and valid.');
|
|
150
154
|
}
|
|
151
155
|
/**
|
|
@@ -153,9 +157,8 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
153
157
|
* This may be used as a caching hint to avoid recomputation.
|
|
154
158
|
*/
|
|
155
159
|
hintKnownEditingResult(edit, result) {
|
|
156
|
-
var _a;
|
|
157
160
|
// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.
|
|
158
|
-
|
|
161
|
+
this.cachingLogViewer?.setKnownEditingResult(edit, result);
|
|
159
162
|
}
|
|
160
163
|
/**
|
|
161
164
|
* Take any needed action between when an edit is completed.
|
|
@@ -172,14 +175,14 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
172
175
|
this.tree.applyEditInternal(edit);
|
|
173
176
|
}
|
|
174
177
|
applyChanges(...changes) {
|
|
175
|
-
(0,
|
|
178
|
+
(0, core_utils_1.assert)(this.currentEdit !== undefined, 0x602 /* Changes must be applied as part of an ongoing edit. */);
|
|
176
179
|
const changeArray = (0, Common_1.unwrapRestOrArray)(changes);
|
|
177
180
|
const { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));
|
|
178
181
|
this.validateChangesApplied({ status, failure: this.currentEdit.failure });
|
|
179
182
|
this.emitChange();
|
|
180
183
|
}
|
|
181
184
|
tryApplyChangesInternal(...changes) {
|
|
182
|
-
(0,
|
|
185
|
+
(0, core_utils_1.assert)(this.currentEdit !== undefined, 0x603 /* Changes must be applied as part of an ongoing edit. */);
|
|
183
186
|
const changeArray = (0, Common_1.unwrapRestOrArray)(changes);
|
|
184
187
|
const { status } = this.currentEdit.applyChanges(changeArray);
|
|
185
188
|
if (status === persisted_types_1.EditStatus.Applied) {
|
|
@@ -195,7 +198,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
195
198
|
}
|
|
196
199
|
tryApplyEdit(...changes) {
|
|
197
200
|
this.openEdit();
|
|
198
|
-
(0,
|
|
201
|
+
(0, core_utils_1.assert)(this.currentEdit !== undefined, 0x604 /* Changes must be applied as part of an ongoing edit. */);
|
|
199
202
|
const changeArray = (0, Common_1.unwrapRestOrArray)(changes);
|
|
200
203
|
const { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));
|
|
201
204
|
if (status === persisted_types_1.EditStatus.Applied) {
|
|
@@ -207,6 +210,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
207
210
|
}
|
|
208
211
|
/**
|
|
209
212
|
* Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.
|
|
213
|
+
*
|
|
210
214
|
* If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current
|
|
211
215
|
* view will reflect those changes.
|
|
212
216
|
*
|
|
@@ -214,16 +218,17 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
214
218
|
* currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.
|
|
215
219
|
*
|
|
216
220
|
* Must only be called during an open edit.
|
|
217
|
-
*
|
|
221
|
+
*
|
|
222
|
+
* @returns The result of the rebase.
|
|
218
223
|
*/
|
|
219
224
|
rebaseCurrentEdit() {
|
|
220
|
-
(0,
|
|
221
|
-
(0,
|
|
225
|
+
(0, core_utils_1.assert)(this.currentEdit !== undefined, 0x605 /* An edit is not open. */);
|
|
226
|
+
(0, core_utils_1.assert)(this.currentEdit.status === persisted_types_1.EditStatus.Applied, 0x606 /* Local edits should always be valid. */);
|
|
222
227
|
// When closed, the result might indicate Malformed due to unused detached entities.
|
|
223
228
|
// This is not an error, as the edit was still open and can still use those entities.
|
|
224
229
|
const priorResults = this.currentEdit.close();
|
|
225
230
|
const rebasedEdit = TransactionInternal_1.TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);
|
|
226
|
-
(0,
|
|
231
|
+
(0, core_utils_1.assert)(rebasedEdit.status !== persisted_types_1.EditStatus.Malformed, 0x607 /* Malformed changes should have been caught on original application. */);
|
|
227
232
|
let status;
|
|
228
233
|
if (rebasedEdit.status === persisted_types_1.EditStatus.Invalid) {
|
|
229
234
|
status = EditValidationResult.Invalid;
|
|
@@ -242,7 +247,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
242
247
|
*/
|
|
243
248
|
abortEdit() {
|
|
244
249
|
const { currentEdit } = this;
|
|
245
|
-
(0,
|
|
250
|
+
(0, core_utils_1.assert)(currentEdit !== undefined, 0x608 /* An edit is not open. */);
|
|
246
251
|
this.currentEdit = undefined;
|
|
247
252
|
this.emitChange();
|
|
248
253
|
}
|
|
@@ -253,7 +258,7 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
253
258
|
*/
|
|
254
259
|
getEditStatus() {
|
|
255
260
|
const { currentEdit } = this;
|
|
256
|
-
(0,
|
|
261
|
+
(0, core_utils_1.assert)(currentEdit !== undefined, 0x609 /* An edit is not open. */);
|
|
257
262
|
// TODO: could this ever be anything other than 'Applied'
|
|
258
263
|
// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?
|
|
259
264
|
return currentEdit.status;
|
|
@@ -263,10 +268,9 @@ class Checkout extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
263
268
|
* @param editIds - the edits to revert
|
|
264
269
|
*/
|
|
265
270
|
revert(editId) {
|
|
266
|
-
var _a;
|
|
267
271
|
(0, Common_1.assertWithMessage)(this.currentEdit !== undefined);
|
|
268
272
|
const index = this.tree.edits.getIndexOfId(editId);
|
|
269
|
-
const edit =
|
|
273
|
+
const edit = this.tree.edits.tryGetEditAtIndex(index) ?? (0, Common_1.fail)('Edit with the specified ID does not exist in memory');
|
|
270
274
|
const before = this.tree.logViewer.getRevisionViewInMemory(index);
|
|
271
275
|
const changes = this.tree.revertChanges(edit.changes, before);
|
|
272
276
|
if (changes !== undefined) {
|