@fluidframework/sequence 1.2.2 → 2.0.0-internal.1.0.0.82159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/intervalCollection.d.ts +5 -10
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +20 -35
- package/dist/intervalCollection.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sequence.d.ts +5 -17
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +4 -28
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +0 -6
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +0 -1
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sharedString.d.ts +4 -0
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +11 -0
- package/dist/sharedString.js.map +1 -1
- package/lib/intervalCollection.d.ts +5 -10
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +21 -36
- package/lib/intervalCollection.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sequence.d.ts +5 -17
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +5 -29
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +0 -6
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +0 -1
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sharedString.d.ts +4 -0
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +11 -0
- package/lib/sharedString.js.map +1 -1
- package/package.json +60 -20
- package/src/intervalCollection.ts +33 -53
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +4 -36
- package/src/sequenceDeltaEvent.ts +0 -7
- package/src/sharedString.ts +13 -2
package/lib/sequence.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Deferred, bufferToString, assert } from "@fluidframework/common-utils";
|
|
6
6
|
import { ChildLogger } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { MessageType, } from "@fluidframework/protocol-definitions";
|
|
8
|
-
import { Client, createAnnotateRangeOp, createGroupOp, createInsertOp, createRemoveRangeOp,
|
|
8
|
+
import { Client, createAnnotateRangeOp, createGroupOp, createInsertOp, createRemoveRangeOp, matchProperties, MergeTreeDeltaType, } from "@fluidframework/merge-tree";
|
|
9
9
|
import { ObjectStoragePartition, SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
10
10
|
import { makeHandlesSerializable, parseHandles, SharedObject, } from "@fluidframework/shared-object-base";
|
|
11
11
|
import { SequenceIntervalCollectionValueType, } from "./intervalCollection";
|
|
@@ -162,25 +162,9 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
162
162
|
getRangeExtentsOfPosition(pos) {
|
|
163
163
|
return this.client.getRangeExtentsOfPosition(pos);
|
|
164
164
|
}
|
|
165
|
-
/**
|
|
166
|
-
* @deprecated - use createLocalReferencePosition
|
|
167
|
-
*/
|
|
168
|
-
createPositionReference(segment, offset, refType) {
|
|
169
|
-
const lref = new LocalReference(this.client, segment, offset, refType);
|
|
170
|
-
if (refType !== ReferenceType.Transient) {
|
|
171
|
-
this.addLocalReference(lref);
|
|
172
|
-
}
|
|
173
|
-
return lref;
|
|
174
|
-
}
|
|
175
165
|
createLocalReferencePosition(segment, offset, refType, properties) {
|
|
176
166
|
return this.client.createLocalReferencePosition(segment, offset, refType, properties);
|
|
177
167
|
}
|
|
178
|
-
/**
|
|
179
|
-
* @deprecated - use localReferencePositionToPosition
|
|
180
|
-
*/
|
|
181
|
-
localRefToPos(localRef) {
|
|
182
|
-
return this.client.localReferencePositionToPosition(localRef);
|
|
183
|
-
}
|
|
184
168
|
localReferencePositionToPosition(lref) {
|
|
185
169
|
return this.client.localReferencePositionToPosition(lref);
|
|
186
170
|
}
|
|
@@ -217,18 +201,6 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
217
201
|
this.submitLocalMessage(translated, metadata);
|
|
218
202
|
}
|
|
219
203
|
}
|
|
220
|
-
/**
|
|
221
|
-
* @deprecated - use createLocalReferencePosition
|
|
222
|
-
*/
|
|
223
|
-
addLocalReference(lref) {
|
|
224
|
-
return this.client.addLocalReference(lref);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* @deprecated - use removeLocalReferencePosition
|
|
228
|
-
*/
|
|
229
|
-
removeLocalReference(lref) {
|
|
230
|
-
return this.client.removeLocalReferencePosition(lref);
|
|
231
|
-
}
|
|
232
204
|
removeLocalReferencePosition(lref) {
|
|
233
205
|
return this.client.removeLocalReferencePosition(lref);
|
|
234
206
|
}
|
|
@@ -256,6 +228,10 @@ export class SharedSegmentSequence extends SharedObject {
|
|
|
256
228
|
walkSegments(handler, start, end, accum, splitRange = false) {
|
|
257
229
|
return this.client.walkSegments(handler, start, end, accum, splitRange);
|
|
258
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* @deprecated for internal use only. public export will be removed.
|
|
233
|
+
* @internal
|
|
234
|
+
*/
|
|
259
235
|
getStackContext(startPos, rangeLabels) {
|
|
260
236
|
return this.client.getStackContext(startPos, rangeLabels);
|
|
261
237
|
}
|
package/lib/sequence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAEH,WAAW,GACd,MAAM,sCA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AC,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","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 LocalReference,\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 /**\n * @deprecated - use createLocalReferencePosition\n */\n public createPositionReference(\n segment: T,\n offset: number,\n refType: ReferenceType): LocalReference {\n const lref = new LocalReference(this.client, segment, offset, refType);\n if (refType !== ReferenceType.Transient) {\n this.addLocalReference(lref);\n }\n return lref;\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 /**\n * @deprecated - use localReferencePositionToPosition\n */\n public localRefToPos(localRef: LocalReference) {\n return this.client.localReferencePositionToPosition(localRef);\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 /**\n * @deprecated - use createLocalReferencePosition\n */\n public addLocalReference(lref: LocalReference) {\n return this.client.addLocalReference(lref);\n }\n\n /**\n * @deprecated - use removeLocalReferencePosition\n */\n public removeLocalReference(lref: LocalReference) {\n return this.client.removeLocalReferencePosition(lref);\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 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,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAEH,WAAW,GACd,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EACH,MAAM,EACN,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,mBAAmB,EAYnB,eAAe,EACf,kBAAkB,GAMrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAEH,uBAAuB,EACvB,YAAY,EACZ,YAAY,GAGf,MAAM,oCAAoC,CAAC;AAI5C,OAAO,EAGH,mCAAmC,GACtC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGpF,MAA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MAAM,CAAC,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","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"]}
|
|
@@ -13,12 +13,6 @@ import { Client, IMergeTreeDeltaCallbackArgs, IMergeTreeDeltaOpArgs, IMergeTreeM
|
|
|
13
13
|
export declare abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
|
|
14
14
|
readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>;
|
|
15
15
|
private readonly mergeTreeClient;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated - Events no longer fire when the change they correspond to had no impact (e.g. a remote delete
|
|
18
|
-
* event for a range that had already been deleted locally).
|
|
19
|
-
* Clients can therefore assume this property is false.
|
|
20
|
-
*/
|
|
21
|
-
readonly isEmpty: boolean;
|
|
22
16
|
readonly deltaOperation: TOperation;
|
|
23
17
|
private readonly sortedRanges;
|
|
24
18
|
private readonly pFirst;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequenceDeltaEvent.d.ts","sourceRoot":"","sources":["../src/sequenceDeltaEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,MAAM,EACN,2BAA2B,EAC3B,qBAAqB,EACrB,iCAAiC,EACjC,QAAQ,EACR,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,WAAW,EAEd,MAAM,4BAA4B,CAAC;AAEpC;;;;;;GAMG;AACH,8BAAsB,aAAa,CAAC,UAAU,SAAS,4BAA4B,GAAG,4BAA4B;
|
|
1
|
+
{"version":3,"file":"sequenceDeltaEvent.d.ts","sourceRoot":"","sources":["../src/sequenceDeltaEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,MAAM,EACN,2BAA2B,EAC3B,qB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AAqB,GAAG,SAAS,EACzD,SAAS,EAAE,iCAAiC,EAC5C,eAAe,EAAE,MAAM;CAI9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,UAAU,SAAS,4BAA4B,GAAG,4BAA4B;IAC/G,SAAS,EAAE,UAAU,CAAC;IACtB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC;IAClB,cAAc,EAAE,WAAW,CAAC;CAC/B"}
|
|
@@ -16,7 +16,6 @@ export class SequenceEvent {
|
|
|
16
16
|
this.deltaArgs = deltaArgs;
|
|
17
17
|
this.mergeTreeClient = mergeTreeClient;
|
|
18
18
|
assert(deltaArgs.deltaSegments.length > 0, 0x2d8 /* "Empty change event should not be emitted." */);
|
|
19
|
-
this.isEmpty = false;
|
|
20
19
|
this.deltaOperation = deltaArgs.operation;
|
|
21
20
|
this.sortedRanges = new Lazy(() => {
|
|
22
21
|
const set = new SortedSegmentSet();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequenceDeltaEvent.js","sourceRoot":"","sources":["../src/sequenceDeltaEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAUH,gBAAgB,GACnB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,OAAgB,aAAa;
|
|
1
|
+
{"version":3,"file":"sequenceDeltaEvent.js","sourceRoot":"","sources":["../src/sequenceDeltaEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAUH,gBAAgB,GACnB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,OAAgB,aAAa;IAM/B,YACoB,SAAkD,EACjD,eAAuB;QADxB,cAAS,GAAT,SAAS,CAAyC;QACjD,oBAAe,GAAf,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CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;CACJ;AAED;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAmB,SAAQ,aAA0C;IAM9E,YACoB,MAA6B,EAC7C,SAAsC,EACtC,eAAuB;QAEvB,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAJlB,WAAM,GAAN,MAAM,CAAuB;QAK7C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,gBAAgB,KAAK,SAAS,CAAC;IACzD,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,OAAO,wBAAyB,SAAQ,aAAuC;IACjF,YACoB,MAAyC,EACzD,SAA4C,EAC5C,eAAuB;QAEvB,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAJlB,WAAM,GAAN,MAAM,CAAmC;IAK7D,CAAC;CACJ;AAkBD,MAAM,IAAI;IAGN,YAA6B,cAAuB;QAAvB,mBAAc,GAAd,cAAc,CAAS;QAChD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,KAAK;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;SACvC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n Client,\n IMergeTreeDeltaCallbackArgs,\n IMergeTreeDeltaOpArgs,\n IMergeTreeMaintenanceCallbackArgs,\n ISegment,\n MergeTreeDeltaOperationType,\n MergeTreeDeltaOperationTypes,\n MergeTreeMaintenanceType,\n PropertySet,\n SortedSegmentSet,\n} from \"@fluidframework/merge-tree\";\n\n/**\n * Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into any future modifications performed to the underlying sequence and merge tree.\n */\nexport abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {\n public readonly deltaOperation: TOperation;\n private readonly sortedRanges: Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>;\n private readonly pFirst: Lazy<ISequenceDeltaRange<TOperation>>;\n private readonly pLast: Lazy<ISequenceDeltaRange<TOperation>>;\n\n constructor(\n public readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>,\n private readonly mergeTreeClient: Client,\n ) {\n assert(deltaArgs.deltaSegments.length > 0, 0x2d8 /* \"Empty change event should not be emitted.\" */);\n this.deltaOperation = deltaArgs.operation;\n\n this.sortedRanges = new Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>(\n () => {\n const set = new SortedSegmentSet<ISequenceDeltaRange<TOperation>>();\n this.deltaArgs.deltaSegments.forEach((delta) => {\n const newRange: ISequenceDeltaRange<TOperation> = {\n operation: this.deltaArgs.operation,\n position: this.mergeTreeClient.getPosition(delta.segment),\n propertyDeltas: delta.propertyDeltas,\n segment: delta.segment,\n };\n set.addOrUpdate(newRange);\n });\n return set;\n });\n\n this.pFirst = new Lazy<ISequenceDeltaRange<TOperation>>(\n () => this.sortedRanges.value.items[0],\n );\n\n this.pLast = new Lazy<ISequenceDeltaRange<TOperation>>(\n () => this.sortedRanges.value.items[this.sortedRanges.value.size - 1],\n );\n }\n\n /**\n * The in-order ranges affected by this delta.\n * These may not be continuous.\n */\n public get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[] {\n return this.sortedRanges.value.items;\n }\n\n /**\n * The client id of the client that made the change which caused the delta event\n */\n public get clientId(): string {\n return this.mergeTreeClient.longClientId;\n }\n\n /**\n * The first of the modified ranges.\n */\n public get first(): Readonly<ISequenceDeltaRange<TOperation>> {\n return this.pFirst.value;\n }\n\n /**\n * The last of the modified ranges.\n */\n public get last(): Readonly<ISequenceDeltaRange<TOperation>> {\n return this.pLast.value;\n }\n}\n\n/**\n * The event object returned on sequenceDelta events.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.\n *\n * For group ops, each op will get its own event, and the group op property will be set on the op args.\n *\n * Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.\n */\nexport class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {\n /**\n * Whether the event was caused by a locally-made change.\n */\n public readonly isLocal: boolean;\n\n constructor(\n public readonly opArgs: IMergeTreeDeltaOpArgs,\n deltaArgs: IMergeTreeDeltaCallbackArgs,\n mergeTreeClient: Client,\n ) {\n super(deltaArgs, mergeTreeClient);\n this.isLocal = opArgs.sequencedMessage === undefined;\n }\n}\n\n/**\n * The event object returned on maintenance events.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.\n */\nexport class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {\n constructor(\n public readonly opArgs: IMergeTreeDeltaOpArgs | undefined,\n deltaArgs: IMergeTreeMaintenanceCallbackArgs,\n mergeTreeClient: Client,\n ) {\n super(deltaArgs, mergeTreeClient);\n }\n}\n\n/**\n * A range that has changed corresponding to a segment modification.\n */\nexport interface ISequenceDeltaRange<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {\n operation: TOperation;\n /**\n * The index of the start of the range.\n */\n position: number;\n /**\n * The segment that corresponds to the range.\n */\n segment: ISegment;\n propertyDeltas: PropertySet;\n}\n\nclass Lazy<T> {\n private pValue: T;\n private pEvaluated: boolean;\n constructor(private readonly valueGenerator: () => T) {\n this.pEvaluated = false;\n }\n\n public get evaluated(): boolean {\n return this.pEvaluated;\n }\n\n public get value(): T {\n if (!this.pEvaluated) {\n this.pEvaluated = true;\n this.pValue = this.valueGenerator();\n }\n return this.pValue;\n }\n}\n"]}
|
package/lib/sharedString.d.ts
CHANGED
|
@@ -130,5 +130,9 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
130
130
|
getTextRangeWithPlaceholders(start: number, end: number): string;
|
|
131
131
|
getTextRangeWithMarkers(start: number, end: number): string;
|
|
132
132
|
getMarkerFromId(id: string): ISegment;
|
|
133
|
+
/**
|
|
134
|
+
* Revert an op
|
|
135
|
+
*/
|
|
136
|
+
protected rollback(content: any, localOpMetadata: unknown): void;
|
|
133
137
|
}
|
|
134
138
|
//# sourceMappingURL=sharedString.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedString.d.ts","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"sharedString.d.ts","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EAEnB,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,WAAW,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AA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|
180
180
|
return this.client.getMarkerFromId(id);
|
|
181
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Revert an op
|
|
184
|
+
*/
|
|
185
|
+
rollback(content, localOpMetadata) {
|
|
186
|
+
if (this.client.rollback !== undefined) {
|
|
187
|
+
this.client.rollback(content, localOpMetadata);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
super.rollback(content, localOpMetadata);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
182
193
|
}
|
|
183
194
|
//# sourceMappingURL=sharedString.js.map
|
package/lib/sharedString.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAMH,MAAM,EAKN,WAAW,GACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AA8BxD;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAa,SAAQ,qBAA0C;IAyBxE,YAAY,QAAgC,EAAS,EAAU,EAAE,UAA8B;QAC3F,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,mBAAmB,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,mBAAmB,CAAC,IAAI,CAAiB,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,UAAU;QACpB,OAAO,IAAI,mBAAmB,EAAE,CAAC;IACrC,CAAC;IAED,IAAW,aAAa;QACpB,O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AE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/G,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;CACJ","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 IRelativePosition,\n ISegment,\n Marker,\n MergeTreeTextHelper,\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: MergeTreeTextHelper;\n\n constructor(document: IFluidDataStoreRuntime, public id: string, attributes: IChannelAttributes) {\n super(document, id, attributes, SharedStringFactory.segmentFromSpec);\n this.mergeTreeTextHelper = this.client.createTextHelper();\n }\n\n /**\n * Inserts a marker at a relative position.\n * @param relativePos1 - The relative position to insert the marker at\n * @param refType - The reference type of the marker\n * @param props - The properties of the marker\n */\n public insertMarkerRelative(\n relativePos1: 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 public getTextAndMarkers(label: string) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getTextAndMarkers(segmentWindow.currentSeq, segmentWindow.clientId, label);\n }\n\n /**\n * Retrieve text from the SharedString in string format.\n * @param start - The starting index of the text to retrieve, or 0 if omitted.\n * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n * @returns The requested text content as a string.\n */\n public getText(start?: number, end?: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"\", start, end);\n }\n\n /**\n * Adds spaces for markers and handles, so that position calculations account for them.\n */\n public getTextWithPlaceholders() {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \");\n }\n\n public getTextRangeWithPlaceholders(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \", start, end);\n }\n\n public getTextRangeWithMarkers(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"*\", start, end);\n }\n\n public getMarkerFromId(id: string): ISegment {\n return this.client.getMarkerFromId(id);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAOH,MAAM,EAIN,WAAW,GACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB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AAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;SAC5C;IACL,CAAC;CACJ","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 public getTextAndMarkers(label: string) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getTextAndMarkers(segmentWindow.currentSeq, segmentWindow.clientId, label);\n }\n\n /**\n * Retrieve text from the SharedString in string format.\n * @param start - The starting index of the text to retrieve, or 0 if omitted.\n * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n * @returns The requested text content as a string.\n */\n public getText(start?: number, end?: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"\", start, end);\n }\n\n /**\n * Adds spaces for markers and handles, so that position calculations account for them.\n */\n public getTextWithPlaceholders() {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \");\n }\n\n public getTextRangeWithPlaceholders(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \", start, end);\n }\n\n public getTextRangeWithMarkers(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"*\", start, end);\n }\n\n public getMarkerFromId(id: string): 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/sequence",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.0.0-internal.1.0.0.82159",
|
|
4
4
|
"description": "Distributed sequence",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -64,28 +64,28 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
66
66
|
"@fluidframework/common-utils": "^0.32.1",
|
|
67
|
-
"@fluidframework/container-utils": "
|
|
68
|
-
"@fluidframework/core-interfaces": "
|
|
69
|
-
"@fluidframework/datastore-definitions": "
|
|
70
|
-
"@fluidframework/merge-tree": "
|
|
71
|
-
"@fluidframework/protocol-definitions": "^0.
|
|
72
|
-
"@fluidframework/runtime-definitions": "
|
|
73
|
-
"@fluidframework/runtime-utils": "
|
|
74
|
-
"@fluidframework/shared-object-base": "
|
|
75
|
-
"@fluidframework/telemetry-utils": "
|
|
67
|
+
"@fluidframework/container-utils": "2.0.0-internal.1.0.0.82159",
|
|
68
|
+
"@fluidframework/core-interfaces": "2.0.0-internal.1.0.0.82159",
|
|
69
|
+
"@fluidframework/datastore-definitions": "2.0.0-internal.1.0.0.82159",
|
|
70
|
+
"@fluidframework/merge-tree": "2.0.0-internal.1.0.0.82159",
|
|
71
|
+
"@fluidframework/protocol-definitions": "^0.1029.1000-0",
|
|
72
|
+
"@fluidframework/runtime-definitions": "2.0.0-internal.1.0.0.82159",
|
|
73
|
+
"@fluidframework/runtime-utils": "2.0.0-internal.1.0.0.82159",
|
|
74
|
+
"@fluidframework/shared-object-base": "2.0.0-internal.1.0.0.82159",
|
|
75
|
+
"@fluidframework/telemetry-utils": "2.0.0-internal.1.0.0.82159",
|
|
76
76
|
"uuid": "^8.3.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@fluid-internal/stochastic-test-utils": "
|
|
80
|
-
"@fluid-internal/test-dds-utils": "
|
|
79
|
+
"@fluid-internal/stochastic-test-utils": "2.0.0-internal.1.0.0.82159",
|
|
80
|
+
"@fluid-internal/test-dds-utils": "2.0.0-internal.1.0.0.82159",
|
|
81
81
|
"@fluidframework/build-common": "^0.24.0",
|
|
82
|
-
"@fluidframework/build-tools": "^0.
|
|
82
|
+
"@fluidframework/build-tools": "^0.3.0-0",
|
|
83
83
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
84
|
-
"@fluidframework/gitresources": "^0.
|
|
85
|
-
"@fluidframework/mocha-test-setup": "
|
|
86
|
-
"@fluidframework/sequence-previous": "npm:@fluidframework/sequence
|
|
87
|
-
"@fluidframework/server-services-client": "^0.
|
|
88
|
-
"@fluidframework/test-runtime-utils": "
|
|
84
|
+
"@fluidframework/gitresources": "^0.1037.1000-0",
|
|
85
|
+
"@fluidframework/mocha-test-setup": "2.0.0-internal.1.0.0.82159",
|
|
86
|
+
"@fluidframework/sequence-previous": "npm:@fluidframework/sequence@^1.0.0",
|
|
87
|
+
"@fluidframework/server-services-client": "^0.1037.1000-0",
|
|
88
|
+
"@fluidframework/test-runtime-utils": "2.0.0-internal.1.0.0.82159",
|
|
89
89
|
"@microsoft/api-extractor": "^7.22.2",
|
|
90
90
|
"@rushstack/eslint-config": "^2.5.1",
|
|
91
91
|
"@types/diff": "^3.5.1",
|
|
@@ -105,7 +105,47 @@
|
|
|
105
105
|
"typescript-formatter": "7.1.0"
|
|
106
106
|
},
|
|
107
107
|
"typeValidation": {
|
|
108
|
-
"version": "
|
|
109
|
-
"broken": {
|
|
108
|
+
"version": "2.0.0",
|
|
109
|
+
"broken": {
|
|
110
|
+
"ClassDeclaration_IntervalCollection": {
|
|
111
|
+
"backCompat": false
|
|
112
|
+
},
|
|
113
|
+
"ClassDeclaration_SequenceInterval": {
|
|
114
|
+
"backCompat": false
|
|
115
|
+
},
|
|
116
|
+
"InterfaceDeclaration_ISharedString": {
|
|
117
|
+
"backCompat": false
|
|
118
|
+
},
|
|
119
|
+
"ClassDeclaration_SequenceEvent": {
|
|
120
|
+
"backCompat": false
|
|
121
|
+
},
|
|
122
|
+
"ClassDeclaration_SequenceDeltaEvent": {
|
|
123
|
+
"backCompat": false
|
|
124
|
+
},
|
|
125
|
+
"ClassDeclaration_SequenceMaintenanceEvent": {
|
|
126
|
+
"backCompat": false
|
|
127
|
+
},
|
|
128
|
+
"ClassDeclaration_SharedNumberSequence": {
|
|
129
|
+
"backCompat": false
|
|
130
|
+
},
|
|
131
|
+
"ClassDeclaration_SharedObjectSequence": {
|
|
132
|
+
"backCompat": false
|
|
133
|
+
},
|
|
134
|
+
"ClassDeclaration_SharedSegmentSequence": {
|
|
135
|
+
"backCompat": false
|
|
136
|
+
},
|
|
137
|
+
"ClassDeclaration_SharedSequence": {
|
|
138
|
+
"backCompat": false
|
|
139
|
+
},
|
|
140
|
+
"ClassDeclaration_SharedString": {
|
|
141
|
+
"backCompat": false
|
|
142
|
+
},
|
|
143
|
+
"TypeAliasDeclaration_SharedStringSegment": {
|
|
144
|
+
"backCompat": false
|
|
145
|
+
},
|
|
146
|
+
"ClassDeclaration_SparseMatrix": {
|
|
147
|
+
"backCompat": false
|
|
148
|
+
}
|
|
149
|
+
}
|
|
110
150
|
}
|
|
111
151
|
}
|