@fluidframework/merge-tree 2.10.0-305357 → 2.10.0-307060
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.cjs +1 -0
- package/api-report/merge-tree.legacy.alpha.api.md +27 -0
- package/dist/collections/index.d.ts +1 -1
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/collections/index.js +2 -1
- package/dist/collections/index.js.map +1 -1
- package/dist/collections/list.d.ts +7 -0
- package/dist/collections/list.d.ts.map +1 -1
- package/dist/collections/list.js +27 -1
- package/dist/collections/list.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +2 -0
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +13 -13
- package/dist/mergeTree.js.map +1 -1
- package/dist/ops.d.ts +36 -0
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js.map +1 -1
- package/dist/segmentPropertiesManager.d.ts +81 -8
- package/dist/segmentPropertiesManager.d.ts.map +1 -1
- package/dist/segmentPropertiesManager.js +211 -61
- package/dist/segmentPropertiesManager.js.map +1 -1
- package/dist/test/propertyManager.spec.d.ts +6 -0
- package/dist/test/propertyManager.spec.d.ts.map +1 -0
- package/dist/test/propertyManager.spec.js +156 -0
- package/dist/test/propertyManager.spec.js.map +1 -0
- package/dist/zamboni.d.ts.map +1 -1
- package/dist/zamboni.js +1 -0
- package/dist/zamboni.js.map +1 -1
- package/lib/collections/index.d.ts +1 -1
- package/lib/collections/index.d.ts.map +1 -1
- package/lib/collections/index.js +1 -1
- package/lib/collections/index.js.map +1 -1
- package/lib/collections/list.d.ts +7 -0
- package/lib/collections/list.d.ts.map +1 -1
- package/lib/collections/list.js +25 -0
- package/lib/collections/list.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +2 -0
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +13 -13
- package/lib/mergeTree.js.map +1 -1
- package/lib/ops.d.ts +36 -0
- package/lib/ops.d.ts.map +1 -1
- package/lib/ops.js.map +1 -1
- package/lib/segmentPropertiesManager.d.ts +81 -8
- package/lib/segmentPropertiesManager.d.ts.map +1 -1
- package/lib/segmentPropertiesManager.js +212 -62
- package/lib/segmentPropertiesManager.js.map +1 -1
- package/lib/test/propertyManager.spec.d.ts +6 -0
- package/lib/test/propertyManager.spec.d.ts.map +1 -0
- package/lib/test/propertyManager.spec.js +154 -0
- package/lib/test/propertyManager.spec.js.map +1 -0
- package/lib/zamboni.d.ts.map +1 -1
- package/lib/zamboni.js +1 -0
- package/lib/zamboni.js.map +1 -1
- package/package.json +22 -15
- package/src/collections/index.ts +7 -1
- package/src/collections/list.ts +29 -0
- package/src/index.ts +3 -0
- package/src/mergeTree.ts +20 -18
- package/src/ops.ts +38 -0
- package/src/segmentPropertiesManager.ts +277 -88
- package/src/zamboni.ts +3 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { strict as assert } from "node:assert";
|
|
6
|
+
import { UnassignedSequenceNumber } from "../constants.js";
|
|
7
|
+
import { matchProperties } from "../properties.js";
|
|
8
|
+
import { PropertiesManager, PropertiesRollback, } from "../segmentPropertiesManager.js";
|
|
9
|
+
describe("PropertiesManager", () => {
|
|
10
|
+
describe("handleProperties", () => {
|
|
11
|
+
it("should handle properties without collaboration", () => {
|
|
12
|
+
const propertiesManager = new PropertiesManager();
|
|
13
|
+
const seg = {
|
|
14
|
+
properties: { key: "value" },
|
|
15
|
+
};
|
|
16
|
+
const op = { props: { key: "newValue" } };
|
|
17
|
+
const deltas = propertiesManager.handleProperties(op, seg, 1, 0, false);
|
|
18
|
+
assert.deepEqual(deltas, { key: "value" });
|
|
19
|
+
assert.deepEqual(seg.properties, { key: "newValue" });
|
|
20
|
+
});
|
|
21
|
+
it("should handle properties with collaboration", () => {
|
|
22
|
+
const propertiesManager = new PropertiesManager();
|
|
23
|
+
const seg = {
|
|
24
|
+
properties: { key: "value" },
|
|
25
|
+
};
|
|
26
|
+
const op = { props: { key: "newValue" } };
|
|
27
|
+
const deltas = propertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 0, true);
|
|
28
|
+
assert.deepEqual(deltas, { key: "value" });
|
|
29
|
+
assert.deepEqual(seg.properties, { key: "newValue" });
|
|
30
|
+
});
|
|
31
|
+
it("should handle properties with rollback", () => {
|
|
32
|
+
const propertiesManager = new PropertiesManager();
|
|
33
|
+
const seg = {
|
|
34
|
+
properties: { key: "value" },
|
|
35
|
+
};
|
|
36
|
+
const op = { props: { key: "newValue" } };
|
|
37
|
+
// Simulate pending state for rollback
|
|
38
|
+
propertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 0, true);
|
|
39
|
+
const deltas = propertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 0, true, PropertiesRollback.Rollback);
|
|
40
|
+
assert.deepEqual(deltas, { key: "newValue" });
|
|
41
|
+
assert.deepEqual(seg.properties, { key: "value" });
|
|
42
|
+
});
|
|
43
|
+
it("should handle properties with seq as a number and collaborating true", () => {
|
|
44
|
+
const propertiesManager = new PropertiesManager();
|
|
45
|
+
const seg = {
|
|
46
|
+
properties: { key: "value" },
|
|
47
|
+
};
|
|
48
|
+
const op = { props: { key: "newValue" } };
|
|
49
|
+
const deltas = propertiesManager.handleProperties(op, seg, 2, 1, true);
|
|
50
|
+
assert.deepEqual(deltas, { key: "value" });
|
|
51
|
+
assert.deepEqual(seg.properties, { key: "newValue" });
|
|
52
|
+
});
|
|
53
|
+
it("should handle properties with seq as a number and collaborating false", () => {
|
|
54
|
+
const propertiesManager = new PropertiesManager();
|
|
55
|
+
const seg = {
|
|
56
|
+
properties: { key: "value" },
|
|
57
|
+
};
|
|
58
|
+
const op = { props: { key: "newValue" } };
|
|
59
|
+
const deltas = propertiesManager.handleProperties(op, seg, 2, 1, false);
|
|
60
|
+
assert.deepEqual(deltas, { key: "value" });
|
|
61
|
+
assert.deepEqual(seg.properties, { key: "newValue" });
|
|
62
|
+
});
|
|
63
|
+
it("should handle properties with adjusts", () => {
|
|
64
|
+
const propertiesManager = new PropertiesManager();
|
|
65
|
+
const seg = {
|
|
66
|
+
properties: { key: 1 },
|
|
67
|
+
};
|
|
68
|
+
const op = { adjust: { key: { delta: 1 } } };
|
|
69
|
+
const deltas = propertiesManager.handleProperties(op, seg, 2, 1, true);
|
|
70
|
+
assert.deepEqual(deltas, { key: 1 });
|
|
71
|
+
assert.deepEqual(seg.properties, { key: 2 });
|
|
72
|
+
});
|
|
73
|
+
it("should handle properties with props and adjusts interleaved", () => {
|
|
74
|
+
const propertiesManager = new PropertiesManager();
|
|
75
|
+
const seg = {
|
|
76
|
+
properties: { key: 1, otherKey: "value" },
|
|
77
|
+
};
|
|
78
|
+
const op1 = { props: { otherKey: "newValue" } };
|
|
79
|
+
const op2 = { adjust: { key: { delta: 1 } } };
|
|
80
|
+
propertiesManager.handleProperties(op1, seg, 2, 1, true);
|
|
81
|
+
const deltas = propertiesManager.handleProperties(op2, seg, 3, 2, true);
|
|
82
|
+
assert.deepEqual(deltas, { key: 1 });
|
|
83
|
+
assert.deepEqual(seg.properties, { key: 2, otherKey: "newValue" });
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
describe("rollbackProperties", () => {
|
|
87
|
+
it("should rollback properties when collaborating is true", () => {
|
|
88
|
+
const propertiesManager = new PropertiesManager();
|
|
89
|
+
const seg = {
|
|
90
|
+
properties: { key: "value" },
|
|
91
|
+
};
|
|
92
|
+
const op = { props: { key: "newValue" } };
|
|
93
|
+
const rollbackDeltas = propertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 0, true);
|
|
94
|
+
const deltas = propertiesManager.rollbackProperties({ props: rollbackDeltas }, seg, true);
|
|
95
|
+
assert.deepEqual(deltas, { key: "newValue" });
|
|
96
|
+
assert.deepEqual(seg.properties, { key: "value" });
|
|
97
|
+
});
|
|
98
|
+
it("should rollback properties when collaborating is false", () => {
|
|
99
|
+
const propertiesManager = new PropertiesManager();
|
|
100
|
+
const seg = {
|
|
101
|
+
properties: { key: "value" },
|
|
102
|
+
};
|
|
103
|
+
const op = { props: { key: "newValue" } };
|
|
104
|
+
const rollbackDeltas = propertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 0, false);
|
|
105
|
+
const deltas = propertiesManager.rollbackProperties({ props: rollbackDeltas }, seg, false);
|
|
106
|
+
assert.deepEqual(deltas, { key: "newValue" });
|
|
107
|
+
assert.deepEqual(seg.properties, { key: "value" });
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
describe("ack", () => {
|
|
111
|
+
it("should acknowledge property changes", () => {
|
|
112
|
+
const propertiesManager = new PropertiesManager();
|
|
113
|
+
const op = { props: { key: "value" } };
|
|
114
|
+
const seg = { properties: {} };
|
|
115
|
+
propertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 1, true);
|
|
116
|
+
assert(propertiesManager.hasPendingProperties({ key: "value" }));
|
|
117
|
+
propertiesManager.ack(1, 0, op);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
describe("copyTo", () => {
|
|
121
|
+
it("should copy properties and manager state", () => {
|
|
122
|
+
const propertiesManager = new PropertiesManager();
|
|
123
|
+
const op = { props: { key: "value" } };
|
|
124
|
+
const seg = { properties: {} };
|
|
125
|
+
propertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 1, true);
|
|
126
|
+
assert(propertiesManager.hasPendingProperties({ key: "value" }));
|
|
127
|
+
const dest = {};
|
|
128
|
+
propertiesManager.copyTo({ key: "value" }, dest);
|
|
129
|
+
assert(dest.propertyManager instanceof PropertiesManager);
|
|
130
|
+
assert(dest.propertyManager.hasPendingProperties({ key: "value" }));
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe("getAtSeq", () => {
|
|
134
|
+
it("should retrieve properties at a specific sequence number", () => {
|
|
135
|
+
const propertiesManager = new PropertiesManager();
|
|
136
|
+
const op = { adjust: { key: { delta: 5 } } };
|
|
137
|
+
const seg = { properties: {} };
|
|
138
|
+
propertiesManager.handleProperties(op, seg, 1, 0, true);
|
|
139
|
+
const properties = propertiesManager.getAtSeq(seg.properties, 0);
|
|
140
|
+
assert(matchProperties(properties, {}));
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
describe("hasPendingProperties", () => {
|
|
144
|
+
it("should check for pending properties", () => {
|
|
145
|
+
const propertiesManager = new PropertiesManager();
|
|
146
|
+
const op = { props: { key: "value" } };
|
|
147
|
+
const seg = { properties: {} };
|
|
148
|
+
propertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 1, true);
|
|
149
|
+
assert(propertiesManager.hasPendingProperties({ key: "value" }));
|
|
150
|
+
assert(!propertiesManager.hasPendingProperties({ otherKey: "otherValue" }));
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
//# sourceMappingURL=propertyManager.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propertyManager.spec.js","sourceRoot":"","sources":["../../src/test/propertyManager.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACN,iBAAiB,EACjB,kBAAkB,GAElB,MAAM,gCAAgC,CAAC;AAExC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACzD,MAAM,iBAAiB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AC,oBAAoB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport { UnassignedSequenceNumber } from \"../constants.js\";\nimport type { ISegmentLeaf } from \"../mergeTreeNodes.js\";\nimport { matchProperties } from \"../properties.js\";\nimport {\n\tPropertiesManager,\n\tPropertiesRollback,\n\ttype PropsOrAdjust,\n} from \"../segmentPropertiesManager.js\";\n\ndescribe(\"PropertiesManager\", () => {\n\tdescribe(\"handleProperties\", () => {\n\t\tit(\"should handle properties without collaboration\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: \"value\" },\n\t\t\t};\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"newValue\" } };\n\t\t\tconst deltas = propertiesManager.handleProperties(op, seg, 1, 0, false);\n\t\t\tassert.deepEqual(deltas, { key: \"value\" });\n\t\t\tassert.deepEqual(seg.properties, { key: \"newValue\" });\n\t\t});\n\n\t\tit(\"should handle properties with collaboration\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: \"value\" },\n\t\t\t};\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"newValue\" } };\n\t\t\tconst deltas = propertiesManager.handleProperties(\n\t\t\t\top,\n\t\t\t\tseg,\n\t\t\t\tUnassignedSequenceNumber,\n\t\t\t\t0,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tassert.deepEqual(deltas, { key: \"value\" });\n\t\t\tassert.deepEqual(seg.properties, { key: \"newValue\" });\n\t\t});\n\n\t\tit(\"should handle properties with rollback\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: \"value\" },\n\t\t\t};\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"newValue\" } };\n\t\t\t// Simulate pending state for rollback\n\t\t\tpropertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 0, true);\n\t\t\tconst deltas = propertiesManager.handleProperties(\n\t\t\t\top,\n\t\t\t\tseg,\n\t\t\t\tUnassignedSequenceNumber,\n\t\t\t\t0,\n\t\t\t\ttrue,\n\t\t\t\tPropertiesRollback.Rollback,\n\t\t\t);\n\t\t\tassert.deepEqual(deltas, { key: \"newValue\" });\n\t\t\tassert.deepEqual(seg.properties, { key: \"value\" });\n\t\t});\n\n\t\tit(\"should handle properties with seq as a number and collaborating true\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: \"value\" },\n\t\t\t};\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"newValue\" } };\n\t\t\tconst deltas = propertiesManager.handleProperties(op, seg, 2, 1, true);\n\t\t\tassert.deepEqual(deltas, { key: \"value\" });\n\t\t\tassert.deepEqual(seg.properties, { key: \"newValue\" });\n\t\t});\n\n\t\tit(\"should handle properties with seq as a number and collaborating false\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: \"value\" },\n\t\t\t};\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"newValue\" } };\n\t\t\tconst deltas = propertiesManager.handleProperties(op, seg, 2, 1, false);\n\t\t\tassert.deepEqual(deltas, { key: \"value\" });\n\t\t\tassert.deepEqual(seg.properties, { key: \"newValue\" });\n\t\t});\n\n\t\tit(\"should handle properties with adjusts\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: 1 },\n\t\t\t};\n\t\t\tconst op: PropsOrAdjust = { adjust: { key: { delta: 1 } } };\n\t\t\tconst deltas = propertiesManager.handleProperties(op, seg, 2, 1, true);\n\t\t\tassert.deepEqual(deltas, { key: 1 });\n\t\t\tassert.deepEqual(seg.properties, { key: 2 });\n\t\t});\n\n\t\tit(\"should handle properties with props and adjusts interleaved\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: 1, otherKey: \"value\" },\n\t\t\t};\n\t\t\tconst op1: PropsOrAdjust = { props: { otherKey: \"newValue\" } };\n\t\t\tconst op2: PropsOrAdjust = { adjust: { key: { delta: 1 } } };\n\t\t\tpropertiesManager.handleProperties(op1, seg, 2, 1, true);\n\t\t\tconst deltas = propertiesManager.handleProperties(op2, seg, 3, 2, true);\n\t\t\tassert.deepEqual(deltas, { key: 1 });\n\t\t\tassert.deepEqual(seg.properties, { key: 2, otherKey: \"newValue\" });\n\t\t});\n\t});\n\n\tdescribe(\"rollbackProperties\", () => {\n\t\tit(\"should rollback properties when collaborating is true\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: \"value\" },\n\t\t\t};\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"newValue\" } };\n\t\t\tconst rollbackDeltas = propertiesManager.handleProperties(\n\t\t\t\top,\n\t\t\t\tseg,\n\t\t\t\tUnassignedSequenceNumber,\n\t\t\t\t0,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tconst deltas = propertiesManager.rollbackProperties(\n\t\t\t\t{ props: rollbackDeltas },\n\t\t\t\tseg,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tassert.deepEqual(deltas, { key: \"newValue\" });\n\t\t\tassert.deepEqual(seg.properties, { key: \"value\" });\n\t\t});\n\n\t\tit(\"should rollback properties when collaborating is false\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {\n\t\t\t\tproperties: { key: \"value\" },\n\t\t\t};\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"newValue\" } };\n\t\t\tconst rollbackDeltas = propertiesManager.handleProperties(\n\t\t\t\top,\n\t\t\t\tseg,\n\t\t\t\tUnassignedSequenceNumber,\n\t\t\t\t0,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tconst deltas = propertiesManager.rollbackProperties(\n\t\t\t\t{ props: rollbackDeltas },\n\t\t\t\tseg,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tassert.deepEqual(deltas, { key: \"newValue\" });\n\t\t\tassert.deepEqual(seg.properties, { key: \"value\" });\n\t\t});\n\t});\n\n\tdescribe(\"ack\", () => {\n\t\tit(\"should acknowledge property changes\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"value\" } };\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = { properties: {} };\n\n\t\t\tpropertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 1, true);\n\t\t\tassert(propertiesManager.hasPendingProperties({ key: \"value\" }));\n\t\t\tpropertiesManager.ack(1, 0, op);\n\t\t});\n\t});\n\n\tdescribe(\"copyTo\", () => {\n\t\tit(\"should copy properties and manager state\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"value\" } };\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = { properties: {} };\n\n\t\t\tpropertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 1, true);\n\t\t\tassert(propertiesManager.hasPendingProperties({ key: \"value\" }));\n\t\t\tconst dest: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = {};\n\t\t\tpropertiesManager.copyTo({ key: \"value\" }, dest);\n\t\t\tassert(dest.propertyManager instanceof PropertiesManager);\n\t\t\tassert(dest.propertyManager.hasPendingProperties({ key: \"value\" }));\n\t\t});\n\t});\n\n\tdescribe(\"getAtSeq\", () => {\n\t\tit(\"should retrieve properties at a specific sequence number\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst op: PropsOrAdjust = { adjust: { key: { delta: 5 } } };\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = { properties: {} };\n\n\t\t\tpropertiesManager.handleProperties(op, seg, 1, 0, true);\n\t\t\tconst properties = propertiesManager.getAtSeq(seg.properties, 0);\n\t\t\tassert(matchProperties(properties, {}));\n\t\t});\n\t});\n\n\tdescribe(\"hasPendingProperties\", () => {\n\t\tit(\"should check for pending properties\", () => {\n\t\t\tconst propertiesManager = new PropertiesManager();\n\t\t\tconst op: PropsOrAdjust = { props: { key: \"value\" } };\n\t\t\tconst seg: Pick<ISegmentLeaf, \"properties\" | \"propertyManager\"> = { properties: {} };\n\n\t\t\tpropertiesManager.handleProperties(op, seg, UnassignedSequenceNumber, 1, true);\n\t\t\tassert(propertiesManager.hasPendingProperties({ key: \"value\" }));\n\t\t\tassert(!propertiesManager.hasPendingProperties({ otherKey: \"otherValue\" }));\n\t\t});\n\t});\n});\n"]}
|
package/lib/zamboni.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zamboni.d.ts","sourceRoot":"","sources":["../src/zamboni.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACN,KAAK,UAAU,EAQf,MAAM,qBAAqB,CAAC;AAG7B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAKpC,wBAAgB,eAAe,CAC9B,SAAS,EAAE,SAAS,EACpB,uBAAuB,SAAqB,GAC1C,IAAI,
|
|
1
|
+
{"version":3,"file":"zamboni.d.ts","sourceRoot":"","sources":["../src/zamboni.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACN,KAAK,UAAU,EAQf,MAAM,qBAAqB,CAAC;AAG7B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAKpC,wBAAgB,eAAe,CAC9B,SAAS,EAAE,SAAS,EACpB,uBAAuB,SAAqB,GAC1C,IAAI,CA4CN;AAGD,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAwDzE"}
|
package/lib/zamboni.js
CHANGED
|
@@ -17,6 +17,7 @@ export function zamboniSegments(mergeTree, zamboniSegmentsMaxCount = zamboniSegm
|
|
|
17
17
|
}
|
|
18
18
|
for (let i = 0; i < zamboniSegmentsMaxCount; i++) {
|
|
19
19
|
let segmentToScour = mergeTree.segmentsToScour.peek()?.value;
|
|
20
|
+
segmentToScour?.segment?.propertyManager?.updateMsn(mergeTree.collabWindow.minSeq);
|
|
20
21
|
if (!segmentToScour || segmentToScour.maxSeq > mergeTree.collabWindow.minSeq) {
|
|
21
22
|
break;
|
|
22
23
|
}
|
package/lib/zamboni.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zamboni.js","sourceRoot":"","sources":["../src/zamboni.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6DAA6D;AAE7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAIN,MAAM,EACN,eAAe,EACf,MAAM,EACN,UAAU,EACV,aAAa,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA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,CAAC,UAAU,CAAC;oBAC3D,WAAW,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;oBAClE,wBAAwB,CAAC;gBAE1B,IAAI,SAAS,EAAE,CAAC;oBACf,WAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC7B,SAAS,CAAC,4BAA4B,EAAE,CACvC;wBACC,SAAS,EAAE,wBAAwB,CAAC,MAAM;wBAC1C,aAAa,EAAE,CAAC,EAAE,OAAO,EAAE,WAAY,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;qBACvD,EACD,SAAS,CACT,CAAC;oBAEF,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;oBAC3B,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,kBAAkB,CAAC,cAAc;wBAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAChF,CAAC;qBAAM,CAAC;oBACP,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACxB,WAAW,GAAG,wBAAwB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC9D,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxB,WAAW,GAAG,SAAS,CAAC;YACzB,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { UnassignedSequenceNumber } from \"./constants.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { MergeTreeMaintenanceType } from \"./mergeTreeDeltaCallback.js\";\nimport {\n\ttype MergeBlock,\n\tIMergeNode,\n\tISegment,\n\tMarker,\n\tMaxNodesInBlock,\n\tseqLTE,\n\ttoMoveInfo,\n\ttoRemovalInfo,\n} from \"./mergeTreeNodes.js\";\nimport { matchProperties } from \"./properties.js\";\n\nexport const zamboniSegmentsMax = 2;\nfunction underflow(node: MergeBlock): boolean {\n\treturn node.childCount < MaxNodesInBlock / 2;\n}\n\nexport function zamboniSegments(\n\tmergeTree: MergeTree,\n\tzamboniSegmentsMaxCount = zamboniSegmentsMax,\n): void {\n\tif (!mergeTree.collabWindow.collaborating) {\n\t\treturn;\n\t}\n\n\tfor (let i = 0; i < zamboniSegmentsMaxCount; i++) {\n\t\tlet segmentToScour = mergeTree.segmentsToScour.peek()?.value;\n\t\tif (!segmentToScour || segmentToScour.maxSeq > mergeTree.collabWindow.minSeq) {\n\t\t\tbreak;\n\t\t}\n\t\tsegmentToScour = mergeTree.segmentsToScour.get()!;\n\t\t// Only skip scouring if needs scour is explicitly false, not true or undefined\n\t\tif (\n\t\t\tsegmentToScour?.segment?.parent &&\n\t\t\tsegmentToScour.segment.parent.needsScour !== false\n\t\t) {\n\t\t\tconst block = segmentToScour.segment.parent;\n\t\t\tconst childrenCopy: IMergeNode[] = [];\n\t\t\tscourNode(block, childrenCopy, mergeTree);\n\t\t\t// This will avoid the cost of re-scouring nodes\n\t\t\t// that have recently been scoured\n\t\t\tblock.needsScour = false;\n\n\t\t\tconst newChildCount = childrenCopy.length;\n\n\t\t\tif (newChildCount < block.childCount) {\n\t\t\t\tblock.childCount = newChildCount;\n\t\t\t\tblock.children = childrenCopy;\n\t\t\t\tfor (let j = 0; j < newChildCount; j++) {\n\t\t\t\t\tblock.assignChild(childrenCopy[j], j, false);\n\t\t\t\t}\n\n\t\t\t\tif (underflow(block) && block.parent) {\n\t\t\t\t\tpackParent(block.parent, mergeTree);\n\t\t\t\t} else {\n\t\t\t\t\tmergeTree.nodeUpdateOrdinals(block);\n\t\t\t\t\tmergeTree.blockUpdatePathLengths(block, UnassignedSequenceNumber, -1, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Interior node with all node children\nexport function packParent(parent: MergeBlock, mergeTree: MergeTree): void {\n\tconst children = parent.children;\n\tlet childIndex: number;\n\tlet childBlock: MergeBlock;\n\tconst holdNodes: IMergeNode[] = [];\n\tfor (childIndex = 0; childIndex < parent.childCount; childIndex++) {\n\t\t// Debug assert not isLeaf()\n\t\tchildBlock = children[childIndex] as MergeBlock;\n\t\tscourNode(childBlock, holdNodes, mergeTree);\n\t\t// Will replace this block with a packed block\n\t\tchildBlock.parent = undefined;\n\t}\n\tif (holdNodes.length > 0) {\n\t\tconst totalNodeCount = holdNodes.length;\n\t\tconst halfOfMaxNodeCount = MaxNodesInBlock / 2;\n\t\tlet childCount = Math.min(\n\t\t\tMaxNodesInBlock - 1,\n\t\t\tMath.floor(totalNodeCount / halfOfMaxNodeCount),\n\t\t);\n\t\tif (childCount < 1) {\n\t\t\tchildCount = 1;\n\t\t}\n\t\tconst baseNodesInBlockCount = Math.floor(totalNodeCount / childCount);\n\t\tlet remainderCount = totalNodeCount % childCount;\n\t\tconst packedBlocks: IMergeNode[] = Array.from({ length: MaxNodesInBlock });\n\t\tlet childrenPackedCount = 0;\n\t\tfor (let nodeIndex = 0; nodeIndex < childCount; nodeIndex++) {\n\t\t\tlet nodeCount = baseNodesInBlockCount;\n\t\t\tif (remainderCount > 0) {\n\t\t\t\tnodeCount++;\n\t\t\t\tremainderCount--;\n\t\t\t}\n\t\t\tconst packedBlock = mergeTree.makeBlock(nodeCount);\n\t\t\tfor (let packedNodeIndex = 0; packedNodeIndex < nodeCount; packedNodeIndex++) {\n\t\t\t\tconst nodeToPack = holdNodes[childrenPackedCount++];\n\t\t\t\tpackedBlock.assignChild(nodeToPack, packedNodeIndex, false);\n\t\t\t}\n\t\t\tpackedBlock.parent = parent;\n\t\t\tpackedBlocks[nodeIndex] = packedBlock;\n\t\t\tmergeTree.nodeUpdateLengthNewStructure(packedBlock);\n\t\t}\n\t\tparent.children = packedBlocks;\n\t\tfor (let j = 0; j < childCount; j++) {\n\t\t\tparent.assignChild(packedBlocks[j], j, false);\n\t\t}\n\t\tparent.childCount = childCount;\n\t} else {\n\t\tparent.children = [];\n\t\tparent.childCount = 0;\n\t}\n\tif (underflow(parent) && parent.parent) {\n\t\tpackParent(parent.parent, mergeTree);\n\t} else {\n\t\tmergeTree.nodeUpdateOrdinals(parent);\n\t\tmergeTree.blockUpdatePathLengths(parent, UnassignedSequenceNumber, -1, true);\n\t}\n}\n\nfunction scourNode(node: MergeBlock, holdNodes: IMergeNode[], mergeTree: MergeTree): void {\n\t// The previous segment is tracked while scouring for the purposes of merging adjacent segments\n\t// when possible.\n\tlet prevSegment: ISegment | undefined;\n\tfor (let k = 0; k < node.childCount; k++) {\n\t\t// TODO Non null asserting, why is this not null?\n\t\tconst childNode = node.children[k]!;\n\t\tif (!childNode.isLeaf() || childNode.segmentGroups?.empty === false) {\n\t\t\tholdNodes.push(childNode);\n\t\t\tprevSegment = undefined;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst segment = childNode;\n\t\tconst removalInfo = toRemovalInfo(segment);\n\t\tconst moveInfo = toMoveInfo(segment);\n\t\tif (removalInfo !== undefined || moveInfo !== undefined) {\n\t\t\t// If the segment's removal is below the MSN and it's not being held onto by a tracking group,\n\t\t\t// it can be unlinked (i.e. removed from the merge-tree)\n\t\t\tif (\n\t\t\t\t((!!removalInfo && seqLTE(removalInfo.removedSeq, mergeTree.collabWindow.minSeq)) ||\n\t\t\t\t\t(!!moveInfo && seqLTE(moveInfo.movedSeq, mergeTree.collabWindow.minSeq))) &&\n\t\t\t\tsegment.trackingCollection.empty\n\t\t\t) {\n\t\t\t\tmergeTree.mergeTreeMaintenanceCallback?.(\n\t\t\t\t\t{\n\t\t\t\t\t\toperation: MergeTreeMaintenanceType.UNLINK,\n\t\t\t\t\t\tdeltaSegments: [{ segment }],\n\t\t\t\t\t},\n\t\t\t\t\tundefined,\n\t\t\t\t);\n\n\t\t\t\tsegment.parent = undefined;\n\n\t\t\t\tif (Marker.is(segment)) {\n\t\t\t\t\tmergeTree.unlinkMarker(segment);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tholdNodes.push(segment);\n\t\t\t}\n\n\t\t\tprevSegment = undefined;\n\t\t} else {\n\t\t\tif (segment.seq! <= mergeTree.collabWindow.minSeq) {\n\t\t\t\tconst segmentHasPositiveLength = (mergeTree.localNetLength(segment) ?? 0) > 0;\n\t\t\t\tconst canAppend =\n\t\t\t\t\tprevSegment?.canAppend(segment) &&\n\t\t\t\t\tmatchProperties(prevSegment.properties, segment.properties) &&\n\t\t\t\t\tprevSegment.trackingCollection.matches(segment.trackingCollection) &&\n\t\t\t\t\tsegmentHasPositiveLength;\n\n\t\t\t\tif (canAppend) {\n\t\t\t\t\tprevSegment!.append(segment);\n\t\t\t\t\tmergeTree.mergeTreeMaintenanceCallback?.(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toperation: MergeTreeMaintenanceType.APPEND,\n\t\t\t\t\t\t\tdeltaSegments: [{ segment: prevSegment! }, { segment }],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\n\t\t\t\t\tsegment.parent = undefined;\n\t\t\t\t\tfor (const tg of segment.trackingCollection.trackingGroups) tg.unlink(segment);\n\t\t\t\t} else {\n\t\t\t\t\tholdNodes.push(segment);\n\t\t\t\t\tprevSegment = segmentHasPositiveLength ? segment : undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tholdNodes.push(segment);\n\t\t\t\tprevSegment = undefined;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"zamboni.js","sourceRoot":"","sources":["../src/zamboni.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6DAA6D;AAE7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAIN,MAAM,EACN,eAAe,EACf,MAAM,EACN,UAAU,EACV,aAAa,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAA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,GACd,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC;oBAC/B,eAAe,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;oBAC3D,WAAW,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;oBAClE,wBAAwB,CAAC;gBAE1B,IAAI,SAAS,EAAE,CAAC;oBACf,WAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC7B,SAAS,CAAC,4BAA4B,EAAE,CACvC;wBACC,SAAS,EAAE,wBAAwB,CAAC,MAAM;wBAC1C,aAAa,EAAE,CAAC,EAAE,OAAO,EAAE,WAAY,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;qBACvD,EACD,SAAS,CACT,CAAC;oBAEF,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;oBAC3B,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,kBAAkB,CAAC,cAAc;wBAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAChF,CAAC;qBAAM,CAAC;oBACP,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACxB,WAAW,GAAG,wBAAwB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC9D,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxB,WAAW,GAAG,SAAS,CAAC;YACzB,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { UnassignedSequenceNumber } from \"./constants.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { MergeTreeMaintenanceType } from \"./mergeTreeDeltaCallback.js\";\nimport {\n\ttype MergeBlock,\n\tIMergeNode,\n\tISegment,\n\tMarker,\n\tMaxNodesInBlock,\n\tseqLTE,\n\ttoMoveInfo,\n\ttoRemovalInfo,\n} from \"./mergeTreeNodes.js\";\nimport { matchProperties } from \"./properties.js\";\n\nexport const zamboniSegmentsMax = 2;\nfunction underflow(node: MergeBlock): boolean {\n\treturn node.childCount < MaxNodesInBlock / 2;\n}\n\nexport function zamboniSegments(\n\tmergeTree: MergeTree,\n\tzamboniSegmentsMaxCount = zamboniSegmentsMax,\n): void {\n\tif (!mergeTree.collabWindow.collaborating) {\n\t\treturn;\n\t}\n\n\tfor (let i = 0; i < zamboniSegmentsMaxCount; i++) {\n\t\tlet segmentToScour = mergeTree.segmentsToScour.peek()?.value;\n\n\t\tsegmentToScour?.segment?.propertyManager?.updateMsn(mergeTree.collabWindow.minSeq);\n\n\t\tif (!segmentToScour || segmentToScour.maxSeq > mergeTree.collabWindow.minSeq) {\n\t\t\tbreak;\n\t\t}\n\t\tsegmentToScour = mergeTree.segmentsToScour.get()!;\n\t\t// Only skip scouring if needs scour is explicitly false, not true or undefined\n\t\tif (\n\t\t\tsegmentToScour?.segment?.parent &&\n\t\t\tsegmentToScour.segment.parent.needsScour !== false\n\t\t) {\n\t\t\tconst block = segmentToScour.segment.parent;\n\t\t\tconst childrenCopy: IMergeNode[] = [];\n\t\t\tscourNode(block, childrenCopy, mergeTree);\n\t\t\t// This will avoid the cost of re-scouring nodes\n\t\t\t// that have recently been scoured\n\t\t\tblock.needsScour = false;\n\n\t\t\tconst newChildCount = childrenCopy.length;\n\n\t\t\tif (newChildCount < block.childCount) {\n\t\t\t\tblock.childCount = newChildCount;\n\t\t\t\tblock.children = childrenCopy;\n\t\t\t\tfor (let j = 0; j < newChildCount; j++) {\n\t\t\t\t\tblock.assignChild(childrenCopy[j], j, false);\n\t\t\t\t}\n\n\t\t\t\tif (underflow(block) && block.parent) {\n\t\t\t\t\tpackParent(block.parent, mergeTree);\n\t\t\t\t} else {\n\t\t\t\t\tmergeTree.nodeUpdateOrdinals(block);\n\t\t\t\t\tmergeTree.blockUpdatePathLengths(block, UnassignedSequenceNumber, -1, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Interior node with all node children\nexport function packParent(parent: MergeBlock, mergeTree: MergeTree): void {\n\tconst children = parent.children;\n\tlet childIndex: number;\n\tlet childBlock: MergeBlock;\n\tconst holdNodes: IMergeNode[] = [];\n\tfor (childIndex = 0; childIndex < parent.childCount; childIndex++) {\n\t\t// Debug assert not isLeaf()\n\t\tchildBlock = children[childIndex] as MergeBlock;\n\t\tscourNode(childBlock, holdNodes, mergeTree);\n\t\t// Will replace this block with a packed block\n\t\tchildBlock.parent = undefined;\n\t}\n\tif (holdNodes.length > 0) {\n\t\tconst totalNodeCount = holdNodes.length;\n\t\tconst halfOfMaxNodeCount = MaxNodesInBlock / 2;\n\t\tlet childCount = Math.min(\n\t\t\tMaxNodesInBlock - 1,\n\t\t\tMath.floor(totalNodeCount / halfOfMaxNodeCount),\n\t\t);\n\t\tif (childCount < 1) {\n\t\t\tchildCount = 1;\n\t\t}\n\t\tconst baseNodesInBlockCount = Math.floor(totalNodeCount / childCount);\n\t\tlet remainderCount = totalNodeCount % childCount;\n\t\tconst packedBlocks: IMergeNode[] = Array.from({ length: MaxNodesInBlock });\n\t\tlet childrenPackedCount = 0;\n\t\tfor (let nodeIndex = 0; nodeIndex < childCount; nodeIndex++) {\n\t\t\tlet nodeCount = baseNodesInBlockCount;\n\t\t\tif (remainderCount > 0) {\n\t\t\t\tnodeCount++;\n\t\t\t\tremainderCount--;\n\t\t\t}\n\t\t\tconst packedBlock = mergeTree.makeBlock(nodeCount);\n\t\t\tfor (let packedNodeIndex = 0; packedNodeIndex < nodeCount; packedNodeIndex++) {\n\t\t\t\tconst nodeToPack = holdNodes[childrenPackedCount++];\n\t\t\t\tpackedBlock.assignChild(nodeToPack, packedNodeIndex, false);\n\t\t\t}\n\t\t\tpackedBlock.parent = parent;\n\t\t\tpackedBlocks[nodeIndex] = packedBlock;\n\t\t\tmergeTree.nodeUpdateLengthNewStructure(packedBlock);\n\t\t}\n\t\tparent.children = packedBlocks;\n\t\tfor (let j = 0; j < childCount; j++) {\n\t\t\tparent.assignChild(packedBlocks[j], j, false);\n\t\t}\n\t\tparent.childCount = childCount;\n\t} else {\n\t\tparent.children = [];\n\t\tparent.childCount = 0;\n\t}\n\tif (underflow(parent) && parent.parent) {\n\t\tpackParent(parent.parent, mergeTree);\n\t} else {\n\t\tmergeTree.nodeUpdateOrdinals(parent);\n\t\tmergeTree.blockUpdatePathLengths(parent, UnassignedSequenceNumber, -1, true);\n\t}\n}\n\nfunction scourNode(node: MergeBlock, holdNodes: IMergeNode[], mergeTree: MergeTree): void {\n\t// The previous segment is tracked while scouring for the purposes of merging adjacent segments\n\t// when possible.\n\tlet prevSegment: ISegment | undefined;\n\tfor (let k = 0; k < node.childCount; k++) {\n\t\t// TODO Non null asserting, why is this not null?\n\t\tconst childNode = node.children[k]!;\n\t\tif (!childNode.isLeaf() || childNode.segmentGroups?.empty === false) {\n\t\t\tholdNodes.push(childNode);\n\t\t\tprevSegment = undefined;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst segment = childNode;\n\t\tconst removalInfo = toRemovalInfo(segment);\n\t\tconst moveInfo = toMoveInfo(segment);\n\t\tif (removalInfo !== undefined || moveInfo !== undefined) {\n\t\t\t// If the segment's removal is below the MSN and it's not being held onto by a tracking group,\n\t\t\t// it can be unlinked (i.e. removed from the merge-tree)\n\t\t\tif (\n\t\t\t\t((!!removalInfo && seqLTE(removalInfo.removedSeq, mergeTree.collabWindow.minSeq)) ||\n\t\t\t\t\t(!!moveInfo && seqLTE(moveInfo.movedSeq, mergeTree.collabWindow.minSeq))) &&\n\t\t\t\tsegment.trackingCollection.empty\n\t\t\t) {\n\t\t\t\tmergeTree.mergeTreeMaintenanceCallback?.(\n\t\t\t\t\t{\n\t\t\t\t\t\toperation: MergeTreeMaintenanceType.UNLINK,\n\t\t\t\t\t\tdeltaSegments: [{ segment }],\n\t\t\t\t\t},\n\t\t\t\t\tundefined,\n\t\t\t\t);\n\n\t\t\t\tsegment.parent = undefined;\n\n\t\t\t\tif (Marker.is(segment)) {\n\t\t\t\t\tmergeTree.unlinkMarker(segment);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tholdNodes.push(segment);\n\t\t\t}\n\n\t\t\tprevSegment = undefined;\n\t\t} else {\n\t\t\tif (segment.seq! <= mergeTree.collabWindow.minSeq) {\n\t\t\t\tconst segmentHasPositiveLength = (mergeTree.localNetLength(segment) ?? 0) > 0;\n\t\t\t\tconst canAppend =\n\t\t\t\t\tprevSegment?.canAppend(segment) &&\n\t\t\t\t\tmatchProperties(prevSegment.properties, segment.properties) &&\n\t\t\t\t\tprevSegment.trackingCollection.matches(segment.trackingCollection) &&\n\t\t\t\t\tsegmentHasPositiveLength;\n\n\t\t\t\tif (canAppend) {\n\t\t\t\t\tprevSegment!.append(segment);\n\t\t\t\t\tmergeTree.mergeTreeMaintenanceCallback?.(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toperation: MergeTreeMaintenanceType.APPEND,\n\t\t\t\t\t\t\tdeltaSegments: [{ segment: prevSegment! }, { segment }],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\n\t\t\t\t\tsegment.parent = undefined;\n\t\t\t\t\tfor (const tg of segment.trackingCollection.trackingGroups) tg.unlink(segment);\n\t\t\t\t} else {\n\t\t\t\t\tholdNodes.push(segment);\n\t\t\t\t\tprevSegment = segmentHasPositiveLength ? segment : undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tholdNodes.push(segment);\n\t\t\t\tprevSegment = undefined;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/merge-tree",
|
|
3
|
-
"version": "2.10.0-
|
|
3
|
+
"version": "2.10.0-307060",
|
|
4
4
|
"description": "Merge tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -81,30 +81,30 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "2.10.0-
|
|
85
|
-
"@fluidframework/container-definitions": "2.10.0-
|
|
86
|
-
"@fluidframework/core-interfaces": "2.10.0-
|
|
87
|
-
"@fluidframework/core-utils": "2.10.0-
|
|
88
|
-
"@fluidframework/datastore-definitions": "2.10.0-
|
|
89
|
-
"@fluidframework/driver-definitions": "2.10.0-
|
|
90
|
-
"@fluidframework/runtime-definitions": "2.10.0-
|
|
91
|
-
"@fluidframework/runtime-utils": "2.10.0-
|
|
92
|
-
"@fluidframework/shared-object-base": "2.10.0-
|
|
93
|
-
"@fluidframework/telemetry-utils": "2.10.0-
|
|
84
|
+
"@fluid-internal/client-utils": "2.10.0-307060",
|
|
85
|
+
"@fluidframework/container-definitions": "2.10.0-307060",
|
|
86
|
+
"@fluidframework/core-interfaces": "2.10.0-307060",
|
|
87
|
+
"@fluidframework/core-utils": "2.10.0-307060",
|
|
88
|
+
"@fluidframework/datastore-definitions": "2.10.0-307060",
|
|
89
|
+
"@fluidframework/driver-definitions": "2.10.0-307060",
|
|
90
|
+
"@fluidframework/runtime-definitions": "2.10.0-307060",
|
|
91
|
+
"@fluidframework/runtime-utils": "2.10.0-307060",
|
|
92
|
+
"@fluidframework/shared-object-base": "2.10.0-307060",
|
|
93
|
+
"@fluidframework/telemetry-utils": "2.10.0-307060"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@arethetypeswrong/cli": "^0.16.4",
|
|
97
97
|
"@biomejs/biome": "~1.9.3",
|
|
98
|
-
"@fluid-internal/mocha-test-setup": "2.10.0-
|
|
99
|
-
"@fluid-private/stochastic-test-utils": "2.10.0-
|
|
100
|
-
"@fluid-private/test-pairwise-generator": "2.10.0-
|
|
98
|
+
"@fluid-internal/mocha-test-setup": "2.10.0-307060",
|
|
99
|
+
"@fluid-private/stochastic-test-utils": "2.10.0-307060",
|
|
100
|
+
"@fluid-private/test-pairwise-generator": "2.10.0-307060",
|
|
101
101
|
"@fluid-tools/benchmark": "^0.50.0",
|
|
102
102
|
"@fluid-tools/build-cli": "^0.50.0",
|
|
103
103
|
"@fluidframework/build-common": "^2.0.3",
|
|
104
104
|
"@fluidframework/build-tools": "^0.50.0",
|
|
105
105
|
"@fluidframework/eslint-config-fluid": "^5.4.0",
|
|
106
106
|
"@fluidframework/merge-tree-previous": "npm:@fluidframework/merge-tree@2.5.0",
|
|
107
|
-
"@fluidframework/test-runtime-utils": "2.10.0-
|
|
107
|
+
"@fluidframework/test-runtime-utils": "2.10.0-307060",
|
|
108
108
|
"@microsoft/api-extractor": "7.47.8",
|
|
109
109
|
"@types/diff": "^3.5.1",
|
|
110
110
|
"@types/mocha": "^9.1.1",
|
|
@@ -195,6 +195,13 @@
|
|
|
195
195
|
},
|
|
196
196
|
"TypeAlias_Trackable": {
|
|
197
197
|
"backCompat": false
|
|
198
|
+
},
|
|
199
|
+
"Class_PropertiesManager": {
|
|
200
|
+
"forwardCompat": false,
|
|
201
|
+
"backCompat": false
|
|
202
|
+
},
|
|
203
|
+
"ClassStatics_PropertiesManager": {
|
|
204
|
+
"backCompat": false
|
|
198
205
|
}
|
|
199
206
|
},
|
|
200
207
|
"entrypoint": "legacy"
|
package/src/collections/index.ts
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export {
|
|
7
|
+
DoublyLinkedList,
|
|
8
|
+
ListNode,
|
|
9
|
+
ListNodeRange,
|
|
10
|
+
walkList,
|
|
11
|
+
iterateListValuesWhile,
|
|
12
|
+
} from "./list.js";
|
|
7
13
|
export {
|
|
8
14
|
ConflictAction,
|
|
9
15
|
Dictionary,
|
package/src/collections/list.ts
CHANGED
|
@@ -273,3 +273,32 @@ export function walkList<T>(
|
|
|
273
273
|
}
|
|
274
274
|
return true;
|
|
275
275
|
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Creates a lazily evaluated iterable which returns values while the predicate returns true,
|
|
279
|
+
* and stops iterating at the first value where the predicate is false.
|
|
280
|
+
* @param start - the node to start the iteration from
|
|
281
|
+
* @param includePredicate - determine if the current value be included in the iteration or stop if iteration
|
|
282
|
+
*/
|
|
283
|
+
export function iterateListValuesWhile<T>(
|
|
284
|
+
start: ListNode<T> | undefined,
|
|
285
|
+
includePredicate: (n: ListNode<T>) => boolean,
|
|
286
|
+
): Iterable<T> {
|
|
287
|
+
let next: ListNode<T> | undefined = start;
|
|
288
|
+
const iterator: IterableIterator<T> = {
|
|
289
|
+
next: (): IteratorResult<T> => {
|
|
290
|
+
if (next !== undefined) {
|
|
291
|
+
const current = next;
|
|
292
|
+
next = current.next;
|
|
293
|
+
if (includePredicate(current) === true) {
|
|
294
|
+
return { value: current.data, done: false };
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return { done: true, value: undefined };
|
|
298
|
+
},
|
|
299
|
+
[Symbol.iterator]() {
|
|
300
|
+
return this;
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
return iterator;
|
|
304
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -88,6 +88,7 @@ export {
|
|
|
88
88
|
createObliterateRangeOp,
|
|
89
89
|
} from "./opBuilder.js";
|
|
90
90
|
export {
|
|
91
|
+
AdjustParams,
|
|
91
92
|
IJSONSegment,
|
|
92
93
|
IMarkerDef,
|
|
93
94
|
IMergeTreeAnnotateMsg,
|
|
@@ -97,6 +98,7 @@ export {
|
|
|
97
98
|
IMergeTreeInsertMsg,
|
|
98
99
|
IMergeTreeOp,
|
|
99
100
|
IMergeTreeRemoveMsg,
|
|
101
|
+
IMergeTreeAnnotateAdjustMsg,
|
|
100
102
|
IRelativePosition,
|
|
101
103
|
MergeTreeDeltaType,
|
|
102
104
|
ReferenceType,
|
|
@@ -124,6 +126,7 @@ export {
|
|
|
124
126
|
reservedTileLabelsKey,
|
|
125
127
|
} from "./referencePositions.js";
|
|
126
128
|
export {
|
|
129
|
+
PropsOrAdjust,
|
|
127
130
|
copyPropertiesAndManager,
|
|
128
131
|
PropertiesManager,
|
|
129
132
|
PropertiesRollback,
|
package/src/mergeTree.ts
CHANGED
|
@@ -153,13 +153,18 @@ function ackSegment(
|
|
|
153
153
|
): boolean {
|
|
154
154
|
const currentSegmentGroup = segment.segmentGroups?.dequeue();
|
|
155
155
|
assert(currentSegmentGroup === segmentGroup, 0x043 /* "On ack, unexpected segmentGroup!" */);
|
|
156
|
-
|
|
156
|
+
assert(opArgs.sequencedMessage !== undefined, "must have sequencedMessage");
|
|
157
|
+
const {
|
|
158
|
+
op,
|
|
159
|
+
sequencedMessage: { sequenceNumber, minimumSequenceNumber },
|
|
160
|
+
} = opArgs;
|
|
161
|
+
switch (op.type) {
|
|
157
162
|
case MergeTreeDeltaType.ANNOTATE: {
|
|
158
163
|
assert(
|
|
159
164
|
!!segment.propertyManager,
|
|
160
165
|
0x044 /* "On annotate ack, missing segment property manager!" */,
|
|
161
166
|
);
|
|
162
|
-
segment.propertyManager.
|
|
167
|
+
segment.propertyManager.ack(sequenceNumber, minimumSequenceNumber, op);
|
|
163
168
|
return true;
|
|
164
169
|
}
|
|
165
170
|
|
|
@@ -168,7 +173,7 @@ function ackSegment(
|
|
|
168
173
|
segment.seq === UnassignedSequenceNumber,
|
|
169
174
|
0x045 /* "On insert, seq number already assigned!" */,
|
|
170
175
|
);
|
|
171
|
-
segment.seq =
|
|
176
|
+
segment.seq = sequenceNumber;
|
|
172
177
|
segment.localSeq = undefined;
|
|
173
178
|
return true;
|
|
174
179
|
}
|
|
@@ -178,7 +183,7 @@ function ackSegment(
|
|
|
178
183
|
assert(removalInfo !== undefined, 0x046 /* "On remove ack, missing removal info!" */);
|
|
179
184
|
segment.localRemovedSeq = undefined;
|
|
180
185
|
if (removalInfo.removedSeq === UnassignedSequenceNumber) {
|
|
181
|
-
removalInfo.removedSeq =
|
|
186
|
+
removalInfo.removedSeq = sequenceNumber;
|
|
182
187
|
return true;
|
|
183
188
|
}
|
|
184
189
|
return false;
|
|
@@ -193,11 +198,10 @@ function ackSegment(
|
|
|
193
198
|
segment.localMovedSeq = obliterateInfo.localSeq = undefined;
|
|
194
199
|
const seqIdx = moveInfo.movedSeqs.indexOf(UnassignedSequenceNumber);
|
|
195
200
|
assert(seqIdx !== -1, 0x86f /* expected movedSeqs to contain unacked seq */);
|
|
196
|
-
moveInfo.movedSeqs[seqIdx] =
|
|
197
|
-
opArgs.sequencedMessage!.sequenceNumber;
|
|
201
|
+
moveInfo.movedSeqs[seqIdx] = sequenceNumber;
|
|
198
202
|
|
|
199
203
|
if (moveInfo.movedSeq === UnassignedSequenceNumber) {
|
|
200
|
-
moveInfo.movedSeq =
|
|
204
|
+
moveInfo.movedSeq = sequenceNumber;
|
|
201
205
|
return true;
|
|
202
206
|
}
|
|
203
207
|
|
|
@@ -205,7 +209,7 @@ function ackSegment(
|
|
|
205
209
|
}
|
|
206
210
|
|
|
207
211
|
default: {
|
|
208
|
-
throw new Error(`${
|
|
212
|
+
throw new Error(`${op.type} is in unrecognized operation type`);
|
|
209
213
|
}
|
|
210
214
|
}
|
|
211
215
|
}
|
|
@@ -1317,11 +1321,9 @@ export class MergeTree {
|
|
|
1317
1321
|
});
|
|
1318
1322
|
});
|
|
1319
1323
|
|
|
1320
|
-
if (
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
) {
|
|
1324
|
-
this.obliterates.addOrUpdate(pendingSegmentGroup.obliterateInfo!);
|
|
1324
|
+
if (pendingSegmentGroup.obliterateInfo !== undefined) {
|
|
1325
|
+
pendingSegmentGroup.obliterateInfo.seq = seq;
|
|
1326
|
+
this.obliterates.addOrUpdate(pendingSegmentGroup.obliterateInfo);
|
|
1325
1327
|
}
|
|
1326
1328
|
|
|
1327
1329
|
// Perform slides after all segments have been acked, so that
|
|
@@ -1928,11 +1930,11 @@ export class MergeTree {
|
|
|
1928
1930
|
);
|
|
1929
1931
|
|
|
1930
1932
|
const propertyManager = (segment.propertyManager ??= new PropertiesManager());
|
|
1931
|
-
const
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
props,
|
|
1933
|
+
const propertyDeltas = propertyManager.handleProperties(
|
|
1934
|
+
{ props },
|
|
1935
|
+
segment,
|
|
1935
1936
|
seq,
|
|
1937
|
+
this.collabWindow.minSeq,
|
|
1936
1938
|
this.collabWindow.collaborating,
|
|
1937
1939
|
rollback,
|
|
1938
1940
|
);
|
|
@@ -2157,7 +2159,7 @@ export class MergeTree {
|
|
|
2157
2159
|
|
|
2158
2160
|
this.slideAckedRemovedSegmentReferences(localOverlapWithRefs);
|
|
2159
2161
|
// opArgs == undefined => test code
|
|
2160
|
-
if (
|
|
2162
|
+
if (start.pos !== end.pos || start.side !== end.side) {
|
|
2161
2163
|
this.mergeTreeDeltaCallback?.(opArgs, {
|
|
2162
2164
|
operation: MergeTreeDeltaType.OBLITERATE,
|
|
2163
2165
|
deltaSegments: movedSegments,
|
package/src/ops.ts
CHANGED
|
@@ -195,6 +195,44 @@ export interface IMergeTreeAnnotateMsg extends IMergeTreeDelta {
|
|
|
195
195
|
relativePos2?: IRelativePosition;
|
|
196
196
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
197
197
|
props: Record<string, any>;
|
|
198
|
+
adjust?: never;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Used to define per key adjustments in an {@link IMergeTreeAnnotateAdjustMsg}
|
|
203
|
+
* @alpha
|
|
204
|
+
* @legacy
|
|
205
|
+
*/
|
|
206
|
+
export interface AdjustParams {
|
|
207
|
+
/**
|
|
208
|
+
* The adjustment delta which will be summed with the current value if it is a number,
|
|
209
|
+
* or summed with zero if the current value is not a number.
|
|
210
|
+
*/
|
|
211
|
+
delta: number;
|
|
212
|
+
/**
|
|
213
|
+
* An optional minimum value for the computed value of the key this adjustment is applied to.
|
|
214
|
+
* The minimum will be applied after the value is applied.
|
|
215
|
+
*/
|
|
216
|
+
min?: number | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* An optional maximum value for the computed value of the key this adjustment is applied to.
|
|
219
|
+
* The maximum will be applied after the value is applied.
|
|
220
|
+
*/
|
|
221
|
+
max?: number | undefined;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @legacy
|
|
226
|
+
* @alpha
|
|
227
|
+
*/
|
|
228
|
+
export interface IMergeTreeAnnotateAdjustMsg extends IMergeTreeDelta {
|
|
229
|
+
type: typeof MergeTreeDeltaType.ANNOTATE;
|
|
230
|
+
pos1?: number;
|
|
231
|
+
pos2?: number;
|
|
232
|
+
relativePos1?: undefined;
|
|
233
|
+
relativePos2?: undefined;
|
|
234
|
+
props?: never;
|
|
235
|
+
adjust: Record<string, AdjustParams>;
|
|
198
236
|
}
|
|
199
237
|
|
|
200
238
|
/**
|