@fluidframework/sequence 2.5.0 → 2.10.0-304831

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.
Files changed (101) hide show
  1. package/api-report/sequence.legacy.alpha.api.md +16 -131
  2. package/dist/index.js +1 -6
  3. package/dist/index.js.map +1 -1
  4. package/dist/intervalCollection.d.ts +2 -2
  5. package/dist/intervalCollection.d.ts.map +1 -1
  6. package/dist/intervalCollection.js +19 -13
  7. package/dist/intervalCollection.js.map +1 -1
  8. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  9. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +1 -1
  10. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  11. package/dist/intervals/index.d.ts +2 -2
  12. package/dist/intervals/index.d.ts.map +1 -1
  13. package/dist/intervals/index.js +2 -2
  14. package/dist/intervals/index.js.map +1 -1
  15. package/dist/intervals/interval.d.ts +1 -8
  16. package/dist/intervals/interval.d.ts.map +1 -1
  17. package/dist/intervals/interval.js +1 -15
  18. package/dist/intervals/interval.js.map +1 -1
  19. package/dist/intervals/intervalUtils.d.ts +4 -11
  20. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  21. package/dist/intervals/intervalUtils.js.map +1 -1
  22. package/dist/intervals/sequenceInterval.d.ts +69 -13
  23. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  24. package/dist/intervals/sequenceInterval.js +8 -52
  25. package/dist/intervals/sequenceInterval.js.map +1 -1
  26. package/dist/legacy.d.ts +0 -2
  27. package/dist/packageVersion.d.ts +1 -1
  28. package/dist/packageVersion.d.ts.map +1 -1
  29. package/dist/packageVersion.js +1 -1
  30. package/dist/packageVersion.js.map +1 -1
  31. package/dist/revertibles.d.ts.map +1 -1
  32. package/dist/revertibles.js +2 -2
  33. package/dist/revertibles.js.map +1 -1
  34. package/dist/sequence.d.ts +1 -3
  35. package/dist/sequence.d.ts.map +1 -1
  36. package/dist/sequence.js +3 -5
  37. package/dist/sequence.js.map +1 -1
  38. package/dist/sequenceDeltaEvent.d.ts +36 -13
  39. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  40. package/dist/sequenceDeltaEvent.js +15 -70
  41. package/dist/sequenceDeltaEvent.js.map +1 -1
  42. package/dist/sharedString.d.ts +1 -3
  43. package/dist/sharedString.d.ts.map +1 -1
  44. package/dist/sharedString.js +1 -3
  45. package/dist/sharedString.js.map +1 -1
  46. package/lib/index.js +1 -2
  47. package/lib/index.js.map +1 -1
  48. package/lib/intervalCollection.d.ts +2 -2
  49. package/lib/intervalCollection.d.ts.map +1 -1
  50. package/lib/intervalCollection.js +21 -15
  51. package/lib/intervalCollection.js.map +1 -1
  52. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  53. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +2 -2
  54. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  55. package/lib/intervals/index.d.ts +2 -2
  56. package/lib/intervals/index.d.ts.map +1 -1
  57. package/lib/intervals/index.js +1 -1
  58. package/lib/intervals/index.js.map +1 -1
  59. package/lib/intervals/interval.d.ts +1 -8
  60. package/lib/intervals/interval.d.ts.map +1 -1
  61. package/lib/intervals/interval.js +2 -16
  62. package/lib/intervals/interval.js.map +1 -1
  63. package/lib/intervals/intervalUtils.d.ts +4 -11
  64. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  65. package/lib/intervals/intervalUtils.js.map +1 -1
  66. package/lib/intervals/sequenceInterval.d.ts +69 -13
  67. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  68. package/lib/intervals/sequenceInterval.js +7 -51
  69. package/lib/intervals/sequenceInterval.js.map +1 -1
  70. package/lib/legacy.d.ts +0 -2
  71. package/lib/packageVersion.d.ts +1 -1
  72. package/lib/packageVersion.d.ts.map +1 -1
  73. package/lib/packageVersion.js +1 -1
  74. package/lib/packageVersion.js.map +1 -1
  75. package/lib/revertibles.d.ts.map +1 -1
  76. package/lib/revertibles.js +3 -3
  77. package/lib/revertibles.js.map +1 -1
  78. package/lib/sequence.d.ts +1 -3
  79. package/lib/sequence.d.ts.map +1 -1
  80. package/lib/sequence.js +4 -6
  81. package/lib/sequence.js.map +1 -1
  82. package/lib/sequenceDeltaEvent.d.ts +36 -13
  83. package/lib/sequenceDeltaEvent.d.ts.map +1 -1
  84. package/lib/sequenceDeltaEvent.js +9 -64
  85. package/lib/sequenceDeltaEvent.js.map +1 -1
  86. package/lib/sharedString.d.ts +1 -3
  87. package/lib/sharedString.d.ts.map +1 -1
  88. package/lib/sharedString.js +1 -3
  89. package/lib/sharedString.js.map +1 -1
  90. package/package.json +90 -20
  91. package/src/intervalCollection.ts +37 -20
  92. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +2 -1
  93. package/src/intervals/index.ts +2 -0
  94. package/src/intervals/interval.ts +3 -24
  95. package/src/intervals/intervalUtils.ts +7 -16
  96. package/src/intervals/sequenceInterval.ts +89 -30
  97. package/src/packageVersion.ts +1 -1
  98. package/src/revertibles.ts +3 -3
  99. package/src/sequence.ts +13 -6
  100. package/src/sequenceDeltaEvent.ts +54 -38
  101. package/src/sharedString.ts +1 -3
