@fluidframework/sequence 1.2.7 → 2.0.0-dev.1.3.0.96595
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/.mocharc.js +12 -0
- package/README.md +19 -18
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +39 -17
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +108 -67
- package/dist/intervalCollection.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/dist/sequence.d.ts +13 -22
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +11 -32
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +0 -6
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +0 -1
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts +5 -5
- package/dist/sharedIntervalCollection.js +5 -5
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedString.d.ts +30 -1
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +40 -5
- package/dist/sharedString.js.map +1 -1
- package/dist/sparsematrix.d.ts +28 -15
- package/dist/sparsematrix.d.ts.map +1 -1
- package/dist/sparsematrix.js +24 -13
- package/dist/sparsematrix.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +39 -17
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +107 -67
- package/lib/intervalCollection.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/lib/sequence.d.ts +13 -22
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +12 -33
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +0 -6
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +0 -1
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sharedIntervalCollection.d.ts +5 -5
- package/lib/sharedIntervalCollection.js +5 -5
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sharedString.d.ts +30 -1
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +38 -4
- package/lib/sharedString.js.map +1 -1
- package/lib/sparsematrix.d.ts +28 -15
- package/lib/sparsematrix.d.ts.map +1 -1
- package/lib/sparsematrix.js +24 -13
- package/lib/sparsematrix.js.map +1 -1
- package/package.json +70 -25
- package/src/index.ts +3 -1
- package/src/intervalCollection.ts +169 -85
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +12 -41
- package/src/sequenceDeltaEvent.ts +0 -7
- package/src/sharedIntervalCollection.ts +5 -5
- package/src/sharedString.ts +44 -6
- package/src/sparsematrix.ts +48 -35
|
@@ -25,12 +25,6 @@ import {
|
|
|
25
25
|
* They will not take into any future modifications performed to the underlying sequence and merge tree.
|
|
26
26
|
*/
|
|
27
27
|
export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated - Events no longer fire when the change they correspond to had no impact (e.g. a remote delete
|
|
30
|
-
* event for a range that had already been deleted locally).
|
|
31
|
-
* Clients can therefore assume this property is false.
|
|
32
|
-
*/
|
|
33
|
-
public readonly isEmpty: boolean;
|
|
34
28
|
public readonly deltaOperation: TOperation;
|
|
35
29
|
private readonly sortedRanges: Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>;
|
|
36
30
|
private readonly pFirst: Lazy<ISequenceDeltaRange<TOperation>>;
|
|
@@ -41,7 +35,6 @@ export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTy
|
|
|
41
35
|
private readonly mergeTreeClient: Client,
|
|
42
36
|
) {
|
|
43
37
|
assert(deltaArgs.deltaSegments.length > 0, 0x2d8 /* "Empty change event should not be emitted." */);
|
|
44
|
-
this.isEmpty = false;
|
|
45
38
|
this.deltaOperation = deltaArgs.operation;
|
|
46
39
|
|
|
47
40
|
this.sortedRanges = new Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>(
|
|
@@ -31,8 +31,8 @@ import { IMapMessageLocalMetadata } from "./defaultMapInterfaces";
|
|
|
31
31
|
const snapshotFileName = "header";
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* The factory that defines the SharedIntervalCollection
|
|
35
|
-
* @deprecated
|
|
34
|
+
* The factory that defines the SharedIntervalCollection.
|
|
35
|
+
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
36
36
|
*/
|
|
37
37
|
export class SharedIntervalCollectionFactory implements IChannelFactory {
|
|
38
38
|
public static readonly Type = "https://graph.microsoft.com/types/sharedIntervalCollection";
|
|
@@ -82,7 +82,7 @@ export interface ISharedIntervalCollection<TInterval extends ISerializableInterv
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* @deprecated
|
|
85
|
+
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
86
86
|
*/
|
|
87
87
|
export class SharedIntervalCollection
|
|
88
88
|
extends SharedObject implements ISharedIntervalCollection<Interval> {
|
|
@@ -128,8 +128,8 @@ export class SharedIntervalCollection
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
* @deprecated
|
|
132
|
-
* are supported. Use
|
|
131
|
+
* @deprecated `IntervalCollection`s are created on a first-write wins basis, and concurrent creates
|
|
132
|
+
* are supported. Use {@link SharedIntervalCollection.getIntervalCollection} instead.
|
|
133
133
|
*/
|
|
134
134
|
public async waitIntervalCollection(
|
|
135
135
|
label: string,
|
package/src/sharedString.ts
CHANGED
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
ICombiningOp,
|
|
8
8
|
IMergeTreeInsertMsg,
|
|
9
9
|
IMergeTreeRemoveMsg,
|
|
10
|
+
IMergeTreeTextHelper,
|
|
10
11
|
IRelativePosition,
|
|
11
12
|
ISegment,
|
|
12
13
|
Marker,
|
|
13
|
-
MergeTreeTextHelper,
|
|
14
14
|
PropertySet,
|
|
15
15
|
ReferencePosition,
|
|
16
16
|
ReferenceType,
|
|
@@ -81,7 +81,7 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
|
|
|
81
81
|
return this;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
private readonly mergeTreeTextHelper:
|
|
84
|
+
private readonly mergeTreeTextHelper: IMergeTreeTextHelper;
|
|
85
85
|
|
|
86
86
|
constructor(document: IFluidDataStoreRuntime, public id: string, attributes: IChannelAttributes) {
|
|
87
87
|
super(document, id, attributes, SharedStringFactory.segmentFromSpec);
|
|
@@ -223,6 +223,9 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
|
|
|
223
223
|
return this.client.findTile(startPos, tileLabel, preceding);
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
/**
|
|
227
|
+
* @deprecated Use the free function {@link getTextAndMarkers} exported by this package instead.
|
|
228
|
+
*/
|
|
226
229
|
public getTextAndMarkers(label: string) {
|
|
227
230
|
const segmentWindow = this.client.getCollabWindow();
|
|
228
231
|
return this.mergeTreeTextHelper.getTextAndMarkers(segmentWindow.currentSeq, segmentWindow.clientId, label);
|
|
@@ -242,14 +245,16 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
|
|
|
242
245
|
/**
|
|
243
246
|
* Adds spaces for markers and handles, so that position calculations account for them.
|
|
244
247
|
*/
|
|
245
|
-
public getTextWithPlaceholders() {
|
|
248
|
+
public getTextWithPlaceholders(start?: number, end?: number) {
|
|
246
249
|
const segmentWindow = this.client.getCollabWindow();
|
|
247
|
-
return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ");
|
|
250
|
+
return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ", start, end);
|
|
248
251
|
}
|
|
249
252
|
|
|
253
|
+
/**
|
|
254
|
+
* @deprecated Use {@link SharedString.getTextWithPlaceholders} instead.
|
|
255
|
+
*/
|
|
250
256
|
public getTextRangeWithPlaceholders(start: number, end: number) {
|
|
251
|
-
|
|
252
|
-
return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ", start, end);
|
|
257
|
+
return this.getTextWithPlaceholders(start, end);
|
|
253
258
|
}
|
|
254
259
|
|
|
255
260
|
public getTextRangeWithMarkers(start: number, end: number) {
|
|
@@ -260,4 +265,37 @@ export class SharedString extends SharedSegmentSequence<SharedStringSegment> imp
|
|
|
260
265
|
public getMarkerFromId(id: string): ISegment {
|
|
261
266
|
return this.client.getMarkerFromId(id);
|
|
262
267
|
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Revert an op
|
|
271
|
+
*/
|
|
272
|
+
protected rollback(content: any, localOpMetadata: unknown): void {
|
|
273
|
+
if (this.client.rollback !== undefined) {
|
|
274
|
+
this.client.rollback(content, localOpMetadata);
|
|
275
|
+
} else {
|
|
276
|
+
super.rollback(content, localOpMetadata);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Splits the text into regions ending with markers with the given `label`.
|
|
283
|
+
* @param sharedString - String to retrieve text and markers from
|
|
284
|
+
* @param label - label to split on
|
|
285
|
+
* @returns Two parallel lists of text and markers, split by markers with the provided `label`.
|
|
286
|
+
*
|
|
287
|
+
* For example:
|
|
288
|
+
* ```typescript
|
|
289
|
+
* // Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
|
|
290
|
+
* const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
|
|
291
|
+
* // parallelText === ["hello", "world"]
|
|
292
|
+
* // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
|
|
293
|
+
* // Note parallelText does not include "missing".
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export function getTextAndMarkers(sharedString: SharedString, label: string): {
|
|
297
|
+
parallelText: string[];
|
|
298
|
+
parallelMarkers: Marker[];
|
|
299
|
+
} {
|
|
300
|
+
return sharedString.getTextAndMarkers(label);
|
|
263
301
|
}
|
package/src/sparsematrix.ts
CHANGED
|
@@ -25,10 +25,11 @@ import { pkgVersion } from "./packageVersion";
|
|
|
25
25
|
import { SharedSegmentSequence, SubSequence } from "./";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* An empty segment that occupies 'cachedLength' positions.
|
|
29
|
-
* to "pad" a run of unoccupied cells.
|
|
28
|
+
* An empty segment that occupies 'cachedLength' positions.
|
|
29
|
+
* {@link SparseMatrix} uses `PaddingSegment` to "pad" a run of unoccupied cells.
|
|
30
30
|
*
|
|
31
|
-
* @deprecated PaddingSegment is part of an abandoned prototype.
|
|
31
|
+
* @deprecated `PaddingSegment` is part of an abandoned prototype.
|
|
32
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
32
33
|
*/
|
|
33
34
|
export class PaddingSegment extends BaseSegment {
|
|
34
35
|
public static readonly typeString = "PaddingSegment";
|
|
@@ -98,12 +99,14 @@ export class PaddingSegment extends BaseSegment {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
|
-
* @deprecated SparseMatrixItem is part of an abandoned prototype.
|
|
102
|
+
* @deprecated `SparseMatrixItem` is part of an abandoned prototype.
|
|
103
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
102
104
|
*/
|
|
103
105
|
export type SparseMatrixItem = Serializable;
|
|
104
106
|
|
|
105
107
|
/**
|
|
106
|
-
* @deprecated RunSegment is part of an abandoned prototype.
|
|
108
|
+
* @deprecated `RunSegment` is part of an abandoned prototype.
|
|
109
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
107
110
|
*/
|
|
108
111
|
export class RunSegment extends SubSequence<SparseMatrixItem> {
|
|
109
112
|
public static readonly typeString = "RunSegment";
|
|
@@ -183,43 +186,51 @@ export class RunSegment extends SubSequence<SparseMatrixItem> {
|
|
|
183
186
|
}
|
|
184
187
|
|
|
185
188
|
/**
|
|
186
|
-
* @deprecated MatrixSegment is part of an abandoned prototype.
|
|
189
|
+
* @deprecated `MatrixSegment` is part of an abandoned prototype.
|
|
190
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
187
191
|
*/
|
|
188
192
|
export type MatrixSegment = RunSegment | PaddingSegment;
|
|
189
193
|
|
|
190
194
|
/**
|
|
191
|
-
* @deprecated maxCol is part of an abandoned prototype.
|
|
195
|
+
* @deprecated `maxCol` is part of an abandoned prototype.
|
|
196
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
192
197
|
*/
|
|
193
198
|
export const maxCol = 0x200000; // X128 Excel maximum of 16,384 columns
|
|
194
199
|
|
|
195
200
|
/**
|
|
196
|
-
* @deprecated maxCols is part of an abandoned prototype.
|
|
197
|
-
|
|
198
|
-
export const maxCols = maxCol + 1;
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @deprecated maxRow is part of an abandoned prototype. Use SharedMatrix instead.
|
|
202
|
-
*/
|
|
203
|
-
export const maxRow = 0xFFFFFFFF; // X4096 Excel maximum of 1,048,576 rows
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* @deprecated maxRows is part of an abandoned prototype. Use SharedMatrix instead.
|
|
207
|
-
*/
|
|
208
|
-
export const maxRows = maxRow + 1;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* @deprecated maxCellPosition is part of an abandoned prototype. Use SharedMatrix instead.
|
|
212
|
-
*/
|
|
213
|
-
export const maxCellPosition = maxCol * maxRow;
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* @deprecated positionToRowCol is part of an abandoned prototype. Use SharedMatrix instead.
|
|
217
|
-
*/
|
|
218
|
-
export const rowColToPosition = (row: number, col: number) => row * maxCols + col;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @deprecated positionToRowCol is part of an abandoned prototype. Use SharedMatrix instead.
|
|
201
|
+
* @deprecated `maxCols` is part of an abandoned prototype.
|
|
202
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
222
203
|
*/
|
|
204
|
+
export const maxCols = maxCol + 1;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @deprecated `maxRow` is part of an abandoned prototype.
|
|
208
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
209
|
+
*/
|
|
210
|
+
export const maxRow = 0xFFFFFFFF; // X4096 Excel maximum of 1,048,576 rows
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated `maxRows` is part of an abandoned prototype.
|
|
214
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
215
|
+
*/
|
|
216
|
+
export const maxRows = maxRow + 1;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated `maxCellPosition` is part of an abandoned prototype.
|
|
220
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
221
|
+
*/
|
|
222
|
+
export const maxCellPosition = maxCol * maxRow;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @deprecated `positionToRowCol` is part of an abandoned prototype.
|
|
226
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
227
|
+
*/
|
|
228
|
+
export const rowColToPosition = (row: number, col: number) => row * maxCols + col;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @deprecated `positionToRowCol` is part of an abandoned prototype.
|
|
232
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
233
|
+
*/
|
|
223
234
|
export function positionToRowCol(position: number) {
|
|
224
235
|
const row = Math.floor(position / maxCols);
|
|
225
236
|
const col = position - (row * maxCols);
|
|
@@ -227,7 +238,8 @@ export function positionToRowCol(position: number) {
|
|
|
227
238
|
}
|
|
228
239
|
|
|
229
240
|
/**
|
|
230
|
-
* @deprecated SparseMatrix is an abandoned prototype.
|
|
241
|
+
* @deprecated `SparseMatrix` is an abandoned prototype.
|
|
242
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
231
243
|
*/
|
|
232
244
|
export class SparseMatrix extends SharedSegmentSequence<MatrixSegment> {
|
|
233
245
|
/**
|
|
@@ -366,7 +378,8 @@ export class SparseMatrix extends SharedSegmentSequence<MatrixSegment> {
|
|
|
366
378
|
}
|
|
367
379
|
|
|
368
380
|
/**
|
|
369
|
-
* @deprecated SparseMatrixFactory is an abandoned prototype.
|
|
381
|
+
* @deprecated `SparseMatrixFactory` is an abandoned prototype.
|
|
382
|
+
* Use {@link @fluidframework/matrix#SharedMatrixFactory} instead.
|
|
370
383
|
*/
|
|
371
384
|
export class SparseMatrixFactory implements IChannelFactory {
|
|
372
385
|
public static Type = "https://graph.microsoft.com/types/mergeTree/sparse-matrix";
|