@fluidframework/tree 2.4.0-297027 → 2.4.0-297385
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/change-family/changeFamily.d.ts +2 -2
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/change-family/editBuilder.d.ts +3 -2
- package/dist/core/change-family/editBuilder.d.ts.map +1 -1
- package/dist/core/change-family/editBuilder.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +2 -1
- package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
- package/dist/core/rebase/changeRebaser.js.map +1 -1
- package/dist/core/rebase/utils.js +1 -1
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +4 -3
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +41 -30
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +4 -6
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +4 -4
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +12 -8
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +179 -60
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts +10 -9
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +9 -7
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -10
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -8
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +32 -20
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.d.ts +6 -1
- package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +25 -9
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +17 -16
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +19 -11
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +1 -1
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +4 -4
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts +2 -2
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js +15 -11
- package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +4 -3
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +2 -3
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +10 -11
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts +5 -5
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.js +4 -4
- package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +1 -1
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +2 -2
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/core/change-family/changeFamily.d.ts +2 -2
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/change-family/editBuilder.d.ts +3 -2
- package/lib/core/change-family/editBuilder.d.ts.map +1 -1
- package/lib/core/change-family/editBuilder.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +2 -1
- package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
- package/lib/core/rebase/changeRebaser.js.map +1 -1
- package/lib/core/rebase/utils.js +1 -1
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +4 -3
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +41 -30
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +4 -6
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +4 -4
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +12 -8
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +180 -61
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts +10 -9
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +9 -7
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -10
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -8
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +32 -20
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.d.ts +6 -1
- package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +25 -9
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +17 -16
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +19 -11
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +1 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +4 -4
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts +2 -2
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js +15 -11
- package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +5 -4
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +2 -3
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +11 -12
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts +5 -5
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.js +4 -4
- package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +2 -2
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +2 -2
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/package.json +23 -23
- package/src/core/change-family/changeFamily.ts +5 -2
- package/src/core/change-family/editBuilder.ts +3 -2
- package/src/core/rebase/changeRebaser.ts +6 -1
- package/src/core/rebase/utils.ts +1 -1
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +92 -47
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +7 -7
- package/src/feature-libraries/mitigatedChangeFamily.ts +11 -4
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +1 -0
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +218 -175
- package/src/feature-libraries/optional-field/optionalField.ts +21 -17
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +2 -10
- package/src/feature-libraries/sequence-field/compose.ts +67 -58
- package/src/feature-libraries/sequence-field/invert.ts +30 -6
- package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +65 -19
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/sharedTree.ts +3 -1
- package/src/shared-tree/sharedTreeChangeFamily.ts +5 -1
- package/src/shared-tree/sharedTreeEditBuilder.ts +23 -12
- package/src/shared-tree/treeCheckout.ts +7 -6
- package/src/shared-tree-core/branch.ts +11 -14
- package/src/shared-tree-core/defaultResubmitMachine.ts +4 -4
- package/src/shared-tree-core/editManager.ts +2 -1
- package/src/shared-tree-core/sharedTreeCore.ts +4 -2
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { TaggedChange } from "../rebase/index.js";
|
|
6
7
|
import type { ChangeFamily, ChangeFamilyEditor } from "./changeFamily.js";
|
|
7
8
|
|
|
8
9
|
export abstract class EditBuilder<TChange> implements ChangeFamilyEditor {
|
|
9
10
|
public constructor(
|
|
10
11
|
protected readonly changeFamily: ChangeFamily<ChangeFamilyEditor, TChange>,
|
|
11
|
-
private readonly changeReceiver: (change: TChange) => void,
|
|
12
|
+
private readonly changeReceiver: (change: TaggedChange<TChange>) => void,
|
|
12
13
|
) {}
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -16,7 +17,7 @@ export abstract class EditBuilder<TChange> implements ChangeFamilyEditor {
|
|
|
16
17
|
*
|
|
17
18
|
* @sealed
|
|
18
19
|
*/
|
|
19
|
-
protected applyChange(change: TChange): void {
|
|
20
|
+
protected applyChange(change: TaggedChange<TChange>): void {
|
|
20
21
|
this.changeReceiver(change);
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -51,6 +51,7 @@ export interface ChangeRebaser<TChangeset> {
|
|
|
51
51
|
* @param changes - The changes to invert.
|
|
52
52
|
* @param isRollback - Whether the inverted change is meant to rollback a change on a branch as is the case when
|
|
53
53
|
* performing a sandwich rebase.
|
|
54
|
+
* @param revision - The revision for the invert changeset.
|
|
54
55
|
* This flag is relevant to merge semantics that are dependent on edit sequencing order:
|
|
55
56
|
* - In the context of an undo, this function inverts a change that is sequenced and applied before the produced inverse.
|
|
56
57
|
* - In the context of a rollback, this function inverts a change that is sequenced after but applied before the produced inverse.
|
|
@@ -59,7 +60,11 @@ export interface ChangeRebaser<TChangeset> {
|
|
|
59
60
|
* `compose([changes, inverse(changes)])` be equal to `compose([])`:
|
|
60
61
|
* See {@link ChangeRebaser} for details.
|
|
61
62
|
*/
|
|
62
|
-
invert(
|
|
63
|
+
invert(
|
|
64
|
+
changes: TaggedChange<TChangeset>,
|
|
65
|
+
isRollback: boolean,
|
|
66
|
+
revision: RevisionTag,
|
|
67
|
+
): TChangeset;
|
|
63
68
|
|
|
64
69
|
/**
|
|
65
70
|
* Rebase `change` over `over`.
|
package/src/core/rebase/utils.ts
CHANGED
|
@@ -444,8 +444,8 @@ function rollbackFromCommit<TChange>(
|
|
|
444
444
|
if (commit.rollback !== undefined) {
|
|
445
445
|
return commit.rollback;
|
|
446
446
|
}
|
|
447
|
-
const untagged = changeRebaser.invert(commit, true);
|
|
448
447
|
const tag = mintRevisionTag();
|
|
448
|
+
const untagged = changeRebaser.invert(commit, true, tag);
|
|
449
449
|
const deeplyTaggedRollback = changeRebaser.changeRevision(untagged, tag, commit.revision);
|
|
450
450
|
const fullyTaggedRollback = tagRollbackInverse(deeplyTaggedRollback, tag, commit.revision);
|
|
451
451
|
|
|
@@ -8,16 +8,17 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
|
8
8
|
|
|
9
9
|
import type { ICodecFamily } from "../../codec/index.js";
|
|
10
10
|
import {
|
|
11
|
+
type ChangeAtomId,
|
|
11
12
|
type ChangeEncodingContext,
|
|
12
13
|
type ChangeFamily,
|
|
13
14
|
type ChangeFamilyEditor,
|
|
14
15
|
type ChangeRebaser,
|
|
15
|
-
type ChangesetLocalId,
|
|
16
16
|
CursorLocationType,
|
|
17
17
|
type DeltaDetachedNodeId,
|
|
18
18
|
type DeltaRoot,
|
|
19
19
|
type FieldUpPath,
|
|
20
20
|
type ITreeCursorSynchronous,
|
|
21
|
+
type RevisionTag,
|
|
21
22
|
type TaggedChange,
|
|
22
23
|
type UpPath,
|
|
23
24
|
compareFieldUpPaths,
|
|
@@ -43,6 +44,7 @@ import {
|
|
|
43
44
|
required as valueFieldKind,
|
|
44
45
|
} from "./defaultFieldKinds.js";
|
|
45
46
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
47
|
+
import type { CellId } from "../sequence-field/index.js";
|
|
46
48
|
|
|
47
49
|
export type DefaultChangeset = ModularChangeset;
|
|
48
50
|
|
|
@@ -68,8 +70,11 @@ export class DefaultChangeFamily
|
|
|
68
70
|
return this.modularFamily.codecs;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
public buildEditor(
|
|
72
|
-
|
|
73
|
+
public buildEditor(
|
|
74
|
+
mintRevisionTag: () => RevisionTag,
|
|
75
|
+
changeReceiver: (change: TaggedChange<DefaultChangeset>) => void,
|
|
76
|
+
): DefaultEditBuilder {
|
|
77
|
+
return new DefaultEditBuilder(this, mintRevisionTag, changeReceiver);
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
|
|
@@ -168,7 +173,8 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
|
|
|
168
173
|
|
|
169
174
|
public constructor(
|
|
170
175
|
family: ChangeFamily<ChangeFamilyEditor, DefaultChangeset>,
|
|
171
|
-
|
|
176
|
+
private readonly mintRevisionTag: () => RevisionTag,
|
|
177
|
+
changeReceiver: (change: TaggedChange<DefaultChangeset>) => void,
|
|
172
178
|
private readonly idCompressor?: IIdCompressor,
|
|
173
179
|
) {
|
|
174
180
|
this.modularBuilder = new ModularEditBuilder(family, fieldKinds, changeReceiver);
|
|
@@ -182,19 +188,25 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
|
|
|
182
188
|
}
|
|
183
189
|
|
|
184
190
|
public addNodeExistsConstraint(path: UpPath): void {
|
|
185
|
-
this.modularBuilder.addNodeExistsConstraint(path);
|
|
191
|
+
this.modularBuilder.addNodeExistsConstraint(path, this.mintRevisionTag());
|
|
186
192
|
}
|
|
187
193
|
|
|
188
194
|
public valueField(field: FieldUpPath): ValueFieldEditBuilder<ITreeCursorSynchronous> {
|
|
189
195
|
return {
|
|
190
196
|
set: (newContent: ITreeCursorSynchronous): void => {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
const
|
|
197
|
+
const revision = this.mintRevisionTag();
|
|
198
|
+
const fill: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };
|
|
199
|
+
const detach: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };
|
|
200
|
+
const build = this.modularBuilder.buildTrees(
|
|
201
|
+
fill.localId,
|
|
202
|
+
newContent,
|
|
203
|
+
revision,
|
|
204
|
+
this.idCompressor,
|
|
205
|
+
);
|
|
194
206
|
const change: FieldChangeset = brand(
|
|
195
207
|
valueFieldKind.changeHandler.editor.set({
|
|
196
|
-
fill
|
|
197
|
-
detach
|
|
208
|
+
fill,
|
|
209
|
+
detach,
|
|
198
210
|
}),
|
|
199
211
|
);
|
|
200
212
|
|
|
@@ -203,8 +215,9 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
|
|
|
203
215
|
field,
|
|
204
216
|
fieldKind: valueFieldKind.identifier,
|
|
205
217
|
change,
|
|
218
|
+
revision,
|
|
206
219
|
};
|
|
207
|
-
this.modularBuilder.submitChanges([build, edit]);
|
|
220
|
+
this.modularBuilder.submitChanges([build, edit], revision);
|
|
208
221
|
},
|
|
209
222
|
};
|
|
210
223
|
}
|
|
@@ -212,21 +225,26 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
|
|
|
212
225
|
public optionalField(field: FieldUpPath): OptionalFieldEditBuilder<ITreeCursorSynchronous> {
|
|
213
226
|
return {
|
|
214
227
|
set: (newContent: ITreeCursorSynchronous | undefined, wasEmpty: boolean): void => {
|
|
215
|
-
const detachId = this.modularBuilder.generateId();
|
|
216
|
-
let fillId: ChangesetLocalId | undefined;
|
|
217
228
|
const edits: EditDescription[] = [];
|
|
218
229
|
let optionalChange: OptionalChangeset;
|
|
230
|
+
const revision = this.mintRevisionTag();
|
|
231
|
+
const detach: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };
|
|
219
232
|
if (newContent !== undefined) {
|
|
220
|
-
|
|
221
|
-
const build = this.modularBuilder.buildTrees(
|
|
233
|
+
const fill: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };
|
|
234
|
+
const build = this.modularBuilder.buildTrees(
|
|
235
|
+
fill.localId,
|
|
236
|
+
newContent,
|
|
237
|
+
revision,
|
|
238
|
+
this.idCompressor,
|
|
239
|
+
);
|
|
222
240
|
edits.push(build);
|
|
223
241
|
|
|
224
242
|
optionalChange = optional.changeHandler.editor.set(wasEmpty, {
|
|
225
|
-
fill
|
|
226
|
-
detach
|
|
243
|
+
fill,
|
|
244
|
+
detach,
|
|
227
245
|
});
|
|
228
246
|
} else {
|
|
229
|
-
optionalChange = optional.changeHandler.editor.clear(wasEmpty,
|
|
247
|
+
optionalChange = optional.changeHandler.editor.clear(wasEmpty, detach);
|
|
230
248
|
}
|
|
231
249
|
|
|
232
250
|
const change: FieldChangeset = brand(optionalChange);
|
|
@@ -235,10 +253,11 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
|
|
|
235
253
|
field,
|
|
236
254
|
fieldKind: optional.identifier,
|
|
237
255
|
change,
|
|
256
|
+
revision,
|
|
238
257
|
};
|
|
239
258
|
edits.push(edit);
|
|
240
259
|
|
|
241
|
-
this.modularBuilder.submitChanges(edits);
|
|
260
|
+
this.modularBuilder.submitChanges(edits, revision);
|
|
242
261
|
},
|
|
243
262
|
};
|
|
244
263
|
}
|
|
@@ -255,17 +274,24 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
|
|
|
255
274
|
} else if (count < 0 || !Number.isSafeInteger(count)) {
|
|
256
275
|
throw new UsageError(`Expected non-negative integer count, got ${count}.`);
|
|
257
276
|
}
|
|
258
|
-
const
|
|
259
|
-
const
|
|
277
|
+
const revision = this.mintRevisionTag();
|
|
278
|
+
const detachCellId = this.modularBuilder.generateId(count);
|
|
279
|
+
const attachCellId: CellId = { localId: this.modularBuilder.generateId(count), revision };
|
|
260
280
|
if (compareFieldUpPaths(sourceField, destinationField)) {
|
|
261
281
|
const change = sequence.changeHandler.editor.move(
|
|
262
282
|
sourceIndex,
|
|
263
283
|
count,
|
|
264
284
|
destIndex,
|
|
265
|
-
|
|
266
|
-
|
|
285
|
+
detachCellId,
|
|
286
|
+
attachCellId,
|
|
287
|
+
revision,
|
|
288
|
+
);
|
|
289
|
+
this.modularBuilder.submitChange(
|
|
290
|
+
sourceField,
|
|
291
|
+
sequence.identifier,
|
|
292
|
+
brand(change),
|
|
293
|
+
revision,
|
|
267
294
|
);
|
|
268
|
-
this.modularBuilder.submitChange(sourceField, sequence.identifier, brand(change));
|
|
269
295
|
} else {
|
|
270
296
|
const detachPath = topDownPath(sourceField.parent);
|
|
271
297
|
const attachPath = topDownPath(destinationField.parent);
|
|
@@ -307,27 +333,38 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
|
|
|
307
333
|
}
|
|
308
334
|
}
|
|
309
335
|
}
|
|
310
|
-
const moveOut = sequence.changeHandler.editor.moveOut(
|
|
336
|
+
const moveOut = sequence.changeHandler.editor.moveOut(
|
|
337
|
+
sourceIndex,
|
|
338
|
+
count,
|
|
339
|
+
detachCellId,
|
|
340
|
+
revision,
|
|
341
|
+
);
|
|
311
342
|
const moveIn = sequence.changeHandler.editor.moveIn(
|
|
312
343
|
destIndex,
|
|
313
344
|
count,
|
|
314
|
-
|
|
315
|
-
|
|
345
|
+
detachCellId,
|
|
346
|
+
attachCellId,
|
|
347
|
+
revision,
|
|
348
|
+
);
|
|
349
|
+
this.modularBuilder.submitChanges(
|
|
350
|
+
[
|
|
351
|
+
{
|
|
352
|
+
type: "field",
|
|
353
|
+
field: sourceField,
|
|
354
|
+
fieldKind: sequence.identifier,
|
|
355
|
+
change: brand(moveOut),
|
|
356
|
+
revision,
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
type: "field",
|
|
360
|
+
field: adjustedAttachField,
|
|
361
|
+
fieldKind: sequence.identifier,
|
|
362
|
+
change: brand(moveIn),
|
|
363
|
+
revision,
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
revision,
|
|
316
367
|
);
|
|
317
|
-
this.modularBuilder.submitChanges([
|
|
318
|
-
{
|
|
319
|
-
type: "field",
|
|
320
|
-
field: sourceField,
|
|
321
|
-
fieldKind: sequence.identifier,
|
|
322
|
-
change: brand(moveOut),
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
type: "field",
|
|
326
|
-
field: adjustedAttachField,
|
|
327
|
-
fieldKind: sequence.identifier,
|
|
328
|
-
change: brand(moveIn),
|
|
329
|
-
},
|
|
330
|
-
]);
|
|
331
368
|
}
|
|
332
369
|
}
|
|
333
370
|
|
|
@@ -340,30 +377,38 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
|
|
|
340
377
|
return;
|
|
341
378
|
}
|
|
342
379
|
|
|
343
|
-
const
|
|
344
|
-
const
|
|
380
|
+
const revision = this.mintRevisionTag();
|
|
381
|
+
const firstId: CellId = { localId: this.modularBuilder.generateId(length), revision };
|
|
382
|
+
const build = this.modularBuilder.buildTrees(
|
|
383
|
+
firstId.localId,
|
|
384
|
+
content,
|
|
385
|
+
revision,
|
|
386
|
+
this.idCompressor,
|
|
387
|
+
);
|
|
345
388
|
const change: FieldChangeset = brand(
|
|
346
|
-
sequence.changeHandler.editor.insert(index, length, firstId),
|
|
389
|
+
sequence.changeHandler.editor.insert(index, length, firstId, revision),
|
|
347
390
|
);
|
|
348
391
|
const attach: FieldEditDescription = {
|
|
349
392
|
type: "field",
|
|
350
393
|
field,
|
|
351
394
|
fieldKind: sequence.identifier,
|
|
352
395
|
change,
|
|
396
|
+
revision,
|
|
353
397
|
};
|
|
354
398
|
// The changes have to be submitted together, otherwise they will be assigned different revisions,
|
|
355
399
|
// which will prevent the build ID and the insert ID from matching.
|
|
356
|
-
this.modularBuilder.submitChanges([build, attach]);
|
|
400
|
+
this.modularBuilder.submitChanges([build, attach], revision);
|
|
357
401
|
},
|
|
358
402
|
remove: (index: number, count: number): void => {
|
|
359
403
|
if (count === 0) {
|
|
360
404
|
return;
|
|
361
405
|
}
|
|
406
|
+
const revision = this.mintRevisionTag();
|
|
362
407
|
const id = this.modularBuilder.generateId(count);
|
|
363
408
|
const change: FieldChangeset = brand(
|
|
364
|
-
sequence.changeHandler.editor.remove(index, count, id),
|
|
409
|
+
sequence.changeHandler.editor.remove(index, count, id, revision),
|
|
365
410
|
);
|
|
366
|
-
this.modularBuilder.submitChange(field, sequence.identifier, change);
|
|
411
|
+
this.modularBuilder.submitChange(field, sequence.identifier, change, revision);
|
|
367
412
|
},
|
|
368
413
|
};
|
|
369
414
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
type
|
|
7
|
+
type ChangeAtomId,
|
|
8
8
|
type DeltaDetachedNodeId,
|
|
9
9
|
type DeltaFieldChanges,
|
|
10
10
|
type FieldKindIdentifier,
|
|
@@ -54,11 +54,9 @@ export const noChangeHandler: FieldChangeHandler<0> = {
|
|
|
54
54
|
export interface ValueFieldEditor extends FieldEditor<OptionalChangeset> {
|
|
55
55
|
/**
|
|
56
56
|
* Creates a change which replaces the current value of the field with `newValue`.
|
|
57
|
-
* @param
|
|
58
|
-
* @param changeId - the ID associated with the replacement of the current content.
|
|
59
|
-
* @param buildId - the ID associated with the creation of the `newContent`.
|
|
57
|
+
* @param ids - The ids for the fill and detach fields.
|
|
60
58
|
*/
|
|
61
|
-
set(ids: { fill:
|
|
59
|
+
set(ids: { fill: ChangeAtomId; detach: ChangeAtomId }): OptionalChangeset;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
const optionalIdentifier = "Optional";
|
|
@@ -77,8 +75,10 @@ export const optional = new FieldKindWithEditor(
|
|
|
77
75
|
|
|
78
76
|
export const valueFieldEditor: ValueFieldEditor = {
|
|
79
77
|
...optionalFieldEditor,
|
|
80
|
-
set: (ids: {
|
|
81
|
-
|
|
78
|
+
set: (ids: {
|
|
79
|
+
fill: ChangeAtomId;
|
|
80
|
+
detach: ChangeAtomId;
|
|
81
|
+
}): OptionalChangeset => optionalFieldEditor.set(false, ids),
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
export const valueChangeHandler: FieldChangeHandler<OptionalChangeset, ValueFieldEditor> = {
|
|
@@ -32,8 +32,11 @@ export function makeMitigatedChangeFamily<TEditor extends ChangeFamilyEditor, TC
|
|
|
32
32
|
onError: (error: unknown) => void,
|
|
33
33
|
): ChangeFamily<TEditor, TChange> {
|
|
34
34
|
return {
|
|
35
|
-
buildEditor: (
|
|
36
|
-
|
|
35
|
+
buildEditor: (
|
|
36
|
+
mintRevisionTag: () => RevisionTag,
|
|
37
|
+
changeReceiver: (change: TaggedChange<TChange>) => void,
|
|
38
|
+
): TEditor => {
|
|
39
|
+
return unmitigatedChangeFamily.buildEditor(mintRevisionTag, changeReceiver);
|
|
37
40
|
},
|
|
38
41
|
rebaser: makeMitigatedRebaser(unmitigatedChangeFamily.rebaser, fallbackChange, onError),
|
|
39
42
|
codecs: unmitigatedChangeFamily.codecs,
|
|
@@ -58,8 +61,12 @@ export function makeMitigatedRebaser<TChange>(
|
|
|
58
61
|
compose: (changes: TaggedChange<TChange>[]): TChange => {
|
|
59
62
|
return withFallback(() => unmitigatedRebaser.compose(changes));
|
|
60
63
|
},
|
|
61
|
-
invert: (
|
|
62
|
-
|
|
64
|
+
invert: (
|
|
65
|
+
changes: TaggedChange<TChange>,
|
|
66
|
+
isRollback: boolean,
|
|
67
|
+
revision: RevisionTag,
|
|
68
|
+
): TChange => {
|
|
69
|
+
return withFallback(() => unmitigatedRebaser.invert(changes, isRollback, revision));
|
|
63
70
|
},
|
|
64
71
|
rebase: (
|
|
65
72
|
change: TaggedChange<TChange>,
|
|
@@ -117,6 +117,7 @@ export interface FieldChangeRebaser<TChangeset> {
|
|
|
117
117
|
change: TChangeset,
|
|
118
118
|
isRollback: boolean,
|
|
119
119
|
genId: IdAllocator,
|
|
120
|
+
revision: RevisionTag | undefined,
|
|
120
121
|
crossFieldManager: CrossFieldManager,
|
|
121
122
|
revisionMetadata: RevisionMetadataSource,
|
|
122
123
|
): TChangeset;
|