@@ -1 +1 @@
1
- {"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAMN,MAAM,EAGN,WAAW,EACX,eAAe,GACf,MAAM,qCAAqC,CAAC;AAE7C,gDAAgD;AAChD,OAAO,EAAE,qBAAqB,EAA+B,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AA8G3D;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,iBAAiB;AAC7B,gDAAgD;AAChD,SAAQ,qBAA0C;IAGlD,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;IAKD,YACC,QAAgC,EACzB,EAAU,EACjB,U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,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,MAAM,eAAe;YACpB,gEAAgE;YAChE,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACjF,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;QACrC,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAG,OAAiB,CAAC;YACjC,IAAI,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBAC5D,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;YACvB,CAAC;QACF,CAAC;IACF,CAAC;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\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\t// eslint-disable-next-line import/no-deprecated\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferenceType,\n\tTextSegment,\n\trefHasTileLabel,\n} from \"@fluidframework/merge-tree/internal\";\n\n// eslint-disable-next-line import/no-deprecated\nimport { SharedSegmentSequence, type ISharedSegmentSequence } from \"./sequence.js\";\nimport { SharedStringFactory } from \"./sequenceFactory.js\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n * @legacy\n * @alpha\n */\nexport interface ISharedString extends ISharedSegmentSequence<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(pos: number, refType: ReferenceType, props?: PropertySet): void;\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\tinsertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): void;\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\tinsertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet): void;\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\treplaceText(start: number, end: number, text: string, props?: PropertySet): void;\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\tremoveText(start: number, end: number): void;\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 */\n\tannotateMarker(marker: Marker, props: PropertySet): void;\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`. Default true.\n\t */\n\tsearchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards?: boolean,\n\t): Marker | undefined;\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\tgetText(start?: number, end?: number): string;\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tgetTextWithPlaceholders(start?: number, end?: number): string;\n\n\tgetTextRangeWithMarkers(start: number, end: number): string;\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\tgetMarkerFromId(id: string): ISegment | undefined;\n}\n\n/**\n * @legacy\n * @alpha\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 * @legacy\n * @alpha\n * @deprecated This functionality was not meant to be exported and will be removed in a future release\n */\nexport class SharedStringClass\n\t// eslint-disable-next-line import/no-deprecated\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\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 * {@inheritDoc ISharedString.insertMarkerRelative}\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): void {\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.insertSegmentLocal(pos, Marker.make(refType, props)),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.insertSegmentLocal(pos, Marker.make(refType, props)),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertTextRelative}\n\t */\n\tpublic insertTextRelative(\n\t\trelativePos1: IRelativePosition,\n\t\ttext: string,\n\t\tprops?: PropertySet,\n\t): void {\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.insertSegmentLocal(pos, TextSegment.make(text, props)),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet): void {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.insertSegmentLocal(pos, TextSegment.make(text, props)),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.replaceText}\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet): void {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.removeText}\n\t */\n\tpublic removeText(start: number, end: number): void {\n\t\tthis.removeRange(start, end);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.annotateMarker}\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet): void {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.searchForMarker}\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 * {@inheritDoc ISharedString.getText}\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 * {@inheritDoc ISharedString.getTextWithPlaceholders}\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\t/**\n\t * {@inheritDoc ISharedString.getTextRangeWithMarkers}\n\t */\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 * {@inheritDoc ISharedString.getMarkerFromId}\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 * @internal\n */\nexport function getTextAndMarkers(\n\tsharedString: ISharedString,\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\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\tplaceholder === \"*\" ? `\\n${segment}` : 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":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG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AAC,MAAM,CAAC;YACnC,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACrC,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;SAAM,CAAC;QACP,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,MAAM,eAAe;YACpB,gEAAgE;YAChE,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACjF,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;QACrC,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAG,OAAiB,CAAC;YACjC,IAAI,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBAC5D,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;YACvB,CAAC;QACF,CAAC;IACF,CAAC;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\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\t// eslint-disable-next-line import/no-deprecated\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferenceType,\n\tTextSegment,\n\trefHasTileLabel,\n} from \"@fluidframework/merge-tree/internal\";\n\n// eslint-disable-next-line import/no-deprecated\nimport { SharedSegmentSequence, type ISharedSegmentSequence } from \"./sequence.js\";\nimport { SharedStringFactory } from \"./sequenceFactory.js\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n * @legacy\n * @alpha\n */\nexport interface ISharedString extends ISharedSegmentSequence<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(pos: number, refType: ReferenceType, props?: PropertySet): void;\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\tinsertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): void;\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\tinsertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet): void;\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\treplaceText(start: number, end: number, text: string, props?: PropertySet): void;\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\tremoveText(start: number, end: number): void;\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 */\n\tannotateMarker(marker: Marker, props: PropertySet): void;\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`. Default true.\n\t */\n\tsearchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards?: boolean,\n\t): Marker | undefined;\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\tgetText(start?: number, end?: number): string;\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tgetTextWithPlaceholders(start?: number, end?: number): string;\n\n\tgetTextRangeWithMarkers(start: number, end: number): string;\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\tgetMarkerFromId(id: string): ISegment | undefined;\n}\n\n/**\n * @legacy\n * @alpha\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 * @internal\n */\nexport class SharedStringClass\n\t// eslint-disable-next-line import/no-deprecated\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\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 * {@inheritDoc ISharedString.insertMarkerRelative}\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): void {\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.insertSegmentLocal(pos, Marker.make(refType, props)),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.insertSegmentLocal(pos, Marker.make(refType, props)),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertTextRelative}\n\t */\n\tpublic insertTextRelative(\n\t\trelativePos1: IRelativePosition,\n\t\ttext: string,\n\t\tprops?: PropertySet,\n\t): void {\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.insertSegmentLocal(pos, TextSegment.make(text, props)),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet): void {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.insertSegmentLocal(pos, TextSegment.make(text, props)),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.replaceText}\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet): void {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.removeText}\n\t */\n\tpublic removeText(start: number, end: number): void {\n\t\tthis.removeRange(start, end);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.annotateMarker}\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet): void {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.searchForMarker}\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 * {@inheritDoc ISharedString.getText}\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 * {@inheritDoc ISharedString.getTextWithPlaceholders}\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\t/**\n\t * {@inheritDoc ISharedString.getTextRangeWithMarkers}\n\t */\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 * {@inheritDoc ISharedString.getMarkerFromId}\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 * @internal\n */\nexport function getTextAndMarkers(\n\tsharedString: ISharedString,\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\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\tplaceholder === \"*\" ? `\\n${segment}` : 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.5.0",
3
+ "version": "2.10.0-304831",
4
4
  "description": "Distributed sequence",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -79,33 +79,33 @@
79
79
  "temp-directory": "nyc/.nyc_output"
80
80
  },
