@fluid-experimental/tree 0.59.1000 → 0.59.2000-63294
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/api-extractor.json +5 -9
- package/dist/Checkout.js +1 -1
- package/dist/Checkout.js.map +1 -1
- package/dist/SharedTree.d.ts +16 -10
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +22 -10
- package/dist/SharedTree.js.map +1 -1
- package/dist/SummaryTestUtilities.js.map +1 -1
- package/dist/Transaction.d.ts +22 -2
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +26 -6
- package/dist/Transaction.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/persisted-types/0.1.1.d.ts +9 -0
- package/dist/persisted-types/0.1.1.d.ts.map +1 -1
- package/dist/persisted-types/0.1.1.js.map +1 -1
- package/lib/Checkout.js +1 -1
- package/lib/Checkout.js.map +1 -1
- package/lib/SharedTree.d.ts +16 -10
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +22 -10
- package/lib/SharedTree.js.map +1 -1
- package/lib/SummaryTestUtilities.js.map +1 -1
- package/lib/Transaction.d.ts +22 -2
- package/lib/Transaction.d.ts.map +1 -1
- package/lib/Transaction.js +25 -5
- package/lib/Transaction.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/persisted-types/0.1.1.d.ts +9 -0
- package/lib/persisted-types/0.1.1.d.ts.map +1 -1
- package/lib/persisted-types/0.1.1.js.map +1 -1
- package/lib/test/Forest.perf.tests.js +5 -3
- package/lib/test/Forest.perf.tests.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +1 -1
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/lib/test/Summary.tests.d.ts.map +1 -1
- package/lib/test/Summary.tests.js +3 -3
- package/lib/test/Summary.tests.js.map +1 -1
- package/lib/test/Transaction.tests.js +36 -2
- package/lib/test/Transaction.tests.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +2 -2
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.js +4 -4
- package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +59 -7
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
- package/lib/test/utilities/SummarySizeTests.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts +2 -0
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +9 -1
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/package.json +21 -18
- package/src/Checkout.ts +1 -1
- package/src/SharedTree.ts +39 -19
- package/src/SummaryTestUtilities.ts +1 -1
- package/src/Transaction.ts +38 -6
- package/src/index.ts +2 -1
- package/src/persisted-types/0.1.1.ts +11 -0
|
@@ -26,7 +26,7 @@ import { convertNodeDataIds } from '../../IdConversion';
|
|
|
26
26
|
import { buildLeaf, SimpleTestTree } from './TestNode';
|
|
27
27
|
import { TestFluidHandle, TestFluidSerializer } from './TestSerializer';
|
|
28
28
|
import { runSharedTreeUndoRedoTestSuite } from './UndoRedoTests';
|
|
29
|
-
import { areNodesEquivalent, assertNoDelta, setUpTestTree, testTrait, testTraitLabel, translateId, spyOnSubmittedOps, normalizeIds, normalizeId, normalizeEdit, setUpLocalServerTestSharedTree, applyNoop, getIdNormalizerFromSharedTree, waitForSummary, } from './TestUtilities';
|
|
29
|
+
import { areNodesEquivalent, assertNoDelta, setUpTestTree, testTrait, testTraitLabel, translateId, spyOnSubmittedOps, normalizeIds, normalizeId, normalizeEdit, setUpLocalServerTestSharedTree, applyNoop, getIdNormalizerFromSharedTree, waitForSummary, getEditLogInternal, } from './TestUtilities';
|
|
30
30
|
function revertEditInTree(tree, edit) {
|
|
31
31
|
return tree.revert(edit);
|
|
32
32
|
}
|
|
@@ -836,7 +836,7 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
836
836
|
headers: { [LoaderHeader.version]: secondSummaryVersion },
|
|
837
837
|
});
|
|
838
838
|
// Verify we loaded a no-history summary.
|
|
839
|
-
expect(tree3.
|
|
839
|
+
expect(tree3.edits.length).to.equal(1);
|
|
840
840
|
let unexpectedHistoryChunkCount = 0;
|
|
841
841
|
tree3.on(SharedTreeDiagnosticEvent.UnexpectedHistoryChunk, () => unexpectedHistoryChunkCount++);
|
|
842
842
|
await testObjectProvider.ensureSynchronized();
|
|
@@ -885,10 +885,12 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
885
885
|
expect(tree.equals(secondTree)).to.be.false;
|
|
886
886
|
containerRuntimeFactory.processAllMessages();
|
|
887
887
|
const { internedStrings } = tree.saveSummary();
|
|
888
|
-
const
|
|
889
|
-
const
|
|
890
|
-
const
|
|
891
|
-
const
|
|
888
|
+
const log = getEditLogInternal(tree);
|
|
889
|
+
const log2 = getEditLogInternal(secondTree);
|
|
890
|
+
const insertEdit = normalizeEdit(tree, log.getEditInSessionAtIndex(1));
|
|
891
|
+
const moveEdit = normalizeEdit(tree, log.getEditInSessionAtIndex(2));
|
|
892
|
+
const insertEdit2 = normalizeEdit(secondTree, log2.getEditInSessionAtIndex(1));
|
|
893
|
+
const moveEdit2 = normalizeEdit(secondTree, log2.getEditInSessionAtIndex(2));
|
|
892
894
|
expect(insertEdit).to.deep.equal(insertEdit2);
|
|
893
895
|
expect(moveEdit).to.deep.equal(moveEdit2);
|
|
894
896
|
expect(tree.equals(secondTree)).to.be.true;
|
|
@@ -920,7 +922,7 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
920
922
|
const testTree = setUpTestTree(tree);
|
|
921
923
|
const uncompressedEdits = [
|
|
922
924
|
{
|
|
923
|
-
changes: tree.
|
|
925
|
+
changes: getEditLogInternal(tree).getEditInSessionAtIndex(0).changes,
|
|
924
926
|
},
|
|
925
927
|
];
|
|
926
928
|
// Apply enough edits for the upload of an edit chunk
|
|
@@ -955,6 +957,56 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
955
957
|
});
|
|
956
958
|
});
|
|
957
959
|
}
|
|
960
|
+
describe('mergeEditsFrom', () => {
|
|
961
|
+
const getTestTreeRootHandle = (tree, testTree) => {
|
|
962
|
+
const view = tree.currentView;
|
|
963
|
+
const handle = new TreeNodeHandle(view, view.root);
|
|
964
|
+
return handle.traits[testTree.traitLabel][0];
|
|
965
|
+
};
|
|
966
|
+
it('can be used with simple edits', () => {
|
|
967
|
+
const { sharedTree, testTree } = createSimpleTestTree();
|
|
968
|
+
const { sharedTree: sharedTree2, testTree: testTree2 } = createSimpleTestTree();
|
|
969
|
+
sharedTree.applyEdit(...Change.insertTree(testTree.buildLeaf(), StablePlace.after(testTree.left)));
|
|
970
|
+
sharedTree.applyEdit(Change.delete(StableRange.all({ parent: testTree.identifier, label: testTree.right.traitLabel })));
|
|
971
|
+
const preEditRootHandle = getTestTreeRootHandle(sharedTree2, testTree2);
|
|
972
|
+
const edits = [0, 1, 2].map((i) => sharedTree.edits.getEditInSessionAtIndex(i));
|
|
973
|
+
// Since the TestTree setup edit is a `setTrait`, this should wipe `testTree2` state.
|
|
974
|
+
sharedTree2.mergeEditsFrom(sharedTree, edits);
|
|
975
|
+
expect(sharedTree2.edits.length).to.equal(4);
|
|
976
|
+
const rootHandle = getTestTreeRootHandle(sharedTree2, testTree2);
|
|
977
|
+
expect(preEditRootHandle.identifier).to.not.equal(rootHandle.identifier);
|
|
978
|
+
expect(rootHandle.traits[testTree2.left.traitLabel].length).to.equal(2);
|
|
979
|
+
});
|
|
980
|
+
it('can be used with a translation map', () => {
|
|
981
|
+
const { sharedTree, testTree } = createSimpleTestTree();
|
|
982
|
+
const { sharedTree: sharedTree2, testTree: testTree2 } = createSimpleTestTree();
|
|
983
|
+
// For each of the identities in the simple test tree...
|
|
984
|
+
const nodeIdGetters = [
|
|
985
|
+
(tree) => tree.identifier,
|
|
986
|
+
(tree) => tree.left.identifier,
|
|
987
|
+
(tree) => tree.right.identifier,
|
|
988
|
+
];
|
|
989
|
+
// Make a map translating that identifier from `testTree` to `testTree2`
|
|
990
|
+
const translationMap = new Map(nodeIdGetters.map((getter) => [
|
|
991
|
+
sharedTree.convertToStableNodeId(getter(testTree)),
|
|
992
|
+
sharedTree2.convertToStableNodeId(getter(testTree2)),
|
|
993
|
+
]));
|
|
994
|
+
sharedTree.applyEdit(...Change.insertTree(testTree.buildLeaf(), StablePlace.after(testTree.left)));
|
|
995
|
+
sharedTree.applyEdit(Change.delete(StableRange.all({ parent: testTree.identifier, label: testTree.right.traitLabel })));
|
|
996
|
+
const edits = [1, 2].map((i) => sharedTree.edits.getEditInSessionAtIndex(i));
|
|
997
|
+
sharedTree2.mergeEditsFrom(sharedTree, edits, (id) => { var _a; return (_a = translationMap.get(id)) !== null && _a !== void 0 ? _a : id; });
|
|
998
|
+
const root = getTestTreeRootHandle(sharedTree, testTree);
|
|
999
|
+
const root2 = getTestTreeRootHandle(sharedTree2, testTree2);
|
|
1000
|
+
const leftTrait = root.traits[testTree.left.traitLabel];
|
|
1001
|
+
const leftTrait2 = root2.traits[testTree2.left.traitLabel];
|
|
1002
|
+
// Inserted leaves should be equivalent.
|
|
1003
|
+
expect(leftTrait2.length).to.equal(2);
|
|
1004
|
+
expect(leftTrait2[1]).to.deep.equal(leftTrait[1]);
|
|
1005
|
+
// Right subtree should have been deleted.
|
|
1006
|
+
expect(Object.entries(root2.traits).length).to.equal(1);
|
|
1007
|
+
expect(root2.traits[testTree2.right.traitLabel]).to.equal(undefined);
|
|
1008
|
+
});
|
|
1009
|
+
});
|
|
958
1010
|
});
|
|
959
1011
|
}
|
|
960
1012
|
//# sourceMappingURL=SharedTreeTests.js.map
|