@fluid-experimental/tree 0.56.7 → 0.57.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/.eslintrc.js +1 -1
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +1 -2
- package/dist/Common.js.map +1 -1
- package/dist/Forest.d.ts.map +1 -1
- package/dist/Forest.js +0 -1
- package/dist/Forest.js.map +1 -1
- package/dist/RevisionValueCache.d.ts.map +1 -1
- package/dist/RevisionValueCache.js +0 -2
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/Snapshot.d.ts.map +1 -1
- package/dist/Snapshot.js.map +1 -1
- package/dist/TreeNodeHandle.d.ts.map +1 -1
- package/dist/TreeNodeHandle.js +0 -1
- package/dist/TreeNodeHandle.js.map +1 -1
- package/dist/default-edits/HistoryEditFactory.d.ts.map +1 -1
- package/dist/default-edits/HistoryEditFactory.js +1 -1
- package/dist/default-edits/HistoryEditFactory.js.map +1 -1
- package/dist/default-edits/PersistedTypes.d.ts.map +1 -1
- package/dist/default-edits/PersistedTypes.js +0 -1
- package/dist/default-edits/PersistedTypes.js.map +1 -1
- package/dist/default-edits/Transaction.d.ts.map +1 -1
- package/dist/default-edits/Transaction.js.map +1 -1
- package/dist/default-edits/UndoRedoHandler.d.ts +1 -1
- package/dist/default-edits/UndoRedoHandler.d.ts.map +1 -1
- package/dist/default-edits/UndoRedoHandler.js +0 -4
- package/dist/default-edits/UndoRedoHandler.js.map +1 -1
- package/dist/generic/GenericSharedTree.d.ts +0 -4
- package/dist/generic/GenericSharedTree.d.ts.map +1 -1
- package/dist/generic/GenericSharedTree.js +0 -6
- package/dist/generic/GenericSharedTree.js.map +1 -1
- package/dist/generic/GenericTransaction.js +0 -1
- package/dist/generic/GenericTransaction.js.map +1 -1
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +1 -2
- package/lib/Common.js.map +1 -1
- package/lib/Forest.d.ts.map +1 -1
- package/lib/Forest.js +0 -1
- package/lib/Forest.js.map +1 -1
- package/lib/RevisionValueCache.d.ts.map +1 -1
- package/lib/RevisionValueCache.js +0 -2
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/Snapshot.d.ts.map +1 -1
- package/lib/Snapshot.js.map +1 -1
- package/lib/TreeNodeHandle.d.ts.map +1 -1
- package/lib/TreeNodeHandle.js +0 -1
- package/lib/TreeNodeHandle.js.map +1 -1
- package/lib/default-edits/HistoryEditFactory.d.ts.map +1 -1
- package/lib/default-edits/HistoryEditFactory.js +1 -1
- package/lib/default-edits/HistoryEditFactory.js.map +1 -1
- package/lib/default-edits/PersistedTypes.d.ts.map +1 -1
- package/lib/default-edits/PersistedTypes.js +0 -1
- package/lib/default-edits/PersistedTypes.js.map +1 -1
- package/lib/default-edits/Transaction.d.ts.map +1 -1
- package/lib/default-edits/Transaction.js.map +1 -1
- package/lib/default-edits/UndoRedoHandler.d.ts +1 -1
- package/lib/default-edits/UndoRedoHandler.d.ts.map +1 -1
- package/lib/default-edits/UndoRedoHandler.js +0 -4
- package/lib/default-edits/UndoRedoHandler.js.map +1 -1
- package/lib/generic/GenericSharedTree.d.ts +0 -4
- package/lib/generic/GenericSharedTree.d.ts.map +1 -1
- package/lib/generic/GenericSharedTree.js +0 -6
- package/lib/generic/GenericSharedTree.js.map +1 -1
- package/lib/generic/GenericTransaction.js +0 -1
- package/lib/generic/GenericTransaction.js.map +1 -1
- package/lib/test/SnapshotUtilities.tests.js +0 -3
- package/lib/test/SnapshotUtilities.tests.js.map +1 -1
- package/lib/test/undoRedoStackManager.d.ts.map +1 -1
- package/lib/test/undoRedoStackManager.js +0 -1
- package/lib/test/undoRedoStackManager.js.map +1 -1
- package/package.json +13 -13
- package/src/Common.ts +1 -2
- package/src/Forest.ts +0 -1
- package/src/RevisionValueCache.ts +0 -2
- package/src/Snapshot.ts +1 -0
- package/src/TreeNodeHandle.ts +0 -1
- package/src/default-edits/HistoryEditFactory.ts +1 -1
- package/src/default-edits/PersistedTypes.ts +0 -1
- package/src/default-edits/Transaction.ts +1 -0
- package/src/default-edits/UndoRedoHandler.ts +1 -5
- package/src/generic/GenericSharedTree.ts +0 -7
- package/src/generic/GenericTransaction.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryEditFactory.js","sourceRoot":"","sources":["../../src/default-edits/HistoryEditFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,sCAAyC;AACzC,0CAA6C;AAE7C,qDAA0G;AAC1G,+CAA4C;AAC5C,mDAAuD;AAEvD;;;;;;;;;;GAUG;AACH,SAAgB,MAAM,CAAC,OAA0B,EAAE,MAAgB;IAClE,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC3D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAgC,CAAC;IAE9D,mEAAmE;IACnE,MAAM,MAAM,GAAG,IAAI,yBAAW,CAAC,MAAM,CAAC,CAAC;IACvC,gDAAgD;IAChD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC7B,qCAAqC;QACrC,QAAQ,MAAM,CAAC,IAAI,EAAE;YACpB,KAAK,2BAAU,CAAC,KAAK,CAAC,CAAC;gBACtB,mEAAmE;gBACnE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;gBACvC,eAAM,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,6DAA6D,CAAC,CAAC;gBACpG,eAAM,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,8DAA8D,CAAC,CAAC;gBACxG,UAAU,CAAC,GAAG,CACb,WAAW,EACX,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAE,IAA4B,CAAC,UAAU,CAAC,CAC9D,CAAC;gBACF,MAAM;aACN;YACD,KAAK,2BAAU,CAAC,MAAM,CAAC,CAAC;gBACvB,MAAM,EAAE,M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AI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE;QACrC,OAAO;YACN,cAAc,EAAE,CAAC,uBAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;YACtE,eAAe;SACf,CAAC;KACF;IAED,MAAM,kBAAkB,GAAG,CAAuB,CAAC;IACnD,OAAO;QACN,cAAc,EAAE;YACf,uBAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,kBAAkB,CAAC;YACpF,uBAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;SACpD;QACD,eAAe;KACf,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,QAAkB,EAAE,kBAA4B;IAC/E,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;IAClC,MAAM,UAAU,GAAG,kBAAkB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;IAE5E,+EAA+E;IAC/E,2CAA2C;IAC3C,IAAI,UAAU,KAAK,IAAI,EAAE;QACxB,OAAO,CAAC,uBAAM,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;KACrD;IACD,OAAO,CAAC,uBAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DetachedSequenceId, NodeId } from '../Identifiers';\nimport { assert, fail } from '../Common';\nimport { Snapshot, Side } from '../Snapshot';\nimport { BuildNode, TreeNode } from '../generic';\nimport { Change, ChangeType, Detach, Insert, SetValue, StableRange, StablePlace } from './PersistedTypes';\nimport { Transaction } from './Transaction';\nimport { rangeFromStableRange } from './EditUtilities';\n\n/**\n * Given a sequence of changes, produces an inverse sequence of changes, i.e. the minimal changes required to revert the given changes\n * @param changes - the changes for which to produce an inverse.\n * @param before - a snapshot of the tree state before `changes` are/were applied - used as a basis for generating the inverse.\n * @returns a sequence of changes _r_ that will produce `before` if applied to a snapshot _A_, where _A_ is the result of\n * applying `changes` to `before`. Applying _r_ to snapshots other than _A_ is legal but may cause the changes to fail to apply or may\n * not be a true semantic inverse.\n *\n * TODO: what should this do if `changes` fails to apply to `before`?\n * @public\n */\nexport function revert(changes: readonly Change[], before: Snapshot): Change[] {\n\tconst result: Change[] = [];\n\n\tconst builtNodes = new Map<DetachedSequenceId, NodeId[]>();\n\tconst detachedNodes = new Map<DetachedSequenceId, NodeId[]>();\n\n\t// Open edit on revision to update it as changes are walked through\n\tconst editor = new Transaction(before);\n\t// Apply `edit`, generating an inverse as we go.\n\tfor (const change of changes) {\n\t\t// Generate an inverse of each change\n\t\tswitch (change.type) {\n\t\t\tcase ChangeType.Build: {\n\t\t\t\t// Save nodes added to the detached state for use in future changes\n\t\t\t\tconst { destination, source } = change;\n\t\t\t\tassert(!builtNodes.has(destination), `Cannot revert Build: destination is already used by a Build`);\n\t\t\t\tassert(!detachedNodes.has(destination), `Cannot revert Build: destination is already used by a Detach`);\n\t\t\t\tbuiltNodes.set(\n\t\t\t\t\tdestination,\n\t\t\t\t\tsource.map((node) => (node as TreeNode<BuildNode>).identifier)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeType.Insert: {\n\t\t\t\tconst { source } = change;\n\t\t\t\tconst nodesBuilt = builtNodes.get(source);\n\t\t\t\tconst nodesDetached = detachedNodes.get(source);\n\n\t\t\t\tif (nodesBuilt !== undefined) {\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesBuilt));\n\t\t\t\t\tbuiltNodes.delete(source);\n\t\t\t\t} else if (nodesDetached !== undefined) {\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesDetached, true));\n\t\t\t\t\tdetachedNodes.delete(source);\n\t\t\t\t} else {\n\t\t\t\t\tfail('Cannot revert Insert: source has not been built or detached.');\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeType.Detach: {\n\t\t\t\tconst { destination } = change;\n\t\t\t\tconst { invertedDetach, detachedNodeIds } = createInvertedDetach(change, editor.view);\n\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!builtNodes.has(destination),\n\t\t\t\t\t\t`Cannot revert Detach: destination is already used by a Build`\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!detachedNodes.has(destination),\n\t\t\t\t\t\t`Cannot revert Detach: destination is already used by a Detach`\n\t\t\t\t\t);\n\t\t\t\t\tdetachedNodes.set(destination, detachedNodeIds);\n\t\t\t\t}\n\n\t\t\t\tresult.unshift(...invertedDetach);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeType.SetValue:\n\t\t\t\tresult.unshift(...createInvertedSetValue(change, editor.view));\n\t\t\t\tbreak;\n\t\t\tcase ChangeType.Constraint:\n\t\t\t\t// TODO:#46759: Support Constraint in reverts\n\t\t\t\tfail('Revert currently does not support Constraints');\n\t\t\tdefault:\n\t\t\t\tfail('Revert does not support the change type.');\n\t\t}\n\n\t\t// Update the revision\n\t\teditor.applyChange(change);\n\t}\n\n\teditor.close();\n\treturn result;\n}\n\n/**\n * Inverse of an Insert is a Detach that starts before the leftmost node inserted and ends after the rightmost.\n */\nfunction createInvertedInsert(insert: Insert, nodesInserted: readonly NodeId[], saveDetached = false): Change {\n\tconst leftmostNode = nodesInserted[0];\n\tconst rightmostNode = nodesInserted[nodesInserted.length - 1];\n\n\tconst source: StableRange = {\n\t\tstart: {\n\t\t\treferenceSibling: leftmostNode,\n\t\t\tside: Side.Before,\n\t\t},\n\t\tend: {\n\t\t\treferenceSibling: rightmostNode,\n\t\t\tside: Side.After,\n\t\t},\n\t};\n\n\treturn Change.detach(source, saveDetached ? insert.source : undefined);\n}\n\n/**\n * If a detach does not include a destination, its inverse is a build and insert. Otherwise, it is just an insert.\n * Information on the nodes that were detached is obtained by going to the revision before the detach.\n *\n * The anchor for the resulting Insert is chosen in the following order:\n * 1. If detach.source.start.side is After: detach.source.start\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"After B\", the anchor for the resulting Insert will also be \"After B\".\n *\n * For nodes [A..F] G H where [A..F] represents the detached nodes,\n * if detach.source.start is \"After start of trait\", the anchor for the resulting Insert will also be \"After start of trait\".\n *\n * 2. Else if detach.source.end.side is Before: detach.source.end\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"Before G\",\n * the anchor for the resulting Insert will be \"Before G\".\n *\n * 3. Else: After the node directly to the left of the originally detached nodes\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"After F\",\n * the anchor for the resulting Insert will be \"After B\".\n *\n * When choosing the anchor, the existing anchors on detach.source are preferred when they have a valid sibling. Otherwise, the valid\n * anchor to the left of the originally detached nodes is chosen.\n */\nfunction createInvertedDetach(\n\tdetach: Detach,\n\tsnapshotBeforeEdit: Snapshot\n): { invertedDetach: Change[]; detachedNodeIds: NodeId[] } {\n\tconst { source } = detach;\n\n\tconst { start, end } = rangeFromStableRange(snapshotBeforeEdit, source);\n\tconst { trait: referenceTrait } = start;\n\tconst nodes = snapshotBeforeEdit.getTrait(referenceTrait);\n\n\tconst startIndex = snapshotBeforeEdit.findIndexWithinTrait(start);\n\tconst endIndex = snapshotBeforeEdit.findIndexWithinTrait(end);\n\tconst detachedNodeIds: NodeId[] = nodes.slice(startIndex, endIndex);\n\n\tconst leftOfDetached = nodes.slice(0, startIndex);\n\n\tlet insertDestination: StablePlace;\n\n\tif (start.side === Side.After) {\n\t\tinsertDestination =\n\t\t\tstart.sibling === undefined\n\t\t\t\t? { side: Side.After, referenceTrait }\n\t\t\t\t: { side: Side.After, referenceSibling: start.sibling };\n\t} else if (end.side === Side.Before) {\n\t\tinsertDestination =\n\t\t\tend.sibling === undefined\n\t\t\t\t? { side: Side.Before, referenceTrait }\n\t\t\t\t: { side: Side.Before, referenceSibling: end.sibling };\n\t} else {\n\t\tconst referenceSibling = leftOfDetached.pop();\n\t\tinsertDestination = {\n\t\t\tside: Side.After,\n\t\t\treferenceSibling,\n\t\t\treferenceTrait: referenceSibling === undefined ? referenceTrait : undefined,\n\t\t};\n\t}\n\n\tif (detach.destination !== undefined) {\n\t\treturn {\n\t\t\tinvertedDetach: [Change.insert(detach.destination, insertDestination)],\n\t\t\tdetachedNodeIds,\n\t\t};\n\t}\n\n\tconst detachedSequenceId = 0 as DetachedSequenceId;\n\treturn {\n\t\tinvertedDetach: [\n\t\t\tChange.build(snapshotBeforeEdit.getChangeNodes(detachedNodeIds), detachedSequenceId),\n\t\t\tChange.insert(detachedSequenceId, insertDestination),\n\t\t],\n\t\tdetachedNodeIds,\n\t};\n}\n\nfunction createInvertedSetValue(setValue: SetValue, revisionBeforeEdit: Snapshot): Change[] {\n\tconst { nodeToModify } = setValue;\n\tconst oldPayload = revisionBeforeEdit.getSnapshotNode(nodeToModify).payload;\n\n\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface)\n\t// eslint-disable-next-line no-null/no-null\n\tif (oldPayload !== null) {\n\t\treturn [Change.setPayload(nodeToModify, oldPayload)];\n\t}\n\treturn [Change.clearPayload(nodeToModify)];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HistoryEditFactory.js","sourceRoot":"","sources":["../../src/default-edits/HistoryEditFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,sCAAyC;AACzC,0CAA6C;AAE7C,qDAA0G;AAC1G,+CAA4C;AAC5C,mDAAuD;AAEvD;;;;;;;;;;GAUG;AACH,SAAgB,MAAM,CAAC,OAA0B,EAAE,MAAgB;IAClE,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC3D,MAAM,aAAa,GAAG,IAAI,GA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AG,QAAQ,CAAC;IAClC,MAAM,UAAU,GAAG,kBAAkB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;IAE5E,+EAA+E;IAC/E,IAAI,UAAU,KAAK,IAAI,EAAE;QACxB,OAAO,CAAC,uBAAM,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;KACrD;IACD,OAAO,CAAC,uBAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DetachedSequenceId, NodeId } from '../Identifiers';\nimport { assert, fail } from '../Common';\nimport { Snapshot, Side } from '../Snapshot';\nimport { BuildNode, TreeNode } from '../generic';\nimport { Change, ChangeType, Detach, Insert, SetValue, StableRange, StablePlace } from './PersistedTypes';\nimport { Transaction } from './Transaction';\nimport { rangeFromStableRange } from './EditUtilities';\n\n/**\n * Given a sequence of changes, produces an inverse sequence of changes, i.e. the minimal changes required to revert the given changes\n * @param changes - the changes for which to produce an inverse.\n * @param before - a snapshot of the tree state before `changes` are/were applied - used as a basis for generating the inverse.\n * @returns a sequence of changes _r_ that will produce `before` if applied to a snapshot _A_, where _A_ is the result of\n * applying `changes` to `before`. Applying _r_ to snapshots other than _A_ is legal but may cause the changes to fail to apply or may\n * not be a true semantic inverse.\n *\n * TODO: what should this do if `changes` fails to apply to `before`?\n * @public\n */\nexport function revert(changes: readonly Change[], before: Snapshot): Change[] {\n\tconst result: Change[] = [];\n\n\tconst builtNodes = new Map<DetachedSequenceId, NodeId[]>();\n\tconst detachedNodes = new Map<DetachedSequenceId, NodeId[]>();\n\n\t// Open edit on revision to update it as changes are walked through\n\tconst editor = new Transaction(before);\n\t// Apply `edit`, generating an inverse as we go.\n\tfor (const change of changes) {\n\t\t// Generate an inverse of each change\n\t\tswitch (change.type) {\n\t\t\tcase ChangeType.Build: {\n\t\t\t\t// Save nodes added to the detached state for use in future changes\n\t\t\t\tconst { destination, source } = change;\n\t\t\t\tassert(!builtNodes.has(destination), `Cannot revert Build: destination is already used by a Build`);\n\t\t\t\tassert(!detachedNodes.has(destination), `Cannot revert Build: destination is already used by a Detach`);\n\t\t\t\tbuiltNodes.set(\n\t\t\t\t\tdestination,\n\t\t\t\t\tsource.map((node) => (node as TreeNode<BuildNode>).identifier)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeType.Insert: {\n\t\t\t\tconst { source } = change;\n\t\t\t\tconst nodesBuilt = builtNodes.get(source);\n\t\t\t\tconst nodesDetached = detachedNodes.get(source);\n\n\t\t\t\tif (nodesBuilt !== undefined) {\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesBuilt));\n\t\t\t\t\tbuiltNodes.delete(source);\n\t\t\t\t} else if (nodesDetached !== undefined) {\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesDetached, true));\n\t\t\t\t\tdetachedNodes.delete(source);\n\t\t\t\t} else {\n\t\t\t\t\tfail('Cannot revert Insert: source has not been built or detached.');\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeType.Detach: {\n\t\t\t\tconst { destination } = change;\n\t\t\t\tconst { invertedDetach, detachedNodeIds } = createInvertedDetach(change, editor.view);\n\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!builtNodes.has(destination),\n\t\t\t\t\t\t`Cannot revert Detach: destination is already used by a Build`\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!detachedNodes.has(destination),\n\t\t\t\t\t\t`Cannot revert Detach: destination is already used by a Detach`\n\t\t\t\t\t);\n\t\t\t\t\tdetachedNodes.set(destination, detachedNodeIds);\n\t\t\t\t}\n\n\t\t\t\tresult.unshift(...invertedDetach);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeType.SetValue:\n\t\t\t\tresult.unshift(...createInvertedSetValue(change, editor.view));\n\t\t\t\tbreak;\n\t\t\tcase ChangeType.Constraint:\n\t\t\t\t// TODO:#46759: Support Constraint in reverts\n\t\t\t\tfail('Revert currently does not support Constraints');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tfail('Revert does not support the change type.');\n\t\t}\n\n\t\t// Update the revision\n\t\teditor.applyChange(change);\n\t}\n\n\teditor.close();\n\treturn result;\n}\n\n/**\n * Inverse of an Insert is a Detach that starts before the leftmost node inserted and ends after the rightmost.\n */\nfunction createInvertedInsert(insert: Insert, nodesInserted: readonly NodeId[], saveDetached = false): Change {\n\tconst leftmostNode = nodesInserted[0];\n\tconst rightmostNode = nodesInserted[nodesInserted.length - 1];\n\n\tconst source: StableRange = {\n\t\tstart: {\n\t\t\treferenceSibling: leftmostNode,\n\t\t\tside: Side.Before,\n\t\t},\n\t\tend: {\n\t\t\treferenceSibling: rightmostNode,\n\t\t\tside: Side.After,\n\t\t},\n\t};\n\n\treturn Change.detach(source, saveDetached ? insert.source : undefined);\n}\n\n/**\n * If a detach does not include a destination, its inverse is a build and insert. Otherwise, it is just an insert.\n * Information on the nodes that were detached is obtained by going to the revision before the detach.\n *\n * The anchor for the resulting Insert is chosen in the following order:\n * 1. If detach.source.start.side is After: detach.source.start\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"After B\", the anchor for the resulting Insert will also be \"After B\".\n *\n * For nodes [A..F] G H where [A..F] represents the detached nodes,\n * if detach.source.start is \"After start of trait\", the anchor for the resulting Insert will also be \"After start of trait\".\n *\n * 2. Else if detach.source.end.side is Before: detach.source.end\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"Before G\",\n * the anchor for the resulting Insert will be \"Before G\".\n *\n * 3. Else: After the node directly to the left of the originally detached nodes\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"After F\",\n * the anchor for the resulting Insert will be \"After B\".\n *\n * When choosing the anchor, the existing anchors on detach.source are preferred when they have a valid sibling. Otherwise, the valid\n * anchor to the left of the originally detached nodes is chosen.\n */\nfunction createInvertedDetach(\n\tdetach: Detach,\n\tsnapshotBeforeEdit: Snapshot\n): { invertedDetach: Change[]; detachedNodeIds: NodeId[] } {\n\tconst { source } = detach;\n\n\tconst { start, end } = rangeFromStableRange(snapshotBeforeEdit, source);\n\tconst { trait: referenceTrait } = start;\n\tconst nodes = snapshotBeforeEdit.getTrait(referenceTrait);\n\n\tconst startIndex = snapshotBeforeEdit.findIndexWithinTrait(start);\n\tconst endIndex = snapshotBeforeEdit.findIndexWithinTrait(end);\n\tconst detachedNodeIds: NodeId[] = nodes.slice(startIndex, endIndex);\n\n\tconst leftOfDetached = nodes.slice(0, startIndex);\n\n\tlet insertDestination: StablePlace;\n\n\tif (start.side === Side.After) {\n\t\tinsertDestination =\n\t\t\tstart.sibling === undefined\n\t\t\t\t? { side: Side.After, referenceTrait }\n\t\t\t\t: { side: Side.After, referenceSibling: start.sibling };\n\t} else if (end.side === Side.Before) {\n\t\tinsertDestination =\n\t\t\tend.sibling === undefined\n\t\t\t\t? { side: Side.Before, referenceTrait }\n\t\t\t\t: { side: Side.Before, referenceSibling: end.sibling };\n\t} else {\n\t\tconst referenceSibling = leftOfDetached.pop();\n\t\tinsertDestination = {\n\t\t\tside: Side.After,\n\t\t\treferenceSibling,\n\t\t\treferenceTrait: referenceSibling === undefined ? referenceTrait : undefined,\n\t\t};\n\t}\n\n\tif (detach.destination !== undefined) {\n\t\treturn {\n\t\t\tinvertedDetach: [Change.insert(detach.destination, insertDestination)],\n\t\t\tdetachedNodeIds,\n\t\t};\n\t}\n\n\tconst detachedSequenceId = 0 as DetachedSequenceId;\n\treturn {\n\t\tinvertedDetach: [\n\t\t\tChange.build(snapshotBeforeEdit.getChangeNodes(detachedNodeIds), detachedSequenceId),\n\t\t\tChange.insert(detachedSequenceId, insertDestination),\n\t\t],\n\t\tdetachedNodeIds,\n\t};\n}\n\nfunction createInvertedSetValue(setValue: SetValue, revisionBeforeEdit: Snapshot): Change[] {\n\tconst { nodeToModify } = setValue;\n\tconst oldPayload = revisionBeforeEdit.getSnapshotNode(nodeToModify).payload;\n\n\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface)\n\tif (oldPayload !== null) {\n\t\treturn [Change.setPayload(nodeToModify, oldPayload)];\n\t}\n\treturn [Change.clearPayload(nodeToModify)];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistedTypes.d.ts","sourceRoot":"","sources":["../../src/default-edits/PersistedTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;GAGG;AACH,oBAAY,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAE/C;;;GAGG;AACH,oBAAY,UAAU;IACrB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,UAAU,IAAA;CACV;AAED;;;;;;;GAOG;AACH,oBAAY,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,UAAU,CAAC;AAErE;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC7C,QAAQ,CAAC,IAAI,E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I9C;;OAEG;kBACW,QAAQ,GAAG,MAAM,KAAG,WAAW;IAC7C;;OAEG;uBACgB,aAAa,KAAG,WAAW;IAC9C;;OAEG;qBACc,aAAa,KAAG,WAAW;CAC5C,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,WAAW;IACvB;;;;OAIG;kBACW,WAAW;kBAAe,WAAW,KAAK,WAAW;;IAUnE;;;OAGG;iBACU,QAAQ,GAAG,MAAM,KAAG,WAAW;IAC5C;;;;OAIG;iBACU,aAAa,KAAG,WAAW;CAIxC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,IAAI,QAAQ,CAEpE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAMzD"}
|
|
@@ -68,7 +68,6 @@ exports.Change = {
|
|
|
68
68
|
clearPayload: (nodeToModify) => ({
|
|
69
69
|
nodeToModify,
|
|
70
70
|
// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface above.)
|
|
71
|
-
// eslint-disable-next-line no-null/no-null
|
|
72
71
|
payload: null,
|
|
73
72
|
type: ChangeType.SetValue,
|
|
74
73
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistedTypes.js","sourceRoot":"","sources":["../../src/default-edits/PersistedTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,sCAAuD;AACvD,0CAAmC;AAoCnC;;;GAGG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,6CAAK,CAAA;IACL,mDAAQ,CAAA;IACR,uDAAU,CAAA;AACX,CAAC,EANW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAMrB;AAuID;;;GAGG;AACH,IAAY,gBAiBX;AAjBD,WAAY,gBAAgB;IAC3B;;OAEG;IACH,iFAAiB,CAAA;IAEjB;;;O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AK,IAAiB,CAAC,UAAU,KAAK,SAAS,CAAC;AACnG,CAAC;AAFD,gCAEC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,IAAuB;IAChD,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC;KACvB;SAAM;QACN,OAAO,IAAI,CAAC;KACZ;AACF,CAAC;AAND,8BAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// All types imported into this file inherit the requirements documented below.\n// These imports are ok because they consist only of type aliases for primitive types,\n// and thus have no impact on serialization as long as the primitive type they are an alias for does not change.\n// This does mean that the various UuidString types must remain strings, and must never change the format unless the process for changing\n// persisted types (as documented below) is followed.\nimport { DetachedSequenceId, NodeId, TraitLabel, UuidString } from '../Identifiers';\nimport { assertNotUndefined, assert } from '../Common';\nimport { Side } from '../Snapshot';\nimport { EditBase, BuildNode, NodeData, Payload, TraitLocation, TreeNodeSequence } from '../generic';\n\n/**\n * Types for Edits in Fluid Ops and Fluid summaries.\n *\n * Types describing locations in the tree are stable in the presence of other concurrent edits.\n *\n * All types are compatible with Fluid Serializable.\n *\n * These types can only be modified in ways that are both backwards and forwards compatible since they\n * are used in edits, and thus are persisted (using Fluid serialization).\n *\n * This means these types cannot be changed in any way that impacts their Fluid serialization\n * except through a very careful process:\n *\n * 1. The planned change must support all old data, and maintain the exact semantics of it.\n * This means that the change is pretty much limited to adding optional fields,\n * or making required fields optional.\n * 2. Support for the new format must be deployed to all users (This means all applications using SharedTree must do this),\n * and this deployment must be confirmed to be stable and will not be rolled back.\n * 3. Usage of the new format may start.\n *\n * Support for the old format can NEVER be removed: it must be maintained indefinably or old documents will break.\n * Because this process puts requirements on applications using shared tree,\n * step 3 should only ever be done in a Major version update,\n * and must be explicitly called out in the release notes\n * stating which versions of SharedTree are supported for documents modified by the new version.\n */\n\n/**\n * The information included in an edit.\n * @public\n */\nexport type DefaultEditBase = EditBase<Change>;\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 * 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 * TODO: Design Decision:\n * If allowing 'moving from nowhere' to restore nodes: all new Nodes must have never before used identifiers.\n * Otherwise could just forbid identifiers currently reachable?\n * Could also allow introducing a node with a particular identifier to mean replacing that node with the new one\n * (could include optional constraint to require/prevent this).\n *\n * @public\n */\nexport interface Build {\n\treadonly destination: DetachedSequenceId;\n\treadonly source: 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: DetachedSequenceId;\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?: DetachedSequenceId;\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\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/**\n * What to do when a Constraint is violated.\n * @public\n */\nexport enum ConstraintEffect {\n\t/**\n\t * Discard Edit.\n\t */\n\tInvalidAndDiscard,\n\n\t/**\n\t * Discard Edit, but record metadata that application may want to try and recover this change by recreating it.\n\t * Should this be the default policy for when another (non Constraint) change is invalid?\n\t */\n\tInvalidRetry,\n\n\t/**\n\t * Apply the change, but flag it for possible reconsideration by the app\n\t * (applying it is better than not, but perhaps the high level logic could produce something better).\n\t */\n\tValidRetry,\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: TreeNodeSequence<BuildNode>, destination: DetachedSequenceId): Build => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Build,\n\t}),\n\n\tinsert: (source: DetachedSequenceId, destination: StablePlace): Insert => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Insert,\n\t}),\n\n\tdetach: (source: StableRange, destination?: DetachedSequenceId): 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\t// eslint-disable-next-line no-null/no-null\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\n/**\n * Helper for creating a `Delete` edit.\n * @public\n */\nexport const Delete = {\n\t/**\n\t * @returns a Change that deletes the supplied part of the tree.\n\t */\n\tcreate: (stableRange: StableRange): Change => Change.detach(stableRange),\n};\n\n/**\n * Helper for creating an `Insert` edit.\n * @public\n */\nexport const Insert = {\n\t/**\n\t * @returns a Change that inserts 'nodes' into the specified location in the tree.\n\t */\n\tcreate: (nodes: TreeNodeSequence<BuildNode>, destination: StablePlace): Change[] => {\n\t\tconst build = Change.build(nodes, 0 as DetachedSequenceId);\n\t\treturn [build, Change.insert(build.destination, destination)];\n\t},\n};\n\n/**\n * Helper for creating a `Move` edit.\n * @public\n */\nexport const Move = {\n\t/**\n\t * @returns a Change that moves the specified content to a new location in the tree.\n\t */\n\tcreate: (source: StableRange, destination: StablePlace): Change[] => {\n\t\tconst detach = Change.detach(source, 0 as DetachedSequenceId);\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 places corresponding to 3 places into the trait a new node\n * could be inserted: at the start, before \"foo\", after \"foo\", before \"bar\", after \"bar\", and at the end.\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 * `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): 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): 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\tconst message = 'StableRange must be constructed with endpoints from the same trait';\n\t\t\t\tassert(start.referenceTrait.parent === end.referenceTrait.parent, message);\n\t\t\t\tassert(start.referenceTrait.label === end.referenceTrait.label, message);\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): StableRange => ({ start: StablePlace.before(node), end: StablePlace.after(node) }),\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\n/**\n * @returns True iff the given `node` is of type NodeData.\n * @internal\n */\nexport function isNodeData(node: NodeData | NodeId): node is NodeData {\n\treturn (node as NodeData).definition !== undefined && (node as NodeData).identifier !== undefined;\n}\n\n/**\n * @returns The NodeId for a given node or its id.\n * @internal\n */\nexport function getNodeId(node: NodeData | NodeId): NodeId {\n\tif (isNodeData(node)) {\n\t\treturn node.identifier;\n\t} else {\n\t\treturn node;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PersistedTypes.js","sourceRoot":"","sources":["../../src/default-edits/PersistedTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,sCAAuD;AACvD,0CAAmC;AAoCnC;;;GAGG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,6CAAK,CAAA;IACL,mDAAQ,CAAA;IACR,uDAAU,CAAA;AACX,CAAC,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KAAK,CAAC;KAC/B,CAAC;CACF,CAAC;AAEF;;;GAGG;AACH,SAAgB,UAAU,CAAC,IAAuB;IACjD,OAAQ,IAAiB,CAAC,UAAU,KAAK,SAAS,IAAK,IAAiB,CAAC,UAAU,KAAK,SAAS,CAAC;AACnG,CAAC;AAFD,gCAEC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,IAAuB;IAChD,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC;KACvB;SAAM;QACN,OAAO,IAAI,CAAC;KACZ;AACF,CAAC;AAND,8BAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// All types imported into this file inherit the requirements documented below.\n// These imports are ok because they consist only of type aliases for primitive types,\n// and thus have no impact on serialization as long as the primitive type they are an alias for does not change.\n// This does mean that the various UuidString types must remain strings, and must never change the format unless the process for changing\n// persisted types (as documented below) is followed.\nimport { DetachedSequenceId, NodeId, TraitLabel, UuidString } from '../Identifiers';\nimport { assertNotUndefined, assert } from '../Common';\nimport { Side } from '../Snapshot';\nimport { EditBase, BuildNode, NodeData, Payload, TraitLocation, TreeNodeSequence } from '../generic';\n\n/**\n * Types for Edits in Fluid Ops and Fluid summaries.\n *\n * Types describing locations in the tree are stable in the presence of other concurrent edits.\n *\n * All types are compatible with Fluid Serializable.\n *\n * These types can only be modified in ways that are both backwards and forwards compatible since they\n * are used in edits, and thus are persisted (using Fluid serialization).\n *\n * This means these types cannot be changed in any way that impacts their Fluid serialization\n * except through a very careful process:\n *\n * 1. The planned change must support all old data, and maintain the exact semantics of it.\n * This means that the change is pretty much limited to adding optional fields,\n * or making required fields optional.\n * 2. Support for the new format must be deployed to all users (This means all applications using SharedTree must do this),\n * and this deployment must be confirmed to be stable and will not be rolled back.\n * 3. Usage of the new format may start.\n *\n * Support for the old format can NEVER be removed: it must be maintained indefinably or old documents will break.\n * Because this process puts requirements on applications using shared tree,\n * step 3 should only ever be done in a Major version update,\n * and must be explicitly called out in the release notes\n * stating which versions of SharedTree are supported for documents modified by the new version.\n */\n\n/**\n * The information included in an edit.\n * @public\n */\nexport type DefaultEditBase = EditBase<Change>;\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 * 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 * TODO: Design Decision:\n * If allowing 'moving from nowhere' to restore nodes: all new Nodes must have never before used identifiers.\n * Otherwise could just forbid identifiers currently reachable?\n * Could also allow introducing a node with a particular identifier to mean replacing that node with the new one\n * (could include optional constraint to require/prevent this).\n *\n * @public\n */\nexport interface Build {\n\treadonly destination: DetachedSequenceId;\n\treadonly source: 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: DetachedSequenceId;\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?: DetachedSequenceId;\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\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/**\n * What to do when a Constraint is violated.\n * @public\n */\nexport enum ConstraintEffect {\n\t/**\n\t * Discard Edit.\n\t */\n\tInvalidAndDiscard,\n\n\t/**\n\t * Discard Edit, but record metadata that application may want to try and recover this change by recreating it.\n\t * Should this be the default policy for when another (non Constraint) change is invalid?\n\t */\n\tInvalidRetry,\n\n\t/**\n\t * Apply the change, but flag it for possible reconsideration by the app\n\t * (applying it is better than not, but perhaps the high level logic could produce something better).\n\t */\n\tValidRetry,\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: TreeNodeSequence<BuildNode>, destination: DetachedSequenceId): Build => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Build,\n\t}),\n\n\tinsert: (source: DetachedSequenceId, destination: StablePlace): Insert => ({\n\t\tdestination,\n\t\tsource,\n\t\ttype: ChangeType.Insert,\n\t}),\n\n\tdetach: (source: StableRange, destination?: DetachedSequenceId): 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\n/**\n * Helper for creating a `Delete` edit.\n * @public\n */\nexport const Delete = {\n\t/**\n\t * @returns a Change that deletes the supplied part of the tree.\n\t */\n\tcreate: (stableRange: StableRange): Change => Change.detach(stableRange),\n};\n\n/**\n * Helper for creating an `Insert` edit.\n * @public\n */\nexport const Insert = {\n\t/**\n\t * @returns a Change that inserts 'nodes' into the specified location in the tree.\n\t */\n\tcreate: (nodes: TreeNodeSequence<BuildNode>, destination: StablePlace): Change[] => {\n\t\tconst build = Change.build(nodes, 0 as DetachedSequenceId);\n\t\treturn [build, Change.insert(build.destination, destination)];\n\t},\n};\n\n/**\n * Helper for creating a `Move` edit.\n * @public\n */\nexport const Move = {\n\t/**\n\t * @returns a Change that moves the specified content to a new location in the tree.\n\t */\n\tcreate: (source: StableRange, destination: StablePlace): Change[] => {\n\t\tconst detach = Change.detach(source, 0 as DetachedSequenceId);\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 places corresponding to 3 places into the trait a new node\n * could be inserted: at the start, before \"foo\", after \"foo\", before \"bar\", after \"bar\", and at the end.\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 * `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): 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): 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\tconst message = 'StableRange must be constructed with endpoints from the same trait';\n\t\t\t\tassert(start.referenceTrait.parent === end.referenceTrait.parent, message);\n\t\t\t\tassert(start.referenceTrait.label === end.referenceTrait.label, message);\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): StableRange => ({ start: StablePlace.before(node), end: StablePlace.after(node) }),\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\n/**\n * @returns True iff the given `node` is of type NodeData.\n * @internal\n */\nexport function isNodeData(node: NodeData | NodeId): node is NodeData {\n\treturn (node as NodeData).definition !== undefined && (node as NodeData).identifier !== undefined;\n}\n\n/**\n * @returns The NodeId for a given node or its id.\n * @internal\n */\nexport function getNodeId(node: NodeData | NodeId): NodeId {\n\tif (isNodeData(node)) {\n\t\treturn node.identifier;\n\t} else {\n\t\treturn node;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/default-edits/Transaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAc,MAAM,gBAAgB,CAAC;AAC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AC,UAAU,CAAC,CAAC;QACtD,IAAI,eAAe,KAAK,SAAS,EAAE;YAClC,mBAAmB,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;SACjB;QACD,uHAAuH;QACvH,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,OAAO,eAAe,CAAC;IACxB,CAAC;CACD;AAnOD,kCAmOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, assertNotUndefined, copyPropertyIfDefined, fail } from '../Common';\nimport { NodeId, DetachedSequenceId, TraitLabel } from '../Identifiers';\nimport { GenericTransaction, BuildNode, EditStatus } from '../generic';\nimport { Snapshot, SnapshotNode } from '../Snapshot';\nimport { EditValidationResult } from '../Checkout';\nimport { Build, Change, ChangeType, Constraint, ConstraintEffect, Detach, Insert, SetValue } from './PersistedTypes';\nimport {\n\tdetachRange,\n\tinsertIntoTrait,\n\trangeFromStableRange,\n\tvalidateStablePlace,\n\tvalidateStableRange,\n\tisDetachedSequenceId,\n} from './EditUtilities';\n\n/**\n * A mutable transaction for applying sequences of changes to a Snapshot.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a Snapshot.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial Snapshot (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n */\nexport class Transaction extends GenericTransaction<Change> {\n\tprotected readonly detached: Map<DetachedSequenceId, readonly NodeId[]> = new Map();\n\n\tpublic static factory(snapshot: Snapshot): Transaction {\n\t\treturn new Transaction(snapshot);\n\t}\n\n\tprotected validateOnClose(): EditStatus {\n\t\t// Making the policy choice that storing a detached sequences in an edit but not using it is an error.\n\t\treturn this.detached.size !== 0 ? EditStatus.Malformed : EditStatus.Applied;\n\t}\n\n\tprotected dispatchChange(change: Change): EditStatus {\n\t\tswitch (change.type) {\n\t\t\tcase ChangeType.Build:\n\t\t\t\treturn this.applyBuild(change);\n\t\t\tcase ChangeType.Insert:\n\t\t\t\treturn this.applyInsert(change);\n\t\t\tcase ChangeType.Detach:\n\t\t\t\treturn this.applyDetach(change);\n\t\t\tcase ChangeType.Constraint:\n\t\t\t\treturn this.applyConstraint(change);\n\t\t\tcase ChangeType.SetValue:\n\t\t\t\treturn this.applySetValue(change);\n\t\t\tdefault:\n\t\t\t\treturn fail('Attempted to apply unsupported change');\n\t\t}\n\t}\n\n\tprivate applyBuild(change: Build): EditStatus {\n\t\tif (this.detached.has(change.destination)) {\n\t\t\treturn EditStatus.Malformed;\n\t\t}\n\n\t\tlet idAlreadyPresent = false;\n\t\tlet duplicateIdInBuild = false;\n\t\tconst map = new Map<NodeId, SnapshotNode>();\n\t\tlet detachedSequenceNotFound = false;\n\t\tconst newIds = this.createSnapshotNodesForTree(\n\t\t\tchange.source,\n\t\t\t(id, snapshotNode) => {\n\t\t\t\tif (map.has(id)) {\n\t\t\t\t\tduplicateIdInBuild = true;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (this.view.hasNode(id)) {\n\t\t\t\t\tidAlreadyPresent = true;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tmap.set(id, snapshotNode);\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdetachedSequenceNotFound = true;\n\t\t\t}\n\t\t);\n\n\t\tif (detachedSequenceNotFound || duplicateIdInBuild) {\n\t\t\treturn EditStatus.Malformed;\n\t\t}\n\t\tif (idAlreadyPresent) {\n\t\t\treturn EditStatus.Invalid;\n\t\t}\n\n\t\tconst view = this.view.addNodes(map.values());\n\t\tthis._view = view;\n\t\tthis.detached.set(change.destination, assertNotUndefined(newIds));\n\t\treturn EditStatus.Applied;\n\t}\n\n\tprivate applyInsert(change: Insert): EditStatus {\n\t\tconst source = this.detached.get(change.source);\n\t\tif (source === undefined) {\n\t\t\treturn EditStatus.Malformed;\n\t\t}\n\n\t\tconst destinationChangeResult = validateStablePlace(this.view, change.destination);\n\t\tif (destinationChangeResult !== EditValidationResult.Valid) {\n\t\t\treturn destinationChangeResult === EditValidationResult.Invalid ? EditStatus.Invalid : EditStatus.Malformed;\n\t\t}\n\n\t\tthis.detached.delete(change.source);\n\t\tthis._view = insertIntoTrait(this.view, source, change.destination);\n\t\treturn EditStatus.Applied;\n\t}\n\n\tprivate applyDetach(change: Detach): EditStatus {\n\t\tconst sourceChangeResult = validateStableRange(this.view, change.source);\n\t\tif (sourceChangeResult !== EditValidationResult.Valid) {\n\t\t\treturn sourceChangeResult === EditValidationResult.Invalid ? EditStatus.Invalid : EditStatus.Malformed;\n\t\t}\n\n\t\tconst result = detachRange(this.view, change.source);\n\t\tlet modifiedView = result.snapshot;\n\t\tconst { detached } = result;\n\n\t\t// Store or dispose detached\n\t\tif (change.destination !== undefined) {\n\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\treturn EditStatus.Malformed;\n\t\t\t}\n\t\t\tthis.detached.set(change.destination, detached);\n\t\t} else {\n\t\t\tmodifiedView = modifiedView.deleteNodes(detached);\n\t\t}\n\n\t\tthis._view = modifiedView;\n\t\treturn EditStatus.Applied;\n\t}\n\n\tprivate applyConstraint(change: Constraint): EditStatus {\n\t\t// TODO: Implement identityHash and contentHash\n\t\tassert(change.identityHash === undefined, 'identityHash constraint is not implemented');\n\t\tassert(change.contentHash === undefined, 'contentHash constraint is not implemented');\n\n\t\tconst sourceChangeResult = validateStableRange(this.view, change.toConstrain);\n\t\tconst onViolation = change.effect === ConstraintEffect.ValidRetry ? EditStatus.Applied : EditStatus.Invalid;\n\t\tif (sourceChangeResult !== EditValidationResult.Valid) {\n\t\t\treturn sourceChangeResult === EditValidationResult.Invalid ? onViolation : EditStatus.Malformed;\n\t\t}\n\n\t\tconst { start, end } = rangeFromStableRange(this.view, change.toConstrain);\n\t\tconst startIndex = this.view.findIndexWithinTrait(start);\n\t\tconst endIndex = this.view.findIndexWithinTrait(end);\n\n\t\tif (change.length !== undefined && change.length !== endIndex - startIndex) {\n\t\t\treturn onViolation;\n\t\t}\n\n\t\tif (change.parentNode !== undefined && change.parentNode !== end.trait.parent) {\n\t\t\treturn onViolation;\n\t\t}\n\n\t\tif (change.label !== undefined && change.label !== end.trait.label) {\n\t\t\treturn onViolation;\n\t\t}\n\n\t\treturn EditStatus.Applied;\n\t}\n\n\tprivate applySetValue(change: SetValue): EditStatus {\n\t\tif (!this.view.hasNode(change.nodeToModify)) {\n\t\t\treturn EditStatus.Invalid;\n\t\t}\n\n\t\tthis._view = this.view.setNodeValue(change.nodeToModify, change.payload);\n\t\treturn EditStatus.Applied;\n\t}\n\n\t/**\n\t * Generates snapshot nodes from the supplied edit nodes.\n\t * Invokes onCreateNode for each new snapshot node, and halts creation early if it returns true.\n\t * Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence.\n\t * @returns all the top-level node IDs in `sequence` (both from nodes and from detached sequences).\n\t */\n\tprotected createSnapshotNodesForTree(\n\t\tsequence: Iterable<BuildNode>,\n\t\tonCreateNode: (id: NodeId, node: SnapshotNode) => boolean,\n\t\tonInvalidDetachedId: () => void\n\t): NodeId[] | undefined {\n\t\tconst topLevelIds: NodeId[] = [];\n\t\tconst unprocessed: BuildNode[] = [];\n\t\tfor (const buildNode of sequence) {\n\t\t\tif (isDetachedSequenceId(buildNode)) {\n\t\t\t\tconst detachedIds = this.getDetachedNodeIds(buildNode, onInvalidDetachedId);\n\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\ttopLevelIds.push(...detachedIds);\n\t\t\t} else {\n\t\t\t\tunprocessed.push(buildNode);\n\t\t\t\ttopLevelIds.push(buildNode.identifier);\n\t\t\t}\n\t\t}\n\t\twhile (unprocessed.length > 0) {\n\t\t\tconst node = unprocessed.pop();\n\t\t\tassert(node !== undefined && !isDetachedSequenceId(node));\n\t\t\tconst traits = new Map<TraitLabel, readonly NodeId[]>();\n\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\tfor (const key in node.traits) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\tconst children = node.traits[key];\n\t\t\t\t\tif (children.length > 0) {\n\t\t\t\t\t\tconst childIds: NodeId[] = [];\n\t\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\t\tif (isDetachedSequenceId(child)) {\n\t\t\t\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(child, onInvalidDetachedId);\n\t\t\t\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchildIds.push(...detachedIds);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tchildIds.push(child.identifier);\n\t\t\t\t\t\t\t\tunprocessed.push(child);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttraits.set(key as TraitLabel, childIds);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst newNode: SnapshotNode = {\n\t\t\t\tidentifier: node.identifier,\n\t\t\t\tdefinition: node.definition,\n\t\t\t\ttraits,\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(node, newNode, 'payload');\n\t\t\tif (onCreateNode(newNode.identifier, newNode)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\t\treturn topLevelIds;\n\t}\n\n\tprivate getDetachedNodeIds(\n\t\tdetachedId: DetachedSequenceId,\n\t\tonInvalidDetachedId: () => void\n\t): readonly NodeId[] | undefined {\n\t\t// Retrieve the detached sequence from the void.\n\t\tconst detachedNodeIds = this.detached.get(detachedId);\n\t\tif (detachedNodeIds === undefined) {\n\t\t\tonInvalidDetachedId();\n\t\t\treturn undefined;\n\t\t}\n\t\t// Since we have retrieved the sequence, remove it from the void to prevent a second tree from multi-parenting it later\n\t\tthis.detached.delete(detachedId);\n\t\treturn detachedNodeIds;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../src/default-edits/Transaction.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,sCAAoF;AAEpF,wCAAuE;AAEvE,0CAAmD;AACnD,qDAAqH;AACrH,mDAOyB;AAEzB;;;;;;;;;;;;GAYG;AACH,MAAa,WAAY,SAAQ,4BAA0B;IAA3D;;QACoB,aAAQ,GAA+C,IAAI,GAAG,EAAE,CAAC;IAmOrF,CAAC;IAjOO,MAAM,CAAC,OAAO,CAAC,QAAkB;QACvC,OAAO,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAES,eAAe;QACxB,sGAAsG;QACtG,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,oBAAU,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAU,CAAC,OAAO,CAAC;IAC7E,CAAC;IAES,cAAc,CAAC,MAAc;QACtC,QAAQ,MAAM,CAAC,IAAI,EAAE;YACpB,KAAK,2BAAU,CAAC,KAAK;gBACpB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAChC,KAAK,2BAAU,CAAC,MAAM;gBACrB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,2BAAU,CAAC,MAAM;gBACrB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,2BAAU,CAAC,UAAU;gBACzB,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YACrC,KAAK,2BAAU,CAAC,QAAQ;gBACvB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACnC;gBACC,OAAO,aAAI,CAAC,uCAAuC,CAAC,CAAC;SACtD;IACF,CAAC;IAEO,UAAU,CAAC,MAAa;QAC/B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AAC,CAAC;6BACxB;yBACD;wBACD,MAAM,CAAC,GAAG,CAAC,GAAiB,EAAE,QAAQ,CAAC,CAAC;qBACxC;iBACD;aACD;YACD,MAAM,OAAO,GAAiB;gBAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,MAAM;aACN,CAAC;YACF,8BAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;YAChD,IAAI,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE;gBAC9C,OAAO,SAAS,CAAC;aACjB;SACD;QACD,OAAO,WAAW,CAAC;IACpB,CAAC;IAEO,kBAAkB,CACzB,UAA8B,EAC9B,mBAA+B;QAE/B,gDAAgD;QAChD,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtD,IAAI,eAAe,KAAK,SAAS,EAAE;YAClC,mBAAmB,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;SACjB;QACD,uHAAuH;QACvH,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,OAAO,eAAe,CAAC;IACxB,CAAC;CACD;AApOD,kCAoOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, assertNotUndefined, copyPropertyIfDefined, fail } from '../Common';\nimport { NodeId, DetachedSequenceId, TraitLabel } from '../Identifiers';\nimport { GenericTransaction, BuildNode, EditStatus } from '../generic';\nimport { Snapshot, SnapshotNode } from '../Snapshot';\nimport { EditValidationResult } from '../Checkout';\nimport { Build, Change, ChangeType, Constraint, ConstraintEffect, Detach, Insert, SetValue } from './PersistedTypes';\nimport {\n\tdetachRange,\n\tinsertIntoTrait,\n\trangeFromStableRange,\n\tvalidateStablePlace,\n\tvalidateStableRange,\n\tisDetachedSequenceId,\n} from './EditUtilities';\n\n/**\n * A mutable transaction for applying sequences of changes to a Snapshot.\n * Allows viewing the intermediate states.\n *\n * Contains necessary state to apply changes within an edit to a Snapshot.\n *\n * May have any number of changes applied to make up the edit.\n * Use `close` to complete the transaction, returning the array of changes and an EditingResult showing the\n * results of applying the changes as an Edit to the initial Snapshot (passed to the constructor).\n *\n * No data outside the Transaction is modified by Transaction:\n * the results from `close` must be used to actually submit an `Edit`.\n */\nexport class Transaction extends GenericTransaction<Change> {\n\tprotected readonly detached: Map<DetachedSequenceId, readonly NodeId[]> = new Map();\n\n\tpublic static factory(snapshot: Snapshot): Transaction {\n\t\treturn new Transaction(snapshot);\n\t}\n\n\tprotected validateOnClose(): EditStatus {\n\t\t// Making the policy choice that storing a detached sequences in an edit but not using it is an error.\n\t\treturn this.detached.size !== 0 ? EditStatus.Malformed : EditStatus.Applied;\n\t}\n\n\tprotected dispatchChange(change: Change): EditStatus {\n\t\tswitch (change.type) {\n\t\t\tcase ChangeType.Build:\n\t\t\t\treturn this.applyBuild(change);\n\t\t\tcase ChangeType.Insert:\n\t\t\t\treturn this.applyInsert(change);\n\t\t\tcase ChangeType.Detach:\n\t\t\t\treturn this.applyDetach(change);\n\t\t\tcase ChangeType.Constraint:\n\t\t\t\treturn this.applyConstraint(change);\n\t\t\tcase ChangeType.SetValue:\n\t\t\t\treturn this.applySetValue(change);\n\t\t\tdefault:\n\t\t\t\treturn fail('Attempted to apply unsupported change');\n\t\t}\n\t}\n\n\tprivate applyBuild(change: Build): EditStatus {\n\t\tif (this.detached.has(change.destination)) {\n\t\t\treturn EditStatus.Malformed;\n\t\t}\n\n\t\tlet idAlreadyPresent = false;\n\t\tlet duplicateIdInBuild = false;\n\t\tconst map = new Map<NodeId, SnapshotNode>();\n\t\tlet detachedSequenceNotFound = false;\n\t\tconst newIds = this.createSnapshotNodesForTree(\n\t\t\tchange.source,\n\t\t\t(id, snapshotNode) => {\n\t\t\t\tif (map.has(id)) {\n\t\t\t\t\tduplicateIdInBuild = true;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (this.view.hasNode(id)) {\n\t\t\t\t\tidAlreadyPresent = true;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tmap.set(id, snapshotNode);\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdetachedSequenceNotFound = true;\n\t\t\t}\n\t\t);\n\n\t\tif (detachedSequenceNotFound || duplicateIdInBuild) {\n\t\t\treturn EditStatus.Malformed;\n\t\t}\n\t\tif (idAlreadyPresent) {\n\t\t\treturn EditStatus.Invalid;\n\t\t}\n\n\t\tconst view = this.view.addNodes(map.values());\n\t\tthis._view = view;\n\t\tthis.detached.set(change.destination, assertNotUndefined(newIds));\n\t\treturn EditStatus.Applied;\n\t}\n\n\tprivate applyInsert(change: Insert): EditStatus {\n\t\tconst source = this.detached.get(change.source);\n\t\tif (source === undefined) {\n\t\t\treturn EditStatus.Malformed;\n\t\t}\n\n\t\tconst destinationChangeResult = validateStablePlace(this.view, change.destination);\n\t\tif (destinationChangeResult !== EditValidationResult.Valid) {\n\t\t\treturn destinationChangeResult === EditValidationResult.Invalid ? EditStatus.Invalid : EditStatus.Malformed;\n\t\t}\n\n\t\tthis.detached.delete(change.source);\n\t\tthis._view = insertIntoTrait(this.view, source, change.destination);\n\t\treturn EditStatus.Applied;\n\t}\n\n\tprivate applyDetach(change: Detach): EditStatus {\n\t\tconst sourceChangeResult = validateStableRange(this.view, change.source);\n\t\tif (sourceChangeResult !== EditValidationResult.Valid) {\n\t\t\treturn sourceChangeResult === EditValidationResult.Invalid ? EditStatus.Invalid : EditStatus.Malformed;\n\t\t}\n\n\t\tconst result = detachRange(this.view, change.source);\n\t\tlet modifiedView = result.snapshot;\n\t\tconst { detached } = result;\n\n\t\t// Store or dispose detached\n\t\tif (change.destination !== undefined) {\n\t\t\tif (this.detached.has(change.destination)) {\n\t\t\t\treturn EditStatus.Malformed;\n\t\t\t}\n\t\t\tthis.detached.set(change.destination, detached);\n\t\t} else {\n\t\t\tmodifiedView = modifiedView.deleteNodes(detached);\n\t\t}\n\n\t\tthis._view = modifiedView;\n\t\treturn EditStatus.Applied;\n\t}\n\n\tprivate applyConstraint(change: Constraint): EditStatus {\n\t\t// TODO: Implement identityHash and contentHash\n\t\tassert(change.identityHash === undefined, 'identityHash constraint is not implemented');\n\t\tassert(change.contentHash === undefined, 'contentHash constraint is not implemented');\n\n\t\tconst sourceChangeResult = validateStableRange(this.view, change.toConstrain);\n\t\tconst onViolation = change.effect === ConstraintEffect.ValidRetry ? EditStatus.Applied : EditStatus.Invalid;\n\t\tif (sourceChangeResult !== EditValidationResult.Valid) {\n\t\t\treturn sourceChangeResult === EditValidationResult.Invalid ? onViolation : EditStatus.Malformed;\n\t\t}\n\n\t\tconst { start, end } = rangeFromStableRange(this.view, change.toConstrain);\n\t\tconst startIndex = this.view.findIndexWithinTrait(start);\n\t\tconst endIndex = this.view.findIndexWithinTrait(end);\n\n\t\tif (change.length !== undefined && change.length !== endIndex - startIndex) {\n\t\t\treturn onViolation;\n\t\t}\n\n\t\tif (change.parentNode !== undefined && change.parentNode !== end.trait.parent) {\n\t\t\treturn onViolation;\n\t\t}\n\n\t\tif (change.label !== undefined && change.label !== end.trait.label) {\n\t\t\treturn onViolation;\n\t\t}\n\n\t\treturn EditStatus.Applied;\n\t}\n\n\tprivate applySetValue(change: SetValue): EditStatus {\n\t\tif (!this.view.hasNode(change.nodeToModify)) {\n\t\t\treturn EditStatus.Invalid;\n\t\t}\n\n\t\tthis._view = this.view.setNodeValue(change.nodeToModify, change.payload);\n\t\treturn EditStatus.Applied;\n\t}\n\n\t/**\n\t * Generates snapshot nodes from the supplied edit nodes.\n\t * Invokes onCreateNode for each new snapshot node, and halts creation early if it returns true.\n\t * Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence.\n\t * @returns all the top-level node IDs in `sequence` (both from nodes and from detached sequences).\n\t */\n\tprotected createSnapshotNodesForTree(\n\t\tsequence: Iterable<BuildNode>,\n\t\tonCreateNode: (id: NodeId, node: SnapshotNode) => boolean,\n\t\tonInvalidDetachedId: () => void\n\t): NodeId[] | undefined {\n\t\tconst topLevelIds: NodeId[] = [];\n\t\tconst unprocessed: BuildNode[] = [];\n\t\tfor (const buildNode of sequence) {\n\t\t\tif (isDetachedSequenceId(buildNode)) {\n\t\t\t\tconst detachedIds = this.getDetachedNodeIds(buildNode, onInvalidDetachedId);\n\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\ttopLevelIds.push(...detachedIds);\n\t\t\t} else {\n\t\t\t\tunprocessed.push(buildNode);\n\t\t\t\ttopLevelIds.push(buildNode.identifier);\n\t\t\t}\n\t\t}\n\t\twhile (unprocessed.length > 0) {\n\t\t\tconst node = unprocessed.pop();\n\t\t\tassert(node !== undefined && !isDetachedSequenceId(node));\n\t\t\tconst traits = new Map<TraitLabel, readonly NodeId[]>();\n\n\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\tfor (const key in node.traits) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\tconst children = node.traits[key];\n\t\t\t\t\tif (children.length > 0) {\n\t\t\t\t\t\tconst childIds: NodeId[] = [];\n\t\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\t\tif (isDetachedSequenceId(child)) {\n\t\t\t\t\t\t\t\tconst detachedIds = this.getDetachedNodeIds(child, onInvalidDetachedId);\n\t\t\t\t\t\t\t\tif (detachedIds === undefined) {\n\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchildIds.push(...detachedIds);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tchildIds.push(child.identifier);\n\t\t\t\t\t\t\t\tunprocessed.push(child);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttraits.set(key as TraitLabel, childIds);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst newNode: SnapshotNode = {\n\t\t\t\tidentifier: node.identifier,\n\t\t\t\tdefinition: node.definition,\n\t\t\t\ttraits,\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(node, newNode, 'payload');\n\t\t\tif (onCreateNode(newNode.identifier, newNode)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\t\treturn topLevelIds;\n\t}\n\n\tprivate getDetachedNodeIds(\n\t\tdetachedId: DetachedSequenceId,\n\t\tonInvalidDetachedId: () => void\n\t): readonly NodeId[] | undefined {\n\t\t// Retrieve the detached sequence from the void.\n\t\tconst detachedNodeIds = this.detached.get(detachedId);\n\t\tif (detachedNodeIds === undefined) {\n\t\t\tonInvalidDetachedId();\n\t\t\treturn undefined;\n\t\t}\n\t\t// Since we have retrieved the sequence, remove it from the void to prevent a second tree from multi-parenting it later\n\t\tthis.detached.delete(detachedId);\n\t\treturn detachedNodeIds;\n\t}\n}\n"]}
|
|
@@ -16,7 +16,7 @@ export interface IUndoConsumer {
|
|
|
16
16
|
* undo redo stack manager
|
|
17
17
|
*/
|
|
18
18
|
export declare class SharedTreeUndoRedoHandler {
|
|
19
|
-
private stackManager;
|
|
19
|
+
private readonly stackManager;
|
|
20
20
|
constructor(stackManager: IUndoConsumer);
|
|
21
21
|
attachTree(tree: SharedTree): void;
|
|
22
22
|
detachTree(tree: SharedTree): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UndoRedoHandler.d.ts","sourceRoot":"","sources":["../../src/default-edits/UndoRedoHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,MAAM,WAAW,WAAW;IAC3B,MAAM,QAAG;IACT,OAAO,QAAG;CACV;AAED,MAAM,WAAW,aAAa;IAC7B,sBAAsB,CAAC,UAAU,EAAE,WAAW,OAAE;CAChD;AAED;;;GAGG;AACH,qBAAa,yBAAyB;
|
|
1
|
+
{"version":3,"file":"UndoRedoHandler.d.ts","sourceRoot":"","sources":["../../src/default-edits/UndoRedoHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,MAAM,WAAW,WAAW;IAC3B,MAAM,QAAG;IACT,OAAO,QAAG;CACV;AAED,MAAM,WAAW,aAAa;IAC7B,sBAAsB,CAAC,UAAU,EAAE,WAAW,OAAE;CAChD;AAED;;;GAGG;AACH,qBAAa,yBAAyB;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,aAAa;IAEjD,UAAU,CAAC,IAAI,EAAE,UAAU;IAG3B,UAAU,CAAC,IAAI,EAAE,UAAU;IAIlC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAc/B;CACF;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,WAAW;IAC3C,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAArC,MAAM,EAAE,MAAM,EAAmB,IAAI,EAAE,UAAU;IAE9D,MAAM;IASN,OAAO;CAGd"}
|
|
@@ -12,8 +12,6 @@ const generic_1 = require("../generic");
|
|
|
12
12
|
* undo redo stack manager
|
|
13
13
|
*/
|
|
14
14
|
class SharedTreeUndoRedoHandler {
|
|
15
|
-
// False positive
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly
|
|
17
15
|
constructor(stackManager) {
|
|
18
16
|
this.stackManager = stackManager;
|
|
19
17
|
this.treeDeltaHandler = (eventArguments) => {
|
|
@@ -35,8 +33,6 @@ exports.SharedTreeUndoRedoHandler = SharedTreeUndoRedoHandler;
|
|
|
35
33
|
* Tracks a change on a shared tree and allows reverting it
|
|
36
34
|
*/
|
|
37
35
|
class SharedTreeRevertible {
|
|
38
|
-
// False positive
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly
|
|
40
36
|
constructor(editId, tree) {
|
|
41
37
|
this.editId = editId;
|
|
42
38
|
this.tree = tree;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UndoRedoHandler.js","sourceRoot":"","sources":["../../src/default-edits/UndoRedoHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,sCAA+C;AAE/C,wCAA0E;AAe1E;;;GAGG;AACH,MAAa,yBAAyB;IACrC,
|
|
1
|
+
{"version":3,"file":"UndoRedoHandler.js","sourceRoot":"","sources":["../../src/default-edits/UndoRedoHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,sCAA+C;AAE/C,wCAA0E;AAe1E;;;GAGG;AACH,MAAa,yBAAyB;IACrC,YAA6B,YAA2B;QAA3B,iBAAY,GAAZ,YAAY,CAAe;QASvC,qBAAgB,GAAG,CAAC,cAAuD,EAAE,EAAE;YAC/F,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;YAE/C,IAAI,KAAK,EAAE;gBACV,IAAI,CAAC,YAAY,CAAC,sBAAsB,CACvC,IAAI,oBAAoB,CACvB,MAAM,EACN,2BAAkB,CACjB,IAAI,EACJ,sGAAsG,CACtG,CACD,CACD,CAAC;aACF;QACF,CAAC,CAAC;IAvByD,CAAC;IAErD,UAAU,CAAC,IAAgB;QACjC,IAAI,CAAC,EAAE,CAAC,yBAAe,CAAC,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;IACM,UAAU,CAAC,IAAgB;QACjC,IAAI,CAAC,GAAG,CAAC,yBAAe,CAAC,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChE,CAAC;CAiBD;AAzBD,8DAyBC;AAED;;GAEG;AACH,MAAa,oBAAoB;IAChC,YAAoB,MAAc,EAAmB,IAAgB;QAAjD,WAAM,GAAN,MAAM,CAAQ;QAAmB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAElE,MAAM;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;QAChE,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;QAE3E,+DAA+D;QAC/D,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAC7D,CAAC;IAEM,OAAO;QACb,OAAO;IACR,CAAC;CACD;AAfD,oDAeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assertNotUndefined } from '../Common';\nimport { EditId } from '../Identifiers';\nimport { EditCommittedEventArguments, SharedTreeEvent } from '../generic';\nimport { SharedTree } from './SharedTree';\n\n// TODO: We temporarily duplicate these contracts from 'framework/undo-redo' to unblock development\n// while we decide on the correct layering for undo.\n\nexport interface IRevertible {\n\trevert();\n\tdiscard();\n}\n\nexport interface IUndoConsumer {\n\tpushToCurrentOperation(revertible: IRevertible);\n}\n\n/**\n * A shared tree undo redo handler that will add revertible local tree changes to the provided\n * undo redo stack manager\n */\nexport class SharedTreeUndoRedoHandler {\n\tconstructor(private readonly stackManager: IUndoConsumer) {}\n\n\tpublic attachTree(tree: SharedTree) {\n\t\ttree.on(SharedTreeEvent.EditCommitted, this.treeDeltaHandler);\n\t}\n\tpublic detachTree(tree: SharedTree) {\n\t\ttree.off(SharedTreeEvent.EditCommitted, this.treeDeltaHandler);\n\t}\n\n\tprivate readonly treeDeltaHandler = (eventArguments: EditCommittedEventArguments<SharedTree>) => {\n\t\tconst { editId, local, tree } = eventArguments;\n\n\t\tif (local) {\n\t\t\tthis.stackManager.pushToCurrentOperation(\n\t\t\t\tnew SharedTreeRevertible(\n\t\t\t\t\teditId,\n\t\t\t\t\tassertNotUndefined(\n\t\t\t\t\t\ttree,\n\t\t\t\t\t\t'An edit committed event for a revertible edit should include the target SharedTree in its arguments.'\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * Tracks a change on a shared tree and allows reverting it\n */\nexport class SharedTreeRevertible implements IRevertible {\n\tconstructor(private editId: EditId, private readonly tree: SharedTree) {}\n\n\tpublic revert() {\n\t\tconst editIndex = this.tree.edits.getIndexOfId(this.editId);\n\t\tconst edit = this.tree.edits.getEditInSessionAtIndex(editIndex);\n\t\tconst snapshotBefore = this.tree.logViewer.getSnapshotInSession(editIndex);\n\n\t\t// Apply the revert edit and set it as the new revertible edit.\n\t\tthis.editId = this.tree.editor.revert(edit, snapshotBefore);\n\t}\n\n\tpublic discard() {\n\t\treturn;\n\t}\n}\n"]}
|
|
@@ -203,10 +203,6 @@ export declare abstract class GenericSharedTree<TChange> extends SharedObject<IS
|
|
|
203
203
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
|
|
204
204
|
*/
|
|
205
205
|
protected processCore(message: ISequencedDocumentMessage, local: boolean): void;
|
|
206
|
-
/**
|
|
207
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}
|
|
208
|
-
*/
|
|
209
|
-
protected registerCore(): void;
|
|
210
206
|
/**
|
|
211
207
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
212
208
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericSharedTree.d.ts","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sC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B,GAAG,qBAAqB;IAIzE;;;;;OAKG;IACI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtC,UAAU,CAAC,EAAE,gBAAgB,CAAC;QAC9B,UAAU,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;KAC3C,GAAG,MAAM;IAUV;;;OAGG;IACI,WAAW,IAAI,qBAAqB;IAkB3C;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,qBAAqB;IAE3F;;;OAGG;IACI,WAAW,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAgCxD,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAWlC,OAAO,CAAC,wBAAwB;IA2BhC;;OAEG;YACW,kBAAkB;IAOhC;;;;;;;;;;;SAWK;IACE,MAAM,CAAC,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,OAAO;IAQ3F;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxE;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAmB/E;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAI9B,OAAO,CAAC,oBAAoB;IAmC5B;;;;;OAKG;IACI,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI;IAuB3C,UAAU,IAAI,sBAAsB;IAI3C,SAAS,CAAC,cAAc;CAGxB"}
|
|
@@ -372,12 +372,6 @@ class GenericSharedTree extends shared_object_base_1.SharedObject {
|
|
|
372
372
|
this.processSequencedEdit(edit, message);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
/**
|
|
376
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}
|
|
377
|
-
*/
|
|
378
|
-
registerCore() {
|
|
379
|
-
// Do nothing
|
|
380
|
-
}
|
|
381
375
|
/**
|
|
382
376
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
383
377
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericSharedTree.js","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AAQzE,iFAAoE;AACpE,2EAM4C;AAE5C,qEAA8G;AAE9G,sCAA6D;AAC7D,wCAAqD;AAErD,0CAAuC;AACvC,gDAA6C;AAC7C,4CAA+E;AAC/E,0EAAyG;AACzG,qDAQ0B;AAC1B,uCAAsG;AAEtG,iEAAiD;AAEjD;;GAEG;AACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC,MAAM,cAAc,GAA+B;IAClD,OAAO,EAAE,4CAAiB;IAC1B,WAAW,EAAE,yBAAW;IACxB,WAAW,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,EAAE;KACX;CACD,CAAC;AAEF;;;GAGG;AACH,IAAY,eAUX;AAVD,WAAY,eAAe;IAC1B;;;;;;;OAOG;IACH,kDAA+B,CAAA;AAChC,CAAC,EAVW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAU1B;AAED;;;GAGG;AACH,IAAY,yBA0BX;AA1BD,WAAY,yBAAyB;IACpC;;OAEG;IACH,wEAA2C,CAAA;IAC3C;;;;;OAKG;IACH,wDAA2B,CAAA;IAC3B;;;;;OAKG;IACH,sEAAyC,CAAA;IACzC;;;;;OAKG;IACH,0EAA6C,CAAA;AAC9C,CAAC,EA1BW,yBAAyB,GAAzB,iCAAyB,KAAzB,iCAAyB,QA0BpC;AA2BD,MAAM,6BAA6B,GAAiC,EAAE,GAAG,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,CAAC;AAEzG;;;GAGG;AACH,MAAsB,iBAA2B,SAAQ,iCAAw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;AA9cD,8CA8cC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, IsoBuffer } from '@fluidframework/common-utils';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelAttributes,\n} from '@fluidframework/datastore-definitions';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tISharedObjectEvents,\n\tserializeHandles,\n\tSharedObject,\n} from '@fluidframework/shared-object-base';\nimport { ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { ChildLogger, ITelemetryLoggerPropertyBags, PerformanceEvent } from '@fluidframework/telemetry-utils';\nimport { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';\nimport { assert, assertNotUndefined, fail } from '../Common';\nimport { EditLog, OrderedEditSet } from '../EditLog';\nimport { EditId } from '../Identifiers';\nimport { Snapshot } from '../Snapshot';\nimport { initialTree } from '../InitialTree';\nimport { CachingLogViewer, EditStatusCallback, LogViewer } from '../LogViewer';\nimport { convertSummaryToReadFormat, deserialize, readFormatVersion } from '../SummaryBackCompatibility';\nimport {\n\tEdit,\n\tSharedTreeOpType,\n\tSharedTreeEditOp,\n\tSharedTreeHandleOp,\n\tEditWithoutId,\n\tSharedTreeOp,\n\tEditStatus,\n} from './PersistedTypes';\nimport { serialize, SharedTreeSummarizer, SharedTreeSummary, SharedTreeSummaryBase } from './Summary';\nimport { GenericTransaction } from './GenericTransaction';\nimport { newEdit } from './GenericEditUtilities';\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = 'header';\n\nconst initialSummary: SharedTreeSummary<unknown> = {\n\tversion: readFormatVersion,\n\tcurrentTree: initialTree,\n\teditHistory: {\n\t\teditChunks: [],\n\t\teditIds: [],\n\t},\n};\n\n/**\n * An event emitted by a `SharedTree` to indicate a state change. See {@link ISharedTreeEvents} for event argument information.\n * @public\n */\nexport enum SharedTreeEvent {\n\t/**\n\t * An edit has been committed to the log.\n\t * This happens when either:\n\t * \t1. A locally generated edit is added to the log.\n\t * \t2. A remotely generated edit is added to the log.\n\t * Note that, for locally generated edits, this event will not be emitted again when that edit is sequenced.\n\t * Passed the EditId of the committed edit, i.e. supports callbacks of type {@link EditCommittedHandler}.\n\t */\n\tEditCommitted = 'committedEdit',\n}\n\n/**\n * An event emitted by a `SharedTree` for diagnostic purposes.\n * See {@link ISharedTreeEvents} for event argument information.\n */\nexport enum SharedTreeDiagnosticEvent {\n\t/**\n\t * A single catch up blob has been uploaded.\n\t */\n\tCatchUpBlobUploaded = 'uploadedCatchUpBlob',\n\t/**\n\t * A valid edit (local or remote) has been applied.\n\t * Passed the EditId of the applied edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tAppliedEdit = 'appliedEdit',\n\t/**\n\t * An invalid edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedInvalidEdit = 'droppedInvalidEdit',\n\t/**\n\t * A malformed edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedMalformedEdit = 'droppedMalformedEdit',\n}\n\n/**\n * The arguments included when the EditCommitted SharedTreeEvent is emitted.\n * @public\n */\nexport interface EditCommittedEventArguments<TSharedTree> {\n\t/** The ID of the edit committed. */\n\teditId: EditId;\n\t/** Whether or not this is a local edit. */\n\tlocal: boolean;\n\t/** The tree the edit was committed on. Required for local edit events handled by SharedTreeUndoRedoHandler. */\n\ttree: TSharedTree;\n}\n\n/**\n * Events which may be emitted by `SharedTree`. See {@link SharedTreeEvent} for documentation of event semantics.\n */\nexport interface ISharedTreeEvents<TSharedTree> extends ISharedObjectEvents {\n\t(event: 'committedEdit', listener: EditCommittedHandler<TSharedTree>);\n}\n\n/**\n * Expected type for a handler of the `EditCommitted` event.\n */\nexport type EditCommittedHandler<TSharedTree> = (args: EditCommittedEventArguments<TSharedTree>) => void;\n\nconst sharedTreeTelemetryProperties: ITelemetryLoggerPropertyBags = { all: { isSharedTreeEvent: true } };\n\n/**\n * A distributed tree.\n * @public\n */\nexport abstract class GenericSharedTree<TChange> extends SharedObject<ISharedTreeEvents<TChange>> {\n\t/**\n\t * The log of completed edits for this SharedTree.\n\t */\n\tprivate editLog: EditLog<TChange>;\n\n\t/**\n\t * As an implementation detail, SharedTree uses a log viewer that caches snapshots at different revisions.\n\t * It is not exposed to avoid accidental correctness issues, but `logViewer` is exposed in order to give clients a way\n\t * to access the revision history.\n\t */\n\tprivate cachingLogViewer: CachingLogViewer<TChange>;\n\n\t/**\n\t * Viewer for trees defined by editLog. This allows access to views of the tree at different revisions (various points in time).\n\t */\n\tpublic get logViewer(): LogViewer {\n\t\treturn this.cachingLogViewer;\n\t}\n\n\tprotected readonly logger: ITelemetryLogger;\n\n\tpublic readonly transactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>;\n\n\t/** Indicates if the client is the oldest member of the quorum. */\n\tprivate currentIsOldest: boolean;\n\n\tprivate readonly processEditResult = (editResult: EditStatus, editId: EditId): void => {\n\t\t// TODO:#44859: Invalid results should be handled by the app\n\t\tthis.emit(GenericSharedTree.eventFromEditResult(editResult), editId);\n\t};\n\n\t/**\n\t * Create a new SharedTreeFactory.\n\t * @param runtime - The runtime the SharedTree will be associated with\n\t * @param id - Unique ID for the SharedTree\n\t * @param expensiveValidation - Enable expensive asserts.\n\t * @param summarizeHistory - Determines if the history is included in summaries.\n\t */\n\tpublic constructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\ttransactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly expensiveValidation = false,\n\t\tprotected readonly summarizeHistory = true\n\t) {\n\t\tsuper(id, runtime, attributes);\n\t\tthis.expensiveValidation = expensiveValidation;\n\t\tthis.transactionFactory = transactionFactory;\n\n\t\t// This code is somewhat duplicated from OldestClientObserver because it currently depends on the container runtime\n\t\t// which SharedTree does not have access to.\n\t\t// TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tthis.currentIsOldest = this.computeIsOldest();\n\t\tquorum.on('addMember', this.updateOldest);\n\t\tquorum.on('removeMember', this.updateOldest);\n\t\truntime.on('connected', this.updateOldest);\n\t\truntime.on('disconnected', this.updateOldest);\n\n\t\tthis.logger = ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(initialSummary, this.processEditResult);\n\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\t}\n\n\t/**\n\t * Re-computes currentIsOldest and emits an event if it has changed.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate readonly updateOldest = () => {\n\t\tconst oldest = this.computeIsOldest();\n\t\tif (this.currentIsOldest !== oldest) {\n\t\t\tthis.currentIsOldest = oldest;\n\t\t\tif (oldest) {\n\t\t\t\tthis.emit('becameOldest');\n\t\t\t} else {\n\t\t\t\tthis.emit('lostOldest');\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Computes the oldest client in the quorum, true by default if the container is detached and false by default if the client isn't connected.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate computeIsOldest(): boolean {\n\t\t// If the container is detached, we are the only ones that know about it and are the oldest by default.\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If we're not connected we can't be the oldest connected client.\n\t\tif (!this.runtime.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.runtime.clientId !== undefined, 'Client id should be set if connected.');\n\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tconst selfSequencedClient = quorum.getMember(this.runtime.clientId);\n\t\t// When in readonly mode our clientId will not be present in the quorum.\n\t\tif (selfSequencedClient === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst members = quorum.getMembers();\n\t\tfor (const sequencedClient of members.values()) {\n\t\t\tif (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// No member of the quorum was older\n\t\treturn true;\n\t}\n\n\t/**\n\t * @returns the current view of the tree.\n\t */\n\tpublic get currentView(): Snapshot {\n\t\treturn this.logViewer.getSnapshotInSession(Number.POSITIVE_INFINITY);\n\t}\n\n\t/**\n\t * @returns the edit history of the tree.\n\t */\n\tpublic get edits(): OrderedEditSet<TChange> {\n\t\treturn this.editLog;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t *\n\t * For convenient imperative variants of edits, see `editor`.\n\t * @internal\n\t */\n\tpublic applyEdit(...changes: TChange[]): EditId {\n\t\tconst edit = newEdit(changes);\n\t\tthis.processLocalEdit(edit);\n\t\treturn edit.id;\n\t}\n\n\tprivate deserializeHandle(serializedHandle: string): IFluidHandle<ArrayBufferLike> {\n\t\tconst deserializeHandle = this.serializer.parse(serializedHandle);\n\t\tassert(typeof deserializeHandle === 'object');\n\t\treturn deserializeHandle as IFluidHandle<ArrayBufferLike>;\n\t}\n\n\t/**\n\t * Uploads the edit chunk and sends the chunk starting revision along with the resulting handle as an op.\n\t */\n\tprivate async uploadEditChunk(edits: readonly EditWithoutId<TChange>[], startRevision: number): Promise<void> {\n\t\ttry {\n\t\t\tconst editHandle = await this.runtime.uploadBlob(IsoBuffer.from(JSON.stringify({ edits })));\n\t\t\tthis.submitLocalMessage({\n\t\t\t\teditHandle: serializeHandles(editHandle, this.serializer, this.handle),\n\t\t\t\tstartRevision,\n\t\t\t\ttype: SharedTreeOpType.Handle,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// If chunk load fails, we will try again later in loadCore on the oldest client so we log the error instead of throwing.\n\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: 'EditChunkUploadFailure',\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tpublic summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));\n\t}\n\n\t/**\n\t * Saves this SharedTree into a serialized summary.\n\t *\n\t * @param options - Optional serializer and summarizer to use. If not passed in, SharedTree's serializer and summarizer are used.\n\t * @internal\n\t */\n\tpublic saveSerializedSummary(options?: {\n\t\tserializer?: IFluidSerializer;\n\t\tsummarizer?: SharedTreeSummarizer<TChange>;\n\t}): string {\n\t\tconst { serializer, summarizer } = options || {};\n\n\t\treturn serialize(\n\t\t\tsummarizer ? summarizer(this.editLog, this.currentView) : this.saveSummary(),\n\t\t\tserializer || this.serializer,\n\t\t\tthis.handle\n\t\t);\n\t}\n\n\t/**\n\t * Saves this SharedTree into a summary.\n\t * @internal\n\t */\n\tpublic saveSummary(): SharedTreeSummaryBase {\n\t\t// If local changes exist, emulate the sequencing of those changes.\n\t\t// Doing so is necessary so edits created during DataObject.initializingFirstTime are included.\n\t\t// Doing so is safe because it is guaranteed that the DDS has not yet been attached. This is because summary creation is only\n\t\t// ever invoked on a DataObject containing local changes when it is attached for the first time. In post-attach flows, an extra\n\t\t// instance of the DataObject is created for generating summaries and will never have local edits.\n\t\tif (this.editLog.numberOfLocalEdits > 0) {\n\t\t\tassert(\n\t\t\t\tthis.runtime.attachState !== AttachState.Attached,\n\t\t\t\t'Summarizing should not occur with local edits except on first attach.'\n\t\t\t);\n\t\t\tthis.editLog.sequenceLocalEdits();\n\t\t}\n\n\t\tassert(this.editLog.numberOfLocalEdits === 0, 'generateSummary must not be called with local edits');\n\t\treturn this.generateSummary(this.editLog);\n\t}\n\n\t/**\n\t * Generates a SharedTree summary for the current state of the tree.\n\t * Will never be called when local edits are present.\n\t */\n\tprotected abstract generateSummary(editLog: OrderedEditSet<TChange>): SharedTreeSummaryBase;\n\n\t/**\n\t * Initialize shared tree with a summary.\n\t * @internal\n\t */\n\tpublic loadSummary(summary: SharedTreeSummaryBase): void {\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(summary, this.processEditResult);\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\n\t\tif (this.runtime.connected) {\n\t\t\tconst noChunksReadyForUpload = this.editLog.getEditChunksReadyForUpload()[Symbol.iterator]().next().done;\n\t\t\tif (noChunksReadyForUpload === undefined || !noChunksReadyForUpload) {\n\t\t\t\t// A client does not become a member of the quorum until it is within the collaboration window.\n\t\t\t\t//\n\t\t\t\t// The collaboration window is the range from the minimum sequence number enforced by the server and head.\n\t\t\t\t// When a client sends an op, they include the last sequence number the client has processed. We call this the reference\n\t\t\t\t// sequence number.\n\t\t\t\t//\n\t\t\t\t// If there are no members in the quorum, we send a no op op in order to have this client added as a member to the quorum.\n\t\t\t\t// This is required so we can ensure only the oldest client will upload blobs during summary load.\n\t\t\t\tif (this.runtime.getQuorum().getMembers().size === 0) {\n\t\t\t\t\tconst noop: SharedTreeOp = {\n\t\t\t\t\t\ttype: SharedTreeOpType.NoOp,\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.submitLocalMessage(noop);\n\t\t\t\t} else if (this.currentIsOldest) {\n\t\t\t\t\tvoid this.uploadCatchUpBlobs();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this client becomes the oldest, it should take care of uploading catch up blobs.\n\t\t\tthis.on('becameOldest', () => void this.uploadCatchUpBlobs());\n\t\t}\n\t}\n\n\tprivate static eventFromEditResult(editStatus: EditStatus): SharedTreeDiagnosticEvent {\n\t\tswitch (editStatus) {\n\t\t\tcase EditStatus.Applied:\n\t\t\t\treturn SharedTreeDiagnosticEvent.AppliedEdit;\n\t\t\tcase EditStatus.Invalid:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedInvalidEdit;\n\t\t\tdefault:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedMalformedEdit;\n\t\t}\n\t}\n\n\tprivate createEditLogFromSummary(\n\t\tsummary: SharedTreeSummaryBase,\n\t\tcallback: EditStatusCallback\n\t): { editLog: EditLog<TChange>; cachingLogViewer: CachingLogViewer<TChange> } {\n\t\tconst convertedSummary = convertSummaryToReadFormat<TChange>(summary);\n\t\tif (typeof convertedSummary === 'string') {\n\t\t\tfail(convertedSummary);\n\t\t}\n\t\tconst { editHistory, currentTree } = convertedSummary;\n\t\tconst currentView = Snapshot.fromTree(currentTree);\n\n\t\tconst editLog = new EditLog(editHistory, this.logger);\n\t\tconst logViewer = new CachingLogViewer(\n\t\t\teditLog,\n\t\t\tSnapshot.fromTree(initialTree),\n\t\t\t// TODO:#47830: Store multiple checkpoints in summary.\n\t\t\t[[editLog.length, { snapshot: currentView }]],\n\t\t\tthis.expensiveValidation,\n\t\t\tcallback,\n\t\t\tthis.logger,\n\t\t\tthis.transactionFactory,\n\t\t\t0\n\t\t);\n\n\t\treturn { editLog, cachingLogViewer: logViewer };\n\t}\n\n\t/**\n\t * Upload any full chunks that have yet to be uploaded.\n\t */\n\tprivate async uploadCatchUpBlobs(): Promise<void> {\n\t\tfor (const [startRevision, chunk] of this.editLog.getEditChunksReadyForUpload()) {\n\t\t\tawait this.uploadEditChunk(chunk, startRevision);\n\t\t\tthis.emit(SharedTreeDiagnosticEvent.CatchUpBlobUploaded);\n\t\t}\n\t}\n\n\t/**\n\t * Compares this shared tree to another for equality.\n\t *\n\t * Equality means that the histories as captured by the EditLogs are equal.\n\t *\n\t * Equality does not include:\n\t * - if an edit is open\n\t * - the shared tree's id\n\t * - local vs sequenced status of edits\n\t * - registered event listeners\n\t * - state of caches\n\t * */\n\tpublic equals<TOtherChangeTypes>(sharedTree: GenericSharedTree<TOtherChangeTypes>): boolean {\n\t\tif (!this.currentView.equals(sharedTree.currentView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.editLog.equals(sharedTree.editLog);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst summaryLoadPerformanceEvent = PerformanceEvent.start(this.logger, { eventName: 'SummaryLoad' });\n\n\t\ttry {\n\t\t\tconst newBlob = await storage.readBlob(snapshotFileName);\n\t\t\tconst blobData = bufferToString(newBlob, 'utf8');\n\n\t\t\tconst summary = deserialize(blobData, this.serializer);\n\t\t\tif (typeof summary === 'string') {\n\t\t\t\tfail(summary);\n\t\t\t}\n\t\t\tthis.loadSummary(summary);\n\n\t\t\tsummaryLoadPerformanceEvent.end({ historySize: this.edits.length });\n\t\t} catch (error) {\n\t\t\tsummaryLoadPerformanceEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(message: ISequencedDocumentMessage, local: boolean): void {\n\t\tthis.cachingLogViewer.setMinimumSequenceNumber(message.minimumSequenceNumber);\n\t\tconst { type } = message.contents;\n\t\tif (type === SharedTreeOpType.Handle) {\n\t\t\tconst { editHandle, startRevision } = message.contents as SharedTreeHandleOp;\n\t\t\tthis.editLog.processEditChunkHandle(this.deserializeHandle(editHandle), startRevision);\n\t\t} else if (type === SharedTreeOpType.Edit) {\n\t\t\tconst semiSerializedEdit = message.contents.edit;\n\t\t\t// semiSerializedEdit may have handles which have been replaced by `serializer.encode`.\n\t\t\t// Since there is no API to un-replace them except via parse, re-stringify the edit, then parse it.\n\t\t\t// Stringify using JSON, not IFluidSerializer since OPs use JSON directly.\n\t\t\t// TODO:Performance:#48025: Avoid this serialization round trip.\n\t\t\tconst stringEdit = JSON.stringify(semiSerializedEdit);\n\t\t\tconst parsedEdit = this.serializer.parse(stringEdit);\n\t\t\tconst edit = parsedEdit as Edit<TChange>;\n\t\t\tthis.processSequencedEdit(edit, message);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}\n\t */\n\tprotected registerCore(): void {\n\t\t// Do nothing\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\t// Do nothing\n\t}\n\n\tprivate processSequencedEdit(edit: Edit<TChange>, message: ISequencedDocumentMessage): void {\n\t\tconst { id: editId } = edit;\n\t\tconst wasLocalEdit = this.editLog.isLocalEdit(editId);\n\n\t\t// If the id of the supplied edit matches a non-local edit already present in the log, this would normally be indicative of an error.\n\t\t// However, the @fluidframework packages prior to 0.37.x have a bug which can cause data corruption by sequencing duplicate edits--\n\t\t// see discussion on the following github issue: https://github.com/microsoft/FluidFramework/issues/4399\n\t\t// To work around this issue, we currently tolerate duplicate ops in loaded documents.\n\t\t// This could be strengthened in the future to only apply to documents which may have been impacted.\n\t\tconst shouldIgnoreEdit = this.editLog.tryGetIndexOfId(editId) !== undefined && !wasLocalEdit;\n\t\tif (shouldIgnoreEdit) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.editLog.addSequencedEdit(edit, message);\n\t\tif (!wasLocalEdit) {\n\t\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\t\teditId,\n\t\t\t\tlocal: false,\n\t\t\t\ttree: this,\n\t\t\t};\n\t\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t\t} else {\n\t\t\t// If this client created the edit that filled up a chunk, it is responsible for uploading that chunk.\n\t\t\tconst lastPair = this.editLog.getLastEditChunk();\n\t\t\tif (lastPair !== undefined) {\n\t\t\t\tconst [startRevision, chunk] = lastPair;\n\t\t\t\tconst edits = assertNotUndefined(chunk.edits);\n\t\t\t\tif (edits.length === this.editLog.editsPerChunk) {\n\t\t\t\t\tvoid this.uploadEditChunk(edits, startRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add an `Edit` directly.\n\t * External users should use one of the more specialized functions, like applyEdit which handles constructing the actual `Edit` object.\n\t * This is exposed as it is useful for testing, particularly with invalid and malformed Edits.\n\t * @internal\n\t */\n\tpublic processLocalEdit(edit: Edit<TChange>): void {\n\t\tconst editOp: SharedTreeEditOp<TChange> = {\n\t\t\ttype: SharedTreeOpType.Edit,\n\t\t\tedit,\n\t\t};\n\n\t\t// IFluidHandles are not allowed in Ops.\n\t\t// Ops can contain Fluid's Serializable (for payloads) which allows IFluidHandles.\n\t\t// So replace the handles before sending:\n\t\tconst semiSerialized = this.serializer.encode(editOp, this.handle);\n\n\t\t// TODO:44711: what should be passed in when unattached?\n\t\tthis.submitLocalMessage(semiSerialized);\n\t\tthis.editLog.addLocalEdit(edit);\n\n\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\teditId: edit.id,\n\t\t\tlocal: true,\n\t\t\ttree: this,\n\t\t};\n\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t}\n\n\tpublic getRuntime(): IFluidDataStoreRuntime {\n\t\treturn this.runtime;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error('not implemented');\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GenericSharedTree.js","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AAQzE,iFAAoE;AACpE,2EAM4C;AAE5C,qEAA8G;AAE9G,sCAA6D;AAC7D,wCAAqD;AAErD,0CAAuC;AACvC,gDAA6C;AAC7C,4C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a,CAAC,CAAC;iBAChD;aACD;SACD;IACF,CAAC;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,IAAmB;QAC1C,MAAM,MAAM,GAA8B;YACzC,IAAI,EAAE,iCAAgB,CAAC,IAAI;YAC3B,IAAI;SACJ,CAAC;QAEF,wCAAwC;QACxC,kFAAkF;QAClF,yCAAyC;QACzC,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnE,wDAAwD;QACxD,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEhC,MAAM,cAAc,GAA4D;YAC/E,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;SACV,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AAvcD,8CAucC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, IsoBuffer } from '@fluidframework/common-utils';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelAttributes,\n} from '@fluidframework/datastore-definitions';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tISharedObjectEvents,\n\tserializeHandles,\n\tSharedObject,\n} from '@fluidframework/shared-object-base';\nimport { ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { ChildLogger, ITelemetryLoggerPropertyBags, PerformanceEvent } from '@fluidframework/telemetry-utils';\nimport { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';\nimport { assert, assertNotUndefined, fail } from '../Common';\nimport { EditLog, OrderedEditSet } from '../EditLog';\nimport { EditId } from '../Identifiers';\nimport { Snapshot } from '../Snapshot';\nimport { initialTree } from '../InitialTree';\nimport { CachingLogViewer, EditStatusCallback, LogViewer } from '../LogViewer';\nimport { convertSummaryToReadFormat, deserialize, readFormatVersion } from '../SummaryBackCompatibility';\nimport {\n\tEdit,\n\tSharedTreeOpType,\n\tSharedTreeEditOp,\n\tSharedTreeHandleOp,\n\tEditWithoutId,\n\tSharedTreeOp,\n\tEditStatus,\n} from './PersistedTypes';\nimport { serialize, SharedTreeSummarizer, SharedTreeSummary, SharedTreeSummaryBase } from './Summary';\nimport { GenericTransaction } from './GenericTransaction';\nimport { newEdit } from './GenericEditUtilities';\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = 'header';\n\nconst initialSummary: SharedTreeSummary<unknown> = {\n\tversion: readFormatVersion,\n\tcurrentTree: initialTree,\n\teditHistory: {\n\t\teditChunks: [],\n\t\teditIds: [],\n\t},\n};\n\n/**\n * An event emitted by a `SharedTree` to indicate a state change. See {@link ISharedTreeEvents} for event argument information.\n * @public\n */\nexport enum SharedTreeEvent {\n\t/**\n\t * An edit has been committed to the log.\n\t * This happens when either:\n\t * \t1. A locally generated edit is added to the log.\n\t * \t2. A remotely generated edit is added to the log.\n\t * Note that, for locally generated edits, this event will not be emitted again when that edit is sequenced.\n\t * Passed the EditId of the committed edit, i.e. supports callbacks of type {@link EditCommittedHandler}.\n\t */\n\tEditCommitted = 'committedEdit',\n}\n\n/**\n * An event emitted by a `SharedTree` for diagnostic purposes.\n * See {@link ISharedTreeEvents} for event argument information.\n */\nexport enum SharedTreeDiagnosticEvent {\n\t/**\n\t * A single catch up blob has been uploaded.\n\t */\n\tCatchUpBlobUploaded = 'uploadedCatchUpBlob',\n\t/**\n\t * A valid edit (local or remote) has been applied.\n\t * Passed the EditId of the applied edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tAppliedEdit = 'appliedEdit',\n\t/**\n\t * An invalid edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedInvalidEdit = 'droppedInvalidEdit',\n\t/**\n\t * A malformed edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedMalformedEdit = 'droppedMalformedEdit',\n}\n\n/**\n * The arguments included when the EditCommitted SharedTreeEvent is emitted.\n * @public\n */\nexport interface EditCommittedEventArguments<TSharedTree> {\n\t/** The ID of the edit committed. */\n\teditId: EditId;\n\t/** Whether or not this is a local edit. */\n\tlocal: boolean;\n\t/** The tree the edit was committed on. Required for local edit events handled by SharedTreeUndoRedoHandler. */\n\ttree: TSharedTree;\n}\n\n/**\n * Events which may be emitted by `SharedTree`. See {@link SharedTreeEvent} for documentation of event semantics.\n */\nexport interface ISharedTreeEvents<TSharedTree> extends ISharedObjectEvents {\n\t(event: 'committedEdit', listener: EditCommittedHandler<TSharedTree>);\n}\n\n/**\n * Expected type for a handler of the `EditCommitted` event.\n */\nexport type EditCommittedHandler<TSharedTree> = (args: EditCommittedEventArguments<TSharedTree>) => void;\n\nconst sharedTreeTelemetryProperties: ITelemetryLoggerPropertyBags = { all: { isSharedTreeEvent: true } };\n\n/**\n * A distributed tree.\n * @public\n */\nexport abstract class GenericSharedTree<TChange> extends SharedObject<ISharedTreeEvents<TChange>> {\n\t/**\n\t * The log of completed edits for this SharedTree.\n\t */\n\tprivate editLog: EditLog<TChange>;\n\n\t/**\n\t * As an implementation detail, SharedTree uses a log viewer that caches snapshots at different revisions.\n\t * It is not exposed to avoid accidental correctness issues, but `logViewer` is exposed in order to give clients a way\n\t * to access the revision history.\n\t */\n\tprivate cachingLogViewer: CachingLogViewer<TChange>;\n\n\t/**\n\t * Viewer for trees defined by editLog. This allows access to views of the tree at different revisions (various points in time).\n\t */\n\tpublic get logViewer(): LogViewer {\n\t\treturn this.cachingLogViewer;\n\t}\n\n\tprotected readonly logger: ITelemetryLogger;\n\n\tpublic readonly transactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>;\n\n\t/** Indicates if the client is the oldest member of the quorum. */\n\tprivate currentIsOldest: boolean;\n\n\tprivate readonly processEditResult = (editResult: EditStatus, editId: EditId): void => {\n\t\t// TODO:#44859: Invalid results should be handled by the app\n\t\tthis.emit(GenericSharedTree.eventFromEditResult(editResult), editId);\n\t};\n\n\t/**\n\t * Create a new SharedTreeFactory.\n\t * @param runtime - The runtime the SharedTree will be associated with\n\t * @param id - Unique ID for the SharedTree\n\t * @param expensiveValidation - Enable expensive asserts.\n\t * @param summarizeHistory - Determines if the history is included in summaries.\n\t */\n\tpublic constructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\ttransactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly expensiveValidation = false,\n\t\tprotected readonly summarizeHistory = true\n\t) {\n\t\tsuper(id, runtime, attributes);\n\t\tthis.expensiveValidation = expensiveValidation;\n\t\tthis.transactionFactory = transactionFactory;\n\n\t\t// This code is somewhat duplicated from OldestClientObserver because it currently depends on the container runtime\n\t\t// which SharedTree does not have access to.\n\t\t// TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tthis.currentIsOldest = this.computeIsOldest();\n\t\tquorum.on('addMember', this.updateOldest);\n\t\tquorum.on('removeMember', this.updateOldest);\n\t\truntime.on('connected', this.updateOldest);\n\t\truntime.on('disconnected', this.updateOldest);\n\n\t\tthis.logger = ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(initialSummary, this.processEditResult);\n\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\t}\n\n\t/**\n\t * Re-computes currentIsOldest and emits an event if it has changed.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate readonly updateOldest = () => {\n\t\tconst oldest = this.computeIsOldest();\n\t\tif (this.currentIsOldest !== oldest) {\n\t\t\tthis.currentIsOldest = oldest;\n\t\t\tif (oldest) {\n\t\t\t\tthis.emit('becameOldest');\n\t\t\t} else {\n\t\t\t\tthis.emit('lostOldest');\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Computes the oldest client in the quorum, true by default if the container is detached and false by default if the client isn't connected.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate computeIsOldest(): boolean {\n\t\t// If the container is detached, we are the only ones that know about it and are the oldest by default.\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If we're not connected we can't be the oldest connected client.\n\t\tif (!this.runtime.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.runtime.clientId !== undefined, 'Client id should be set if connected.');\n\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tconst selfSequencedClient = quorum.getMember(this.runtime.clientId);\n\t\t// When in readonly mode our clientId will not be present in the quorum.\n\t\tif (selfSequencedClient === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst members = quorum.getMembers();\n\t\tfor (const sequencedClient of members.values()) {\n\t\t\tif (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// No member of the quorum was older\n\t\treturn true;\n\t}\n\n\t/**\n\t * @returns the current view of the tree.\n\t */\n\tpublic get currentView(): Snapshot {\n\t\treturn this.logViewer.getSnapshotInSession(Number.POSITIVE_INFINITY);\n\t}\n\n\t/**\n\t * @returns the edit history of the tree.\n\t */\n\tpublic get edits(): OrderedEditSet<TChange> {\n\t\treturn this.editLog;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t *\n\t * For convenient imperative variants of edits, see `editor`.\n\t * @internal\n\t */\n\tpublic applyEdit(...changes: TChange[]): EditId {\n\t\tconst edit = newEdit(changes);\n\t\tthis.processLocalEdit(edit);\n\t\treturn edit.id;\n\t}\n\n\tprivate deserializeHandle(serializedHandle: string): IFluidHandle<ArrayBufferLike> {\n\t\tconst deserializeHandle = this.serializer.parse(serializedHandle);\n\t\tassert(typeof deserializeHandle === 'object');\n\t\treturn deserializeHandle as IFluidHandle<ArrayBufferLike>;\n\t}\n\n\t/**\n\t * Uploads the edit chunk and sends the chunk starting revision along with the resulting handle as an op.\n\t */\n\tprivate async uploadEditChunk(edits: readonly EditWithoutId<TChange>[], startRevision: number): Promise<void> {\n\t\ttry {\n\t\t\tconst editHandle = await this.runtime.uploadBlob(IsoBuffer.from(JSON.stringify({ edits })));\n\t\t\tthis.submitLocalMessage({\n\t\t\t\teditHandle: serializeHandles(editHandle, this.serializer, this.handle),\n\t\t\t\tstartRevision,\n\t\t\t\ttype: SharedTreeOpType.Handle,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// If chunk load fails, we will try again later in loadCore on the oldest client so we log the error instead of throwing.\n\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: 'EditChunkUploadFailure',\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tpublic summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));\n\t}\n\n\t/**\n\t * Saves this SharedTree into a serialized summary.\n\t *\n\t * @param options - Optional serializer and summarizer to use. If not passed in, SharedTree's serializer and summarizer are used.\n\t * @internal\n\t */\n\tpublic saveSerializedSummary(options?: {\n\t\tserializer?: IFluidSerializer;\n\t\tsummarizer?: SharedTreeSummarizer<TChange>;\n\t}): string {\n\t\tconst { serializer, summarizer } = options || {};\n\n\t\treturn serialize(\n\t\t\tsummarizer ? summarizer(this.editLog, this.currentView) : this.saveSummary(),\n\t\t\tserializer || this.serializer,\n\t\t\tthis.handle\n\t\t);\n\t}\n\n\t/**\n\t * Saves this SharedTree into a summary.\n\t * @internal\n\t */\n\tpublic saveSummary(): SharedTreeSummaryBase {\n\t\t// If local changes exist, emulate the sequencing of those changes.\n\t\t// Doing so is necessary so edits created during DataObject.initializingFirstTime are included.\n\t\t// Doing so is safe because it is guaranteed that the DDS has not yet been attached. This is because summary creation is only\n\t\t// ever invoked on a DataObject containing local changes when it is attached for the first time. In post-attach flows, an extra\n\t\t// instance of the DataObject is created for generating summaries and will never have local edits.\n\t\tif (this.editLog.numberOfLocalEdits > 0) {\n\t\t\tassert(\n\t\t\t\tthis.runtime.attachState !== AttachState.Attached,\n\t\t\t\t'Summarizing should not occur with local edits except on first attach.'\n\t\t\t);\n\t\t\tthis.editLog.sequenceLocalEdits();\n\t\t}\n\n\t\tassert(this.editLog.numberOfLocalEdits === 0, 'generateSummary must not be called with local edits');\n\t\treturn this.generateSummary(this.editLog);\n\t}\n\n\t/**\n\t * Generates a SharedTree summary for the current state of the tree.\n\t * Will never be called when local edits are present.\n\t */\n\tprotected abstract generateSummary(editLog: OrderedEditSet<TChange>): SharedTreeSummaryBase;\n\n\t/**\n\t * Initialize shared tree with a summary.\n\t * @internal\n\t */\n\tpublic loadSummary(summary: SharedTreeSummaryBase): void {\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(summary, this.processEditResult);\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\n\t\tif (this.runtime.connected) {\n\t\t\tconst noChunksReadyForUpload = this.editLog.getEditChunksReadyForUpload()[Symbol.iterator]().next().done;\n\t\t\tif (noChunksReadyForUpload === undefined || !noChunksReadyForUpload) {\n\t\t\t\t// A client does not become a member of the quorum until it is within the collaboration window.\n\t\t\t\t//\n\t\t\t\t// The collaboration window is the range from the minimum sequence number enforced by the server and head.\n\t\t\t\t// When a client sends an op, they include the last sequence number the client has processed. We call this the reference\n\t\t\t\t// sequence number.\n\t\t\t\t//\n\t\t\t\t// If there are no members in the quorum, we send a no op op in order to have this client added as a member to the quorum.\n\t\t\t\t// This is required so we can ensure only the oldest client will upload blobs during summary load.\n\t\t\t\tif (this.runtime.getQuorum().getMembers().size === 0) {\n\t\t\t\t\tconst noop: SharedTreeOp = {\n\t\t\t\t\t\ttype: SharedTreeOpType.NoOp,\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.submitLocalMessage(noop);\n\t\t\t\t} else if (this.currentIsOldest) {\n\t\t\t\t\tvoid this.uploadCatchUpBlobs();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this client becomes the oldest, it should take care of uploading catch up blobs.\n\t\t\tthis.on('becameOldest', () => void this.uploadCatchUpBlobs());\n\t\t}\n\t}\n\n\tprivate static eventFromEditResult(editStatus: EditStatus): SharedTreeDiagnosticEvent {\n\t\tswitch (editStatus) {\n\t\t\tcase EditStatus.Applied:\n\t\t\t\treturn SharedTreeDiagnosticEvent.AppliedEdit;\n\t\t\tcase EditStatus.Invalid:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedInvalidEdit;\n\t\t\tdefault:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedMalformedEdit;\n\t\t}\n\t}\n\n\tprivate createEditLogFromSummary(\n\t\tsummary: SharedTreeSummaryBase,\n\t\tcallback: EditStatusCallback\n\t): { editLog: EditLog<TChange>; cachingLogViewer: CachingLogViewer<TChange> } {\n\t\tconst convertedSummary = convertSummaryToReadFormat<TChange>(summary);\n\t\tif (typeof convertedSummary === 'string') {\n\t\t\tfail(convertedSummary);\n\t\t}\n\t\tconst { editHistory, currentTree } = convertedSummary;\n\t\tconst currentView = Snapshot.fromTree(currentTree);\n\n\t\tconst editLog = new EditLog(editHistory, this.logger);\n\t\tconst logViewer = new CachingLogViewer(\n\t\t\teditLog,\n\t\t\tSnapshot.fromTree(initialTree),\n\t\t\t// TODO:#47830: Store multiple checkpoints in summary.\n\t\t\t[[editLog.length, { snapshot: currentView }]],\n\t\t\tthis.expensiveValidation,\n\t\t\tcallback,\n\t\t\tthis.logger,\n\t\t\tthis.transactionFactory,\n\t\t\t0\n\t\t);\n\n\t\treturn { editLog, cachingLogViewer: logViewer };\n\t}\n\n\t/**\n\t * Upload any full chunks that have yet to be uploaded.\n\t */\n\tprivate async uploadCatchUpBlobs(): Promise<void> {\n\t\tfor (const [startRevision, chunk] of this.editLog.getEditChunksReadyForUpload()) {\n\t\t\tawait this.uploadEditChunk(chunk, startRevision);\n\t\t\tthis.emit(SharedTreeDiagnosticEvent.CatchUpBlobUploaded);\n\t\t}\n\t}\n\n\t/**\n\t * Compares this shared tree to another for equality.\n\t *\n\t * Equality means that the histories as captured by the EditLogs are equal.\n\t *\n\t * Equality does not include:\n\t * - if an edit is open\n\t * - the shared tree's id\n\t * - local vs sequenced status of edits\n\t * - registered event listeners\n\t * - state of caches\n\t * */\n\tpublic equals<TOtherChangeTypes>(sharedTree: GenericSharedTree<TOtherChangeTypes>): boolean {\n\t\tif (!this.currentView.equals(sharedTree.currentView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.editLog.equals(sharedTree.editLog);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst summaryLoadPerformanceEvent = PerformanceEvent.start(this.logger, { eventName: 'SummaryLoad' });\n\n\t\ttry {\n\t\t\tconst newBlob = await storage.readBlob(snapshotFileName);\n\t\t\tconst blobData = bufferToString(newBlob, 'utf8');\n\n\t\t\tconst summary = deserialize(blobData, this.serializer);\n\t\t\tif (typeof summary === 'string') {\n\t\t\t\tfail(summary);\n\t\t\t}\n\t\t\tthis.loadSummary(summary);\n\n\t\t\tsummaryLoadPerformanceEvent.end({ historySize: this.edits.length });\n\t\t} catch (error) {\n\t\t\tsummaryLoadPerformanceEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(message: ISequencedDocumentMessage, local: boolean): void {\n\t\tthis.cachingLogViewer.setMinimumSequenceNumber(message.minimumSequenceNumber);\n\t\tconst { type } = message.contents;\n\t\tif (type === SharedTreeOpType.Handle) {\n\t\t\tconst { editHandle, startRevision } = message.contents as SharedTreeHandleOp;\n\t\t\tthis.editLog.processEditChunkHandle(this.deserializeHandle(editHandle), startRevision);\n\t\t} else if (type === SharedTreeOpType.Edit) {\n\t\t\tconst semiSerializedEdit = message.contents.edit;\n\t\t\t// semiSerializedEdit may have handles which have been replaced by `serializer.encode`.\n\t\t\t// Since there is no API to un-replace them except via parse, re-stringify the edit, then parse it.\n\t\t\t// Stringify using JSON, not IFluidSerializer since OPs use JSON directly.\n\t\t\t// TODO:Performance:#48025: Avoid this serialization round trip.\n\t\t\tconst stringEdit = JSON.stringify(semiSerializedEdit);\n\t\t\tconst parsedEdit = this.serializer.parse(stringEdit);\n\t\t\tconst edit = parsedEdit as Edit<TChange>;\n\t\t\tthis.processSequencedEdit(edit, message);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\t// Do nothing\n\t}\n\n\tprivate processSequencedEdit(edit: Edit<TChange>, message: ISequencedDocumentMessage): void {\n\t\tconst { id: editId } = edit;\n\t\tconst wasLocalEdit = this.editLog.isLocalEdit(editId);\n\n\t\t// If the id of the supplied edit matches a non-local edit already present in the log, this would normally be indicative of an error.\n\t\t// However, the @fluidframework packages prior to 0.37.x have a bug which can cause data corruption by sequencing duplicate edits--\n\t\t// see discussion on the following github issue: https://github.com/microsoft/FluidFramework/issues/4399\n\t\t// To work around this issue, we currently tolerate duplicate ops in loaded documents.\n\t\t// This could be strengthened in the future to only apply to documents which may have been impacted.\n\t\tconst shouldIgnoreEdit = this.editLog.tryGetIndexOfId(editId) !== undefined && !wasLocalEdit;\n\t\tif (shouldIgnoreEdit) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.editLog.addSequencedEdit(edit, message);\n\t\tif (!wasLocalEdit) {\n\t\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\t\teditId,\n\t\t\t\tlocal: false,\n\t\t\t\ttree: this,\n\t\t\t};\n\t\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t\t} else {\n\t\t\t// If this client created the edit that filled up a chunk, it is responsible for uploading that chunk.\n\t\t\tconst lastPair = this.editLog.getLastEditChunk();\n\t\t\tif (lastPair !== undefined) {\n\t\t\t\tconst [startRevision, chunk] = lastPair;\n\t\t\t\tconst edits = assertNotUndefined(chunk.edits);\n\t\t\t\tif (edits.length === this.editLog.editsPerChunk) {\n\t\t\t\t\tvoid this.uploadEditChunk(edits, startRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add an `Edit` directly.\n\t * External users should use one of the more specialized functions, like applyEdit which handles constructing the actual `Edit` object.\n\t * This is exposed as it is useful for testing, particularly with invalid and malformed Edits.\n\t * @internal\n\t */\n\tpublic processLocalEdit(edit: Edit<TChange>): void {\n\t\tconst editOp: SharedTreeEditOp<TChange> = {\n\t\t\ttype: SharedTreeOpType.Edit,\n\t\t\tedit,\n\t\t};\n\n\t\t// IFluidHandles are not allowed in Ops.\n\t\t// Ops can contain Fluid's Serializable (for payloads) which allows IFluidHandles.\n\t\t// So replace the handles before sending:\n\t\tconst semiSerialized = this.serializer.encode(editOp, this.handle);\n\n\t\t// TODO:44711: what should be passed in when unattached?\n\t\tthis.submitLocalMessage(semiSerialized);\n\t\tthis.editLog.addLocalEdit(edit);\n\n\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\teditId: edit.id,\n\t\t\tlocal: true,\n\t\t\ttree: this,\n\t\t};\n\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t}\n\n\tpublic getRuntime(): IFluidDataStoreRuntime {\n\t\treturn this.runtime;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error('not implemented');\n\t}\n}\n"]}
|