81
81
  "dependencies": {
82
- "@fluid-internal/client-utils": "~2.5.0",
83
- "@fluidframework/core-interfaces": "~2.5.0",
84
- "@fluidframework/core-utils": "~2.5.0",
85
- "@fluidframework/datastore-definitions": "~2.5.0",
86
- "@fluidframework/driver-definitions": "~2.5.0",
87
- "@fluidframework/merge-tree": "~2.5.0",
88
- "@fluidframework/runtime-definitions": "~2.5.0",
89
- "@fluidframework/runtime-utils": "~2.5.0",
90
- "@fluidframework/shared-object-base": "~2.5.0",
91
- "@fluidframework/telemetry-utils": "~2.5.0",
82
+ "@fluid-internal/client-utils": "2.10.0-304831",
83
+ "@fluidframework/core-interfaces": "2.10.0-304831",
84
+ "@fluidframework/core-utils": "2.10.0-304831",
85
+ "@fluidframework/datastore-definitions": "2.10.0-304831",
86
+ "@fluidframework/driver-definitions": "2.10.0-304831",
87
+ "@fluidframework/merge-tree": "2.10.0-304831",
88
+ "@fluidframework/runtime-definitions": "2.10.0-304831",
89
+ "@fluidframework/runtime-utils": "2.10.0-304831",
90
+ "@fluidframework/shared-object-base": "2.10.0-304831",
91
+ "@fluidframework/telemetry-utils": "2.10.0-304831",
92
92
  "double-ended-queue": "^2.1.0-0",
93
93
  "uuid": "^9.0.0"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@arethetypeswrong/cli": "^0.16.4",
97
97
  "@biomejs/biome": "~1.9.3",
98
- "@fluid-internal/mocha-test-setup": "~2.5.0",
99
- "@fluid-private/stochastic-test-utils": "~2.5.0",
100
- "@fluid-private/test-dds-utils": "~2.5.0",
98
+ "@fluid-internal/mocha-test-setup": "2.10.0-304831",
99
+ "@fluid-private/stochastic-test-utils": "2.10.0-304831",
100
+ "@fluid-private/test-dds-utils": "2.10.0-304831",
101
101
  "@fluid-tools/benchmark": "^0.50.0",
102
- "@fluid-tools/build-cli": "^0.49.0",
102
+ "@fluid-tools/build-cli": "^0.50.0",
103
103
  "@fluidframework/build-common": "^2.0.3",
104
- "@fluidframework/build-tools": "^0.49.0",
105
- "@fluidframework/container-definitions": "~2.5.0",
104
+ "@fluidframework/build-tools": "^0.50.0",
105
+ "@fluidframework/container-definitions": "2.10.0-304831",
106
106
  "@fluidframework/eslint-config-fluid": "^5.4.0",
107
- "@fluidframework/sequence-previous": "npm:@fluidframework/sequence@~2.4.0",
108
- "@fluidframework/test-runtime-utils": "~2.5.0",
107
+ "@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.5.0",
108
+ "@fluidframework/test-runtime-utils": "2.10.0-304831",
109
109
  "@microsoft/api-extractor": "7.47.8",
110
110
  "@types/diff": "^3.5.1",
111
111
  "@types/double-ended-queue": "^2.1.0",
@@ -136,7 +136,77 @@
136
136
  }
