@fluidframework/sequence 0.48.2 → 0.49.0-39313
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/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 +31 -2
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +2 -2
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +18 -0
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +6 -0
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sharedString.d.ts +38 -27
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +23 -27
- package/dist/sharedString.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 +31 -2
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +2 -2
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +18 -0
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +6 -0
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sharedString.d.ts +38 -27
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +23 -27
- package/lib/sharedString.js.map +1 -1
- package/package.json +13 -13
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +32 -5
- package/src/sequenceDeltaEvent.ts +18 -0
- package/src/sharedString.ts +43 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequenceDeltaEvent.js","sourceRoot":"","sources":["../src/sequenceDeltaEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAUH,gBAA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H,MAAM,OAAO,kBAAmB,SAAQ,aAA0C;IAM9E,YACoB,MAA6B,EAC7C,SAAsC,EACtC,eAAuB;QAEvB,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAJlB,WAAM,GAAN,MAAM,CAAuB;QAK7C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,gBAAgB,KAAK,SAAS,CAAC;IACzD,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,OAAO,wBAAyB,SAAQ,aAAuC;IACjF,YACoB,MAAyC,EACzD,SAA4C,EAC5C,eAAuB;QAEvB,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAJlB,WAAM,GAAN,MAAM,CAAmC;IAK7D,CAAC;CACJ;AAkBD,MAAM,IAAI;IAGN,YAA6B,cAAuB;QAAvB,mBAAc,GAAd,cAAc,CAAS;QAChD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,KAAK;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;SACvC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n Client,\n IMergeTreeDeltaCallbackArgs,\n IMergeTreeDeltaOpArgs,\n IMergeTreeMaintenanceCallbackArgs,\n ISegment,\n MergeTreeDeltaOperationType,\n MergeTreeDeltaOperationTypes,\n MergeTreeMaintenanceType,\n PropertySet,\n SortedSegmentSet,\n} from \"@fluidframework/merge-tree\";\n\n/**\n * Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.\n *\n * The properties of this object and its sub-objects represent a point in time state\n * at the time the operation was applied. They will not take into any future modifications\n * performed to the underlying sequence and merge tree.\n */\nexport abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {\n public readonly isEmpty: boolean;\n public readonly deltaOperation: TOperation;\n private readonly sortedRanges: Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>;\n private readonly pFirst: Lazy<ISequenceDeltaRange<TOperation>>;\n private readonly pLast: Lazy<ISequenceDeltaRange<TOperation>>;\n\n constructor(\n public readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>,\n private readonly mergeTreeClient: Client,\n ) {\n this.isEmpty = deltaArgs.deltaSegments.length === 0;\n this.deltaOperation = deltaArgs.operation;\n\n this.sortedRanges = new Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>(\n () => {\n const set = new SortedSegmentSet<ISequenceDeltaRange<TOperation>>();\n this.deltaArgs.deltaSegments.forEach((delta) => {\n const newRange: ISequenceDeltaRange<TOperation> = {\n operation: this.deltaArgs.operation,\n position: this.mergeTreeClient.getPosition(delta.segment),\n propertyDeltas: delta.propertyDeltas,\n segment: delta.segment,\n };\n set.addOrUpdate(newRange);\n });\n return set;\n });\n\n this.pFirst = new Lazy<ISequenceDeltaRange<TOperation>>(\n () => {\n if (this.isEmpty) {\n return undefined;\n }\n return this.sortedRanges.value.items[0];\n });\n\n this.pLast = new Lazy<ISequenceDeltaRange<TOperation>>(\n () => {\n if (this.isEmpty) {\n return undefined;\n }\n return this.sortedRanges.value.items[this.sortedRanges.value.size - 1];\n });\n }\n\n /**\n * The in-order ranges affected by this delta.\n * These may not be continous.\n */\n public get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[] {\n return this.sortedRanges.value.items;\n }\n\n /**\n * The client id of the client that made the change which caused the delta event\n */\n public get clientId(): string {\n return this.mergeTreeClient.longClientId;\n }\n\n /**\n * The first of the modified ranges.\n */\n public get first(): Readonly<ISequenceDeltaRange<TOperation>> {\n return this.pFirst.value;\n }\n\n /**\n * The last of the modified ranges.\n */\n public get last(): Readonly<ISequenceDeltaRange<TOperation>> {\n return this.pLast.value;\n }\n}\n\n/**\n * The event object returned on sequenceDelta events.\n *\n * The properties of this object and its sub-objects represent a point in time state\n * at the time the operation was applied. They will not take into any future modifications\n * performed to the underlying sequence and merge tree.\n *\n * For group ops, each op will get it's own event, and the group op property will be set on the op args.\n *\n * Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.\n */\nexport class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {\n /**\n * Whether the event was caused by a locally-made change.\n */\n public readonly isLocal: boolean;\n\n constructor(\n public readonly opArgs: IMergeTreeDeltaOpArgs,\n deltaArgs: IMergeTreeDeltaCallbackArgs,\n mergeTreeClient: Client,\n ) {\n super(deltaArgs, mergeTreeClient);\n this.isLocal = opArgs.sequencedMessage === undefined;\n }\n}\n\n/**\n * The event object returned on maintenance events.\n *\n * The properties of this object and its sub-objects represent a point in time state\n * at the time the operation was applied. They will not take into any future modifications\n * performed to the underlying sequence and merge tree.\n */\nexport class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {\n constructor(\n public readonly opArgs: IMergeTreeDeltaOpArgs | undefined,\n deltaArgs: IMergeTreeMaintenanceCallbackArgs,\n mergeTreeClient: Client,\n ) {\n super(deltaArgs, mergeTreeClient);\n }\n}\n\n/**\n * A range that has changed corresponding to a segment modification.\n */\nexport interface ISequenceDeltaRange<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {\n operation: TOperation;\n /**\n * The index of the start of the range.\n */\n position: number;\n /**\n * The segment that corresponds to the range.\n */\n segment: ISegment;\n propertyDeltas: PropertySet;\n}\n\nclass Lazy<T> {\n private pValue: T;\n private pEvaluated: boolean;\n constructor(private readonly valueGenerator: () => T) {\n this.pEvaluated = false;\n }\n\n public get evaluated(): boolean {\n return this.pEvaluated;\n }\n\n public get value(): T {\n if (!this.pEvaluated) {\n this.pEvaluated = true;\n this.pValue = this.valueGenerator();\n }\n return this.pValue;\n }\n}\n"]}
|
package/lib/sharedString.d.ts
CHANGED
|
@@ -10,14 +10,29 @@ import { SharedStringFactory } from "./sequenceFactory";
|
|
|
10
10
|
* Fluid object interface describing access methods on a SharedString
|
|
11
11
|
*/
|
|
12
12
|
export interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
|
|
13
|
+
/**
|
|
14
|
+
* Inserts the text at the position.
|
|
15
|
+
* @param pos - The position to insert the text at
|
|
16
|
+
* @param text - The text to insert
|
|
17
|
+
* @param props - The properties of text
|
|
18
|
+
*/
|
|
13
19
|
insertText(pos: number, text: string, props?: MergeTree.PropertySet): any;
|
|
20
|
+
/**
|
|
21
|
+
* Inserts a marker at the position.
|
|
22
|
+
* @param pos - The position to insert the marker at
|
|
23
|
+
* @param refType - The reference type of the marker
|
|
24
|
+
* @param props - The properties of the marker
|
|
25
|
+
*/
|
|
14
26
|
insertMarker(pos: number, refType: MergeTree.ReferenceType, props?: MergeTree.PropertySet): any;
|
|
27
|
+
/**
|
|
28
|
+
* {@inheritDoc SharedSegmentSequence.posFromRelativePos}
|
|
29
|
+
*/
|
|
15
30
|
posFromRelativePos(relativePos: MergeTree.IRelativePosition): any;
|
|
16
31
|
}
|
|
17
32
|
export declare type SharedStringSegment = MergeTree.TextSegment | MergeTree.Marker;
|
|
18
33
|
/**
|
|
19
34
|
* The Shared String is a specialized data structure for handling collaborative
|
|
20
|
-
*
|
|
35
|
+
* text. It is based on a more general Sequence data structure but has
|
|
21
36
|
* additional features that make working with text easier.
|
|
22
37
|
*
|
|
23
38
|
* In addition to text, a Shared String can also contain markers. Markers can be
|
|
@@ -28,8 +43,7 @@ export declare type SharedStringSegment = MergeTree.TextSegment | MergeTree.Mark
|
|
|
28
43
|
export declare class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {
|
|
29
44
|
id: string;
|
|
30
45
|
/**
|
|
31
|
-
* Create a new shared string
|
|
32
|
-
*
|
|
46
|
+
* Create a new shared string.
|
|
33
47
|
* @param runtime - data store runtime the new shared string belongs to
|
|
34
48
|
* @param id - optional name of the shared string
|
|
35
49
|
* @returns newly create shared string (but not attached yet)
|
|
@@ -37,7 +51,6 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
37
51
|
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedString;
|
|
38
52
|
/**
|
|
39
53
|
* Get a factory for SharedString to register with the data store.
|
|
40
|
-
*
|
|
41
54
|
* @returns a factory that creates and load SharedString
|
|
42
55
|
*/
|
|
43
56
|
static getFactory(): SharedStringFactory;
|
|
@@ -45,59 +58,51 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
45
58
|
private readonly mergeTreeTextHelper;
|
|
46
59
|
constructor(document: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
|
|
47
60
|
/**
|
|
48
|
-
* Inserts a marker at a relative
|
|
49
|
-
*
|
|
50
|
-
* @param relativePos1 - The relative postition to insert the marker at
|
|
61
|
+
* Inserts a marker at a relative position.
|
|
62
|
+
* @param relativePos1 - The relative position to insert the marker at
|
|
51
63
|
* @param refType - The reference type of the marker
|
|
52
64
|
* @param props - The properties of the marker
|
|
53
65
|
*/
|
|
54
66
|
insertMarkerRelative(relativePos1: MergeTree.IRelativePosition, refType: MergeTree.ReferenceType, props?: MergeTree.PropertySet): void;
|
|
55
67
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @param pos - The postition to insert the marker at
|
|
59
|
-
* @param refType - The reference type of the marker
|
|
60
|
-
* @param props - The properties of the marker
|
|
68
|
+
* {@inheritDoc ISharedString.insertMarker}
|
|
61
69
|
*/
|
|
62
70
|
insertMarker(pos: number, refType: MergeTree.ReferenceType, props?: MergeTree.PropertySet): MergeTree.IMergeTreeInsertMsg;
|
|
63
71
|
/**
|
|
64
|
-
* Inserts the text at the
|
|
65
|
-
*
|
|
66
|
-
* @param relativePos1 - The relative postition to insert the text at
|
|
72
|
+
* Inserts the text at the position.
|
|
73
|
+
* @param relativePos1 - The relative position to insert the text at
|
|
67
74
|
* @param text - The text to insert
|
|
68
75
|
* @param props - The properties of text
|
|
69
76
|
*/
|
|
70
77
|
insertTextRelative(relativePos1: MergeTree.IRelativePosition, text: string, props?: MergeTree.PropertySet): void;
|
|
71
78
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @param pos - The postition to insert the text at
|
|
75
|
-
* @param text - The text to insert
|
|
76
|
-
* @param props - The properties of text
|
|
79
|
+
* {@inheritDoc ISharedString.insertText}
|
|
77
80
|
*/
|
|
78
81
|
insertText(pos: number, text: string, props?: MergeTree.PropertySet): void;
|
|
79
82
|
/**
|
|
80
83
|
* Replaces a range with the provided text.
|
|
81
|
-
*
|
|
82
84
|
* @param start - The inclusive start of the range to replace
|
|
83
85
|
* @param end - The exclusive end of the range to replace
|
|
84
86
|
* @param text - The text to replace the range with
|
|
85
87
|
* @param props - Optional. The properties of the replacement text
|
|
86
88
|
*/
|
|
87
89
|
replaceText(start: number, end: number, text: string, props?: MergeTree.PropertySet): void;
|
|
90
|
+
/**
|
|
91
|
+
* Removes the text in the given range.
|
|
92
|
+
* @param start - The inclusive start of the range to remove
|
|
93
|
+
* @param end - The exclusive end of the range to replace
|
|
94
|
+
* @returns the message sent.
|
|
95
|
+
*/
|
|
88
96
|
removeText(start: number, end: number): MergeTree.IMergeTreeRemoveMsg;
|
|
89
97
|
/**
|
|
90
|
-
* Annotates the marker with the provided properties
|
|
91
|
-
* and calls the callback on concensus.
|
|
92
|
-
*
|
|
98
|
+
* Annotates the marker with the provided properties and calls the callback on consensus.
|
|
93
99
|
* @param marker - The marker to annotate
|
|
94
100
|
* @param props - The properties to annotate the marker with
|
|
95
101
|
* @param consensusCallback - The callback called when consensus is reached
|
|
96
102
|
*/
|
|
97
103
|
annotateMarkerNotifyConsensus(marker: MergeTree.Marker, props: MergeTree.PropertySet, callback: (m: MergeTree.Marker) => void): void;
|
|
98
104
|
/**
|
|
99
|
-
* Annotates the marker with the provided properties
|
|
100
|
-
*
|
|
105
|
+
* Annotates the marker with the provided properties.
|
|
101
106
|
* @param marker - The marker to annotate
|
|
102
107
|
* @param props - The properties to annotate the marker with
|
|
103
108
|
* @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
|
|
@@ -111,9 +116,15 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
111
116
|
parallelText: string[];
|
|
112
117
|
parallelMarkers: MergeTree.Marker[];
|
|
113
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* Retrieve text from the SharedString in string format.
|
|
121
|
+
* @param start - The starting index of the text to retrieve, or 0 if omitted.
|
|
122
|
+
* @param end - The ending index of the text to retrieve, or the end of the string if omitted
|
|
123
|
+
* @returns The requested text content as a string.
|
|
124
|
+
*/
|
|
114
125
|
getText(start?: number, end?: number): string;
|
|
115
126
|
/**
|
|
116
|
-
* Adds spaces for markers and handles, so that position calculations account for them
|
|
127
|
+
* Adds spaces for markers and handles, so that position calculations account for them.
|
|
117
128
|
*/
|
|
118
129
|
getTextWithPlaceholders(): string;
|
|
119
130
|
getTextRangeWithPlaceholders(start: number, end: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedString.d.ts","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,qBAAqB,CAAC,mBAAmB,CAAC;IAC7E,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS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AAI;IAO3C;;;;;OAKG;IACI,cAAc,CACjB,MAAM,EAAE,SAAS,CAAC,MAAM,EACxB,KAAK,EAAE,SAAS,CAAC,WAAW,EAC5B,WAAW,CAAC,EAAE,SAAS,CAAC,YAAY;IAOjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,UAAO;;;;IAI1E,iBAAiB,CAAC,KAAK,EAAE,MAAM;;;;IAKtC;;;;;OAKG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAK3C;;OAEG;IACI,uBAAuB;IAKvB,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKvD,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKlD,eAAe,CAAC,EAAE,EAAE,MAAM;CAGpC"}
|
package/lib/sharedString.js
CHANGED
|
@@ -7,7 +7,7 @@ import { SharedSegmentSequence } from "./sequence";
|
|
|
7
7
|
import { SharedStringFactory } from "./sequenceFactory";
|
|
8
8
|
/**
|
|
9
9
|
* The Shared String is a specialized data structure for handling collaborative
|
|
10
|
-
*
|
|
10
|
+
* text. It is based on a more general Sequence data structure but has
|
|
11
11
|
* additional features that make working with text easier.
|
|
12
12
|
*
|
|
13
13
|
* In addition to text, a Shared String can also contain markers. Markers can be
|
|
@@ -22,8 +22,7 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
22
22
|
this.mergeTreeTextHelper = this.client.createTextHelper();
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Create a new shared string
|
|
26
|
-
*
|
|
25
|
+
* Create a new shared string.
|
|
27
26
|
* @param runtime - data store runtime the new shared string belongs to
|
|
28
27
|
* @param id - optional name of the shared string
|
|
29
28
|
* @returns newly create shared string (but not attached yet)
|
|
@@ -33,7 +32,6 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
33
32
|
}
|
|
34
33
|
/**
|
|
35
34
|
* Get a factory for SharedString to register with the data store.
|
|
36
|
-
*
|
|
37
35
|
* @returns a factory that creates and load SharedString
|
|
38
36
|
*/
|
|
39
37
|
static getFactory() {
|
|
@@ -43,9 +41,8 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
43
41
|
return this;
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
46
|
-
* Inserts a marker at a relative
|
|
47
|
-
*
|
|
48
|
-
* @param relativePos1 - The relative postition to insert the marker at
|
|
44
|
+
* Inserts a marker at a relative position.
|
|
45
|
+
* @param relativePos1 - The relative position to insert the marker at
|
|
49
46
|
* @param refType - The reference type of the marker
|
|
50
47
|
* @param props - The properties of the marker
|
|
51
48
|
*/
|
|
@@ -61,11 +58,7 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @param pos - The postition to insert the marker at
|
|
67
|
-
* @param refType - The reference type of the marker
|
|
68
|
-
* @param props - The properties of the marker
|
|
61
|
+
* {@inheritDoc ISharedString.insertMarker}
|
|
69
62
|
*/
|
|
70
63
|
insertMarker(pos, refType, props) {
|
|
71
64
|
const segment = new MergeTree.Marker(refType);
|
|
@@ -79,9 +72,8 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
79
72
|
return insertOp;
|
|
80
73
|
}
|
|
81
74
|
/**
|
|
82
|
-
* Inserts the text at the
|
|
83
|
-
*
|
|
84
|
-
* @param relativePos1 - The relative postition to insert the text at
|
|
75
|
+
* Inserts the text at the position.
|
|
76
|
+
* @param relativePos1 - The relative position to insert the text at
|
|
85
77
|
* @param text - The text to insert
|
|
86
78
|
* @param props - The properties of text
|
|
87
79
|
*/
|
|
@@ -97,11 +89,7 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
97
89
|
}
|
|
98
90
|
}
|
|
99
91
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @param pos - The postition to insert the text at
|
|
103
|
-
* @param text - The text to insert
|
|
104
|
-
* @param props - The properties of text
|
|
92
|
+
* {@inheritDoc ISharedString.insertText}
|
|
105
93
|
*/
|
|
106
94
|
insertText(pos, text, props) {
|
|
107
95
|
const segment = new MergeTree.TextSegment(text);
|
|
@@ -115,7 +103,6 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
115
103
|
}
|
|
116
104
|
/**
|
|
117
105
|
* Replaces a range with the provided text.
|
|
118
|
-
*
|
|
119
106
|
* @param start - The inclusive start of the range to replace
|
|
120
107
|
* @param end - The exclusive end of the range to replace
|
|
121
108
|
* @param text - The text to replace the range with
|
|
@@ -124,13 +111,17 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
124
111
|
replaceText(start, end, text, props) {
|
|
125
112
|
this.replaceRange(start, end, MergeTree.TextSegment.make(text, props));
|
|
126
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Removes the text in the given range.
|
|
116
|
+
* @param start - The inclusive start of the range to remove
|
|
117
|
+
* @param end - The exclusive end of the range to replace
|
|
118
|
+
* @returns the message sent.
|
|
119
|
+
*/
|
|
127
120
|
removeText(start, end) {
|
|
128
121
|
return this.removeRange(start, end);
|
|
129
122
|
}
|
|
130
123
|
/**
|
|
131
|
-
* Annotates the marker with the provided properties
|
|
132
|
-
* and calls the callback on concensus.
|
|
133
|
-
*
|
|
124
|
+
* Annotates the marker with the provided properties and calls the callback on consensus.
|
|
134
125
|
* @param marker - The marker to annotate
|
|
135
126
|
* @param props - The properties to annotate the marker with
|
|
136
127
|
* @param consensusCallback - The callback called when consensus is reached
|
|
@@ -142,8 +133,7 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
142
133
|
}
|
|
143
134
|
}
|
|
144
135
|
/**
|
|
145
|
-
* Annotates the marker with the provided properties
|
|
146
|
-
*
|
|
136
|
+
* Annotates the marker with the provided properties.
|
|
147
137
|
* @param marker - The marker to annotate
|
|
148
138
|
* @param props - The properties to annotate the marker with
|
|
149
139
|
* @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
|
|
@@ -161,12 +151,18 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
161
151
|
const segmentWindow = this.client.getCollabWindow();
|
|
162
152
|
return this.mergeTreeTextHelper.getTextAndMarkers(segmentWindow.currentSeq, segmentWindow.clientId, label);
|
|
163
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Retrieve text from the SharedString in string format.
|
|
156
|
+
* @param start - The starting index of the text to retrieve, or 0 if omitted.
|
|
157
|
+
* @param end - The ending index of the text to retrieve, or the end of the string if omitted
|
|
158
|
+
* @returns The requested text content as a string.
|
|
159
|
+
*/
|
|
164
160
|
getText(start, end) {
|
|
165
161
|
const segmentWindow = this.client.getCollabWindow();
|
|
166
162
|
return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "", start, end);
|
|
167
163
|
}
|
|
168
164
|
/**
|
|
169
|
-
* Adds spaces for markers and handles, so that position calculations account for them
|
|
165
|
+
* Adds spaces for markers and handles, so that position calculations account for them.
|
|
170
166
|
*/
|
|
171
167
|
getTextWithPlaceholders() {
|
|
172
168
|
const segmentWindow = this.client.getCollabWindow();
|
package/lib/sharedString.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAexD;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAa,SAAQ,qBAA0C;IA2BxE,YAAY,QAAgC,EAAS,EAAU,EAAE,UAA8B;QAC3F,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;QADpB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AAC,CAAC;IAC9G,CAAC;IACD;;OAEG;IACI,uBAAuB;QAC1B,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,EAAE,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnG,CAAC;IACM,4BAA4B,CAAC,KAAa,EAAE,GAAW;QAC1D,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,EAAE,aAAa,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/G,CAAC;IACM,uBAAuB,CAAC,KAAa,EAAE,GAAW;QACrD,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,EAAE,aAAa,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/G,CAAC;IAEM,eAAe,CAAC,EAAU;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-unassigned-import\nimport { } from \"@fluidframework/core-interfaces\";\nimport * as MergeTree from \"@fluidframework/merge-tree\";\nimport { IFluidDataStoreRuntime, IChannelAttributes } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\nimport { SharedStringFactory } from \"./sequenceFactory\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n insertText(pos: number, text: string, props?: MergeTree.PropertySet);\n\n insertMarker(pos: number, refType: MergeTree.ReferenceType, props?: MergeTree.PropertySet);\n\n posFromRelativePos(relativePos: MergeTree.IRelativePosition);\n}\n\nexport type SharedStringSegment = MergeTree.TextSegment | MergeTree.Marker;\n\n/**\n * The Shared String is a specialized data structure for handling collaborative\n * text. It is based on a more general Sequence data structure but has\n * additional features that make working with text easier.\n *\n * In addition to text, a Shared String can also contain markers. Markers can be\n * used to store metadata at positions within the text, like the details of an\n * image or Fluid object that should be rendered with the text.\n *\n */\nexport class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {\n /**\n * Create a new shared string\n *\n * @param runtime - data store runtime the new shared string belongs to\n * @param id - optional name of the shared string\n * @returns newly create shared string (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n }\n\n /**\n * Get a factory for SharedString to register with the data store.\n *\n * @returns a factory that creates and load SharedString\n */\n public static getFactory() {\n return new SharedStringFactory();\n }\n\n public get ISharedString(): ISharedString {\n return this;\n }\n\n private readonly mergeTreeTextHelper: MergeTree.MergeTreeTextHelper;\n\n constructor(document: IFluidDataStoreRuntime, public id: string, attributes: IChannelAttributes) {\n super(document, id, attributes, SharedStringFactory.segmentFromSpec);\n this.mergeTreeTextHelper = this.client.createTextHelper();\n }\n\n /**\n * Inserts a marker at a relative postition\n *\n * @param relativePos1 - The relative postition to insert the marker at\n * @param refType - The reference type of the marker\n * @param props - The properties of the marker\n */\n public insertMarkerRelative(\n relativePos1: MergeTree.IRelativePosition,\n refType: MergeTree.ReferenceType,\n props?: MergeTree.PropertySet) {\n const segment = new MergeTree.Marker(refType);\n if (props) {\n segment.addProperties(props);\n }\n\n const pos = this.posFromRelativePos(relativePos1);\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * Inserts a marker at the postition\n *\n * @param pos - The postition to insert the marker at\n * @param refType - The reference type of the marker\n * @param props - The properties of the marker\n */\n public insertMarker(\n pos: number,\n refType: MergeTree.ReferenceType,\n props?: MergeTree.PropertySet) {\n const segment = new MergeTree.Marker(refType);\n if (props) {\n segment.addProperties(props);\n }\n\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n return insertOp;\n }\n\n /**\n * Inserts the text at the postition\n *\n * @param relativePos1 - The relative postition to insert the text at\n * @param text - The text to insert\n * @param props - The properties of text\n */\n public insertTextRelative(relativePos1: MergeTree.IRelativePosition, text: string, props?: MergeTree.PropertySet) {\n const segment = new MergeTree.TextSegment(text);\n if (props) {\n segment.addProperties(props);\n }\n\n const pos = this.posFromRelativePos(relativePos1);\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * Inserts the text at the postition\n *\n * @param pos - The postition to insert the text at\n * @param text - The text to insert\n * @param props - The properties of text\n */\n public insertText(pos: number, text: string, props?: MergeTree.PropertySet) {\n const segment = new MergeTree.TextSegment(text);\n if (props) {\n segment.addProperties(props);\n }\n\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n /**\n * Replaces a range with the provided text.\n *\n * @param start - The inclusive start of the range to replace\n * @param end - The exclusive end of the range to replace\n * @param text - The text to replace the range with\n * @param props - Optional. The properties of the replacement text\n */\n public replaceText(start: number, end: number, text: string, props?: MergeTree.PropertySet) {\n this.replaceRange(start, end, MergeTree.TextSegment.make(text, props));\n }\n\n public removeText(start: number, end: number) {\n return this.removeRange(start, end);\n }\n\n /**\n * Annotates the marker with the provided properties\n * and calls the callback on concensus.\n *\n * @param marker - The marker to annotate\n * @param props - The properties to annotate the marker with\n * @param consensusCallback - The callback called when consensus is reached\n */\n public annotateMarkerNotifyConsensus(\n marker: MergeTree.Marker,\n props: MergeTree.PropertySet,\n callback: (m: MergeTree.Marker) => void) {\n const annotateOp = this.client.annotateMarkerNotifyConsensus(marker, props, callback);\n if (annotateOp) {\n this.submitSequenceMessage(annotateOp);\n }\n }\n\n /**\n * Annotates the marker with the provided properties\n *\n * @param marker - The marker to annotate\n * @param props - The properties to annotate the marker with\n * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n */\n public annotateMarker(\n marker: MergeTree.Marker,\n props: MergeTree.PropertySet,\n combiningOp?: MergeTree.ICombiningOp) {\n const annotateOp = this.client.annotateMarker(marker, props, combiningOp);\n if (annotateOp) {\n this.submitSequenceMessage(annotateOp);\n }\n }\n\n public findTile(startPos: number | undefined, tileLabel: string, preceding = true) {\n return this.client.findTile(startPos, tileLabel, preceding);\n }\n\n public getTextAndMarkers(label: string) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getTextAndMarkers(segmentWindow.currentSeq, segmentWindow.clientId, label);\n }\n public getText(start?: number, end?: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"\", start, end);\n }\n /**\n * Adds spaces for markers and handles, so that position calculations account for them\n */\n public getTextWithPlaceholders() {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \");\n }\n public getTextRangeWithPlaceholders(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \", start, end);\n }\n public getTextRangeWithMarkers(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"*\", start, end);\n }\n\n public getMarkerFromId(id: string) {\n return this.client.getMarkerFromId(id);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],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AC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-unassigned-import\nimport { } from \"@fluidframework/core-interfaces\";\nimport * as MergeTree from \"@fluidframework/merge-tree\";\nimport { IFluidDataStoreRuntime, IChannelAttributes } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\nimport { SharedStringFactory } from \"./sequenceFactory\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n /**\n * Inserts the text at the position.\n * @param pos - The position to insert the text at\n * @param text - The text to insert\n * @param props - The properties of text\n */\n insertText(pos: number, text: string, props?: MergeTree.PropertySet);\n\n /**\n * Inserts a marker at the position.\n * @param pos - The position to insert the marker at\n * @param refType - The reference type of the marker\n * @param props - The properties of the marker\n */\n insertMarker(pos: number, refType: MergeTree.ReferenceType, props?: MergeTree.PropertySet);\n\n /**\n * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n */\n posFromRelativePos(relativePos: MergeTree.IRelativePosition);\n}\n\nexport type SharedStringSegment = MergeTree.TextSegment | MergeTree.Marker;\n\n/**\n * The Shared String is a specialized data structure for handling collaborative\n * text. It is based on a more general Sequence data structure but has\n * additional features that make working with text easier.\n *\n * In addition to text, a Shared String can also contain markers. Markers can be\n * used to store metadata at positions within the text, like the details of an\n * image or Fluid object that should be rendered with the text.\n *\n */\nexport class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {\n /**\n * Create a new shared string.\n * @param runtime - data store runtime the new shared string belongs to\n * @param id - optional name of the shared string\n * @returns newly create shared string (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n }\n\n /**\n * Get a factory for SharedString to register with the data store.\n * @returns a factory that creates and load SharedString\n */\n public static getFactory() {\n return new SharedStringFactory();\n }\n\n public get ISharedString(): ISharedString {\n return this;\n }\n\n private readonly mergeTreeTextHelper: MergeTree.MergeTreeTextHelper;\n\n constructor(document: IFluidDataStoreRuntime, public id: string, attributes: IChannelAttributes) {\n super(document, id, attributes, SharedStringFactory.segmentFromSpec);\n this.mergeTreeTextHelper = this.client.createTextHelper();\n }\n\n /**\n * Inserts a marker at a relative position.\n * @param relativePos1 - The relative position to insert the marker at\n * @param refType - The reference type of the marker\n * @param props - The properties of the marker\n */\n public insertMarkerRelative(\n relativePos1: MergeTree.IRelativePosition,\n refType: MergeTree.ReferenceType,\n props?: MergeTree.PropertySet) {\n const segment = new MergeTree.Marker(refType);\n if (props) {\n segment.addProperties(props);\n }\n\n const pos = this.posFromRelativePos(relativePos1);\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * {@inheritDoc ISharedString.insertMarker}\n */\n public insertMarker(\n pos: number,\n refType: MergeTree.ReferenceType,\n props?: MergeTree.PropertySet) {\n const segment = new MergeTree.Marker(refType);\n if (props) {\n segment.addProperties(props);\n }\n\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n return insertOp;\n }\n\n /**\n * Inserts the text at the position.\n * @param relativePos1 - The relative position to insert the text at\n * @param text - The text to insert\n * @param props - The properties of text\n */\n public insertTextRelative(relativePos1: MergeTree.IRelativePosition, text: string, props?: MergeTree.PropertySet) {\n const segment = new MergeTree.TextSegment(text);\n if (props) {\n segment.addProperties(props);\n }\n\n const pos = this.posFromRelativePos(relativePos1);\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * {@inheritDoc ISharedString.insertText}\n */\n public insertText(pos: number, text: string, props?: MergeTree.PropertySet) {\n const segment = new MergeTree.TextSegment(text);\n if (props) {\n segment.addProperties(props);\n }\n\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * Replaces a range with the provided text.\n * @param start - The inclusive start of the range to replace\n * @param end - The exclusive end of the range to replace\n * @param text - The text to replace the range with\n * @param props - Optional. The properties of the replacement text\n */\n public replaceText(start: number, end: number, text: string, props?: MergeTree.PropertySet) {\n this.replaceRange(start, end, MergeTree.TextSegment.make(text, props));\n }\n\n /**\n * Removes the text in the given range.\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to replace\n * @returns the message sent.\n */\n public removeText(start: number, end: number) {\n return this.removeRange(start, end);\n }\n\n /**\n * Annotates the marker with the provided properties and calls the callback on consensus.\n * @param marker - The marker to annotate\n * @param props - The properties to annotate the marker with\n * @param consensusCallback - The callback called when consensus is reached\n */\n public annotateMarkerNotifyConsensus(\n marker: MergeTree.Marker,\n props: MergeTree.PropertySet,\n callback: (m: MergeTree.Marker) => void) {\n const annotateOp = this.client.annotateMarkerNotifyConsensus(marker, props, callback);\n if (annotateOp) {\n this.submitSequenceMessage(annotateOp);\n }\n }\n\n /**\n * Annotates the marker with the provided properties.\n * @param marker - The marker to annotate\n * @param props - The properties to annotate the marker with\n * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n */\n public annotateMarker(\n marker: MergeTree.Marker,\n props: MergeTree.PropertySet,\n combiningOp?: MergeTree.ICombiningOp) {\n const annotateOp = this.client.annotateMarker(marker, props, combiningOp);\n if (annotateOp) {\n this.submitSequenceMessage(annotateOp);\n }\n }\n\n public findTile(startPos: number | undefined, tileLabel: string, preceding = true) {\n return this.client.findTile(startPos, tileLabel, preceding);\n }\n\n public getTextAndMarkers(label: string) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getTextAndMarkers(segmentWindow.currentSeq, segmentWindow.clientId, label);\n }\n\n /**\n * Retrieve text from the SharedString in string format.\n * @param start - The starting index of the text to retrieve, or 0 if omitted.\n * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n * @returns The requested text content as a string.\n */\n public getText(start?: number, end?: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"\", start, end);\n }\n\n /**\n * Adds spaces for markers and handles, so that position calculations account for them.\n */\n public getTextWithPlaceholders() {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \");\n }\n\n public getTextRangeWithPlaceholders(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \", start, end);\n }\n\n public getTextRangeWithMarkers(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"*\", start, end);\n }\n\n public getMarkerFromId(id: string) {\n return this.client.getMarkerFromId(id);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/sequence",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0-39313",
|
|
4
4
|
"description": "Distributed sequence",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": "https://github.com/microsoft/FluidFramework",
|
|
@@ -60,23 +60,23 @@
|
|
|
60
60
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
61
61
|
"@fluidframework/common-utils": "^0.32.1",
|
|
62
62
|
"@fluidframework/core-interfaces": "^0.39.7",
|
|
63
|
-
"@fluidframework/datastore-definitions": "
|
|
64
|
-
"@fluidframework/merge-tree": "
|
|
65
|
-
"@fluidframework/protocol-definitions": "^0.
|
|
66
|
-
"@fluidframework/runtime-definitions": "
|
|
67
|
-
"@fluidframework/runtime-utils": "
|
|
68
|
-
"@fluidframework/shared-object-base": "
|
|
69
|
-
"@fluidframework/telemetry-utils": "
|
|
63
|
+
"@fluidframework/datastore-definitions": "0.49.0-39313",
|
|
64
|
+
"@fluidframework/merge-tree": "0.49.0-39313",
|
|
65
|
+
"@fluidframework/protocol-definitions": "^0.1025.0-38844",
|
|
66
|
+
"@fluidframework/runtime-definitions": "0.49.0-39313",
|
|
67
|
+
"@fluidframework/runtime-utils": "0.49.0-39313",
|
|
68
|
+
"@fluidframework/shared-object-base": "0.49.0-39313",
|
|
69
|
+
"@fluidframework/telemetry-utils": "0.49.0-39313",
|
|
70
70
|
"uuid": "^8.3.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@fluid-internal/test-dds-utils": "
|
|
73
|
+
"@fluid-internal/test-dds-utils": "0.49.0-39313",
|
|
74
74
|
"@fluidframework/build-common": "^0.23.0",
|
|
75
75
|
"@fluidframework/eslint-config-fluid": "^0.23.0",
|
|
76
|
-
"@fluidframework/gitresources": "^0.1031.0",
|
|
77
|
-
"@fluidframework/mocha-test-setup": "
|
|
78
|
-
"@fluidframework/server-services-client": "^0.
|
|
79
|
-
"@fluidframework/test-runtime-utils": "
|
|
76
|
+
"@fluidframework/gitresources": "^0.1031.0-37526",
|
|
77
|
+
"@fluidframework/mocha-test-setup": "0.49.0-39313",
|
|
78
|
+
"@fluidframework/server-services-client": "^0.1032.0-39277",
|
|
79
|
+
"@fluidframework/test-runtime-utils": "0.49.0-39313",
|
|
80
80
|
"@microsoft/api-extractor": "^7.16.1",
|
|
81
81
|
"@types/diff": "^3.5.1",
|
|
82
82
|
"@types/mocha": "^8.2.2",
|
package/src/packageVersion.ts
CHANGED
package/src/sequence.ts
CHANGED
|
@@ -42,9 +42,36 @@ import { ISharedIntervalCollection } from "./sharedIntervalCollection";
|
|
|
42
42
|
const snapshotFileName = "header";
|
|
43
43
|
const contentPath = "content";
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Events emitted in response to changes to the sequence data.
|
|
47
|
+
*
|
|
48
|
+
* ### "sequenceDelta"
|
|
49
|
+
*
|
|
50
|
+
* The sequenceDelta event is emitted when segments are inserted, annotated, or removed.
|
|
51
|
+
*
|
|
52
|
+
* #### Listener signature
|
|
53
|
+
*
|
|
54
|
+
* ```typescript
|
|
55
|
+
* (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void
|
|
56
|
+
* ```
|
|
57
|
+
* - `event` - Various information on the segments that were modified.
|
|
58
|
+
*
|
|
59
|
+
* - `target` - The sequence itself.
|
|
60
|
+
*
|
|
61
|
+
* ### "maintenance"
|
|
62
|
+
*
|
|
63
|
+
* The maintenance event is emitted when segments are modified during merge-tree maintenance.
|
|
64
|
+
*
|
|
65
|
+
* #### Listener signature
|
|
66
|
+
*
|
|
67
|
+
* ```typescript
|
|
68
|
+
* (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void
|
|
69
|
+
* ```
|
|
70
|
+
* - `event` - Various information on the segments that were modified.
|
|
71
|
+
*
|
|
72
|
+
* - `target` - The sequence itself.
|
|
73
|
+
*/
|
|
74
|
+
export interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
|
|
48
75
|
(event: "sequenceDelta", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void);
|
|
49
76
|
(event: "maintenance",
|
|
50
77
|
listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void);
|
|
@@ -208,7 +235,7 @@ export abstract class SharedSegmentSequence<T extends MergeTree.ISegment>
|
|
|
208
235
|
/**
|
|
209
236
|
* Inserts the content of the register.
|
|
210
237
|
*
|
|
211
|
-
* @param pos - The
|
|
238
|
+
* @param pos - The position to insert the content at.
|
|
212
239
|
* @param register - The name of the register to get the content from
|
|
213
240
|
*/
|
|
214
241
|
public paste(pos: number, register: string) {
|
|
@@ -261,7 +288,7 @@ export abstract class SharedSegmentSequence<T extends MergeTree.ISegment>
|
|
|
261
288
|
/**
|
|
262
289
|
* Annotates the range with the provided properties
|
|
263
290
|
*
|
|
264
|
-
* @param start - The inclusive start
|
|
291
|
+
* @param start - The inclusive start position of the range to annotate
|
|
265
292
|
* @param end - The exclusive end position of the range to annotate
|
|
266
293
|
* @param props - The properties to annotate the range with
|
|
267
294
|
* @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
|
|
@@ -84,10 +84,16 @@ export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTy
|
|
|
84
84
|
return this.mergeTreeClient.longClientId;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* The first of the modified ranges.
|
|
89
|
+
*/
|
|
87
90
|
public get first(): Readonly<ISequenceDeltaRange<TOperation>> {
|
|
88
91
|
return this.pFirst.value;
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
/**
|
|
95
|
+
* The last of the modified ranges.
|
|
96
|
+
*/
|
|
91
97
|
public get last(): Readonly<ISequenceDeltaRange<TOperation>> {
|
|
92
98
|
return this.pLast.value;
|
|
93
99
|
}
|
|
@@ -105,6 +111,9 @@ export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTy
|
|
|
105
111
|
* Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.
|
|
106
112
|
*/
|
|
107
113
|
export class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {
|
|
114
|
+
/**
|
|
115
|
+
* Whether the event was caused by a locally-made change.
|
|
116
|
+
*/
|
|
108
117
|
public readonly isLocal: boolean;
|
|
109
118
|
|
|
110
119
|
constructor(
|
|
@@ -134,9 +143,18 @@ export class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenance
|
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
145
|
|
|
146
|
+
/**
|
|
147
|
+
* A range that has changed corresponding to a segment modification.
|
|
148
|
+
*/
|
|
137
149
|
export interface ISequenceDeltaRange<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
|
|
138
150
|
operation: TOperation;
|
|
151
|
+
/**
|
|
152
|
+
* The index of the start of the range.
|
|
153
|
+
*/
|
|
139
154
|
position: number;
|
|
155
|
+
/**
|
|
156
|
+
* The segment that corresponds to the range.
|
|
157
|
+
*/
|
|
140
158
|
segment: ISegment;
|
|
141
159
|
propertyDeltas: PropertySet;
|
|
142
160
|
}
|