@fluidframework/sequence 2.0.0-dev.7.3.0.211848 → 2.0.0-dev.7.4.0.214930
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/CHANGELOG.md +4 -0
- package/api-extractor.json +12 -1
- package/api-report/sequence.api.md +10 -5
- package/dist/defaultMap.d.ts +3 -3
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMap.js +7 -2
- package/dist/defaultMap.js.map +1 -1
- package/dist/defaultMapInterfaces.d.ts +10 -8
- package/dist/defaultMapInterfaces.d.ts.map +1 -1
- package/dist/defaultMapInterfaces.js.map +1 -1
- package/dist/intervalCollection.d.ts +33 -4
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +4 -1
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervals/intervalUtils.d.ts +4 -0
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js.map +1 -1
- package/dist/localValues.d.ts +2 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/revertibles.d.ts +0 -2
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence-alpha.d.ts +1625 -0
- package/dist/sequence-beta.d.ts +1540 -0
- package/dist/sequence-public.d.ts +1540 -0
- package/dist/sequence-untrimmed.d.ts +1798 -0
- package/dist/sharedString.d.ts +4 -0
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +4 -0
- package/dist/sharedString.js.map +1 -1
- package/lib/defaultMap.d.ts +3 -3
- package/lib/defaultMap.d.ts.map +1 -1
- package/lib/defaultMap.js +7 -2
- package/lib/defaultMap.js.map +1 -1
- package/lib/defaultMapInterfaces.d.ts +10 -8
- package/lib/defaultMapInterfaces.d.ts.map +1 -1
- package/lib/defaultMapInterfaces.js.map +1 -1
- package/lib/intervalCollection.d.ts +33 -4
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +4 -1
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervals/intervalUtils.d.ts +4 -0
- package/lib/intervals/intervalUtils.d.ts.map +1 -1
- package/lib/intervals/intervalUtils.js.map +1 -1
- package/lib/localValues.d.ts +2 -1
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/revertibles.d.ts +0 -2
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence-alpha.d.ts +1625 -0
- package/lib/sequence-beta.d.ts +1540 -0
- package/lib/sequence-public.d.ts +1540 -0
- package/lib/sequence-untrimmed.d.ts +1798 -0
- package/lib/sharedString.d.ts +4 -0
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +4 -0
- package/lib/sharedString.js.map +1 -1
- package/package.json +31 -19
- package/src/defaultMap.ts +22 -16
- package/src/defaultMapInterfaces.ts +14 -10
- package/src/intervalCollection.ts +41 -10
- package/src/intervals/intervalUtils.ts +4 -1
- package/src/localValues.ts +2 -1
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +0 -2
- package/src/sharedString.ts +4 -0
package/lib/sharedString.d.ts
CHANGED
|
@@ -104,6 +104,10 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
|
|
|
104
104
|
* @param marker - The marker to annotate
|
|
105
105
|
* @param props - The properties to annotate the marker with
|
|
106
106
|
* @param consensusCallback - The callback called when consensus is reached
|
|
107
|
+
*
|
|
108
|
+
* @deprecated We no longer intend to support this functionality and it will
|
|
109
|
+
* be removed in a future release. There is no replacement for this
|
|
110
|
+
* functionality.
|
|
107
111
|
*/
|
|
108
112
|
annotateMarkerNotifyConsensus(marker: Marker, props: PropertySet, callback: (m: Marker) => void): void;
|
|
109
113
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedString.d.ts","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EAEnB,iBAAiB,EACjB,QAAQ,EAER,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,aAAa,EAEb,WAAW,EACX,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;AAExD;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,qBAAqB,CAAC,mBAAmB,CAAC;IAChF;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAEjE;;;;;OAKG;IACH,YAAY,CACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,aAAa,EACtB,KAAK,CAAC,EAAE,WAAW,GACjB,mBAAmB,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAAC;CAC3D;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,MAAM,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,qBAAa,YACZ,SAAQ,qBAAqB,CAAC,mBAAmB,CACjD,YAAW,aAAa;IA4BhB,EAAE,EAAE,MAAM;IA1BlB;;;;;OAKG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM;IAIjE;;;OAGG;WACW,UAAU;IAIxB,IAAW,aAAa,IAAI,a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OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAOhE;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,GACV;IACF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC1B,CAWA"}
|
package/lib/sharedString.js
CHANGED
|
@@ -113,6 +113,10 @@ export class SharedString extends SharedSegmentSequence {
|
|
|
113
113
|
* @param marker - The marker to annotate
|
|
114
114
|
* @param props - The properties to annotate the marker with
|
|
115
115
|
* @param consensusCallback - The callback called when consensus is reached
|
|
116
|
+
*
|
|
117
|
+
* @deprecated We no longer intend to support this functionality and it will
|
|
118
|
+
* be removed in a future release. There is no replacement for this
|
|
119
|
+
* functionality.
|
|
116
120
|
*/
|
|
117
121
|
annotateMarkerNotifyConsensus(marker, props, callback) {
|
|
118
122
|
this.guardReentrancy(() => this.client.annotateMarkerNotifyConsensus(marker, props, callback));
|
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,EAQN,MAAM,EAIN,eAAe,EACf,WAAW,GACX,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAsCxD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,YACZ,SAAQ,qBAA0C;IAGlD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAA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,CAAC,EAAE;gBAC3D,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC9C,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;aACtB;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICombiningOp,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferencePosition,\n\tReferenceType,\n\trefHasTileLabel,\n\tTextSegment,\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 * @public\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n\t/**\n\t * Inserts the text at the position.\n\t * @param pos - The position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of the text\n\t */\n\tinsertText(pos: number, text: string, props?: PropertySet): void;\n\n\t/**\n\t * Inserts a marker at the position.\n\t * @param pos - The position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tinsertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined;\n\n\t/**\n\t * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n\t */\n\tposFromRelativePos(relativePos: IRelativePosition): number;\n}\n\n/**\n * @public\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 * @public\n */\nexport class SharedString\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\t/**\n\t * Create a new shared string.\n\t * @param runtime - data store runtime the new shared string belongs to\n\t * @param id - optional name of the shared string\n\t * @returns newly create shared string (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n\t}\n\n\t/**\n\t * Get a factory for SharedString to register with the data store.\n\t * @returns a factory that creates and load SharedString\n\t */\n\tpublic static getFactory() {\n\t\treturn new SharedStringFactory();\n\t}\n\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\tprivate readonly mergeTreeTextHelper: IMergeTreeTextHelper;\n\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(document, id, attributes, SharedStringFactory.segmentFromSpec as any);\n\t\tthis.mergeTreeTextHelper = this.client.createTextHelper();\n\t}\n\n\t/**\n\t * Inserts a marker at a relative position.\n\t * @param relativePos1 - The relative position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\treturn this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Inserts the text at the position.\n\t * @param relativePos1 - The relative position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tpublic insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Replaces a range with the provided text.\n\t * @param start - The inclusive start of the range to replace\n\t * @param end - The exclusive end of the range to replace\n\t * @param text - The text to replace the range with\n\t * @param props - Optional. The properties of the replacement text\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet) {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * Removes the text in the given range.\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to replace\n\t * @returns the message sent.\n\t */\n\tpublic removeText(start: number, end: number): IMergeTreeRemoveMsg {\n\t\treturn this.removeRange(start, end);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties and calls the callback on consensus.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param consensusCallback - The callback called when consensus is reached\n\t */\n\tpublic annotateMarkerNotifyConsensus(\n\t\tmarker: Marker,\n\t\tprops: PropertySet,\n\t\tcallback: (m: Marker) => void,\n\t) {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.annotateMarkerNotifyConsensus(marker, props, callback),\n\t\t);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp) {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props, combiningOp));\n\t}\n\n\t/**\n\t * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.\n\t * Note that Markers receive `ReferenceType.Tile` by default.\n\t * @deprecated Use `searchForMarker` instead.\n\t * @param startPos - Position at which to start the search\n\t * @param clientId - clientId dictating the perspective to search from\n\t * @param tileLabel - Label of the tile to search for\n\t * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`\n\t */\n\tpublic findTile(\n\t\tstartPos: number | undefined,\n\t\ttileLabel: string,\n\t\tpreceding = true,\n\t):\n\t\t| {\n\t\t\t\ttile: ReferencePosition;\n\t\t\t\tpos: number;\n\t\t }\n\t\t| undefined {\n\t\treturn this.client.findTile(startPos ?? 0, tileLabel, preceding);\n\t}\n\n\t/**\n\t * Searches a string for the nearest marker in either direction to a given start position.\n\t * The search will include the start position, so markers at the start position are valid\n\t * results of the search.\n\t * @param startPos - Position at which to start the search\n\t * @param markerLabel - Label of the marker to search for\n\t * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`\n\t */\n\tpublic searchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards = true,\n\t): Marker | undefined {\n\t\treturn this.client.searchForMarker(startPos, markerLabel, forwards);\n\t}\n\n\t/**\n\t * Retrieve text from the SharedString in string format.\n\t * @param start - The starting index of the text to retrieve, or 0 if omitted.\n\t * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n\t * @returns The requested text content as a string.\n\t */\n\tpublic getText(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tpublic getTextWithPlaceholders(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\" \",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\tpublic getTextRangeWithMarkers(start: number, end: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"*\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided\n\t * id in this `SharedString`.\n\t */\n\tpublic getMarkerFromId(id: string): ISegment | undefined {\n\t\treturn this.client.getMarkerFromId(id);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tif (this.client.rollback !== undefined) {\n\t\t\tthis.client.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t}\n\t}\n}\n\ninterface ITextAndMarkerAccumulator {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n\tparallelMarkerLabel: string;\n\tplaceholder?: string;\n\ttagsInProgress: string[];\n\ttextSegment: TextSegment;\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n * @public\n */\nexport function getTextAndMarkers(\n\tsharedString: SharedString,\n\tlabel: string,\n\tstart?: number,\n\tend?: number,\n): {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n} {\n\tconst accum: ITextAndMarkerAccumulator = {\n\t\tparallelMarkerLabel: label,\n\t\tparallelMarkers: [],\n\t\tparallelText: [],\n\t\ttagsInProgress: [],\n\t\ttextSegment: new TextSegment(\"\"),\n\t};\n\n\tsharedString.walkSegments(gatherTextAndMarkers, start, end, accum);\n\treturn { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };\n}\n\nconst gatherTextAndMarkers: ISegmentAction<ITextAndMarkerAccumulator> = (\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\taccumText: ITextAndMarkerAccumulator,\n) => {\n\tconst { placeholder, tagsInProgress, textSegment } = accumText;\n\tif (TextSegment.is(segment)) {\n\t\tlet beginTags = \"\";\n\t\tlet endTags = \"\";\n\t\t// TODO: let clients pass in function to get tag\n\t\tconst tags = [] as string[];\n\t\tconst initTags = [] as string[];\n\n\t\tif (segment.properties?.[\"font-weight\"]) {\n\t\t\ttags.push(\"b\");\n\t\t}\n\t\tif (segment.properties?.[\"text-decoration\"]) {\n\t\t\ttags.push(\"u\");\n\t\t}\n\t\tconst remTags = [] as string[];\n\t\tif (tags.length > 0) {\n\t\t\tfor (const tag of tags) {\n\t\t\t\tif (!tagsInProgress.includes(tag)) {\n\t\t\t\t\tbeginTags += `<${tag}>`;\n\t\t\t\t\tinitTags.push(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tif (!tags.includes(accumTag)) {\n\t\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\t\tremTags.push(accumTag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const initTag of initTags.reverse()) {\n\t\t\t\ttagsInProgress.push(initTag);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\tremTags.push(accumTag);\n\t\t\t}\n\t\t}\n\t\tfor (const remTag of remTags) {\n\t\t\tconst remdex = tagsInProgress.indexOf(remTag);\n\t\t\tif (remdex >= 0) {\n\t\t\t\ttagsInProgress.splice(remdex, 1);\n\t\t\t}\n\t\t}\n\t\ttextSegment.text += endTags;\n\t\ttextSegment.text += beginTags;\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else {\n\t\tif (placeholder && placeholder.length > 0) {\n\t\t\tconst placeholderText =\n\t\t\t\tplaceholder === \"*\"\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\t `\\n${segment.toString()}`\n\t\t\t\t\t: placeholder.repeat(segment.cachedLength);\n\t\t\ttextSegment.text += placeholderText;\n\t\t} else {\n\t\t\tconst marker = segment as Marker;\n\t\t\tif (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {\n\t\t\t\taccumText.parallelMarkers.push(marker);\n\t\t\t\taccumText.parallelText.push(textSegment.text);\n\t\t\t\ttextSegment.text = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"sharedString.js","sourceRoot":"","sources":["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M;QACN,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1C,MAAM,eAAe,GACpB,WAAW,KAAK,GAAG;gBAClB,CAAC,CAAC,gEAAgE;oBAChE,KAAK,OAAO,CAAC,QAAQ,EAAE,EAAE;gBAC3B,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;SACpC;aAAM;YACN,MAAM,MAAM,GAAG,OAAiB,CAAC;YACjC,IAAI,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE;gBAC3D,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC9C,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;aACtB;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICombiningOp,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferencePosition,\n\tReferenceType,\n\trefHasTileLabel,\n\tTextSegment,\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 * @public\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n\t/**\n\t * Inserts the text at the position.\n\t * @param pos - The position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of the text\n\t */\n\tinsertText(pos: number, text: string, props?: PropertySet): void;\n\n\t/**\n\t * Inserts a marker at the position.\n\t * @param pos - The position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tinsertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined;\n\n\t/**\n\t * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n\t */\n\tposFromRelativePos(relativePos: IRelativePosition): number;\n}\n\n/**\n * @public\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 * @public\n */\nexport class SharedString\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\t/**\n\t * Create a new shared string.\n\t * @param runtime - data store runtime the new shared string belongs to\n\t * @param id - optional name of the shared string\n\t * @returns newly create shared string (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n\t}\n\n\t/**\n\t * Get a factory for SharedString to register with the data store.\n\t * @returns a factory that creates and load SharedString\n\t */\n\tpublic static getFactory() {\n\t\treturn new SharedStringFactory();\n\t}\n\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\tprivate readonly mergeTreeTextHelper: IMergeTreeTextHelper;\n\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(document, id, attributes, SharedStringFactory.segmentFromSpec as any);\n\t\tthis.mergeTreeTextHelper = this.client.createTextHelper();\n\t}\n\n\t/**\n\t * Inserts a marker at a relative position.\n\t * @param relativePos1 - The relative position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\treturn this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Inserts the text at the position.\n\t * @param relativePos1 - The relative position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tpublic insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Replaces a range with the provided text.\n\t * @param start - The inclusive start of the range to replace\n\t * @param end - The exclusive end of the range to replace\n\t * @param text - The text to replace the range with\n\t * @param props - Optional. The properties of the replacement text\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet) {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * Removes the text in the given range.\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to replace\n\t * @returns the message sent.\n\t */\n\tpublic removeText(start: number, end: number): IMergeTreeRemoveMsg {\n\t\treturn this.removeRange(start, end);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties and calls the callback on consensus.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param consensusCallback - The callback called when consensus is reached\n\t *\n\t * @deprecated We no longer intend to support this functionality and it will\n\t * be removed in a future release. There is no replacement for this\n\t * functionality.\n\t */\n\tpublic annotateMarkerNotifyConsensus(\n\t\tmarker: Marker,\n\t\tprops: PropertySet,\n\t\tcallback: (m: Marker) => void,\n\t) {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.annotateMarkerNotifyConsensus(marker, props, callback),\n\t\t);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp) {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props, combiningOp));\n\t}\n\n\t/**\n\t * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.\n\t * Note that Markers receive `ReferenceType.Tile` by default.\n\t * @deprecated Use `searchForMarker` instead.\n\t * @param startPos - Position at which to start the search\n\t * @param clientId - clientId dictating the perspective to search from\n\t * @param tileLabel - Label of the tile to search for\n\t * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`\n\t */\n\tpublic findTile(\n\t\tstartPos: number | undefined,\n\t\ttileLabel: string,\n\t\tpreceding = true,\n\t):\n\t\t| {\n\t\t\t\ttile: ReferencePosition;\n\t\t\t\tpos: number;\n\t\t }\n\t\t| undefined {\n\t\treturn this.client.findTile(startPos ?? 0, tileLabel, preceding);\n\t}\n\n\t/**\n\t * Searches a string for the nearest marker in either direction to a given start position.\n\t * The search will include the start position, so markers at the start position are valid\n\t * results of the search.\n\t * @param startPos - Position at which to start the search\n\t * @param markerLabel - Label of the marker to search for\n\t * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`\n\t */\n\tpublic searchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards = true,\n\t): Marker | undefined {\n\t\treturn this.client.searchForMarker(startPos, markerLabel, forwards);\n\t}\n\n\t/**\n\t * Retrieve text from the SharedString in string format.\n\t * @param start - The starting index of the text to retrieve, or 0 if omitted.\n\t * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n\t * @returns The requested text content as a string.\n\t */\n\tpublic getText(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tpublic getTextWithPlaceholders(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\" \",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\tpublic getTextRangeWithMarkers(start: number, end: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"*\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided\n\t * id in this `SharedString`.\n\t */\n\tpublic getMarkerFromId(id: string): ISegment | undefined {\n\t\treturn this.client.getMarkerFromId(id);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tif (this.client.rollback !== undefined) {\n\t\t\tthis.client.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t}\n\t}\n}\n\ninterface ITextAndMarkerAccumulator {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n\tparallelMarkerLabel: string;\n\tplaceholder?: string;\n\ttagsInProgress: string[];\n\ttextSegment: TextSegment;\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n * @public\n */\nexport function getTextAndMarkers(\n\tsharedString: SharedString,\n\tlabel: string,\n\tstart?: number,\n\tend?: number,\n): {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n} {\n\tconst accum: ITextAndMarkerAccumulator = {\n\t\tparallelMarkerLabel: label,\n\t\tparallelMarkers: [],\n\t\tparallelText: [],\n\t\ttagsInProgress: [],\n\t\ttextSegment: new TextSegment(\"\"),\n\t};\n\n\tsharedString.walkSegments(gatherTextAndMarkers, start, end, accum);\n\treturn { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };\n}\n\nconst gatherTextAndMarkers: ISegmentAction<ITextAndMarkerAccumulator> = (\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\taccumText: ITextAndMarkerAccumulator,\n) => {\n\tconst { placeholder, tagsInProgress, textSegment } = accumText;\n\tif (TextSegment.is(segment)) {\n\t\tlet beginTags = \"\";\n\t\tlet endTags = \"\";\n\t\t// TODO: let clients pass in function to get tag\n\t\tconst tags = [] as string[];\n\t\tconst initTags = [] as string[];\n\n\t\tif (segment.properties?.[\"font-weight\"]) {\n\t\t\ttags.push(\"b\");\n\t\t}\n\t\tif (segment.properties?.[\"text-decoration\"]) {\n\t\t\ttags.push(\"u\");\n\t\t}\n\t\tconst remTags = [] as string[];\n\t\tif (tags.length > 0) {\n\t\t\tfor (const tag of tags) {\n\t\t\t\tif (!tagsInProgress.includes(tag)) {\n\t\t\t\t\tbeginTags += `<${tag}>`;\n\t\t\t\t\tinitTags.push(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tif (!tags.includes(accumTag)) {\n\t\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\t\tremTags.push(accumTag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const initTag of initTags.reverse()) {\n\t\t\t\ttagsInProgress.push(initTag);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\tremTags.push(accumTag);\n\t\t\t}\n\t\t}\n\t\tfor (const remTag of remTags) {\n\t\t\tconst remdex = tagsInProgress.indexOf(remTag);\n\t\t\tif (remdex >= 0) {\n\t\t\t\ttagsInProgress.splice(remdex, 1);\n\t\t\t}\n\t\t}\n\t\ttextSegment.text += endTags;\n\t\ttextSegment.text += beginTags;\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else {\n\t\tif (placeholder && placeholder.length > 0) {\n\t\t\tconst placeholderText =\n\t\t\t\tplaceholder === \"*\"\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\t `\\n${segment.toString()}`\n\t\t\t\t\t: placeholder.repeat(segment.cachedLength);\n\t\t\ttextSegment.text += placeholderText;\n\t\t} else {\n\t\t\tconst marker = segment as Marker;\n\t\t\tif (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {\n\t\t\t\taccumText.parallelMarkers.push(marker);\n\t\t\t\taccumText.parallelText.push(textSegment.text);\n\t\t\t\ttextSegment.text = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/sequence",
|
|
3
|
-
"version": "2.0.0-dev.7.
|
|
3
|
+
"version": "2.0.0-dev.7.4.0.214930",
|
|
4
4
|
"description": "Distributed sequence",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -35,35 +35,36 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluid-internal/client-utils": "2.0.0-dev.7.
|
|
39
|
-
"@fluidframework/core-interfaces": "2.0.0-dev.7.
|
|
40
|
-
"@fluidframework/core-utils": "2.0.0-dev.7.
|
|
41
|
-
"@fluidframework/datastore-definitions": "2.0.0-dev.7.
|
|
42
|
-
"@fluidframework/merge-tree": "2.0.0-dev.7.
|
|
38
|
+
"@fluid-internal/client-utils": "2.0.0-dev.7.4.0.214930",
|
|
39
|
+
"@fluidframework/core-interfaces": "2.0.0-dev.7.4.0.214930",
|
|
40
|
+
"@fluidframework/core-utils": "2.0.0-dev.7.4.0.214930",
|
|
41
|
+
"@fluidframework/datastore-definitions": "2.0.0-dev.7.4.0.214930",
|
|
42
|
+
"@fluidframework/merge-tree": "2.0.0-dev.7.4.0.214930",
|
|
43
43
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
44
|
-
"@fluidframework/runtime-definitions": "2.0.0-dev.7.
|
|
45
|
-
"@fluidframework/runtime-utils": "2.0.0-dev.7.
|
|
46
|
-
"@fluidframework/shared-object-base": "2.0.0-dev.7.
|
|
47
|
-
"@fluidframework/telemetry-utils": "2.0.0-dev.7.
|
|
44
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev.7.4.0.214930",
|
|
45
|
+
"@fluidframework/runtime-utils": "2.0.0-dev.7.4.0.214930",
|
|
46
|
+
"@fluidframework/shared-object-base": "2.0.0-dev.7.4.0.214930",
|
|
47
|
+
"@fluidframework/telemetry-utils": "2.0.0-dev.7.4.0.214930",
|
|
48
48
|
"uuid": "^9.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@fluid-private/stochastic-test-utils": "2.0.0-dev.7.
|
|
52
|
-
"@fluid-private/test-dds-utils": "2.0.0-dev.7.
|
|
51
|
+
"@fluid-private/stochastic-test-utils": "2.0.0-dev.7.4.0.214930",
|
|
52
|
+
"@fluid-private/test-dds-utils": "2.0.0-dev.7.4.0.214930",
|
|
53
53
|
"@fluid-tools/benchmark": "^0.48.0",
|
|
54
|
-
"@fluid-tools/build-cli": "0.28.0
|
|
54
|
+
"@fluid-tools/build-cli": "^0.28.0",
|
|
55
55
|
"@fluidframework/build-common": "^2.0.3",
|
|
56
|
-
"@fluidframework/build-tools": "0.28.0
|
|
56
|
+
"@fluidframework/build-tools": "^0.28.0",
|
|
57
57
|
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
58
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev.7.
|
|
58
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev.7.4.0.214930",
|
|
59
59
|
"@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.0.0-internal.7.2.0",
|
|
60
|
-
"@fluidframework/test-runtime-utils": "2.0.0-dev.7.
|
|
60
|
+
"@fluidframework/test-runtime-utils": "2.0.0-dev.7.4.0.214930",
|
|
61
61
|
"@microsoft/api-extractor": "^7.38.3",
|
|
62
62
|
"@types/diff": "^3.5.1",
|
|
63
63
|
"@types/mocha": "^9.1.1",
|
|
64
64
|
"@types/node": "^16.18.38",
|
|
65
65
|
"@types/random-js": "^1.0.31",
|
|
66
66
|
"c8": "^7.7.1",
|
|
67
|
+
"copyfiles": "^2.4.1",
|
|
67
68
|
"cross-env": "^7.0.3",
|
|
68
69
|
"diff": "^3.5.0",
|
|
69
70
|
"eslint": "~8.50.0",
|
|
@@ -78,6 +79,14 @@
|
|
|
78
79
|
},
|
|
79
80
|
"fluidBuild": {
|
|
80
81
|
"tasks": {
|
|
82
|
+
"build:docs": {
|
|
83
|
+
"dependsOn": [
|
|
84
|
+
"...",
|
|
85
|
+
"api-extractor:commonjs",
|
|
86
|
+
"api-extractor:esnext"
|
|
87
|
+
],
|
|
88
|
+
"script": false
|
|
89
|
+
},
|
|
81
90
|
"build:test": [
|
|
82
91
|
"...",
|
|
83
92
|
"@fluidframework/merge-tree#build:test"
|
|
@@ -88,10 +97,13 @@
|
|
|
88
97
|
"broken": {}
|
|
89
98
|
},
|
|
90
99
|
"scripts": {
|
|
100
|
+
"api": "fluid-build . --task api",
|
|
101
|
+
"api-extractor:commonjs": "api-extractor run --local",
|
|
102
|
+
"api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
|
|
91
103
|
"build": "fluid-build . --task build",
|
|
92
104
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
93
105
|
"build:compile": "fluid-build . --task compile",
|
|
94
|
-
"build:docs": "
|
|
106
|
+
"build:docs": "fluid-build . --task api",
|
|
95
107
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
96
108
|
"build:genver": "gen-version",
|
|
97
109
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
@@ -104,8 +116,8 @@
|
|
|
104
116
|
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
105
117
|
"perf": "cross-env FLUID_TEST_VERBOSE=1 mocha \"dist/**/*.spec.js\" --node-option unhandled-rejections=strict,expose-gc --exit -r node_modules/@fluidframework/mocha-test-setup --perfMode --fgrep @Benchmark --reporter @fluid-tools/benchmark/dist/MochaReporter.js --timeout 30000",
|
|
106
118
|
"perf:measure": "npm run perf -- --fgrep @Measurement",
|
|
107
|
-
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
108
|
-
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
119
|
+
"prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
120
|
+
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
109
121
|
"test": "npm run test:mocha",
|
|
110
122
|
"test:benchmark:report": "mocha \"dist/test/*.perf.spec.js\" --node-option unhandled-rejections=strict,expose-gc --exit --perfMode --fgrep @Benchmark -r @fluidframework/mocha-test-setup --reporter @fluid-tools/benchmark/dist/MochaReporter.js --timeout 60000",
|
|
111
123
|
"test:coverage": "c8 npm test",
|
package/src/defaultMap.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
ISerializableValue,
|
|
19
19
|
ISerializedValue,
|
|
20
20
|
IValueChanged,
|
|
21
|
+
// eslint-disable-next-line import/no-deprecated
|
|
21
22
|
IValueOpEmitter,
|
|
22
23
|
IValueType,
|
|
23
24
|
IValueTypeOperationValue,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
IMapMessageLocalMetadata,
|
|
26
27
|
SequenceOptions,
|
|
27
28
|
} from "./defaultMapInterfaces";
|
|
29
|
+
import { IntervalOpType, SerializedIntervalDelta } from "./intervals";
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Defines the means to process and submit a given op on a map.
|
|
@@ -131,7 +133,7 @@ export class DefaultMap<T> {
|
|
|
131
133
|
private readonly serializer: IFluidSerializer,
|
|
132
134
|
private readonly handle: IFluidHandle,
|
|
133
135
|
private readonly submitMessage: (
|
|
134
|
-
op:
|
|
136
|
+
op: IMapValueTypeOperation,
|
|
135
137
|
localOpMetadata: IMapMessageLocalMetadata,
|
|
136
138
|
) => void,
|
|
137
139
|
private readonly type: IValueType<T>,
|
|
@@ -292,21 +294,24 @@ export class DefaultMap<T> {
|
|
|
292
294
|
* also sent if we are asked to resubmit the message.
|
|
293
295
|
* @returns True if the operation was submitted, false otherwise.
|
|
294
296
|
*/
|
|
295
|
-
public tryResubmitMessage(
|
|
297
|
+
public tryResubmitMessage(
|
|
298
|
+
op: IMapOperation,
|
|
299
|
+
localOpMetadata: IMapMessageLocalMetadata,
|
|
300
|
+
): boolean {
|
|
296
301
|
const type: string = op.type;
|
|
297
302
|
const handler = this.messageHandlers.get(type);
|
|
298
303
|
if (handler !== undefined) {
|
|
299
|
-
handler.resubmit(op
|
|
304
|
+
handler.resubmit(op, localOpMetadata);
|
|
300
305
|
return true;
|
|
301
306
|
}
|
|
302
307
|
return false;
|
|
303
308
|
}
|
|
304
309
|
|
|
305
|
-
public tryGetStashedOpLocalMetadata(op:
|
|
310
|
+
public tryGetStashedOpLocalMetadata(op: IMapOperation): unknown {
|
|
306
311
|
const type: string = op.type;
|
|
307
312
|
if (this.messageHandlers.has(type)) {
|
|
308
313
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
309
|
-
return this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op
|
|
314
|
+
return this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op);
|
|
310
315
|
}
|
|
311
316
|
throw new Error("no apply stashed op handler");
|
|
312
317
|
}
|
|
@@ -406,12 +411,11 @@ export class DefaultMap<T> {
|
|
|
406
411
|
assert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
|
|
407
412
|
|
|
408
413
|
const handler = localValue.getOpHandler(op.value.opName);
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
|
|
414
|
+
const rebased = handler.rebase(localValue.value, op.value, localOpMetadata);
|
|
415
|
+
if (rebased !== undefined) {
|
|
416
|
+
const { rebasedOp, rebasedLocalOpMetadata } = rebased;
|
|
417
|
+
this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
|
|
418
|
+
}
|
|
415
419
|
},
|
|
416
420
|
getStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {
|
|
417
421
|
assert(
|
|
@@ -430,13 +434,15 @@ export class DefaultMap<T> {
|
|
|
430
434
|
* @param key - The key of the map that the value type will be stored on
|
|
431
435
|
* @returns A value op emitter for the given key
|
|
432
436
|
*/
|
|
437
|
+
// eslint-disable-next-line import/no-deprecated
|
|
433
438
|
private makeMapValueOpEmitter(key: string): IValueOpEmitter {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
439
|
+
// eslint-disable-next-line import/no-deprecated
|
|
440
|
+
const emit: IValueOpEmitter["emit"] = (
|
|
441
|
+
opName: IntervalOpType,
|
|
442
|
+
previousValue: unknown,
|
|
443
|
+
params: SerializedIntervalDelta,
|
|
438
444
|
localOpMetadata: IMapMessageLocalMetadata,
|
|
439
|
-
) => {
|
|
445
|
+
): void => {
|
|
440
446
|
const translatedParams = makeHandlesSerializable(params, this.serializer, this.handle);
|
|
441
447
|
|
|
442
448
|
const op: IMapValueTypeOperation = {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
8
8
|
import { IEventThisPlaceHolder } from "@fluidframework/core-interfaces";
|
|
9
|
+
import { ISerializedInterval, IntervalOpType, SerializedIntervalDelta } from "./intervals";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Type of "valueChanged" event parameter.
|
|
@@ -25,20 +26,21 @@ export interface IValueChanged {
|
|
|
25
26
|
/**
|
|
26
27
|
* Value types are given an IValueOpEmitter to emit their ops through the container type that holds them.
|
|
27
28
|
* @internal
|
|
29
|
+
* @deprecated - will be remove from public api as there is no public used of this type
|
|
28
30
|
*/
|
|
29
31
|
export interface IValueOpEmitter {
|
|
30
32
|
/**
|
|
31
33
|
* Called by the value type to emit a value type operation through the container type holding it.
|
|
32
34
|
* @param opName - Name of the emitted operation
|
|
33
|
-
* @param previousValue - JSONable previous value as defined by the value type
|
|
35
|
+
* @param previousValue - JSONable previous value as defined by the value type @deprecated unused
|
|
34
36
|
* @param params - JSONable params for the operation as defined by the value type
|
|
35
37
|
* @param localOpMetadata - JSONable local metadata which should be submitted with the op
|
|
36
38
|
* @internal
|
|
37
39
|
*/
|
|
38
40
|
emit(
|
|
39
|
-
opName:
|
|
40
|
-
previousValue:
|
|
41
|
-
params:
|
|
41
|
+
opName: IntervalOpType,
|
|
42
|
+
previousValue: undefined,
|
|
43
|
+
params: SerializedIntervalDelta,
|
|
42
44
|
localOpMetadata: IMapMessageLocalMetadata,
|
|
43
45
|
): void;
|
|
44
46
|
}
|
|
@@ -123,7 +125,7 @@ export interface IValueOperation<T> {
|
|
|
123
125
|
*/
|
|
124
126
|
process(
|
|
125
127
|
value: T,
|
|
126
|
-
params:
|
|
128
|
+
params: ISerializedInterval,
|
|
127
129
|
local: boolean,
|
|
128
130
|
message: ISequencedDocumentMessage | undefined,
|
|
129
131
|
localOpMetadata: IMapMessageLocalMetadata | undefined,
|
|
@@ -141,7 +143,9 @@ export interface IValueOperation<T> {
|
|
|
141
143
|
value: T,
|
|
142
144
|
op: IValueTypeOperationValue,
|
|
143
145
|
localOpMetadata: IMapMessageLocalMetadata,
|
|
144
|
-
):
|
|
146
|
+
):
|
|
147
|
+
| { rebasedOp: IValueTypeOperationValue; rebasedLocalOpMetadata: IMapMessageLocalMetadata }
|
|
148
|
+
| undefined;
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
/**
|
|
@@ -164,7 +168,7 @@ export interface IValueType<T> {
|
|
|
164
168
|
* Operations that can be applied to the value type.
|
|
165
169
|
* @alpha
|
|
166
170
|
*/
|
|
167
|
-
ops: Map<
|
|
171
|
+
ops: Map<IntervalOpType, IValueOperation<T>>;
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
export interface ISharedDefaultMapEvents extends ISharedObjectEvents {
|
|
@@ -182,7 +186,7 @@ export interface ISharedDefaultMapEvents extends ISharedObjectEvents {
|
|
|
182
186
|
* JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
|
|
183
187
|
* and ops (set).
|
|
184
188
|
*
|
|
185
|
-
* The DefaultMap
|
|
189
|
+
* The DefaultMap implementation for sequence has been specialized to only support a single ValueType, which serializes
|
|
186
190
|
* and deserializes via .store() and .load().
|
|
187
191
|
*/
|
|
188
192
|
export interface ISerializableValue {
|
|
@@ -222,10 +226,10 @@ export interface IValueTypeOperationValue {
|
|
|
222
226
|
/**
|
|
223
227
|
* The name of the operation.
|
|
224
228
|
*/
|
|
225
|
-
opName:
|
|
229
|
+
opName: IntervalOpType;
|
|
226
230
|
|
|
227
231
|
/**
|
|
228
232
|
* The payload that is submitted along with the operation.
|
|
229
233
|
*/
|
|
230
|
-
value:
|
|
234
|
+
value: SerializedIntervalDelta;
|
|
231
235
|
}
|
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
IValueOpEmitter,
|
|
36
36
|
IValueOperation,
|
|
37
37
|
IValueType,
|
|
38
|
-
IValueTypeOperationValue,
|
|
39
38
|
SequenceOptions,
|
|
40
39
|
} from "./defaultMapInterfaces";
|
|
41
40
|
import {
|
|
@@ -512,7 +511,7 @@ export class SequenceIntervalCollectionValueType
|
|
|
512
511
|
return SequenceIntervalCollectionValueType._factory;
|
|
513
512
|
}
|
|
514
513
|
|
|
515
|
-
public get ops(): Map<
|
|
514
|
+
public get ops(): Map<IntervalOpType, IValueOperation<IntervalCollection<SequenceInterval>>> {
|
|
516
515
|
return SequenceIntervalCollectionValueType._ops;
|
|
517
516
|
}
|
|
518
517
|
|
|
@@ -552,7 +551,7 @@ export class IntervalCollectionValueType implements IValueType<IntervalCollectio
|
|
|
552
551
|
return IntervalCollectionValueType._factory;
|
|
553
552
|
}
|
|
554
553
|
|
|
555
|
-
public get ops(): Map<
|
|
554
|
+
public get ops(): Map<IntervalOpType, IValueOperation<IntervalCollection<Interval>>> {
|
|
556
555
|
return IntervalCollectionValueType._ops;
|
|
557
556
|
}
|
|
558
557
|
|
|
@@ -562,21 +561,24 @@ export class IntervalCollectionValueType implements IValueType<IntervalCollectio
|
|
|
562
561
|
}
|
|
563
562
|
|
|
564
563
|
export function makeOpsMap<T extends ISerializableInterval>(): Map<
|
|
565
|
-
|
|
564
|
+
IntervalOpType,
|
|
566
565
|
IValueOperation<IntervalCollection<T>>
|
|
567
566
|
> {
|
|
568
|
-
const rebase = (
|
|
569
|
-
collection
|
|
570
|
-
op
|
|
571
|
-
localOpMetadata
|
|
567
|
+
const rebase: IValueOperation<IntervalCollection<T>>["rebase"] = (
|
|
568
|
+
collection,
|
|
569
|
+
op,
|
|
570
|
+
localOpMetadata,
|
|
572
571
|
) => {
|
|
573
572
|
const { localSeq } = localOpMetadata;
|
|
574
573
|
const rebasedValue = collection.rebaseLocalInterval(op.opName, op.value, localSeq);
|
|
574
|
+
if (rebasedValue === undefined) {
|
|
575
|
+
return undefined;
|
|
576
|
+
}
|
|
575
577
|
const rebasedOp = { ...op, value: rebasedValue };
|
|
576
578
|
return { rebasedOp, rebasedLocalOpMetadata: localOpMetadata };
|
|
577
579
|
};
|
|
578
580
|
|
|
579
|
-
return new Map<
|
|
581
|
+
return new Map<IntervalOpType, IValueOperation<IntervalCollection<T>>>([
|
|
580
582
|
[
|
|
581
583
|
IntervalOpType.ADD,
|
|
582
584
|
{
|
|
@@ -919,6 +921,14 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval>
|
|
|
919
921
|
): void;
|
|
920
922
|
|
|
921
923
|
/**
|
|
924
|
+
* @deprecated - Users must manually attach the corresponding interval index to utilize this functionality, for instance:
|
|
925
|
+
*
|
|
926
|
+
* ```typescript
|
|
927
|
+
* const overlappingIntervalsIndex = createOverlappingIntervalsIndex(sharedString);
|
|
928
|
+
* collection.attachIndex(overlappingIntervalsIndex)
|
|
929
|
+
* const result = overlappingIntervalsIndex.findOverlappingIntervals(start, end);
|
|
930
|
+
* ```
|
|
931
|
+
*
|
|
922
932
|
* @returns an array of all intervals in this collection that overlap with the interval
|
|
923
933
|
* `[startPosition, endPosition]`.
|
|
924
934
|
*/
|
|
@@ -929,8 +939,29 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval>
|
|
|
929
939
|
*/
|
|
930
940
|
map(fn: (interval: TInterval) => void): void;
|
|
931
941
|
|
|
942
|
+
/**
|
|
943
|
+
* @deprecated - due to the forthcoming change where the endpointIndex will no longer be
|
|
944
|
+
* automatically added to the collection. Users are advised to independently attach the
|
|
945
|
+
* index to the collection and utilize the API accordingly, for instance:
|
|
946
|
+
* ```typescript
|
|
947
|
+
* const endpointIndex = createEndpointIndex(sharedString);
|
|
948
|
+
* collection.attachIndex(endpointIndex);
|
|
949
|
+
* const result1 = endpointIndex.previousInterval(pos);
|
|
950
|
+
* ```
|
|
951
|
+
* If an index is used repeatedly, applications should generally attach it once and store it in memory.
|
|
952
|
+
*/
|
|
932
953
|
previousInterval(pos: number): TInterval | undefined;
|
|
933
954
|
|
|
955
|
+
/**
|
|
956
|
+
* @deprecated - due to the forthcoming change where the endpointIndex will no longer be
|
|
957
|
+
* automatically added to the collection. Users are advised to independently attach the
|
|
958
|
+
* index to the collection and utilize the API accordingly, for instance:
|
|
959
|
+
* ```typescript
|
|
960
|
+
* const endpointIndex = createEndpointIndex(sharedString);
|
|
961
|
+
* collection.attachIndex(endpointIndex);
|
|
962
|
+
* const result2 = endpointIndex.nextInterval(pos);
|
|
963
|
+
* ```
|
|
964
|
+
*/
|
|
934
965
|
nextInterval(pos: number): TInterval | undefined;
|
|
935
966
|
}
|
|
936
967
|
|
|
@@ -1867,7 +1898,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
1867
1898
|
): void {
|
|
1868
1899
|
if (local) {
|
|
1869
1900
|
// Local ops were applied when the message was created and there's no "pending delete"
|
|
1870
|
-
// state to
|
|
1901
|
+
// state to book keep: remote operation application takes into account possibility of
|
|
1871
1902
|
// locally deleted interval whenever a lookup happens.
|
|
1872
1903
|
return;
|
|
1873
1904
|
}
|
|
@@ -81,7 +81,10 @@ export const IntervalOpType = {
|
|
|
81
81
|
PROPERTY_CHANGED: "propertyChanged",
|
|
82
82
|
POSITION_REMOVE: "positionRemove",
|
|
83
83
|
} as const;
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
|
+
* @alpha
|
|
86
|
+
*/
|
|
87
|
+
export type IntervalOpType = (typeof IntervalOpType)[keyof typeof IntervalOpType];
|
|
85
88
|
/**
|
|
86
89
|
* @public
|
|
87
90
|
*/
|
package/src/localValues.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
IValueOperation,
|
|
12
12
|
IValueType,
|
|
13
13
|
} from "./defaultMapInterfaces";
|
|
14
|
+
import { IntervalOpType } from "./intervals";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* A local value to be stored in a container type DDS.
|
|
@@ -88,7 +89,7 @@ export class ValueTypeLocalValue<T> implements ILocalValue<T> {
|
|
|
88
89
|
* @param opName - The name of the operation that needs processing
|
|
89
90
|
* @returns The object which can process the given op
|
|
90
91
|
*/
|
|
91
|
-
public getOpHandler(opName:
|
|
92
|
+
public getOpHandler(opName: IntervalOpType): IValueOperation<T> {
|
|
92
93
|
const handler = this.valueType.ops.get(opName);
|
|
93
94
|
if (!handler) {
|
|
94
95
|
throw new Error("Unknown type message");
|
package/src/packageVersion.ts
CHANGED
package/src/revertibles.ts
CHANGED
|
@@ -37,8 +37,6 @@ export type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertib
|
|
|
37
37
|
|
|
38
38
|
const idMap = new Map<string, string>();
|
|
39
39
|
|
|
40
|
-
type IntervalOpType = (typeof IntervalOpType)[keyof typeof IntervalOpType];
|
|
41
|
-
|
|
42
40
|
/**
|
|
43
41
|
* Data for undoing edits affecting Intervals.
|
|
44
42
|
*
|
package/src/sharedString.ts
CHANGED
|
@@ -196,6 +196,10 @@ export class SharedString
|
|
|
196
196
|
* @param marker - The marker to annotate
|
|
197
197
|
* @param props - The properties to annotate the marker with
|
|
198
198
|
* @param consensusCallback - The callback called when consensus is reached
|
|
199
|
+
*
|
|
200
|
+
* @deprecated We no longer intend to support this functionality and it will
|
|
201
|
+
* be removed in a future release. There is no replacement for this
|
|
202
|
+
* functionality.
|
|
199
203
|
*/
|
|
200
204
|
public annotateMarkerNotifyConsensus(
|
|
201
205
|
marker: Marker,
|