137
137
  },
138
138
  "typeValidation": {
139
- "broken": {},
139
+ "broken": {
140
+ "ClassStatics_SequenceDeltaEvent": {
141
+ "backCompat": false
142
+ },
143
+ "ClassStatics_SequenceEvent": {
144
+ "backCompat": false
145
+ },
146
+ "ClassStatics_SequenceInterval": {
147
+ "backCompat": false
148
+ },
149
+ "ClassStatics_SequenceMaintenanceEvent": {
150
+ "backCompat": false
151
+ },
152
+ "Class_BaseSegment": {
153
+ "backCompat": false
154
+ },
155
+ "Class_Marker": {
156
+ "backCompat": false
157
+ },
158
+ "Class_SequenceDeltaEvent": {
159
+ "backCompat": false
160
+ },
161
+ "Class_SequenceEvent": {
162
+ "backCompat": false
163
+ },
164
+ "Class_SequenceInterval": {
165
+ "backCompat": false
166
+ },
167
+ "Class_SequenceMaintenanceEvent": {
168
+ "backCompat": false
169
+ },
170
+ "Class_TextSegment": {
171
+ "backCompat": false
172
+ },
173
+ "Class_TrackingGroup": {
174
+ "backCompat": false
175
+ },
176
+ "ClassStatics_BaseSegment": {
177
+ "backCompat": false
178
+ },
179
+ "ClassStatics_Marker": {
180
+ "backCompat": false
181
+ },
182
+ "ClassStatics_TextSegment": {
183
+ "backCompat": false
184
+ },
185
+ "ClassStatics_TrackingGroup": {
186
+ "backCompat": false
187
+ },
188
+ "Interface_ISegment": {
189
+ "backCompat": false
190
+ },
191
+ "Interface_ISequenceDeltaRange": {
192
+ "backCompat": false
193
+ },
194
+ "Interface_ISerializableInterval": {
195
+ "backCompat": false
196
+ },
197
+ "Interface_ReferencePosition": {
198
+ "backCompat": false
199
+ },
200
+ "TypeAlias_IntervalRevertible": {
201
+ "backCompat": false
202
+ },
203
+ "TypeAlias_SharedStringRevertible": {
204
+ "backCompat": false
205
+ },
206
+ "TypeAlias_SharedStringSegment": {
207
+ "backCompat": false
208
+ }
209
+ },
140
210
  "entrypoint": "legacy"
141
211
  },
