@fluid-experimental/tree 1.3.0 → 1.3.1
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/dist/HistoryEditFactory.d.ts +5 -3
- package/dist/HistoryEditFactory.d.ts.map +1 -1
- package/dist/HistoryEditFactory.js +18 -3
- package/dist/HistoryEditFactory.js.map +1 -1
- package/dist/SharedTree.js +1 -1
- package/dist/SharedTree.js.map +1 -1
- package/lib/HistoryEditFactory.d.ts +5 -3
- package/lib/HistoryEditFactory.d.ts.map +1 -1
- package/lib/HistoryEditFactory.js +18 -3
- package/lib/HistoryEditFactory.js.map +1 -1
- package/lib/SharedTree.js +1 -1
- package/lib/SharedTree.js.map +1 -1
- package/lib/test/HistoryEditFactory.tests.js +48 -9
- package/lib/test/HistoryEditFactory.tests.js.map +1 -1
- package/package.json +17 -17
- package/src/HistoryEditFactory.ts +24 -3
- package/src/SharedTree.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryEditFactory.tests.js","sourceRoot":"","sources":["../../src/test/HistoryEditFactory.tests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAkB,IAAI,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACpH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACvB,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IAEnC,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC5C,MAAM,eAAe,GAAG,CAAuB,CAAC;QAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,iBA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ed under the MIT License.\n */\n\nimport { expect } from 'chai';\nimport { revert } from '../HistoryEditFactory';\nimport { DetachedSequenceId } from '../Identifiers';\nimport { ChangeInternal, DetachInternal, Side, StablePlaceInternal, StableRangeInternal } from '../persisted-types';\nimport { expectDefined } from './utilities/TestCommon';\nimport { refreshTestTree } from './utilities/TestUtilities';\n\ndescribe('revert', () => {\n\tconst testTree = refreshTestTree();\n\n\tit('can revert a single detached node', () => {\n\t\tconst firstDetachedId = 0 as DetachedSequenceId;\n\t\tconst node = testTree.buildLeafInternal();\n\t\tconst firstBuild = ChangeInternal.build([node], firstDetachedId);\n\t\tconst insertedNodeId = 1 as DetachedSequenceId;\n\t\tconst insertedBuild = ChangeInternal.build([firstDetachedId], insertedNodeId);\n\t\tconst insertChange = ChangeInternal.insert(insertedNodeId, {\n\t\t\treferenceTrait: testTree.left.traitLocation,\n\t\t\tside: Side.After,\n\t\t});\n\t\tconst result = expectDefined(revert([firstBuild, insertedBuild, insertChange], testTree.view));\n\t\texpect(result.length).to.equal(1);\n\t\tconst revertedChange = result[0] as DetachInternal;\n\t\texpect(revertedChange.source.start.referenceSibling).to.deep.equal(node.identifier);\n\t\texpect(revertedChange.source.end.referenceSibling).to.deep.equal(node.identifier);\n\t});\n\n\tit('can revert multiple detached nodes', () => {\n\t\tconst firstDetachedId = 0 as DetachedSequenceId;\n\t\tconst firstNode = testTree.buildLeafInternal();\n\t\tconst firstBuild = ChangeInternal.build([firstNode], firstDetachedId);\n\t\tconst secondDetachedId = 1 as DetachedSequenceId;\n\t\tconst secondNode = testTree.buildLeafInternal();\n\t\tconst secondBuild = ChangeInternal.build([secondNode], secondDetachedId);\n\t\tconst insertedNodeId = 2 as DetachedSequenceId;\n\t\tconst insertedBuild = ChangeInternal.build([firstDetachedId, secondDetachedId], insertedNodeId);\n\t\tconst insertChange = ChangeInternal.insert(insertedNodeId, {\n\t\t\treferenceTrait: testTree.left.traitLocation,\n\t\t\tside: Side.After,\n\t\t});\n\t\tconst result = expectDefined(revert([firstBuild, secondBuild, insertedBuild, insertChange], testTree.view));\n\t\texpect(result.length).to.equal(1);\n\t\tconst revertedChange = result[0] as DetachInternal;\n\t\texpect(revertedChange.source.start.referenceSibling).to.deep.equal(firstNode.identifier);\n\t\texpect(revertedChange.source.end.referenceSibling).to.deep.equal(secondNode.identifier);\n\t});\n\n\tdescribe('returns undefined for reverts that require more context than the view directly before the edit', () => {\n\t\tdescribe('because the edit conflicted', () => {\n\t\t\tit('when reverting a detach of a node that is not in the tree', () => {\n\t\t\t\tconst nodeNotInTree = testTree.buildLeafInternal();\n\t\t\t\tconst change = ChangeInternal.detach(StableRangeInternal.only(nodeNotInTree));\n\t\t\t\tconst result = revert([change], testTree.view);\n\t\t\t\texpect(result).to.be.undefined;\n\t\t\t});\n\n\t\t\tit('when reverting a set value of a node that is not in the tree', () => {\n\t\t\t\tconst nodeNotInTree = testTree.buildLeafInternal();\n\t\t\t\tconst change = ChangeInternal.setPayload(nodeNotInTree, '42');\n\t\t\t\tconst result = revert([change], testTree.view);\n\t\t\t\texpect(result).to.be.undefined;\n\t\t\t});\n\t\t});\n\n\t\tdescribe('because the edit was malformed', () => {\n\t\t\tit('when reverting an insert whose source is not insertable', () => {\n\t\t\t\tconst detachedId = 0 as DetachedSequenceId;\n\t\t\t\t// Revert an insert where the source is not a valid detached sequence ID (nothing has been built/detached with that ID)\n\t\t\t\texpect(\n\t\t\t\t\trevert(\n\t\t\t\t\t\t[ChangeInternal.insert(detachedId, StablePlaceInternal.atStartOf(testTree.left.traitLocation))],\n\t\t\t\t\t\ttestTree.view\n\t\t\t\t\t)\n\t\t\t\t).to.be.undefined;\n\t\t\t\t// Revert a duplicate insert (the source has already been inserted by a previous insert in the same edit)\n\t\t\t\texpect(\n\t\t\t\t\trevert(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tChangeInternal.build([testTree.buildLeafInternal()], detachedId),\n\t\t\t\t\t\t\tChangeInternal.insert(\n\t\t\t\t\t\t\t\tdetachedId,\n\t\t\t\t\t\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tChangeInternal.insert(\n\t\t\t\t\t\t\t\tdetachedId,\n\t\t\t\t\t\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttestTree.view\n\t\t\t\t\t)\n\t\t\t\t).to.be.undefined;\n\t\t\t});\n\n\t\t\tit('when reverting a detach whose destination is already occupied', () => {\n\t\t\t\tconst detachedId = 0 as DetachedSequenceId;\n\t\t\t\t// Revert a detach where the destination is already occupied due to a prior detach\n\t\t\t\texpect(\n\t\t\t\t\trevert(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tChangeInternal.detach(StableRangeInternal.only(testTree.left), detachedId),\n\t\t\t\t\t\t\tChangeInternal.detach(StableRangeInternal.only(testTree.left), detachedId),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttestTree.view\n\t\t\t\t\t)\n\t\t\t\t).to.be.undefined;\n\t\t\t\t// Revert a detach where the destination is already occupied due to a prior build\n\t\t\t\texpect(\n\t\t\t\t\trevert(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tChangeInternal.build([testTree.buildLeafInternal()], detachedId),\n\t\t\t\t\t\t\tChangeInternal.detach(StableRangeInternal.only(testTree.left), detachedId),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttestTree.view\n\t\t\t\t\t)\n\t\t\t\t).to.be.undefined;\n\t\t\t});\n\t\t});\n\t});\n});\n"]}
|
|
1
|
+
{"version":3,"file":"HistoryEditFactory.tests.js","sourceRoot":"","sources":["../../src/test/HistoryEditFactory.tests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAwB,mBAAmB,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CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;iBAC1E,EACD,QAAQ,CAAC,IAAI,CACb,CACD,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;gBAClB,iFAAiF;gBACjF,MAAM,CACL,MAAM,CACL;oBACC,cAAc,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,EAAE,UAAU,CAAC;oBAChE,cAAc,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;iBAC1E,EACD,QAAQ,CAAC,IAAI,CACb,CACD,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;YACnB,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { expect } from 'chai';\nimport { revert } from '../HistoryEditFactory';\nimport { DetachedSequenceId, TraitLabel } from '../Identifiers';\nimport { ChangeInternal, DetachInternal, Side, StablePlaceInternal, StableRangeInternal } from '../persisted-types';\nimport { expectDefined } from './utilities/TestCommon';\nimport { refreshTestTree } from './utilities/TestUtilities';\n\ndescribe('revert', () => {\n\tconst testTree = refreshTestTree();\n\n\tit('can revert a single detached node', () => {\n\t\tconst firstDetachedId = 0 as DetachedSequenceId;\n\t\tconst node = testTree.buildLeafInternal();\n\t\tconst firstBuild = ChangeInternal.build([node], firstDetachedId);\n\t\tconst insertedNodeId = 1 as DetachedSequenceId;\n\t\tconst insertedBuild = ChangeInternal.build([firstDetachedId], insertedNodeId);\n\t\tconst insertChange = ChangeInternal.insert(\n\t\t\tinsertedNodeId,\n\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t);\n\t\tconst result = expectDefined(revert([firstBuild, insertedBuild, insertChange], testTree.view));\n\t\texpect(result.length).to.equal(1);\n\t\tconst revertedChange = result[0] as DetachInternal;\n\t\texpect(revertedChange.source.start.referenceSibling).to.deep.equal(node.identifier);\n\t\texpect(revertedChange.source.end.referenceSibling).to.deep.equal(node.identifier);\n\t});\n\n\tit('can revert multiple detached nodes', () => {\n\t\tconst firstDetachedId = 0 as DetachedSequenceId;\n\t\tconst firstNode = testTree.buildLeafInternal();\n\t\tconst firstBuild = ChangeInternal.build([firstNode], firstDetachedId);\n\t\tconst secondDetachedId = 1 as DetachedSequenceId;\n\t\tconst secondNode = testTree.buildLeafInternal();\n\t\tconst secondBuild = ChangeInternal.build([secondNode], secondDetachedId);\n\t\tconst insertedNodeId = 2 as DetachedSequenceId;\n\t\tconst insertedBuild = ChangeInternal.build([firstDetachedId, secondDetachedId], insertedNodeId);\n\t\tconst insertChange = ChangeInternal.insert(\n\t\t\tinsertedNodeId,\n\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t);\n\t\tconst result = expectDefined(revert([firstBuild, secondBuild, insertedBuild, insertChange], testTree.view));\n\t\texpect(result.length).to.equal(1);\n\t\tconst revertedChange = result[0] as DetachInternal;\n\t\texpect(revertedChange.source.start.referenceSibling).to.deep.equal(firstNode.identifier);\n\t\texpect(revertedChange.source.end.referenceSibling).to.deep.equal(secondNode.identifier);\n\t});\n\n\tit('handles reverting the insert of empty nodes, with subsequent non-empty nodes', () => {\n\t\t// build and insert of empty traits\n\t\tconst emptyTraitNodeId = 0 as DetachedSequenceId;\n\t\tconst emptyTraitBuild = ChangeInternal.build([], emptyTraitNodeId);\n\t\tconst emptyTraitInsert = ChangeInternal.insert(\n\t\t\temptyTraitNodeId,\n\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t);\n\n\t\t// build and insert of non-empty traits\n\t\tconst firstDetachedId = 1 as DetachedSequenceId;\n\t\tconst firstNode = testTree.buildLeafInternal();\n\t\tconst firstBuild = ChangeInternal.build([firstNode], firstDetachedId);\n\t\tconst insertedNodeId = 3 as DetachedSequenceId;\n\t\tconst insertedBuild = ChangeInternal.build([firstDetachedId], insertedNodeId);\n\t\tconst insertChange = ChangeInternal.insert(\n\t\t\tinsertedNodeId,\n\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t);\n\t\tconst result = expectDefined(\n\t\t\trevert([emptyTraitBuild, emptyTraitInsert, firstBuild, insertedBuild, insertChange], testTree.view)\n\t\t);\n\t\texpect(result.length).to.equal(1);\n\t\tconst revertedChange = result[0] as DetachInternal;\n\t\texpect(revertedChange.source.start.referenceSibling).to.deep.equal(firstNode.identifier);\n\t});\n\n\t/** This is a regression test for a bug where we make sure that any built/detached nodes are cleared when any\n\t * empty insert/detach change is skipped once encountered. The expected outcome is undefined, as during the second\n\t * empty insert (with the same DetachSequenceId), there should be no such node in the builtNodes.\n\t */\n\tit('handles reverting the insert of empty nodes, with subsequent empty nodes of same DetachedSequenceId', () => {\n\t\tconst emptyTraitNodeId = 0 as DetachedSequenceId;\n\t\tconst emptyTraitBuild = ChangeInternal.build([], emptyTraitNodeId);\n\t\tconst emptyTraitInsert = ChangeInternal.insert(\n\t\t\temptyTraitNodeId,\n\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t);\n\t\tconst result = revert([emptyTraitBuild, emptyTraitInsert, emptyTraitInsert], testTree.view);\n\t\texpect(result).to.be.undefined;\n\t});\n\n\tit('handles reverting the detach of an empty trait', () => {\n\t\tconst insertedNodeId = 0 as DetachedSequenceId;\n\t\tconst result = expectDefined(\n\t\t\trevert(\n\t\t\t\t[\n\t\t\t\t\tChangeInternal.detach(\n\t\t\t\t\t\tStableRangeInternal.all({\n\t\t\t\t\t\t\tlabel: 'someNonExistentTraitLabel' as TraitLabel,\n\t\t\t\t\t\t\tparent: testTree.identifier,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tinsertedNodeId\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\ttestTree.view\n\t\t\t)\n\t\t);\n\t\texpect(result).to.have.lengthOf(0);\n\t});\n\n\tit('handles reverting the insert of an empty trait', () => {\n\t\tconst emptyTraitNodeId = 0 as DetachedSequenceId;\n\t\tconst emptyTraitBuild = ChangeInternal.build([], emptyTraitNodeId);\n\t\tconst emptyTraitInsert = ChangeInternal.insert(\n\t\t\temptyTraitNodeId,\n\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t);\n\t\tconst result = expectDefined(revert([emptyTraitBuild, emptyTraitInsert], testTree.view));\n\t\texpect(result).to.have.lengthOf(0);\n\t});\n\n\tdescribe('returns undefined for reverts that require more context than the view directly before the edit', () => {\n\t\tdescribe('because the edit conflicted', () => {\n\t\t\tit('when reverting a detach of a node that is not in the tree', () => {\n\t\t\t\tconst nodeNotInTree = testTree.buildLeafInternal();\n\t\t\t\tconst change = ChangeInternal.detach(StableRangeInternal.only(nodeNotInTree));\n\t\t\t\tconst result = revert([change], testTree.view);\n\t\t\t\texpect(result).to.be.undefined;\n\t\t\t});\n\n\t\t\tit('when reverting a set value of a node that is not in the tree', () => {\n\t\t\t\tconst nodeNotInTree = testTree.buildLeafInternal();\n\t\t\t\tconst change = ChangeInternal.setPayload(nodeNotInTree, '42');\n\t\t\t\tconst result = revert([change], testTree.view);\n\t\t\t\texpect(result).to.be.undefined;\n\t\t\t});\n\t\t});\n\n\t\tdescribe('because the edit was malformed', () => {\n\t\t\tit('when reverting an insert whose source is not insertable', () => {\n\t\t\t\tconst detachedId = 0 as DetachedSequenceId;\n\t\t\t\t// Revert an insert where the source is not a valid detached sequence ID (nothing has been built/detached with that ID)\n\t\t\t\texpect(\n\t\t\t\t\trevert(\n\t\t\t\t\t\t[ChangeInternal.insert(detachedId, StablePlaceInternal.atStartOf(testTree.left.traitLocation))],\n\t\t\t\t\t\ttestTree.view\n\t\t\t\t\t)\n\t\t\t\t).to.be.undefined;\n\t\t\t\t// Revert a duplicate insert (the source has already been inserted by a previous insert in the same edit)\n\t\t\t\texpect(\n\t\t\t\t\trevert(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tChangeInternal.build([testTree.buildLeafInternal()], detachedId),\n\t\t\t\t\t\t\tChangeInternal.insert(\n\t\t\t\t\t\t\t\tdetachedId,\n\t\t\t\t\t\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tChangeInternal.insert(\n\t\t\t\t\t\t\t\tdetachedId,\n\t\t\t\t\t\t\t\tStablePlaceInternal.atStartOf(testTree.left.traitLocation)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttestTree.view\n\t\t\t\t\t)\n\t\t\t\t).to.be.undefined;\n\t\t\t});\n\n\t\t\tit('when reverting a detach whose destination is already occupied', () => {\n\t\t\t\tconst detachedId = 0 as DetachedSequenceId;\n\t\t\t\t// Revert a detach where the destination is already occupied due to a prior detach\n\t\t\t\texpect(\n\t\t\t\t\trevert(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tChangeInternal.detach(StableRangeInternal.only(testTree.left), detachedId),\n\t\t\t\t\t\t\tChangeInternal.detach(StableRangeInternal.only(testTree.left), detachedId),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttestTree.view\n\t\t\t\t\t)\n\t\t\t\t).to.be.undefined;\n\t\t\t\t// Revert a detach where the destination is already occupied due to a prior build\n\t\t\t\texpect(\n\t\t\t\t\trevert(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tChangeInternal.build([testTree.buildLeafInternal()], detachedId),\n\t\t\t\t\t\t\tChangeInternal.detach(StableRangeInternal.only(testTree.left), detachedId),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttestTree.view\n\t\t\t\t\t)\n\t\t\t\t).to.be.undefined;\n\t\t\t});\n\t\t});\n\t});\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/tree",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
40
40
|
"@fluidframework/common-utils": "^0.32.1",
|
|
41
|
-
"@fluidframework/container-definitions": "^1.3.
|
|
42
|
-
"@fluidframework/core-interfaces": "^1.3.
|
|
43
|
-
"@fluidframework/datastore-definitions": "^1.3.
|
|
41
|
+
"@fluidframework/container-definitions": "^1.3.1",
|
|
42
|
+
"@fluidframework/core-interfaces": "^1.3.1",
|
|
43
|
+
"@fluidframework/datastore-definitions": "^1.3.1",
|
|
44
44
|
"@fluidframework/protocol-definitions": "^0.1028.2000",
|
|
45
|
-
"@fluidframework/runtime-definitions": "^1.3.
|
|
46
|
-
"@fluidframework/shared-object-base": "^1.3.
|
|
47
|
-
"@fluidframework/telemetry-utils": "^1.3.
|
|
45
|
+
"@fluidframework/runtime-definitions": "^1.3.1",
|
|
46
|
+
"@fluidframework/shared-object-base": "^1.3.1",
|
|
47
|
+
"@fluidframework/telemetry-utils": "^1.3.1",
|
|
48
48
|
"buffer": "^6.0.3",
|
|
49
49
|
"denque": "^1.5.1",
|
|
50
50
|
"lru-cache": "^6.0.0",
|
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
"uuid": "^8.3.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@fluid-internal/stochastic-test-utils": "^1.3.
|
|
55
|
+
"@fluid-internal/stochastic-test-utils": "^1.3.1",
|
|
56
56
|
"@fluid-tools/benchmark": "^0.40.0",
|
|
57
57
|
"@fluidframework/build-common": "^0.24.0",
|
|
58
|
-
"@fluidframework/container-loader": "^1.3.
|
|
59
|
-
"@fluidframework/container-runtime": "^1.3.
|
|
58
|
+
"@fluidframework/container-loader": "^1.3.1",
|
|
59
|
+
"@fluidframework/container-runtime": "^1.3.1",
|
|
60
60
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
61
|
-
"@fluidframework/mocha-test-setup": "^1.3.
|
|
62
|
-
"@fluidframework/runtime-utils": "^1.3.
|
|
63
|
-
"@fluidframework/test-driver-definitions": "^1.3.
|
|
64
|
-
"@fluidframework/test-drivers": "^1.3.
|
|
65
|
-
"@fluidframework/test-runtime-utils": "^1.3.
|
|
66
|
-
"@fluidframework/test-utils": "^1.3.
|
|
67
|
-
"@fluidframework/undo-redo": "^1.3.
|
|
61
|
+
"@fluidframework/mocha-test-setup": "^1.3.1",
|
|
62
|
+
"@fluidframework/runtime-utils": "^1.3.1",
|
|
63
|
+
"@fluidframework/test-driver-definitions": "^1.3.1",
|
|
64
|
+
"@fluidframework/test-drivers": "^1.3.1",
|
|
65
|
+
"@fluidframework/test-runtime-utils": "^1.3.1",
|
|
66
|
+
"@fluidframework/test-utils": "^1.3.1",
|
|
67
|
+
"@fluidframework/undo-redo": "^1.3.1",
|
|
68
68
|
"@microsoft/api-extractor": "^7.22.2",
|
|
69
69
|
"@rushstack/eslint-config": "^2.5.1",
|
|
70
70
|
"@types/lru-cache": "^5.1.0",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { ITelemetryLogger } from '@fluidframework/common-definitions';
|
|
6
7
|
import { DetachedSequenceId, isDetachedSequenceId, NodeId } from './Identifiers';
|
|
7
8
|
import { assert, fail } from './Common';
|
|
8
9
|
import { rangeFromStableRange } from './TreeViewUtilities';
|
|
@@ -28,14 +29,19 @@ import { getChangeNodeFromViewNode } from './SerializationUtilities';
|
|
|
28
29
|
* @param changes - the changes for which to produce an inverse.
|
|
29
30
|
* @param before - a view of the tree state before `changes` are/were applied - used as a basis for generating the inverse.
|
|
30
31
|
* @returns if the changes could be reverted, a sequence of changes _r_ that will produce `before` if applied to a view _A_, where _A_ is the result of
|
|
31
|
-
* applying `changes` to `before`.
|
|
32
|
-
* not
|
|
32
|
+
* applying `changes` to `before`. Note that the size of the array of reverted changes may not be the same as the input array, and may even be empty in cases where
|
|
33
|
+
* the view did not change. Applying _r_ to views other than _A_ is legal but may cause the changes to fail to apply or may not be a true semantic inverse.
|
|
34
|
+
* If the changes could not be reverted given the state of `before`, returns undefined.
|
|
33
35
|
*
|
|
34
36
|
* TODO: what should this do if `changes` fails to apply to `before`?
|
|
35
37
|
* TODO:#68574: Pass a view that corresponds to the appropriate Fluid reference sequence number rather than the view just before
|
|
36
38
|
* @internal
|
|
37
39
|
*/
|
|
38
|
-
export function revert(
|
|
40
|
+
export function revert(
|
|
41
|
+
changes: readonly ChangeInternal[],
|
|
42
|
+
before: RevisionView,
|
|
43
|
+
logger?: ITelemetryLogger
|
|
44
|
+
): ChangeInternal[] | undefined {
|
|
39
45
|
const result: ChangeInternal[] = [];
|
|
40
46
|
|
|
41
47
|
const builtNodes = new Map<DetachedSequenceId, NodeId[]>();
|
|
@@ -74,9 +80,19 @@ export function revert(changes: readonly ChangeInternal[], before: RevisionView)
|
|
|
74
80
|
const nodesDetached = detachedNodes.get(source);
|
|
75
81
|
|
|
76
82
|
if (nodesBuilt !== undefined) {
|
|
83
|
+
if (nodesBuilt.length === 0) {
|
|
84
|
+
builtNodes.delete(source);
|
|
85
|
+
logger?.sendTelemetryEvent({ eventName: 'reverting insertion of empty traits' });
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
77
88
|
result.unshift(createInvertedInsert(change, nodesBuilt));
|
|
78
89
|
builtNodes.delete(source);
|
|
79
90
|
} else if (nodesDetached !== undefined) {
|
|
91
|
+
if (nodesDetached.length === 0) {
|
|
92
|
+
detachedNodes.delete(source);
|
|
93
|
+
logger?.sendTelemetryEvent({ eventName: 'reverting insertion of empty traits' });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
80
96
|
result.unshift(createInvertedInsert(change, nodesDetached, true));
|
|
81
97
|
detachedNodes.delete(source);
|
|
82
98
|
} else {
|
|
@@ -96,6 +112,11 @@ export function revert(changes: readonly ChangeInternal[], before: RevisionView)
|
|
|
96
112
|
}
|
|
97
113
|
const { invertedDetach, detachedNodeIds } = invert;
|
|
98
114
|
|
|
115
|
+
if (detachedNodeIds.length === 0) {
|
|
116
|
+
logger?.sendTelemetryEvent({ eventName: 'reverting detachment of empty traits' });
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
|
|
99
120
|
if (destination !== undefined) {
|
|
100
121
|
if (builtNodes.has(destination) || detachedNodes.has(destination)) {
|
|
101
122
|
// Malformed: destination was already used by a prior build or detach
|
package/src/SharedTree.ts
CHANGED
|
@@ -1506,7 +1506,7 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
|
|
|
1506
1506
|
* @internal
|
|
1507
1507
|
*/
|
|
1508
1508
|
public revertChanges(changes: readonly InternalizedChange[], before: RevisionView): ChangeInternal[] | undefined {
|
|
1509
|
-
return revert(changes as unknown as readonly ChangeInternal[], before);
|
|
1509
|
+
return revert(changes as unknown as readonly ChangeInternal[], before, this.logger);
|
|
1510
1510
|
}
|
|
1511
1511
|
|
|
1512
1512
|
/**
|