@fluidframework/sequence 2.32.0 → 2.33.0-333010
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/intervalCollection.d.ts +7 -5
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +59 -46
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalCollectionMap.d.ts +4 -4
- package/dist/intervalCollectionMap.d.ts.map +1 -1
- package/dist/intervalCollectionMap.js +16 -50
- package/dist/intervalCollectionMap.js.map +1 -1
- package/dist/intervalCollectionMapInterfaces.d.ts +21 -15
- package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -1
- package/dist/intervalCollectionMapInterfaces.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/intervalCollection.d.ts +7 -5
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +60 -47
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalCollectionMap.d.ts +4 -4
- package/lib/intervalCollectionMap.d.ts.map +1 -1
- package/lib/intervalCollectionMap.js +17 -51
- package/lib/intervalCollectionMap.js.map +1 -1
- package/lib/intervalCollectionMapInterfaces.d.ts +21 -15
- package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -1
- package/lib/intervalCollectionMapInterfaces.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +16 -16
- package/src/intervalCollection.ts +76 -54
- package/src/intervalCollectionMap.ts +19 -61
- package/src/intervalCollectionMapInterfaces.ts +33 -29
- package/src/packageVersion.ts +1 -1
|
@@ -13,9 +13,6 @@ import { ValueType, IFluidSerializer } from "@fluidframework/shared-object-base/
|
|
|
13
13
|
import { makeSerializable } from "./IntervalCollectionValues.js";
|
|
14
14
|
import {
|
|
15
15
|
IntervalCollection,
|
|
16
|
-
opsMap,
|
|
17
|
-
toOptionalSequencePlace,
|
|
18
|
-
toSequencePlace,
|
|
19
16
|
type ISerializedIntervalCollectionV1,
|
|
20
17
|
type ISerializedIntervalCollectionV2,
|
|
21
18
|
} from "./intervalCollection.js";
|
|
@@ -25,7 +22,6 @@ import {
|
|
|
25
22
|
ISerializableIntervalCollection,
|
|
26
23
|
SequenceOptions,
|
|
27
24
|
} from "./intervalCollectionMapInterfaces.js";
|
|
28
|
-
import { getSerializedProperties } from "./intervals/index.js";
|
|
29
25
|
|
|
30
26
|
function isMapOperation(op: unknown): op is IMapOperation {
|
|
31
27
|
return typeof op === "object" && op !== null && "type" in op && op.type === "act";
|
|
@@ -190,63 +186,33 @@ export class IntervalCollectionMap {
|
|
|
190
186
|
|
|
191
187
|
/**
|
|
192
188
|
* Submit the given op if a handler is registered.
|
|
193
|
-
* @param
|
|
189
|
+
* @param content - The operation to attempt to submit
|
|
194
190
|
* @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime
|
|
195
191
|
* and not sent to the server. This will be sent back when this message is received back from the server. This is
|
|
196
192
|
* also sent if we are asked to resubmit the message.
|
|
197
193
|
* @returns True if the operation was submitted, false otherwise.
|
|
198
194
|
*/
|
|
199
|
-
public tryResubmitMessage(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
195
|
+
public tryResubmitMessage(
|
|
196
|
+
content: unknown,
|
|
197
|
+
localOpMetadata: IMapMessageLocalMetadata,
|
|
198
|
+
): boolean {
|
|
199
|
+
if (isMapOperation(content)) {
|
|
200
|
+
const { value, key } = content;
|
|
201
|
+
const localValue = this.data.get(key);
|
|
203
202
|
assert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
|
|
204
|
-
|
|
205
|
-
const handler = opsMap[op.value.opName];
|
|
206
|
-
const rebased = handler.rebase(localValue, op.value, localOpMetadata);
|
|
207
|
-
if (rebased !== undefined) {
|
|
208
|
-
const { rebasedOp, rebasedLocalOpMetadata } = rebased;
|
|
209
|
-
this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
|
|
210
|
-
}
|
|
203
|
+
localValue.resubmitMessage(value, localOpMetadata);
|
|
211
204
|
return true;
|
|
212
205
|
}
|
|
213
206
|
return false;
|
|
214
207
|
}
|
|
215
208
|
|
|
216
|
-
public tryApplyStashedOp(
|
|
217
|
-
if (isMapOperation(
|
|
218
|
-
const { value, key } =
|
|
209
|
+
public tryApplyStashedOp(content: unknown): boolean {
|
|
210
|
+
if (isMapOperation(content)) {
|
|
211
|
+
const { value, key } = content;
|
|
219
212
|
const map = this.get(key);
|
|
220
|
-
const { id, properties } = getSerializedProperties(value.value);
|
|
221
213
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
map.add({
|
|
225
|
-
id,
|
|
226
|
-
// Todo: we should improve typing so we know add ops always have start and end
|
|
227
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
228
|
-
start: toSequencePlace(value.value.start!, value.value.startSide),
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
230
|
-
end: toSequencePlace(value.value.end!, value.value.endSide),
|
|
231
|
-
props: properties,
|
|
232
|
-
});
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
case "change": {
|
|
236
|
-
map.change(id, {
|
|
237
|
-
start: toOptionalSequencePlace(value.value.start, value.value.startSide),
|
|
238
|
-
end: toOptionalSequencePlace(value.value.end, value.value.endSide),
|
|
239
|
-
props: properties,
|
|
240
|
-
});
|
|
241
|
-
return true;
|
|
242
|
-
}
|
|
243
|
-
case "delete": {
|
|
244
|
-
map.removeIntervalById(id);
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
default:
|
|
248
|
-
throw new Error("unknown ops should not be stashed");
|
|
249
|
-
}
|
|
214
|
+
map.applyStashedOp(value);
|
|
215
|
+
return true;
|
|
250
216
|
}
|
|
251
217
|
return false;
|
|
252
218
|
}
|
|
@@ -267,23 +233,15 @@ export class IntervalCollectionMap {
|
|
|
267
233
|
* (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate.
|
|
268
234
|
*/
|
|
269
235
|
public tryProcessMessage(
|
|
270
|
-
|
|
236
|
+
content: unknown,
|
|
271
237
|
local: boolean,
|
|
272
238
|
message: ISequencedDocumentMessage,
|
|
273
239
|
localOpMetadata: unknown,
|
|
274
240
|
): boolean {
|
|
275
|
-
if (isMapOperation(
|
|
276
|
-
const
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
const translatedValue = op.value.value as any;
|
|
280
|
-
handler.process(
|
|
281
|
-
previousValue,
|
|
282
|
-
translatedValue,
|
|
283
|
-
local,
|
|
284
|
-
message,
|
|
285
|
-
localOpMetadata as IMapMessageLocalMetadata,
|
|
286
|
-
);
|
|
241
|
+
if (isMapOperation(content)) {
|
|
242
|
+
const { value, key } = content;
|
|
243
|
+
const localValue = this.data.get(key) ?? this.createCore(key, local);
|
|
244
|
+
localValue.process(value, local, message, localOpMetadata as IMapMessageLocalMetadata);
|
|
287
245
|
return true;
|
|
288
246
|
}
|
|
289
247
|
return false;
|
|
@@ -74,25 +74,6 @@ export interface IIntervalCollectionOperation {
|
|
|
74
74
|
message: ISequencedDocumentMessage | undefined,
|
|
75
75
|
localOpMetadata: IMapMessageLocalMetadata | undefined,
|
|
76
76
|
): void;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Rebases an `op` on `value` from its original perspective (ref/local seq) to the current
|
|
80
|
-
* perspective. Should be invoked on reconnection.
|
|
81
|
-
* @param value - The current value stored at the given key, which should be the value type.
|
|
82
|
-
* @param op - The op to be rebased.
|
|
83
|
-
* @param localOpMetadata - Any local metadata that was originally submitted with the op.
|
|
84
|
-
* @returns A rebased version of the op and any local metadata that should be submitted with it.
|
|
85
|
-
*/
|
|
86
|
-
rebase(
|
|
87
|
-
value: IntervalCollection,
|
|
88
|
-
op: IIntervalCollectionTypeOperationValue,
|
|
89
|
-
localOpMetadata: IMapMessageLocalMetadata,
|
|
90
|
-
):
|
|
91
|
-
| {
|
|
92
|
-
rebasedOp: IIntervalCollectionTypeOperationValue;
|
|
93
|
-
rebasedLocalOpMetadata: IMapMessageLocalMetadata;
|
|
94
|
-
}
|
|
95
|
-
| undefined;
|
|
96
77
|
}
|
|
97
78
|
|
|
98
79
|
/**
|
|
@@ -138,14 +119,37 @@ export interface ISerializedIntervalCollection {
|
|
|
138
119
|
* serializable via JSON.stringify/parse but differs in that it has no equivalency with an in-memory value - rather
|
|
139
120
|
* it just describes an operation to be applied to an already-in-memory value.
|
|
140
121
|
*/
|
|
141
|
-
export
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
122
|
+
export type IIntervalCollectionTypeOperationValue =
|
|
123
|
+
| {
|
|
124
|
+
/**
|
|
125
|
+
* The name of the operation.
|
|
126
|
+
*/
|
|
127
|
+
opName: typeof IntervalDeltaOpType.ADD;
|
|
146
128
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
129
|
+
/**
|
|
130
|
+
* The payload that is submitted along with the operation.
|
|
131
|
+
*/
|
|
132
|
+
value: ISerializedInterval;
|
|
133
|
+
}
|
|
134
|
+
| {
|
|
135
|
+
/**
|
|
136
|
+
* The name of the operation.
|
|
137
|
+
*/
|
|
138
|
+
opName: typeof IntervalDeltaOpType.CHANGE;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The payload that is submitted along with the operation.
|
|
142
|
+
*/
|
|
143
|
+
value: SerializedIntervalDelta;
|
|
144
|
+
}
|
|
145
|
+
| {
|
|
146
|
+
/**
|
|
147
|
+
* The name of the operation.
|
|
148
|
+
*/
|
|
149
|
+
opName: typeof IntervalDeltaOpType.DELETE;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The payload that is submitted along with the operation.
|
|
153
|
+
*/
|
|
154
|
+
value: SerializedIntervalDelta;
|
|
155
|
+
};
|
package/src/packageVersion.ts
CHANGED