142
212
  "scripts": {
@@ -29,6 +29,8 @@ import {
29
29
  Side,
30
30
  SequencePlace,
31
31
  endpointPosAndSide,
32
+ PropertiesManager,
33
+ type ISegmentInternal,
32
34
  } from "@fluidframework/merge-tree/internal";
33
35
  import { LoggingError, UsageError } from "@fluidframework/telemetry-utils/internal";
34
36
  import { v4 as uuid } from "uuid";
@@ -60,12 +62,14 @@ import {
60
62
  IntervalStickiness,
61
63
  IntervalType,
62
64
  SequenceInterval,
65
+ SequenceIntervalClass,
63
66
  SerializedIntervalDelta,
64
67
  createInterval,
65
68
  createPositionReferenceFromSegoff,
66
69
  endReferenceSlidingPreference,
67
70
  sequenceIntervalHelpers,
68
71
  startReferenceSlidingPreference,
72
+ type ISerializableIntervalPrivate,
69
73
  } from "./intervals/index.js";
70
74
 
71
75
  export const reservedIntervalIdKey = "intervalId";
@@ -313,7 +317,7 @@ export class LocalIntervalCollection<TInterval extends ISerializableInterval> {
313
317
  }
314
318
 
315
319
  private linkEndpointsToInterval(interval: TInterval): void {
316
- if (interval instanceof SequenceInterval) {
320
+ if (interval instanceof SequenceIntervalClass) {
317
321
  interval.start.addProperties({ interval });
318
322
  interval.end.addProperties({ interval });
319
323
  }
@@ -382,15 +386,15 @@ export class LocalIntervalCollection<TInterval extends ISerializableInterval> {
382
386
  ref.canSlideToEndpoint,
383
387
  );
384
388
  };
385
- if (interval instanceof SequenceInterval) {
386
- let previousInterval: (TInterval & SequenceInterval) | undefined;
389
+ if (interval instanceof SequenceIntervalClass) {
390
+ let previousInterval: (TInterval & SequenceIntervalClass) | undefined;
387
391
  let pendingChanges = 0;
388
392
  interval.addPositionChangeListeners(
389
393
  () => {
390
394
  pendingChanges++;
391
395
  // Note: both start and end can change and invoke beforeSlide on each endpoint before afterSlide.
392
396
  if (!previousInterval) {
393
- previousInterval = interval.clone() as TInterval & SequenceInterval;
397
+ previousInterval = interval.clone() as TInterval & SequenceIntervalClass;
394
398
  previousInterval.start = cloneRef(previousInterval.start);
395
399
  previousInterval.end = cloneRef(previousInterval.end);
396
400
  this.removeIntervalFromIndexes(interval);
@@ -413,7 +417,7 @@ export class LocalIntervalCollection<TInterval extends ISerializableInterval> {
413
417
  }
414
418
 
415
419
  private removeIntervalListeners(interval: TInterval) {
416
- if (interval instanceof SequenceInterval) {
420
+ if (interval instanceof SequenceIntervalClass) {
417
421
  interval.removePositionChangeListeners();
418
422
  }
419
423
  }
@@ -1147,7 +1151,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1147
1151
  // is restored as single-endpoint changes re-use previous references.
1148
1152
  let startRefType: ReferenceType;
1149
1153
  let endRefType: ReferenceType;
1150
- if (previousInterval instanceof SequenceInterval) {
1154
+ if (previousInterval instanceof SequenceIntervalClass) {
1151
1155
  startRefType = previousInterval.start.refType;
1152
1156
  endRefType = previousInterval.end.refType;
1153
1157
  previousInterval.start.refType = ReferenceType.Transient;
@@ -1165,7 +1169,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1165
1169
  /**
1166
1170
  * {@inheritdoc IIntervalCollection.getIntervalById}
1167
1171
  */
1168
- public getIntervalById(id: string): TInterval | undefined {
1172
+ public getIntervalById(id: string): ISerializableIntervalPrivate<TInterval> | undefined {
1169
1173
  if (!this.localCollection) {
1170
1174
  throw new LoggingError("attach must be called before accessing intervals");
1171
1175
  }
@@ -1221,7 +1225,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1221
1225
  );
1222
1226
 
1223
1227
  if (interval) {
1224
- if (!this.isCollaborating && interval instanceof SequenceInterval) {
1228
+ if (!this.isCollaborating && interval instanceof SequenceIntervalClass) {
1225
1229
  setSlideOnRemove(interval.start);
1226
1230
  setSlideOnRemove(interval.end);
1227
1231
  }
@@ -1324,15 +1328,17 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1324
1328
  let deltaProps: PropertySet | undefined;
1325
1329
  let newInterval: TInterval | undefined;
1326
1330
  if (props !== undefined) {
1327
- deltaProps = interval.addProperties(
1331
+ interval.propertyManager ??= new PropertiesManager();
1332
+ deltaProps = interval.propertyManager.addProperties(
1333
+ interval.properties,
1328
1334
  props,
1329
- true,
1330
1335
  this.isCollaborating ? UnassignedSequenceNumber : UniversalSequenceNumber,
1336
+ true,
1331
1337
  );
1332
1338
  }
1333
1339
  if (start !== undefined && end !== undefined) {
1334
1340
  newInterval = this.localCollection.changeInterval(interval, start, end);
1335
- if (!this.isCollaborating && newInterval instanceof SequenceInterval) {
1341
+ if (!this.isCollaborating && newInterval instanceof SequenceIntervalClass) {
1336
1342
  setSlideOnRemove(newInterval.start);
1337
1343
  setSlideOnRemove(newInterval.end);
1338
1344
  }
@@ -1370,7 +1376,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1370
1376
  if (newInterval) {
1371
1377
  this.addPendingChange(id, serializedInterval);
1372
1378
  this.emitChange(newInterval, interval, true, false);
1373
- if (interval instanceof SequenceInterval) {
1379
+ if (interval instanceof SequenceIntervalClass) {
1374
1380
  this.client?.removeLocalReferencePosition(interval.start);
1375
1381
  this.client?.removeLocalReferencePosition(interval.end);
1376
1382
  }
@@ -1476,15 +1482,17 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1476
1482
  // strip it out of the properties here.
1477
1483
  const { [reservedIntervalIdKey]: id, ...newProps } = serializedInterval.properties ?? {};
1478
1484
  assert(id !== undefined, 0x3fe /* id must exist on the interval */);
1479
- const interval: TInterval | undefined = this.getIntervalById(id);
1485
+ const interval: ISerializableIntervalPrivate<TInterval> | undefined =
1486
+ this.getIntervalById(id);
1480
1487
  if (!interval) {
1481
1488
  // The interval has been removed locally; no-op.
1482
1489
  return;
1483
1490
  }
1484
1491
 
1485
1492
  if (local) {
1493
+ interval.propertyManager ??= new PropertiesManager();
1486
1494
  // Let the propertyManager prune its pending change-properties set.
1487
- interval.propertyManager?.ackPendingProperties({
1495
+ interval.propertyManager.ackPendingProperties({
1488
1496
  type: MergeTreeDeltaType.ANNOTATE,
1489
1497
  props: serializedInterval.properties ?? {},
1490
1498
  });
@@ -1515,7 +1523,13 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1515
1523
  op,
1516
1524
  ) ?? interval;
1517
1525
  }
1518
- const deltaProps = newInterval.addProperties(newProps, true, op.sequenceNumber);
1526
+ newInterval.propertyManager ??= new PropertiesManager();
1527
+ const deltaProps = newInterval.propertyManager.addProperties(
1528
+ newInterval.properties,
1529
+ newProps,
1530
+ op.sequenceNumber,
1531
+ true,
1532
+ );
1519
1533
  if (this.onDeserialize) {
1520
1534
  this.onDeserialize(newInterval);
1521
1535
  }
@@ -1611,7 +1625,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1611
1625
  if (localInterval !== undefined) {
1612
1626
  // we know we must be using `SequenceInterval` because `this.client` exists
1613
1627
  assert(
1614
- localInterval instanceof SequenceInterval,
1628
+ localInterval instanceof SequenceIntervalClass,
1615
1629
  0x3a0 /* localInterval must be `SequenceInterval` when used with client */,
1616
1630
  );
1617
1631
  // The rebased op may place this interval's endpoints on different segments. Calling `changeInterval` here
@@ -1635,7 +1649,10 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1635
1649
  if (!this.client) {
1636
1650
  throw new LoggingError("client does not exist");
1637
1651
  }
1638
- const segoff = { segment: lref.getSegment(), offset: lref.getOffset() };
1652
+ const segoff: { segment: ISegmentInternal | undefined; offset: number | undefined } = {
1653
+ segment: lref.getSegment(),
1654
+ offset: lref.getOffset(),
1655
+ };
1639
1656
  if (segoff.segment?.localRefs?.has(lref) !== true) {
1640
1657
  return undefined;
1641
1658
  }
@@ -1653,7 +1670,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1653
1670
 
1654
1671
  private ackInterval(interval: TInterval, op: ISequencedDocumentMessage): void {
1655
1672
  // Only SequenceIntervals need potential sliding
1656
- if (!(interval instanceof SequenceInterval)) {
1673
+ if (!(interval instanceof SequenceIntervalClass)) {
1657
1674
  return;
1658
1675
  }
1659
1676
 
@@ -1719,7 +1736,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1719
1736
  if (props) {
1720
1737
  interval.start.addProperties(props);
1721
1738
  }
1722
- const oldSeg = oldInterval.start.getSegment();
1739
+ const oldSeg: ISegmentInternal | undefined = oldInterval.start.getSegment();
1723
1740
  // remove and rebuild start interval as transient for event
1724
1741
  this.client.removeLocalReferencePosition(oldInterval.start);
1725
1742
  oldInterval.start.refType = ReferenceType.Transient;
@@ -1741,7 +1758,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1741
1758
  interval.end.addProperties(props);
1742
1759
  }
1743
1760
  // remove and rebuild end interval as transient for event
1744
- const oldSeg = oldInterval.end.getSegment();
1761
+ const oldSeg: ISegmentInternal | undefined = oldInterval.end.getSegment();
1745
1762
  this.client.removeLocalReferencePosition(oldInterval.end);
1746
1763
  oldInterval.end.refType = ReferenceType.Transient;
1747
1764
  oldSeg?.localRefs?.addLocalRef(oldInterval.end, oldInterval.end.getOffset());
@@ -16,6 +16,7 @@ import {
16
16
  import {
17
17
  IntervalType,
18
18
  SequenceInterval,
19
+ SequenceIntervalClass,
19
20
  createPositionReferenceFromSegoff,
20
21
  sequenceIntervalHelpers,
21
22
  } from "../intervals/index.js";
@@ -56,7 +57,7 @@ class OverlappingSequenceIntervalsIndex
56
57
  return [];
57
58
  }
58
59
 
59
- const transientInterval = new SequenceInterval(
60
+ const transientInterval = new SequenceIntervalClass(
60
61
  this.client,
61
62
  startLref,
62
63
  endLref,
@@ -12,6 +12,7 @@ export {
12
12
  IntervalDeltaOpType,
13
13
  IIntervalHelpers,
14
14
  IntervalStickiness,
15
+ ISerializableIntervalPrivate,
15
16
  SerializedIntervalDelta,
16
17
  CompressedSerializedInterval,
17
18
  endReferenceSlidingPreference,
@@ -20,6 +21,7 @@ export {
20
21
  export { Interval, createInterval, intervalHelpers } from "./interval.js";
21
22
  export {
22
23
  SequenceInterval,
24
+ SequenceIntervalClass,
23
25
  createSequenceInterval,
24
26
  createPositionReferenceFromSegoff,
25
27
  sequenceIntervalHelpers,
@@ -14,6 +14,7 @@ import {
14
14
  reservedRangeLabelsKey,
15
15
  SequencePlace,
16
16
  addProperties,
17
+ copyPropertiesAndManager,
17
18
  } from "@fluidframework/merge-tree/internal";
18
19
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
19
20
 
@@ -38,10 +39,7 @@ export class Interval implements ISerializableInterval {
38
39
  /***/
39
40
  public auxProps: PropertySet[] | undefined;
40
41
 
41
- /**
42
- * {@inheritDoc ISerializableInterval.propertyManager}
43
- */
44
- public readonly propertyManager: PropertiesManager = new PropertiesManager();
42
+ public propertyManager?: PropertiesManager;
45
43
 
46
44
  constructor(
47
45
  public start: number,
@@ -172,19 +170,6 @@ export class Interval implements ISerializableInterval {
172
170
  return this.properties;
173
171
  }
174
172
 
175
- /**
176
- * {@inheritDoc ISerializableInterval.addProperties}
177
- */
178
- public addProperties(
179
- newProps: PropertySet,
180
- collaborating: boolean = false,
181
- seq?: number,
182
- ): PropertySet | undefined {
183
- if (newProps) {
184
- return this.propertyManager.addProperties(this.properties, newProps, seq, collaborating);
185
- }
186
- }
187
-
188
173
  /**
189
174
  * {@inheritDoc IInterval.modify}
190
175
  */
@@ -208,13 +193,7 @@ export class Interval implements ISerializableInterval {
208
193
  return;
209
194
  }
210
195
  const newInterval = new Interval(startPos, endPos);
211
- if (this.properties) {
212
- this.propertyManager.copyTo(
213
- this.properties,
214
- newInterval.properties,
215
- newInterval.propertyManager,
216
- );
217
- }
196
+ copyPropertiesAndManager(this, newInterval);
218
197
  return newInterval;
219
198
  }
220
199
  }
@@ -160,31 +160,22 @@ export interface ISerializedInterval {
160
160
  export interface ISerializableInterval extends IInterval {
161
161
  /** Serializable bag of properties associated with the interval. */
162
162
  properties: PropertySet;
163
- /**
164
- * @deprecated - This property should not be used externally and will be removed in a subsequent release.
165
- */
166
- // eslint-disable-next-line import/no-deprecated
167
- propertyManager: PropertiesManager;
163
+
168
164
  /***/
169
165
  serialize(): ISerializedInterval;
170
- /**
171
- * @deprecated - This function should not be used externally and will be removed in a subsequent release.
172
- */
173
- addProperties(
174
- props: PropertySet,
175
- collaborating?: boolean,
176
- seq?: number,
177
- ): PropertySet | undefined;
166
+
178
167
  /**
179
168
  * Gets the id associated with this interval.
180
169
  * When the interval is used as part of an interval collection, this id can be used to modify or remove the
181
170
  * interval.
182
- * @remarks This signature includes `undefined` strictly for backwards-compatibility reasons, as older versions
183
- * of Fluid didn't always write interval ids.
184
171
  */
185
- getIntervalId(): string | undefined;
172
+ getIntervalId(): string;
186
173
  }
187
174
 
175
+ export type ISerializableIntervalPrivate<T extends ISerializableInterval> = T & {
176
+ propertyManager?: PropertiesManager;
177
+ };
178
+
188
179
  /**
189
180
  * Represents a change that should be applied to an existing interval.
190
181
  * Changes can modify any of start/end/properties, with `undefined` signifying no change should be made.