@fluidframework/sequence 2.0.0-internal.1.1.1 → 2.0.0-internal.1.2.0.93071
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/README.md +19 -18
- 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 +2 -2
- package/dist/sequence.js +2 -2
- package/dist/sequence.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 +2 -2
- package/dist/sharedString.js +2 -2
- 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/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 +2 -2
- package/lib/sequence.js +2 -2
- package/lib/sequence.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 +2 -2
- package/lib/sharedString.js +2 -2
- 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 +17 -17
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +2 -2
- package/src/sharedIntervalCollection.ts +5 -5
- package/src/sharedString.ts +2 -2
- package/src/sparsematrix.ts +48 -35
package/README.md
CHANGED
|
@@ -156,7 +156,7 @@ specified range. Setting a property key to null will remove that property from t
|
|
|
156
156
|
### Sequence delta event
|
|
157
157
|
|
|
158
158
|
Whenever an operation is performed on a sequence a *sequenceDelta* event will be raised. This event provides the ranges
|
|
159
|
-
affected by the operation, the type of the operation, and the properties that were
|
|
159
|
+
affected by the operation, the type of the operation, and the properties that were changed by the operation.
|
|
160
160
|
|
|
161
161
|
```typescript
|
|
162
162
|
sharedString.on("sequenceDelta", ({ deltaOperation, ranges, isLocal }) => {
|
|
@@ -375,6 +375,24 @@ The following example illustrates these properties and highlights the major APIs
|
|
|
375
375
|
comments.removeIntervalById(comment.getIntervalId());
|
|
376
376
|
```
|
|
377
377
|
|
|
378
|
+
## SharedString
|
|
379
|
+
|
|
380
|
+
SharedString is a specialized data structure for handling collaborative text. It is based on a more general
|
|
381
|
+
Sequence data structure but has additional features that make working with text easier.
|
|
382
|
+
|
|
383
|
+
In addition to text, a SharedString can also contain markers.
|
|
384
|
+
Markers can be used to store metadata at positions within the text, like a reference to an image or Fluid object that should be rendered with the text.
|
|
385
|
+
|
|
386
|
+
Both markers and text are stored as segments in the SharedString.
|
|
387
|
+
Text segments will be split and merged when modifications are made to the SharedString and will therefore have variable length
|
|
388
|
+
matching the length of the text content they contain.
|
|
389
|
+
Marker segments are never split or merged, and always have a length of 1.
|
|
390
|
+
|
|
391
|
+
The length of the SharedString will be the combined length of all the text and marker segments.
|
|
392
|
+
Just like with other sequences, when talking about positions in a SharedString we use the terms near and far.
|
|
393
|
+
The nearest position in a SharedString is 0, and the farthest position is its length.
|
|
394
|
+
When comparing two positions the nearer positions is closer to 0, and the farther position is closer to the length.
|
|
395
|
+
|
|
378
396
|
### Intervals vs. markers
|
|
379
397
|
|
|
380
398
|
Interval endpoints and markers both implement *ReferencePosition* and seem to serve a similar function so it's not obvious how they differ and why you would choose one or the other.
|
|
@@ -394,23 +412,6 @@ Using the interval collection API has two main benefits:
|
|
|
394
412
|
If the ops were submitted using standard insert and delete APIs instead, there would be some potential for data loss if the delete
|
|
395
413
|
operation ended up acknowledged by the server but the insert operation did not.
|
|
396
414
|
|
|
397
|
-
## SharedString
|
|
398
|
-
|
|
399
|
-
The SharedString is a specialized data structure for handling collaborative text. It is based on a more general
|
|
400
|
-
Sequence data structure but has additional features that make working with text easier.
|
|
401
|
-
|
|
402
|
-
In addition to text, a SharedString can also contain markers. Markers can be used to store metadata at positions within
|
|
403
|
-
the text, like the details of an image or Fluid object that should be rendered with the text.
|
|
404
|
-
|
|
405
|
-
Both markers and text are stored as segments in the SharedString. Text segments will be split and merged when
|
|
406
|
-
modifications are made to the SharedString and will therefore have variable length matching the length of the text
|
|
407
|
-
content they contain. Marker segments are never split or merged, and always have a length of 1.
|
|
408
|
-
|
|
409
|
-
The length of the SharedString will be the combined length of all the text and marker segments. Just like with other
|
|
410
|
-
sequences, when talking about positions in a SharedString we use the terms near and far. The nearest position in a
|
|
411
|
-
SharedString is 0, and the farthest position is its length. When comparing two positions the nearer positions is closer
|
|
412
|
-
to 0, and the farther position is closer to the length.
|
|
413
|
-
|
|
414
415
|
### Examples
|
|
415
416
|
|
|
416
417
|
- Rich Text Editor Implementations
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/sequence";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.1.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.1.2.0.93071";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,6BAA6B,CAAC;AAClD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,6BAA6B,CAAC;AAClD,eAAO,MAAM,UAAU,+BAA+B,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/sequence";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.1.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.1.2.0.93071";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-internal.1.2.0.93071\";\n"]}
|
package/dist/sequence.d.ts
CHANGED
|
@@ -146,8 +146,8 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
146
146
|
getCurrentSeq(): number;
|
|
147
147
|
insertAtReferencePosition(pos: ReferencePosition, segment: T): void;
|
|
148
148
|
/**
|
|
149
|
-
* @deprecated
|
|
150
|
-
* are supported. Use
|
|
149
|
+
* @deprecated `IntervalCollection`s are created on a first-write wins basis, and concurrent creates
|
|
150
|
+
* are supported. Use {@link SharedSegmentSequence.getIntervalCollection} instead.
|
|
151
151
|
*/
|
|
152
152
|
waitIntervalCollection(label: string): Promise<IntervalCollection<SequenceInterval>>;
|
|
153
153
|
getIntervalCollection(label: string): IntervalCollection<SequenceInterval>;
|
package/dist/sequence.js
CHANGED
|
@@ -248,8 +248,8 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
|
-
* @deprecated
|
|
252
|
-
* are supported. Use
|
|
251
|
+
* @deprecated `IntervalCollection`s are created on a first-write wins basis, and concurrent creates
|
|
252
|
+
* are supported. Use {@link SharedSegmentSequence.getIntervalCollection} instead.
|
|
253
253
|
*/
|
|
254
254
|
async waitIntervalCollection(label) {
|
|
255
255
|
return this.intervalCollections.get(label);
|
package/dist/sequence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAAgF;AAChF,qEAA8D;AAC9D,+EAG8C;AAM9C,2DAwBoC;AACpC,iEAA2F;AAC3F,2EAO4C;AAI5C,6DAI8B;AAC9B,6CAA0C;AAE1C,6DAAoF;AAGpF,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,MAAM,WAAW,GAAG,SAAS,CAAC;AA2C9B,MAAsB,qBAClB,SAAQ,iCAA0C;IAiElD,YACqB,gBAAwC,EAClD,EAAU,EACjB,UAA8B,EACd,eAAiD;QAEjE,KAAK,CAAC,EAAE,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;QAL1C,qBAAgB,GAAhB,gBAAgB,CAAwB;QAClD,OAAE,GAAF,EAAE,CAAQ;QAED,oBAAe,GAAf,eAAe,CAAkC;QAfrE,mDAAmD;QACzC,mBAAc,GAAG,IAAI,uBAAQ,EAAQ,CAAC;QAChD,mDAAmD;QACl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AC,GAAG,CAAC,CAAC;YAC7D,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACpD;IACL,CAAC;CACJ;AAhmBD,sDAgmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { Deferred, bufferToString, assert } from \"@fluidframework/common-utils\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport {\n ISequencedDocumentMessage,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n Client,\n createAnnotateRangeOp,\n createGroupOp,\n createInsertOp,\n createRemoveRangeOp,\n ICombiningOp,\n IJSONSegment,\n IMergeTreeAnnotateMsg,\n IMergeTreeDeltaOp,\n IMergeTreeGroupMsg,\n IMergeTreeOp,\n IMergeTreeRemoveMsg,\n IRelativePosition,\n ISegment,\n ISegmentAction,\n LocalReferencePosition,\n matchProperties,\n MergeTreeDeltaType,\n PropertySet,\n RangeStackMap,\n ReferencePosition,\n ReferenceType,\n SegmentGroup,\n} from \"@fluidframework/merge-tree\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport {\n IFluidSerializer,\n makeHandlesSerializable,\n parseHandles,\n SharedObject,\n ISharedObjectEvents,\n SummarySerializer,\n} from \"@fluidframework/shared-object-base\";\nimport { IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\n\nimport {\n IntervalCollection,\n SequenceInterval,\n SequenceIntervalCollectionValueType,\n} from \"./intervalCollection\";\nimport { DefaultMap } from \"./defaultMap\";\nimport { IMapMessageLocalMetadata, IValueChanged } from \"./defaultMapInterfaces\";\nimport { SequenceDeltaEvent, SequenceMaintenanceEvent } from \"./sequenceDeltaEvent\";\nimport { ISharedIntervalCollection } from \"./sharedIntervalCollection\";\n\nconst snapshotFileName = \"header\";\nconst contentPath = \"content\";\n\n/**\n * Events emitted in response to changes to the sequence data.\n *\n * @remarks\n *\n * The following is the list of events emitted.\n *\n * ### \"sequenceDelta\"\n *\n * The sequenceDelta event is emitted when segments are inserted, annotated, or removed.\n *\n * #### Listener signature\n *\n * ```typescript\n * (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void\n * ```\n * - `event` - Various information on the segments that were modified.\n *\n * - `target` - The sequence itself.\n *\n * ### \"maintenance\"\n *\n * The maintenance event is emitted when segments are modified during merge-tree maintenance.\n *\n * #### Listener signature\n *\n * ```typescript\n * (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void\n * ```\n * - `event` - Various information on the segments that were modified.\n *\n * - `target` - The sequence itself.\n */\nexport interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {\n (event: \"createIntervalCollection\",\n listener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void);\n (event: \"sequenceDelta\", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void);\n (event: \"maintenance\",\n listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void);\n}\n\nexport abstract class SharedSegmentSequence<T extends ISegment>\n extends SharedObject<ISharedSegmentSequenceEvents>\n implements ISharedIntervalCollection<SequenceInterval> {\n get loaded(): Promise<void> {\n return this.loadedDeferred.promise;\n }\n\n private static createOpsFromDelta(event: SequenceDeltaEvent): IMergeTreeDeltaOp[] {\n const ops: IMergeTreeDeltaOp[] = [];\n for (const r of event.ranges) {\n switch (event.deltaOperation) {\n case MergeTreeDeltaType.ANNOTATE: {\n const lastAnnotate = ops[ops.length - 1] as IMergeTreeAnnotateMsg;\n const props = {};\n for (const key of Object.keys(r.propertyDeltas)) {\n props[key] = r.segment.properties?.[key] ?? null;\n }\n if (lastAnnotate && lastAnnotate.pos2 === r.position &&\n matchProperties(lastAnnotate.props, props)) {\n lastAnnotate.pos2 += r.segment.cachedLength;\n } else {\n ops.push(createAnnotateRangeOp(\n r.position,\n r.position + r.segment.cachedLength,\n props,\n undefined));\n }\n break;\n }\n\n case MergeTreeDeltaType.INSERT:\n ops.push(createInsertOp(\n r.position,\n r.segment.clone().toJSONObject()));\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n const lastRem = ops[ops.length - 1] as IMergeTreeRemoveMsg;\n if (lastRem?.pos1 === r.position) {\n lastRem.pos2 += r.segment.cachedLength;\n } else {\n ops.push(createRemoveRangeOp(\n r.position,\n r.position + r.segment.cachedLength));\n }\n break;\n }\n\n default:\n }\n }\n return ops;\n }\n\n protected client: Client;\n // Deferred that triggers once the object is loaded\n protected loadedDeferred = new Deferred<void>();\n // cache out going ops created when partial loading\n private readonly loadedDeferredOutgoingOps:\n [IMergeTreeOp, SegmentGroup | SegmentGroup[]][] = [];\n // cache incoming ops that arrive when partial loading\n private deferIncomingOps = true;\n private readonly loadedDeferredIncomingOps: ISequencedDocumentMessage[] = [];\n\n private messagesSinceMSNChange: ISequencedDocumentMessage[] = [];\n private readonly intervalCollections: DefaultMap<IntervalCollection<SequenceInterval>>;\n constructor(\n private readonly dataStoreRuntime: IFluidDataStoreRuntime,\n public id: string,\n attributes: IChannelAttributes,\n public readonly segmentFromSpec: (spec: IJSONSegment) => ISegment,\n ) {\n super(id, dataStoreRuntime, attributes, \"fluid_sequence_\");\n\n this.loadedDeferred.promise.catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"SequenceLoadFailed\" }, error);\n });\n\n this.client = new Client(\n segmentFromSpec,\n ChildLogger.create(this.logger, \"SharedSegmentSequence.MergeTreeClient\"),\n dataStoreRuntime.options);\n\n super.on(\"newListener\", (event) => {\n switch (event) {\n case \"sequenceDelta\":\n if (!this.client.mergeTreeDeltaCallback) {\n this.client.mergeTreeDeltaCallback = (opArgs, deltaArgs) => {\n this.emit(\"sequenceDelta\", new SequenceDeltaEvent(opArgs, deltaArgs, this.client), this);\n };\n }\n break;\n case \"maintenance\":\n if (!this.client.mergeTreeMaintenanceCallback) {\n this.client.mergeTreeMaintenanceCallback = (args, opArgs) => {\n this.emit(\"maintenance\", new SequenceMaintenanceEvent(opArgs, args, this.client), this);\n };\n }\n break;\n default:\n }\n });\n super.on(\"removeListener\", (event: string | symbol) => {\n switch (event) {\n case \"sequenceDelta\":\n if (super.listenerCount(event) === 0) {\n this.client.mergeTreeDeltaCallback = undefined;\n }\n break;\n case \"maintenance\":\n if (super.listenerCount(event) === 0) {\n this.client.mergeTreeMaintenanceCallback = undefined;\n }\n break;\n default:\n break;\n }\n });\n\n this.intervalCollections = new DefaultMap(\n this.serializer,\n this.handle,\n (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n new SequenceIntervalCollectionValueType(),\n );\n }\n\n /**\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to remove\n */\n public removeRange(start: number, end: number): IMergeTreeRemoveMsg {\n const removeOp = this.client.removeRangeLocal(start, end);\n if (removeOp) {\n this.submitSequenceMessage(removeOp);\n }\n return removeOp;\n }\n\n public groupOperation(groupOp: IMergeTreeGroupMsg) {\n this.client.localTransaction(groupOp);\n this.submitSequenceMessage(groupOp);\n }\n\n public getContainingSegment(pos: number) {\n return this.client.getContainingSegment<T>(pos);\n }\n\n /**\n * Returns the length of the current sequence for the client\n */\n public getLength() {\n return this.client.getLength();\n }\n\n /**\n * Returns the current position of a segment, and -1 if the segment\n * does not exist in this sequence\n * @param segment - The segment to get the position of\n */\n public getPosition(segment: ISegment): number {\n return this.client.getPosition(segment);\n }\n\n /**\n * Annotates the range with the provided properties\n *\n * @param start - The inclusive start position of the range to annotate\n * @param end - The exclusive end position of the range to annotate\n * @param props - The properties to annotate the range with\n * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n *\n */\n public annotateRange(\n start: number,\n end: number,\n props: PropertySet,\n combiningOp?: ICombiningOp) {\n const annotateOp =\n this.client.annotateRangeLocal(start, end, props, combiningOp);\n if (annotateOp) {\n this.submitSequenceMessage(annotateOp);\n }\n }\n\n public getPropertiesAtPosition(pos: number) {\n return this.client.getPropertiesAtPosition(pos);\n }\n\n public getRangeExtentsOfPosition(pos: number) {\n return this.client.getRangeExtentsOfPosition(pos);\n }\n\n public createLocalReferencePosition(\n segment: T,\n offset: number,\n refType: ReferenceType,\n properties: PropertySet | undefined): LocalReferencePosition {\n return this.client.createLocalReferencePosition(\n segment,\n offset,\n refType,\n properties);\n }\n\n public localReferencePositionToPosition(lref: ReferencePosition): number {\n return this.client.localReferencePositionToPosition(lref);\n }\n\n /**\n * Resolves a remote client's position against the local sequence\n * and returns the remote client's position relative to the local\n * sequence. The client ref seq must be above the minimum sequence number\n * or the return value will be undefined.\n * Generally this method is used in conjunction with signals which provide\n * point in time values for the below parameters, and is useful for things\n * like displaying user position. It should not be used with persisted values\n * as persisted values will quickly become invalid as the remoteClientRefSeq\n * moves below the minimum sequence number\n * @param remoteClientPosition - The remote client's position to resolve\n * @param remoteClientRefSeq - The reference sequence number of the remote client\n * @param remoteClientId - The client id of the remote client\n */\n public resolveRemoteClientPosition(\n remoteClientPosition: number,\n remoteClientRefSeq: number,\n remoteClientId: string): number {\n return this.client.resolveRemoteClientPosition(\n remoteClientPosition,\n remoteClientRefSeq,\n remoteClientId);\n }\n\n public submitSequenceMessage(message: IMergeTreeOp) {\n if (!this.isAttached()) {\n return;\n }\n const translated = makeHandlesSerializable(message, this.serializer, this.handle);\n const metadata = this.client.peekPendingSegmentGroups(\n message.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1);\n\n // if loading isn't complete, we need to cache\n // local ops until loading is complete, and then\n // they will be resent\n if (!this.loadedDeferred.isCompleted) {\n this.loadedDeferredOutgoingOps.push([translated, metadata]);\n } else {\n this.submitLocalMessage(translated, metadata);\n }\n }\n\n public removeLocalReferencePosition(lref: LocalReferencePosition) {\n return this.client.removeLocalReferencePosition(lref);\n }\n\n /**\n * Given a position specified relative to a marker id, lookup the marker\n * and convert the position to a character position.\n * @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.\n */\n public posFromRelativePos(relativePos: IRelativePosition) {\n return this.client.posFromRelativePos(relativePos);\n }\n\n /**\n * Walk the underlying segments of the sequence.\n * The walked segments may extend beyond the range\n * if the segments cross the ranges start or end boundaries.\n * Set split range to true to ensure only segments within the\n * range are walked.\n *\n * @param handler - The function to handle each segment\n * @param start - Optional. The start of range walk.\n * @param end - Optional. The end of range walk\n * @param accum - Optional. An object that will be passed to the handler for accumulation\n * @param splitRange - Optional. Splits boundary segments on the range boundaries\n */\n public walkSegments<TClientData>(\n handler: ISegmentAction<TClientData>,\n start?: number, end?: number, accum?: TClientData,\n splitRange: boolean = false) {\n return this.client.walkSegments<TClientData>(handler, start, end, accum, splitRange);\n }\n\n /**\n * @deprecated for internal use only. public export will be removed.\n * @internal\n */\n public getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap {\n return this.client.getStackContext(startPos, rangeLabels);\n }\n\n public getCurrentSeq() {\n return this.client.getCurrentSeq();\n }\n\n public insertAtReferencePosition(pos: ReferencePosition, segment: T) {\n const insertOp = this.client.insertAtReferencePositionLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * @deprecated - IntervalCollections are created on a first-write wins basis, and concurrent creates\n * are supported. Use `getIntervalCollection` instead.\n */\n public async waitIntervalCollection(\n label: string,\n ): Promise<IntervalCollection<SequenceInterval>> {\n return this.intervalCollections.get(label);\n }\n\n public getIntervalCollection(label: string): IntervalCollection<SequenceInterval> {\n return this.intervalCollections.get(label);\n }\n\n /**\n * @returns an iterable object that enumerates the IntervalCollection labels\n * Usage:\n * const iter = this.getIntervalCollectionKeys();\n * for (key of iter)\n * const collection = this.getIntervalCollection(key);\n * ...\n */\n public getIntervalCollectionLabels(): IterableIterator<string> {\n return this.intervalCollections.keys();\n }\n\n protected summarizeCore(\n serializer: IFluidSerializer,\n telemetryContext?: ITelemetryContext,\n ): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n\n // conditionally write the interval collection blob\n // only if it has entries\n if (this.intervalCollections.size > 0) {\n builder.addBlob(snapshotFileName, this.intervalCollections.serialize(serializer));\n }\n\n builder.addWithStats(contentPath, this.summarizeMergeTree(serializer));\n\n return builder.getSummaryTree();\n }\n\n /**\n * Runs serializer over the GC data for this SharedMatrix.\n * All the IFluidHandle's represent routes to other objects.\n */\n protected processGCDataCore(serializer: SummarySerializer) {\n if (this.intervalCollections.size > 0) {\n this.intervalCollections.serialize(serializer);\n }\n\n this.client.serializeGCData(this.handle, serializer);\n }\n\n /**\n * Replace the range specified from start to end with the provided segment\n * This is done by inserting the segment at the end of the range, followed\n * by removing the contents of the range\n * For a zero or reverse range (start \\>= end), insert at end do not remove anything\n * @param start - The start of the range to replace\n * @param end - The end of the range to replace\n * @param segment - The segment that will replace the range\n */\n protected replaceRange(start: number, end: number, segment: ISegment) {\n // Insert at the max end of the range when start > end, but still remove the range later\n const insertIndex: number = Math.max(start, end);\n\n // Insert first, so local references can slide to the inserted seg if any\n const insert = this.client.insertSegmentLocal(insertIndex, segment);\n if (insert) {\n if (start < end) {\n const remove = this.client.removeRangeLocal(start, end);\n this.submitSequenceMessage(createGroupOp(insert, remove));\n } else {\n this.submitSequenceMessage(insert);\n }\n }\n }\n\n protected onConnect() {\n // Update merge tree collaboration information with new client ID and then resend pending ops\n this.client.startOrUpdateCollaboration(this.runtime.clientId);\n }\n\n protected onDisconnect() { }\n\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n if (!this.intervalCollections.tryResubmitMessage(content, localOpMetadata as IMapMessageLocalMetadata)) {\n this.submitSequenceMessage(\n this.client.regeneratePendingOp(\n content as IMergeTreeOp,\n localOpMetadata as SegmentGroup | SegmentGroup[]));\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n */\n protected async loadCore(storage: IChannelStorageService) {\n if (await storage.contains(snapshotFileName)) {\n const blob = await storage.readBlob(snapshotFileName);\n const header = bufferToString(blob, \"utf8\");\n this.intervalCollections.populate(header);\n }\n\n try {\n // this will load the header, and return a promise\n // that will resolve when the body is loaded\n // and the catchup ops are available.\n const { catchupOpsP } = await this.client.load(\n this.runtime,\n new ObjectStoragePartition(storage, contentPath),\n this.serializer);\n\n // setup a promise to process the\n // catch up ops, and finishing the loading process\n const loadCatchUpOps = catchupOpsP\n .then((msgs) => {\n msgs.forEach((m) => {\n const collabWindow = this.client.getCollabWindow();\n if (m.minimumSequenceNumber < collabWindow.minSeq\n || m.referenceSequenceNumber < collabWindow.minSeq\n || m.sequenceNumber <= collabWindow.minSeq\n || m.sequenceNumber <= collabWindow.currentSeq) {\n throw new Error(`Invalid catchup operations in snapshot: ${JSON.stringify({\n op: {\n seq: m.sequenceNumber,\n minSeq: m.minimumSequenceNumber,\n refSeq: m.referenceSequenceNumber,\n },\n collabWindow: {\n seq: collabWindow.currentSeq,\n minSeq: collabWindow.minSeq,\n },\n })}`);\n }\n this.processMergeTreeMsg(m);\n });\n this.loadFinished();\n })\n .catch((error) => {\n this.loadFinished(error);\n });\n if (this.dataStoreRuntime.options?.sequenceInitializeFromHeaderOnly !== true) {\n // if we not doing partial load, await the catch up ops,\n // and the finalization of the load\n await loadCatchUpOps;\n }\n } catch (error) {\n this.loadFinished(error);\n }\n }\n\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n // if loading isn't complete, we need to cache all\n // incoming ops to be applied after loading is complete\n if (this.deferIncomingOps) {\n assert(!local, 0x072 /* \"Unexpected local op when loading not finished\" */);\n this.loadedDeferredIncomingOps.push(message);\n } else {\n assert(message.type === MessageType.Operation, 0x073 /* \"Sequence message not operation\" */);\n\n const handled = this.intervalCollections.tryProcessMessage(\n message.contents,\n local,\n message,\n localOpMetadata,\n );\n\n if (!handled) {\n this.processMergeTreeMsg(message, local);\n }\n }\n }\n\n protected didAttach() {\n // If we are not local, and we've attached we need to start generating and sending ops\n // so start collaboration and provide a default client id incase we are not connected\n if (this.isAttached()) {\n this.client.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n }\n }\n\n protected initializeLocalCore() {\n super.initializeLocalCore();\n this.loadFinished();\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n */\n protected applyStashedOp(content: any): unknown {\n return this.client.applyStashedOp(content);\n }\n\n private summarizeMergeTree(serializer: IFluidSerializer): ISummaryTreeWithStats {\n // Are we fully loaded? If not, things will go south\n assert(this.loadedDeferred.isCompleted, 0x074 /* \"Snapshot called when not fully loaded\" */);\n const minSeq = this.runtime.deltaManager.minimumSequenceNumber;\n\n this.processMinSequenceNumberChanged(minSeq);\n\n this.messagesSinceMSNChange.forEach((m) => { m.minimumSequenceNumber = minSeq; });\n\n return this.client.summarize(this.runtime, this.handle, serializer, this.messagesSinceMSNChange);\n }\n\n private processMergeTreeMsg(rawMessage: ISequencedDocumentMessage, local?: boolean) {\n const message = parseHandles(rawMessage, this.serializer);\n\n const ops: IMergeTreeDeltaOp[] = [];\n function transformOps(event: SequenceDeltaEvent) {\n ops.push(...SharedSegmentSequence.createOpsFromDelta(event));\n }\n const needsTransformation = message.referenceSequenceNumber !== message.sequenceNumber - 1;\n let stashMessage: Readonly<ISequencedDocumentMessage> = message;\n if (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {\n if (needsTransformation) {\n this.on(\"sequenceDelta\", transformOps);\n }\n }\n\n this.client.applyMsg(message, local);\n\n if (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {\n if (needsTransformation) {\n this.removeListener(\"sequenceDelta\", transformOps);\n // shallow clone the message as we only overwrite top level properties,\n // like referenceSequenceNumber and content only\n stashMessage = {\n ...message,\n referenceSequenceNumber: stashMessage.sequenceNumber - 1,\n contents: ops.length !== 1 ? createGroupOp(...ops) : ops[0],\n };\n }\n\n this.messagesSinceMSNChange.push(stashMessage);\n\n // Do GC every once in a while...\n if (this.messagesSinceMSNChange.length > 20\n && this.messagesSinceMSNChange[20].sequenceNumber < message.minimumSequenceNumber) {\n this.processMinSequenceNumberChanged(message.minimumSequenceNumber);\n }\n }\n }\n\n private processMinSequenceNumberChanged(minSeq: number) {\n let index = 0;\n for (; index < this.messagesSinceMSNChange.length; index++) {\n if (this.messagesSinceMSNChange[index].sequenceNumber > minSeq) {\n break;\n }\n }\n if (index !== 0) {\n this.messagesSinceMSNChange = this.messagesSinceMSNChange.slice(index);\n }\n }\n\n private loadFinished(error?: any) {\n if (!this.loadedDeferred.isCompleted) {\n // Initialize the interval collections\n this.initializeIntervalCollections();\n if (error) {\n this.loadedDeferred.reject(error);\n throw error;\n } else {\n // it is important this series remains synchronous\n // first we stop deferring incoming ops, and apply then all\n this.deferIncomingOps = false;\n for (const message of this.loadedDeferredIncomingOps) {\n this.processCore(message, false, undefined);\n }\n this.loadedDeferredIncomingOps.length = 0;\n\n // then resolve the loaded promise\n // and resubmit all the outstanding ops, as the snapshot\n // is fully loaded, and all outstanding ops are applied\n this.loadedDeferred.resolve();\n\n for (const [messageContent, opMetadata] of this.loadedDeferredOutgoingOps) {\n this.reSubmitCore(messageContent, opMetadata);\n }\n this.loadedDeferredOutgoingOps.length = 0;\n }\n }\n }\n\n private initializeIntervalCollections() {\n // Listen and initialize new SharedIntervalCollections\n this.intervalCollections.eventEmitter.on(\"create\", ({ key, previousValue }: IValueChanged, local: boolean) => {\n const intervalCollection = this.intervalCollections.get(key);\n if (!intervalCollection.attached) {\n intervalCollection.attachGraph(this.client, key);\n }\n assert(previousValue === undefined, 0x2c1 /* \"Creating an interval collection that already exists?\" */);\n this.emit(\"createIntervalCollection\", key, local, this);\n });\n\n // Initialize existing SharedIntervalCollections\n for (const key of this.intervalCollections.keys()) {\n const intervalCollection = this.intervalCollections.get(key);\n intervalCollection.attachGraph(this.client, key);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAAgF;AAChF,qEAA8D;AAC9D,+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AAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7D,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE;gBAC9B,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;aACpD;YACD,IAAA,qBAAM,EAAC,aAAa,KAAK,SAAS,EAAE,KAAK,CAAC,4DAA4D,CAAC,CAAC;YACxG,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,gDAAgD;QAChD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,EAAE;YAC/C,MAAM,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7D,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACpD;IACL,CAAC;CACJ;AAhmBD,sDAgmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { Deferred, bufferToString, assert } from \"@fluidframework/common-utils\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport {\n ISequencedDocumentMessage,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n Client,\n createAnnotateRangeOp,\n createGroupOp,\n createInsertOp,\n createRemoveRangeOp,\n ICombiningOp,\n IJSONSegment,\n IMergeTreeAnnotateMsg,\n IMergeTreeDeltaOp,\n IMergeTreeGroupMsg,\n IMergeTreeOp,\n IMergeTreeRemoveMsg,\n IRelativePosition,\n ISegment,\n ISegmentAction,\n LocalReferencePosition,\n matchProperties,\n MergeTreeDeltaType,\n PropertySet,\n RangeStackMap,\n ReferencePosition,\n ReferenceType,\n SegmentGroup,\n} from \"@fluidframework/merge-tree\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport {\n IFluidSerializer,\n makeHandlesSerializable,\n parseHandles,\n SharedObject,\n ISharedObjectEvents,\n SummarySerializer,\n} from \"@fluidframework/shared-object-base\";\nimport { IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\n\nimport {\n IntervalCollection,\n SequenceInterval,\n SequenceIntervalCollectionValueType,\n} from \"./intervalCollection\";\nimport { DefaultMap } from \"./defaultMap\";\nimport { IMapMessageLocalMetadata, IValueChanged } from \"./defaultMapInterfaces\";\nimport { SequenceDeltaEvent, SequenceMaintenanceEvent } from \"./sequenceDeltaEvent\";\nimport { ISharedIntervalCollection } from \"./sharedIntervalCollection\";\n\nconst snapshotFileName = \"header\";\nconst contentPath = \"content\";\n\n/**\n * Events emitted in response to changes to the sequence data.\n *\n * @remarks\n *\n * The following is the list of events emitted.\n *\n * ### \"sequenceDelta\"\n *\n * The sequenceDelta event is emitted when segments are inserted, annotated, or removed.\n *\n * #### Listener signature\n *\n * ```typescript\n * (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void\n * ```\n * - `event` - Various information on the segments that were modified.\n *\n * - `target` - The sequence itself.\n *\n * ### \"maintenance\"\n *\n * The maintenance event is emitted when segments are modified during merge-tree maintenance.\n *\n * #### Listener signature\n *\n * ```typescript\n * (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void\n * ```\n * - `event` - Various information on the segments that were modified.\n *\n * - `target` - The sequence itself.\n */\nexport interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {\n (event: \"createIntervalCollection\",\n listener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void);\n (event: \"sequenceDelta\", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void);\n (event: \"maintenance\",\n listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void);\n}\n\nexport abstract class SharedSegmentSequence<T extends ISegment>\n extends SharedObject<ISharedSegmentSequenceEvents>\n implements ISharedIntervalCollection<SequenceInterval> {\n get loaded(): Promise<void> {\n return this.loadedDeferred.promise;\n }\n\n private static createOpsFromDelta(event: SequenceDeltaEvent): IMergeTreeDeltaOp[] {\n const ops: IMergeTreeDeltaOp[] = [];\n for (const r of event.ranges) {\n switch (event.deltaOperation) {\n case MergeTreeDeltaType.ANNOTATE: {\n const lastAnnotate = ops[ops.length - 1] as IMergeTreeAnnotateMsg;\n const props = {};\n for (const key of Object.keys(r.propertyDeltas)) {\n props[key] = r.segment.properties?.[key] ?? null;\n }\n if (lastAnnotate && lastAnnotate.pos2 === r.position &&\n matchProperties(lastAnnotate.props, props)) {\n lastAnnotate.pos2 += r.segment.cachedLength;\n } else {\n ops.push(createAnnotateRangeOp(\n r.position,\n r.position + r.segment.cachedLength,\n props,\n undefined));\n }\n break;\n }\n\n case MergeTreeDeltaType.INSERT:\n ops.push(createInsertOp(\n r.position,\n r.segment.clone().toJSONObject()));\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n const lastRem = ops[ops.length - 1] as IMergeTreeRemoveMsg;\n if (lastRem?.pos1 === r.position) {\n lastRem.pos2 += r.segment.cachedLength;\n } else {\n ops.push(createRemoveRangeOp(\n r.position,\n r.position + r.segment.cachedLength));\n }\n break;\n }\n\n default:\n }\n }\n return ops;\n }\n\n protected client: Client;\n // Deferred that triggers once the object is loaded\n protected loadedDeferred = new Deferred<void>();\n // cache out going ops created when partial loading\n private readonly loadedDeferredOutgoingOps:\n [IMergeTreeOp, SegmentGroup | SegmentGroup[]][] = [];\n // cache incoming ops that arrive when partial loading\n private deferIncomingOps = true;\n private readonly loadedDeferredIncomingOps: ISequencedDocumentMessage[] = [];\n\n private messagesSinceMSNChange: ISequencedDocumentMessage[] = [];\n private readonly intervalCollections: DefaultMap<IntervalCollection<SequenceInterval>>;\n constructor(\n private readonly dataStoreRuntime: IFluidDataStoreRuntime,\n public id: string,\n attributes: IChannelAttributes,\n public readonly segmentFromSpec: (spec: IJSONSegment) => ISegment,\n ) {\n super(id, dataStoreRuntime, attributes, \"fluid_sequence_\");\n\n this.loadedDeferred.promise.catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"SequenceLoadFailed\" }, error);\n });\n\n this.client = new Client(\n segmentFromSpec,\n ChildLogger.create(this.logger, \"SharedSegmentSequence.MergeTreeClient\"),\n dataStoreRuntime.options);\n\n super.on(\"newListener\", (event) => {\n switch (event) {\n case \"sequenceDelta\":\n if (!this.client.mergeTreeDeltaCallback) {\n this.client.mergeTreeDeltaCallback = (opArgs, deltaArgs) => {\n this.emit(\"sequenceDelta\", new SequenceDeltaEvent(opArgs, deltaArgs, this.client), this);\n };\n }\n break;\n case \"maintenance\":\n if (!this.client.mergeTreeMaintenanceCallback) {\n this.client.mergeTreeMaintenanceCallback = (args, opArgs) => {\n this.emit(\"maintenance\", new SequenceMaintenanceEvent(opArgs, args, this.client), this);\n };\n }\n break;\n default:\n }\n });\n super.on(\"removeListener\", (event: string | symbol) => {\n switch (event) {\n case \"sequenceDelta\":\n if (super.listenerCount(event) === 0) {\n this.client.mergeTreeDeltaCallback = undefined;\n }\n break;\n case \"maintenance\":\n if (super.listenerCount(event) === 0) {\n this.client.mergeTreeMaintenanceCallback = undefined;\n }\n break;\n default:\n break;\n }\n });\n\n this.intervalCollections = new DefaultMap(\n this.serializer,\n this.handle,\n (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n new SequenceIntervalCollectionValueType(),\n );\n }\n\n /**\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to remove\n */\n public removeRange(start: number, end: number): IMergeTreeRemoveMsg {\n const removeOp = this.client.removeRangeLocal(start, end);\n if (removeOp) {\n this.submitSequenceMessage(removeOp);\n }\n return removeOp;\n }\n\n public groupOperation(groupOp: IMergeTreeGroupMsg) {\n this.client.localTransaction(groupOp);\n this.submitSequenceMessage(groupOp);\n }\n\n public getContainingSegment(pos: number) {\n return this.client.getContainingSegment<T>(pos);\n }\n\n /**\n * Returns the length of the current sequence for the client\n */\n public getLength() {\n return this.client.getLength();\n }\n\n /**\n * Returns the current position of a segment, and -1 if the segment\n * does not exist in this sequence\n * @param segment - The segment to get the position of\n */\n public getPosition(segment: ISegment): number {\n return this.client.getPosition(segment);\n }\n\n /**\n * Annotates the range with the provided properties\n *\n * @param start - The inclusive start position of the range to annotate\n * @param end - The exclusive end position of the range to annotate\n * @param props - The properties to annotate the range with\n * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n *\n */\n public annotateRange(\n start: number,\n end: number,\n props: PropertySet,\n combiningOp?: ICombiningOp) {\n const annotateOp =\n this.client.annotateRangeLocal(start, end, props, combiningOp);\n if (annotateOp) {\n this.submitSequenceMessage(annotateOp);\n }\n }\n\n public getPropertiesAtPosition(pos: number) {\n return this.client.getPropertiesAtPosition(pos);\n }\n\n public getRangeExtentsOfPosition(pos: number) {\n return this.client.getRangeExtentsOfPosition(pos);\n }\n\n public createLocalReferencePosition(\n segment: T,\n offset: number,\n refType: ReferenceType,\n properties: PropertySet | undefined): LocalReferencePosition {\n return this.client.createLocalReferencePosition(\n segment,\n offset,\n refType,\n properties);\n }\n\n public localReferencePositionToPosition(lref: ReferencePosition): number {\n return this.client.localReferencePositionToPosition(lref);\n }\n\n /**\n * Resolves a remote client's position against the local sequence\n * and returns the remote client's position relative to the local\n * sequence. The client ref seq must be above the minimum sequence number\n * or the return value will be undefined.\n * Generally this method is used in conjunction with signals which provide\n * point in time values for the below parameters, and is useful for things\n * like displaying user position. It should not be used with persisted values\n * as persisted values will quickly become invalid as the remoteClientRefSeq\n * moves below the minimum sequence number\n * @param remoteClientPosition - The remote client's position to resolve\n * @param remoteClientRefSeq - The reference sequence number of the remote client\n * @param remoteClientId - The client id of the remote client\n */\n public resolveRemoteClientPosition(\n remoteClientPosition: number,\n remoteClientRefSeq: number,\n remoteClientId: string): number {\n return this.client.resolveRemoteClientPosition(\n remoteClientPosition,\n remoteClientRefSeq,\n remoteClientId);\n }\n\n public submitSequenceMessage(message: IMergeTreeOp) {\n if (!this.isAttached()) {\n return;\n }\n const translated = makeHandlesSerializable(message, this.serializer, this.handle);\n const metadata = this.client.peekPendingSegmentGroups(\n message.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1);\n\n // if loading isn't complete, we need to cache\n // local ops until loading is complete, and then\n // they will be resent\n if (!this.loadedDeferred.isCompleted) {\n this.loadedDeferredOutgoingOps.push([translated, metadata]);\n } else {\n this.submitLocalMessage(translated, metadata);\n }\n }\n\n public removeLocalReferencePosition(lref: LocalReferencePosition) {\n return this.client.removeLocalReferencePosition(lref);\n }\n\n /**\n * Given a position specified relative to a marker id, lookup the marker\n * and convert the position to a character position.\n * @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.\n */\n public posFromRelativePos(relativePos: IRelativePosition) {\n return this.client.posFromRelativePos(relativePos);\n }\n\n /**\n * Walk the underlying segments of the sequence.\n * The walked segments may extend beyond the range\n * if the segments cross the ranges start or end boundaries.\n * Set split range to true to ensure only segments within the\n * range are walked.\n *\n * @param handler - The function to handle each segment\n * @param start - Optional. The start of range walk.\n * @param end - Optional. The end of range walk\n * @param accum - Optional. An object that will be passed to the handler for accumulation\n * @param splitRange - Optional. Splits boundary segments on the range boundaries\n */\n public walkSegments<TClientData>(\n handler: ISegmentAction<TClientData>,\n start?: number, end?: number, accum?: TClientData,\n splitRange: boolean = false) {\n return this.client.walkSegments<TClientData>(handler, start, end, accum, splitRange);\n }\n\n /**\n * @deprecated for internal use only. public export will be removed.\n * @internal\n */\n public getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap {\n return this.client.getStackContext(startPos, rangeLabels);\n }\n\n public getCurrentSeq() {\n return this.client.getCurrentSeq();\n }\n\n public insertAtReferencePosition(pos: ReferencePosition, segment: T) {\n const insertOp = this.client.insertAtReferencePositionLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * @deprecated `IntervalCollection`s are created on a first-write wins basis, and concurrent creates\n * are supported. Use {@link SharedSegmentSequence.getIntervalCollection} instead.\n */\n public async waitIntervalCollection(\n label: string,\n ): Promise<IntervalCollection<SequenceInterval>> {\n return this.intervalCollections.get(label);\n }\n\n public getIntervalCollection(label: string): IntervalCollection<SequenceInterval> {\n return this.intervalCollections.get(label);\n }\n\n /**\n * @returns an iterable object that enumerates the IntervalCollection labels\n * Usage:\n * const iter = this.getIntervalCollectionKeys();\n * for (key of iter)\n * const collection = this.getIntervalCollection(key);\n * ...\n */\n public getIntervalCollectionLabels(): IterableIterator<string> {\n return this.intervalCollections.keys();\n }\n\n protected summarizeCore(\n serializer: IFluidSerializer,\n telemetryContext?: ITelemetryContext,\n ): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n\n // conditionally write the interval collection blob\n // only if it has entries\n if (this.intervalCollections.size > 0) {\n builder.addBlob(snapshotFileName, this.intervalCollections.serialize(serializer));\n }\n\n builder.addWithStats(contentPath, this.summarizeMergeTree(serializer));\n\n return builder.getSummaryTree();\n }\n\n /**\n * Runs serializer over the GC data for this SharedMatrix.\n * All the IFluidHandle's represent routes to other objects.\n */\n protected processGCDataCore(serializer: SummarySerializer) {\n if (this.intervalCollections.size > 0) {\n this.intervalCollections.serialize(serializer);\n }\n\n this.client.serializeGCData(this.handle, serializer);\n }\n\n /**\n * Replace the range specified from start to end with the provided segment\n * This is done by inserting the segment at the end of the range, followed\n * by removing the contents of the range\n * For a zero or reverse range (start \\>= end), insert at end do not remove anything\n * @param start - The start of the range to replace\n * @param end - The end of the range to replace\n * @param segment - The segment that will replace the range\n */\n protected replaceRange(start: number, end: number, segment: ISegment) {\n // Insert at the max end of the range when start > end, but still remove the range later\n const insertIndex: number = Math.max(start, end);\n\n // Insert first, so local references can slide to the inserted seg if any\n const insert = this.client.insertSegmentLocal(insertIndex, segment);\n if (insert) {\n if (start < end) {\n const remove = this.client.removeRangeLocal(start, end);\n this.submitSequenceMessage(createGroupOp(insert, remove));\n } else {\n this.submitSequenceMessage(insert);\n }\n }\n }\n\n protected onConnect() {\n // Update merge tree collaboration information with new client ID and then resend pending ops\n this.client.startOrUpdateCollaboration(this.runtime.clientId);\n }\n\n protected onDisconnect() { }\n\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n if (!this.intervalCollections.tryResubmitMessage(content, localOpMetadata as IMapMessageLocalMetadata)) {\n this.submitSequenceMessage(\n this.client.regeneratePendingOp(\n content as IMergeTreeOp,\n localOpMetadata as SegmentGroup | SegmentGroup[]));\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n */\n protected async loadCore(storage: IChannelStorageService) {\n if (await storage.contains(snapshotFileName)) {\n const blob = await storage.readBlob(snapshotFileName);\n const header = bufferToString(blob, \"utf8\");\n this.intervalCollections.populate(header);\n }\n\n try {\n // this will load the header, and return a promise\n // that will resolve when the body is loaded\n // and the catchup ops are available.\n const { catchupOpsP } = await this.client.load(\n this.runtime,\n new ObjectStoragePartition(storage, contentPath),\n this.serializer);\n\n // setup a promise to process the\n // catch up ops, and finishing the loading process\n const loadCatchUpOps = catchupOpsP\n .then((msgs) => {\n msgs.forEach((m) => {\n const collabWindow = this.client.getCollabWindow();\n if (m.minimumSequenceNumber < collabWindow.minSeq\n || m.referenceSequenceNumber < collabWindow.minSeq\n || m.sequenceNumber <= collabWindow.minSeq\n || m.sequenceNumber <= collabWindow.currentSeq) {\n throw new Error(`Invalid catchup operations in snapshot: ${JSON.stringify({\n op: {\n seq: m.sequenceNumber,\n minSeq: m.minimumSequenceNumber,\n refSeq: m.referenceSequenceNumber,\n },\n collabWindow: {\n seq: collabWindow.currentSeq,\n minSeq: collabWindow.minSeq,\n },\n })}`);\n }\n this.processMergeTreeMsg(m);\n });\n this.loadFinished();\n })\n .catch((error) => {\n this.loadFinished(error);\n });\n if (this.dataStoreRuntime.options?.sequenceInitializeFromHeaderOnly !== true) {\n // if we not doing partial load, await the catch up ops,\n // and the finalization of the load\n await loadCatchUpOps;\n }\n } catch (error) {\n this.loadFinished(error);\n }\n }\n\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n // if loading isn't complete, we need to cache all\n // incoming ops to be applied after loading is complete\n if (this.deferIncomingOps) {\n assert(!local, 0x072 /* \"Unexpected local op when loading not finished\" */);\n this.loadedDeferredIncomingOps.push(message);\n } else {\n assert(message.type === MessageType.Operation, 0x073 /* \"Sequence message not operation\" */);\n\n const handled = this.intervalCollections.tryProcessMessage(\n message.contents,\n local,\n message,\n localOpMetadata,\n );\n\n if (!handled) {\n this.processMergeTreeMsg(message, local);\n }\n }\n }\n\n protected didAttach() {\n // If we are not local, and we've attached we need to start generating and sending ops\n // so start collaboration and provide a default client id incase we are not connected\n if (this.isAttached()) {\n this.client.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n }\n }\n\n protected initializeLocalCore() {\n super.initializeLocalCore();\n this.loadFinished();\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n */\n protected applyStashedOp(content: any): unknown {\n return this.client.applyStashedOp(content);\n }\n\n private summarizeMergeTree(serializer: IFluidSerializer): ISummaryTreeWithStats {\n // Are we fully loaded? If not, things will go south\n assert(this.loadedDeferred.isCompleted, 0x074 /* \"Snapshot called when not fully loaded\" */);\n const minSeq = this.runtime.deltaManager.minimumSequenceNumber;\n\n this.processMinSequenceNumberChanged(minSeq);\n\n this.messagesSinceMSNChange.forEach((m) => { m.minimumSequenceNumber = minSeq; });\n\n return this.client.summarize(this.runtime, this.handle, serializer, this.messagesSinceMSNChange);\n }\n\n private processMergeTreeMsg(rawMessage: ISequencedDocumentMessage, local?: boolean) {\n const message = parseHandles(rawMessage, this.serializer);\n\n const ops: IMergeTreeDeltaOp[] = [];\n function transformOps(event: SequenceDeltaEvent) {\n ops.push(...SharedSegmentSequence.createOpsFromDelta(event));\n }\n const needsTransformation = message.referenceSequenceNumber !== message.sequenceNumber - 1;\n let stashMessage: Readonly<ISequencedDocumentMessage> = message;\n if (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {\n if (needsTransformation) {\n this.on(\"sequenceDelta\", transformOps);\n }\n }\n\n this.client.applyMsg(message, local);\n\n if (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {\n if (needsTransformation) {\n this.removeListener(\"sequenceDelta\", transformOps);\n // shallow clone the message as we only overwrite top level properties,\n // like referenceSequenceNumber and content only\n stashMessage = {\n ...message,\n referenceSequenceNumber: stashMessage.sequenceNumber - 1,\n contents: ops.length !== 1 ? createGroupOp(...ops) : ops[0],\n };\n }\n\n this.messagesSinceMSNChange.push(stashMessage);\n\n // Do GC every once in a while...\n if (this.messagesSinceMSNChange.length > 20\n && this.messagesSinceMSNChange[20].sequenceNumber < message.minimumSequenceNumber) {\n this.processMinSequenceNumberChanged(message.minimumSequenceNumber);\n }\n }\n }\n\n private processMinSequenceNumberChanged(minSeq: number) {\n let index = 0;\n for (; index < this.messagesSinceMSNChange.length; index++) {\n if (this.messagesSinceMSNChange[index].sequenceNumber > minSeq) {\n break;\n }\n }\n if (index !== 0) {\n this.messagesSinceMSNChange = this.messagesSinceMSNChange.slice(index);\n }\n }\n\n private loadFinished(error?: any) {\n if (!this.loadedDeferred.isCompleted) {\n // Initialize the interval collections\n this.initializeIntervalCollections();\n if (error) {\n this.loadedDeferred.reject(error);\n throw error;\n } else {\n // it is important this series remains synchronous\n // first we stop deferring incoming ops, and apply then all\n this.deferIncomingOps = false;\n for (const message of this.loadedDeferredIncomingOps) {\n this.processCore(message, false, undefined);\n }\n this.loadedDeferredIncomingOps.length = 0;\n\n // then resolve the loaded promise\n // and resubmit all the outstanding ops, as the snapshot\n // is fully loaded, and all outstanding ops are applied\n this.loadedDeferred.resolve();\n\n for (const [messageContent, opMetadata] of this.loadedDeferredOutgoingOps) {\n this.reSubmitCore(messageContent, opMetadata);\n }\n this.loadedDeferredOutgoingOps.length = 0;\n }\n }\n }\n\n private initializeIntervalCollections() {\n // Listen and initialize new SharedIntervalCollections\n this.intervalCollections.eventEmitter.on(\"create\", ({ key, previousValue }: IValueChanged, local: boolean) => {\n const intervalCollection = this.intervalCollections.get(key);\n if (!intervalCollection.attached) {\n intervalCollection.attachGraph(this.client, key);\n }\n assert(previousValue === undefined, 0x2c1 /* \"Creating an interval collection that already exists?\" */);\n this.emit(\"createIntervalCollection\", key, local, this);\n });\n\n // Initialize existing SharedIntervalCollections\n for (const key of this.intervalCollections.keys()) {\n const intervalCollection = this.intervalCollections.get(key);\n intervalCollection.attachGraph(this.client, key);\n }\n }\n}\n"]}
|
|
@@ -8,8 +8,8 @@ import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
|
8
8
|
import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
9
|
import { Interval, IntervalCollection, ISerializableInterval } from "./intervalCollection";
|
|
10
10
|
/**
|
|
11
|
-
* The factory that defines the SharedIntervalCollection
|
|
12
|
-
* @deprecated
|
|
11
|
+
* The factory that defines the SharedIntervalCollection.
|
|
12
|
+
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
13
13
|
*/
|
|
14
14
|
export declare class SharedIntervalCollectionFactory implements IChannelFactory {
|
|
15
15
|
static readonly Type = "https://graph.microsoft.com/types/sharedIntervalCollection";
|
|
@@ -27,7 +27,7 @@ export interface ISharedIntervalCollection<TInterval extends ISerializableInterv
|
|
|
27
27
|
getIntervalCollection(label: string): IntervalCollection<TInterval>;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* @deprecated
|
|
30
|
+
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
31
31
|
*/
|
|
32
32
|
export declare class SharedIntervalCollection extends SharedObject implements ISharedIntervalCollection<Interval> {
|
|
33
33
|
/**
|
|
@@ -52,8 +52,8 @@ export declare class SharedIntervalCollection extends SharedObject implements IS
|
|
|
52
52
|
*/
|
|
53
53
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
54
54
|
/**
|
|
55
|
-
* @deprecated
|
|
56
|
-
* are supported. Use
|
|
55
|
+
* @deprecated `IntervalCollection`s are created on a first-write wins basis, and concurrent creates
|
|
56
|
+
* are supported. Use {@link SharedIntervalCollection.getIntervalCollection} instead.
|
|
57
57
|
*/
|
|
58
58
|
waitIntervalCollection(label: string): Promise<IntervalCollection<Interval>>;
|
|
59
59
|
getIntervalCollection(label: string): IntervalCollection<Interval>;
|
|
@@ -14,8 +14,8 @@ const defaultMap_1 = require("./defaultMap");
|
|
|
14
14
|
const packageVersion_1 = require("./packageVersion");
|
|
15
15
|
const snapshotFileName = "header";
|
|
16
16
|
/**
|
|
17
|
-
* The factory that defines the SharedIntervalCollection
|
|
18
|
-
* @deprecated
|
|
17
|
+
* The factory that defines the SharedIntervalCollection.
|
|
18
|
+
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
19
19
|
*/
|
|
20
20
|
class SharedIntervalCollectionFactory {
|
|
21
21
|
get type() {
|
|
@@ -46,7 +46,7 @@ SharedIntervalCollectionFactory.Attributes = {
|
|
|
46
46
|
packageVersion: packageVersion_1.pkgVersion,
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
|
-
* @deprecated
|
|
49
|
+
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
50
50
|
*/
|
|
51
51
|
class SharedIntervalCollection extends shared_object_base_1.SharedObject {
|
|
52
52
|
/**
|
|
@@ -77,8 +77,8 @@ class SharedIntervalCollection extends shared_object_base_1.SharedObject {
|
|
|
77
77
|
return new SharedIntervalCollectionFactory();
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
* @deprecated
|
|
81
|
-
* are supported. Use
|
|
80
|
+
* @deprecated `IntervalCollection`s are created on a first-write wins basis, and concurrent creates
|
|
81
|
+
* are supported. Use {@link SharedIntervalCollection.getIntervalCollection} instead.
|
|
82
82
|
*/
|
|
83
83
|
async waitIntervalCollection(label) {
|
|
84
84
|
return this.intervalCollections.get(this.getIntervalCollectionPath(label));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedIntervalCollection.js","sourceRoot":"","sources":["../src/sharedIntervalCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+DAA8D;AAQ9D,+EAA8F;AAE9F,2EAI4C;AAC5C,6DAK8B;AAC9B,6CAA0C;AAC1C,qDAA8C;AAG9C,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAa,+BAA+B;IASxC,IAAW,IAAI;QACX,OAAO,+BAA+B,CAAC,IAAI,CAAC;IAChD,CAAC;IAED,IAAW,UAAU;QACjB,OAAO,+BAA+B,CAAC,UAAU,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAC9B,MAAM,GAAG,GAAG,IAAI,wBAAwB,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAClE,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzB,OAAO,GAAG,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,OAA+B,EAAE,EAAU;QACrD,MAAM,GAAG,GAAG,IAAI,wBAAwB,CACpC,EAAE,EACF,OAAO,EACP,IAAI,CAAC,UAAU,CAAC,CAAC;QACrB,GAAG,CAAC,eAAe,EAAE,CAAC;QAEtB,OAAO,GAAG,CAAC;IACf,CAAC;;AAvCL,0EAwCC;AAvC0B,oCAAI,GAAG,4DAA4D,CAAC;AAEpE,0CAAU,GAAuB;IACpD,IAAI,EAAE,+BAA+B,CAAC,IAAI;IAC1C,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,2BAAU;CAC7B,CAAC;AAwCN;;GAEG;AACH,MAAa,wBACT,SAAQ,iCAA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zD,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,EAAE,eAA2C,CAAC,CAAC;IACtG,CAAC;IAES,YAAY,KAAK,CAAC;IAE5B;;OAEG;IACO,KAAK,CAAC,QAAQ,CAAC,OAA+B;QACpD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAES,WAAW,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QAC9F,IAAI,OAAO,CAAC,IAAI,KAAK,kCAAW,CAAC,SAAS,EAAE;YACxC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;SACjG;IACL,CAAC;IAED;;;OAGG;IACO,yBAAyB,CAAC,KAAa;QAC7C,OAAO,KAAK,CAAC;IACjB,CAAC;IAES,cAAc;QACpB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ;AA/FD,4DA+FC;KAzEoB,MAAM,CAAC,WAAW","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluidframework/common-utils\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n createSingleBlobSummary,\n IFluidSerializer,\n SharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport {\n Interval,\n IntervalCollection,\n IntervalCollectionValueType,\n ISerializableInterval,\n} from \"./intervalCollection\";\nimport { DefaultMap } from \"./defaultMap\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IMapMessageLocalMetadata } from \"./defaultMapInterfaces\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * The factory that defines the SharedIntervalCollection
|
|
1
|
+
{"version":3,"file":"sharedIntervalCollection.js","sourceRoot":"","sources":["../src/sharedIntervalCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+DAA8D;AAQ9D,+EAA8F;AAE9F,2EAI4C;AAC5C,6DAK8B;AAC9B,6CAA0C;AAC1C,qDAA8C;AAG9C,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAa,+BAA+B;IASxC,IAAW,IAAI;QACX,OAAO,+BAA+B,CAAC,IAAI,CAAC;IAChD,CAAC;IAED,IAAW,UAAU;QACjB,OAAO,+BAA+B,CAAC,UAAU,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAC9B,MAAM,GAAG,GAAG,IAAI,wBAAwB,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAClE,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzB,OAAO,GAAG,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,OAA+B,EAAE,EAAU;QACrD,MAAM,GAAG,GAAG,IAAI,wBAAwB,CACpC,EAAE,EACF,OAAO,EACP,IAAI,CAAC,UAAU,CAAC,CAAC;QACrB,GAAG,CAAC,eAAe,EAAE,CAAC;QAEtB,OAAO,GAAG,CAAC;IACf,CAAC;;AAvCL,0EAwCC;AAvC0B,oCAAI,GAAG,4DAA4D,CAAC;AAEpE,0CAAU,GAAuB;IACpD,IAAI,EAAE,+BAA+B,CAAC,IAAI;IAC1C,qBAAqB,EAAE,KAAK;IAC5B,cAAc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U,CAAC,CAAC,CAAC;IACrG,CAAC;IAES,YAAY,CAAC,OAAY,EAAE,eAAwB;QACzD,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,EAAE,eAA2C,CAAC,CAAC;IACtG,CAAC;IAES,YAAY,KAAK,CAAC;IAE5B;;OAEG;IACO,KAAK,CAAC,QAAQ,CAAC,OAA+B;QACpD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAES,WAAW,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QAC9F,IAAI,OAAO,CAAC,IAAI,KAAK,kCAAW,CAAC,SAAS,EAAE;YACxC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;SACjG;IACL,CAAC;IAED;;;OAGG;IACO,yBAAyB,CAAC,KAAa;QAC7C,OAAO,KAAK,CAAC;IACjB,CAAC;IAES,cAAc;QACpB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ;AA/FD,4DA+FC;KAzEoB,MAAM,CAAC,WAAW","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluidframework/common-utils\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n createSingleBlobSummary,\n IFluidSerializer,\n SharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport {\n Interval,\n IntervalCollection,\n IntervalCollectionValueType,\n ISerializableInterval,\n} from \"./intervalCollection\";\nimport { DefaultMap } from \"./defaultMap\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IMapMessageLocalMetadata } from \"./defaultMapInterfaces\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * The factory that defines the SharedIntervalCollection.\n * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.\n */\nexport class SharedIntervalCollectionFactory implements IChannelFactory {\n public static readonly Type = \"https://graph.microsoft.com/types/sharedIntervalCollection\";\n\n public static readonly Attributes: IChannelAttributes = {\n type: SharedIntervalCollectionFactory.Type,\n snapshotFormatVersion: \"0.1\",\n packageVersion: pkgVersion,\n };\n\n public get type() {\n return SharedIntervalCollectionFactory.Type;\n }\n\n public get attributes() {\n return SharedIntervalCollectionFactory.Attributes;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n */\n public async load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n attributes: IChannelAttributes): Promise<SharedIntervalCollection> {\n const map = new SharedIntervalCollection(id, runtime, attributes);\n await map.load(services);\n\n return map;\n }\n\n public create(runtime: IFluidDataStoreRuntime, id: string): SharedIntervalCollection {\n const map = new SharedIntervalCollection(\n id,\n runtime,\n this.attributes);\n map.initializeLocal();\n\n return map;\n }\n}\n\nexport interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {\n waitIntervalCollection(label: string): Promise<IntervalCollection<TInterval>>;\n getIntervalCollection(label: string): IntervalCollection<TInterval>;\n}\n\n/**\n * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.\n */\nexport class SharedIntervalCollection\n extends SharedObject implements ISharedIntervalCollection<Interval> {\n /**\n * Create a SharedIntervalCollection\n *\n * @param runtime - data store runtime the new shared map belongs to\n * @param id - optional name of the shared map\n * @returns newly create shared map (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, SharedIntervalCollectionFactory.Type) as SharedIntervalCollection;\n }\n\n /**\n * Get a factory for SharedIntervalCollection to register with the data store.\n *\n * @returns a factory that creates and load SharedIntervalCollection\n */\n public static getFactory(): IChannelFactory {\n return new SharedIntervalCollectionFactory();\n }\n\n public readonly [Symbol.toStringTag]: string = \"SharedIntervalCollection\";\n private readonly intervalCollections: DefaultMap<IntervalCollection<Interval>>;\n\n /**\n * Constructs a new shared SharedIntervalCollection. If the object is non-local an id and service interfaces will\n * be provided\n */\n constructor(\n id: string,\n runtime: IFluidDataStoreRuntime,\n attributes: IChannelAttributes,\n ) {\n super(id, runtime, attributes, \"fluid_sharedIntervalCollection_\");\n this.intervalCollections = new DefaultMap(\n this.serializer,\n this.handle,\n (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n new IntervalCollectionValueType(),\n );\n }\n\n /**\n * @deprecated `IntervalCollection`s are created on a first-write wins basis, and concurrent creates\n * are supported. Use {@link SharedIntervalCollection.getIntervalCollection} instead.\n */\n public async waitIntervalCollection(\n label: string,\n ): Promise<IntervalCollection<Interval>> {\n return this.intervalCollections.get(this.getIntervalCollectionPath(label));\n }\n\n public getIntervalCollection(label: string): IntervalCollection<Interval> {\n const realLabel = this.getIntervalCollectionPath(label);\n const sharedCollection = this.intervalCollections.get(realLabel);\n return sharedCollection;\n }\n\n protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n return createSingleBlobSummary(snapshotFileName, this.intervalCollections.serialize(serializer));\n }\n\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n this.intervalCollections.tryResubmitMessage(content, localOpMetadata as IMapMessageLocalMetadata);\n }\n\n protected onDisconnect() { }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n */\n protected async loadCore(storage: IChannelStorageService) {\n const blob = await storage.readBlob(snapshotFileName);\n const header = bufferToString(blob, \"utf8\");\n this.intervalCollections.populate(header);\n }\n\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n if (message.type === MessageType.Operation) {\n this.intervalCollections.tryProcessMessage(message.contents, local, message, localOpMetadata);\n }\n }\n\n /**\n * Creates the full path of the intervalCollection label\n * @param label - the incoming label\n */\n protected getIntervalCollectionPath(label: string): string {\n return label;\n }\n\n protected applyStashedOp() {\n throw new Error(\"not implemented\");\n }\n}\n"]}
|
package/dist/sharedString.d.ts
CHANGED
|
@@ -113,7 +113,7 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
113
113
|
pos: number;
|
|
114
114
|
};
|
|
115
115
|
/**
|
|
116
|
-
* @deprecated
|
|
116
|
+
* @deprecated Use the free function {@link getTextAndMarkers} exported by this package instead.
|
|
117
117
|
*/
|
|
118
118
|
getTextAndMarkers(label: string): {
|
|
119
119
|
parallelText: string[];
|
|
@@ -131,7 +131,7 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
131
131
|
*/
|
|
132
132
|
getTextWithPlaceholders(start?: number, end?: number): string;
|
|
133
133
|
/**
|
|
134
|
-
* @deprecated
|
|
134
|
+
* @deprecated Use {@link SharedString.getTextWithPlaceholders} instead.
|
|
135
135
|
*/
|
|
136
136
|
getTextRangeWithPlaceholders(start: number, end: number): string;
|
|
137
137
|
getTextRangeWithMarkers(start: number, end: number): string;
|
package/dist/sharedString.js
CHANGED
|
@@ -151,7 +151,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
151
151
|
return this.client.findTile(startPos, tileLabel, preceding);
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
|
-
* @deprecated
|
|
154
|
+
* @deprecated Use the free function {@link getTextAndMarkers} exported by this package instead.
|
|
155
155
|
*/
|
|
156
156
|
getTextAndMarkers(label) {
|
|
157
157
|
const segmentWindow = this.client.getCollabWindow();
|
|
@@ -175,7 +175,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
175
175
|
return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ", start, end);
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
|
-
* @deprecated
|
|
178
|
+
* @deprecated Use {@link SharedString.getTextWithPlaceholders} instead.
|
|
179
179
|
*/
|
|
180
180
|
getTextRangeWithPlaceholders(start, end) {
|
|
181
181
|
return this.getTextWithPlaceholders(start, end);
|
package/dist/sharedString.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAYoC;AAEpC,yCAAmD;AACnD,uDAAwD;AA8BxD;;;;;;;;;GASG;AACH,MAAa,YAAa,SAAQ,gCAA0C;IAyBxE,YAAY,QAAgC,EAAS,EAAU,EAAE,UAA8B;QAC3F,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,qCAAmB,CAAC,eAAe,CAAC,CAAC;QADpB,OAAE,GAAF,EAAE,CAAQ;QAE3D,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC9D,CAAC;IA3BD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAC7D,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,qCAAmB,CAAC,IAAI,CAAiB,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,UAAU;QACpB,OAAO,IAAI,qCAAmB,EAAE,CAAC;IACrC,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IASD;;;;;OAKG;IACI,oBAAoB,CACvB,YAA+B,EAC/B,OAAsB,EACtB,KAAmB;QACnB,MAAM,OAAO,GAAG,IAAI,mBAAM,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,KAAK,EAAE;YACP,OAAO,CAAC,aAAa,CAAC,KAAK,C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E,GAAG,CAAC,CAAC;IAC/G,CAAC;IAEM,eAAe,CAAC,EAAU;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACrD,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE;YACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;SAClD;aAAM;YACH,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;SAC5C;IACL,CAAC;CACJ;AA1ND,oCA0NC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,iBAAiB,CAAC,YAA0B,EAAE,KAAa;IAIvE,OAAO,YAAY,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AALD,8CAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ICombiningOp,\n IMergeTreeInsertMsg,\n IMergeTreeRemoveMsg,\n IMergeTreeTextHelper,\n IRelativePosition,\n ISegment,\n Marker,\n PropertySet,\n ReferencePosition,\n ReferenceType,\n TextSegment,\n} 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 the text\n */\n insertText(pos: number, text: string, props?: PropertySet): void;\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: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg;\n\n /**\n * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n */\n posFromRelativePos(relativePos: IRelativePosition): number;\n}\n\nexport type SharedStringSegment = TextSegment | 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: IMergeTreeTextHelper;\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: IRelativePosition,\n refType: ReferenceType,\n props?: PropertySet) {\n const segment = new 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: ReferenceType,\n props?: PropertySet): IMergeTreeInsertMsg {\n const segment = new 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: IRelativePosition, text: string, props?: PropertySet) {\n const segment = new 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?: PropertySet) {\n const segment = new 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?: PropertySet) {\n this.replaceRange(start, end, 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): IMergeTreeRemoveMsg {\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: Marker,\n props: PropertySet,\n callback: (m: 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: Marker,\n props: PropertySet,\n combiningOp?: 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 tile: ReferencePosition;\n pos: number;\n } {\n return this.client.findTile(startPos, tileLabel, preceding);\n }\n\n /**\n * @deprecated - use the free function `getTextAndMarkers` exported by this package instead.\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(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 * @deprecated - use `getTextWithPlaceholders` instead.\n */\n public getTextRangeWithPlaceholders(start: number, end: number) {\n return this.getTextWithPlaceholders(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): ISegment {\n return this.client.getMarkerFromId(id);\n }\n\n /**\n * Revert an op\n */\n protected rollback(content: any, localOpMetadata: unknown): void {\n if (this.client.rollback !== undefined) {\n this.client.rollback(content, localOpMetadata);\n } else {\n super.rollback(content, localOpMetadata);\n }\n }\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n *\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n */\nexport function getTextAndMarkers(sharedString: SharedString, label: string): {\n parallelText: string[];\n parallelMarkers: Marker[];\n} {\n return sharedString.getTextAndMarkers(label);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAYoC;AAEpC,yCAAmD;AACnD,uDAAwD;AA8BxD;;;;;;;;;GASG;AACH,MAAa,YAAa,SAAQ,gCAA0C;IAyBxE,YAAY,QAAgC,EAAS,EAAU,EAAE,UAA8B;QAC3F,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,qCAAmB,CAAC,eAAe,CAAC,CAAC;QADpB,OAAE,GAAF,EAAE,CAAQ;QAE3D,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC9D,CAAC;IA3BD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAC7D,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,qCAAmB,CAAC,IAAI,CAAiB,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,UAAU;QACpB,OAAO,IAAI,qCAAmB,EAAE,CAAC;IACrC,CAAC;IAED,IAAW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D,CAAC;IAEM,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;IAED;;OAEG;IACO,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACrD,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE;YACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;SAClD;aAAM;YACH,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;SAC5C;IACL,CAAC;CACJ;AA1ND,oCA0NC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,iBAAiB,CAAC,YAA0B,EAAE,KAAa;IAIvE,OAAO,YAAY,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AALD,8CAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ICombiningOp,\n IMergeTreeInsertMsg,\n IMergeTreeRemoveMsg,\n IMergeTreeTextHelper,\n IRelativePosition,\n ISegment,\n Marker,\n PropertySet,\n ReferencePosition,\n ReferenceType,\n TextSegment,\n} 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 the text\n */\n insertText(pos: number, text: string, props?: PropertySet): void;\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: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg;\n\n /**\n * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n */\n posFromRelativePos(relativePos: IRelativePosition): number;\n}\n\nexport type SharedStringSegment = TextSegment | 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: IMergeTreeTextHelper;\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: IRelativePosition,\n refType: ReferenceType,\n props?: PropertySet) {\n const segment = new 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: ReferenceType,\n props?: PropertySet): IMergeTreeInsertMsg {\n const segment = new 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: IRelativePosition, text: string, props?: PropertySet) {\n const segment = new 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?: PropertySet) {\n const segment = new 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?: PropertySet) {\n this.replaceRange(start, end, 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): IMergeTreeRemoveMsg {\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: Marker,\n props: PropertySet,\n callback: (m: 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: Marker,\n props: PropertySet,\n combiningOp?: 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 tile: ReferencePosition;\n pos: number;\n } {\n return this.client.findTile(startPos, tileLabel, preceding);\n }\n\n /**\n * @deprecated Use the free function {@link getTextAndMarkers} exported by this package instead.\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(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 * @deprecated Use {@link SharedString.getTextWithPlaceholders} instead.\n */\n public getTextRangeWithPlaceholders(start: number, end: number) {\n return this.getTextWithPlaceholders(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): ISegment {\n return this.client.getMarkerFromId(id);\n }\n\n /**\n * Revert an op\n */\n protected rollback(content: any, localOpMetadata: unknown): void {\n if (this.client.rollback !== undefined) {\n this.client.rollback(content, localOpMetadata);\n } else {\n super.rollback(content, localOpMetadata);\n }\n }\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n *\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n */\nexport function getTextAndMarkers(sharedString: SharedString, label: string): {\n parallelText: string[];\n parallelMarkers: Marker[];\n} {\n return sharedString.getTextAndMarkers(label);\n}\n"]}
|