Skip to content

Commit

Permalink
Add ISharedSegmentSequence (#21067)
Browse files Browse the repository at this point in the history
## Description

Fix that ISharedString extends SharedObject (the class).

This resolves one issue preventing tagging of "legacy" DDSes as public
since before this change doing so for SharedString would pull in a lot
more than it should.

## Breaking Changes

ISharedString no longer extends SharedSegmentSequence and instead
extends the new ISharedSegmentSequence, which may be missing some APIs.

Attempt to migrate off the missing APIs, but if that is not practical,
request the be added to ISharedSegmentSequence and cast to
SharedSegmentSequence as a workaround temporally.
  • Loading branch information
CraigMacomber authored May 17, 2024
1 parent f59863d commit 47465f4
Show file tree
Hide file tree
Showing 15 changed files with 374 additions and 216 deletions.
10 changes: 10 additions & 0 deletions .changeset/loud-maps-fall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"fluid-framework": minor
"@fluidframework/sequence": minor
---

Stop ISharedString extending SharedObject

ISharedString no longer extends SharedSegmentSequence and instead extends the new ISharedSegmentSequence, which may be missing some APIs.

Attempt to migrate off the missing APIs, but if that is not practical, request they be added to ISharedSegmentSequence and cast to SharedSegmentSequence as a workaround temporally.
2 changes: 1 addition & 1 deletion examples/data-objects/codemirror/src/codeMirrorView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CodeMirrorView {
// https://stackoverflow.com/questions/18828658/how-to-kill-a-codemirror-instance

if (this.sequenceDeltaCb) {
this.text.removeListener("sequenceDelta", this.sequenceDeltaCb);
this.text.off("sequenceDelta", this.sequenceDeltaCb);
this.sequenceDeltaCb = undefined;
}

Expand Down
58 changes: 55 additions & 3 deletions packages/dds/sequence/api-report/sequence.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { IRelativePosition } from '@fluidframework/merge-tree/internal';
import { ISegment } from '@fluidframework/merge-tree/internal';
import { ISegmentAction } from '@fluidframework/merge-tree/internal';
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
import { ISharedObject } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions/internal';
Expand Down Expand Up @@ -371,6 +372,43 @@ export interface ISharedIntervalCollection<TInterval extends ISerializableInterv
getIntervalCollection(label: string): IIntervalCollection<TInterval>;
}

// @alpha (undocumented)
export interface ISharedSegmentSequence<T extends ISegment> extends ISharedObject<ISharedSegmentSequenceEvents>, ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver {
annotateRange(start: number, end: number, props: PropertySet): void;
createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
getContainingSegment(pos: number): {
segment: T | undefined;
offset: number | undefined;
};
// (undocumented)
getCurrentSeq(): number;
getIntervalCollection(label: string): IIntervalCollection<SequenceInterval>;
// (undocumented)
getIntervalCollectionLabels(): IterableIterator<string>;
getLength(): number;
getPosition(segment: ISegment): number;
// (undocumented)
getPropertiesAtPosition(pos: number): PropertySet | undefined;
// (undocumented)
getRangeExtentsOfPosition(pos: number): {
posStart: number | undefined;
posAfterEnd: number | undefined;
};
// @deprecated (undocumented)
groupOperation(groupOp: IMergeTreeGroupMsg): void;
initializeLocal(): void;
insertAtReferencePosition(pos: ReferencePosition, segment: T): void;
insertFromSpec(pos: number, spec: IJSONSegment): void;
localReferencePositionToPosition(lref: ReferencePosition): number;
obliterateRange(start: number, end: number): void;
posFromRelativePos(relativePos: IRelativePosition): number;
removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
// (undocumented)
removeRange(start: number, end: number): void;
resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
}

// @alpha
export interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
// (undocumented)
Expand All @@ -382,7 +420,7 @@ export interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
}

// @alpha
export interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
export interface ISharedString extends ISharedSegmentSequence<SharedStringSegment> {
annotateMarker(marker: Marker, props: PropertySet): void;
getMarkerFromId(id: string): ISegment | undefined;
getText(start?: number, end?: number): string;
Expand Down Expand Up @@ -568,24 +606,30 @@ export class SharedIntervalCollectionFactory implements IChannelFactory {
}

// @alpha (undocumented)
export abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver {
export abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedSegmentSequence<T> {
constructor(dataStoreRuntime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, segmentFromSpec: (spec: IJSONSegment) => ISegment);
// (undocumented)
annotateRange(start: number, end: number, props: PropertySet): void;
protected applyStashedOp(content: any): void;
// (undocumented)
protected client: Client;
// (undocumented)
createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
protected didAttach(): void;
// (undocumented)
getContainingSegment(pos: number): {
segment: T | undefined;
offset: number | undefined;
};
// (undocumented)
getCurrentSeq(): number;
// (undocumented)
getIntervalCollection(label: string): IIntervalCollection<SequenceInterval>;
// (undocumented)
getIntervalCollectionLabels(): IterableIterator<string>;
// (undocumented)
getLength(): number;
// (undocumented)
getPosition(segment: ISegment): number;
// (undocumented)
getPropertiesAtPosition(pos: number): PropertySet | undefined;
Expand All @@ -594,33 +638,41 @@ export abstract class SharedSegmentSequence<T extends ISegment> extends SharedOb
posStart: number | undefined;
posAfterEnd: number | undefined;
};
// @deprecated (undocumented)
// (undocumented)
groupOperation(groupOp: IMergeTreeGroupMsg): void;
protected guardReentrancy: <TRet>(callback: () => TRet) => TRet;
// (undocumented)
id: string;
protected initializeLocalCore(): void;
// (undocumented)
insertAtReferencePosition(pos: ReferencePosition, segment: T): void;
// (undocumented)
insertFromSpec(pos: number, spec: IJSONSegment): void;
protected loadCore(storage: IChannelStorageService): Promise<void>;
// @deprecated
get loaded(): Promise<void>;
// (undocumented)
localReferencePositionToPosition(lref: ReferencePosition): number;
// (undocumented)
obliterateRange(start: number, end: number): void;
protected onConnect(): void;
protected onDisconnect(): void;
// (undocumented)
posFromRelativePos(relativePos: IRelativePosition): number;
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
protected processGCDataCore(serializer: IFluidSerializer): void;
// (undocumented)
removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
// (undocumented)
removeRange(start: number, end: number): void;
protected replaceRange(start: number, end: number, segment: ISegment): void;
// (undocumented)
resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
protected reSubmitCore(content: any, localOpMetadata: unknown): void;
// (undocumented)
readonly segmentFromSpec: (spec: IJSONSegment) => ISegment;
protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
// (undocumented)
walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
}

Expand Down
12 changes: 11 additions & 1 deletion packages/dds/sequence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@
}
},
"typeValidation": {
"broken": {}
"broken": {
"InterfaceDeclaration_ISharedString": {
"backCompat": false
},
"TypeAliasDeclaration_SharedString": {
"backCompat": false
},
"ClassDeclaration_SharedStringClass": {
"backCompat": false
}
}
}
}
6 changes: 5 additions & 1 deletion packages/dds/sequence/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export {
revertSharedStringRevertibles,
SharedStringRevertible,
} from "./revertibles.js";
export { ISharedSegmentSequenceEvents, SharedSegmentSequence } from "./sequence.js";
export {
ISharedSegmentSequenceEvents,
SharedSegmentSequence,
ISharedSegmentSequence,
} from "./sequence.js";
export {
ISequenceDeltaRange,
SequenceDeltaEvent,
Expand Down
Loading

0 comments on commit 47465f4

Please sign in to comment.