@fluidframework/sequence 2.0.0-rc.4.0.5 → 2.0.0-rc.5.0.0

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 (168) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/api-extractor/api-extractor-lint-beta.cjs.json +5 -0
  3. package/api-extractor/api-extractor-lint-beta.esm.json +5 -0
  4. package/api-extractor/api-extractor-lint-bundle.json +5 -0
  5. package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
  6. package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
  7. package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
  8. package/api-extractor/api-extractor-lint-public.esm.json +5 -0
  9. package/api-extractor.json +1 -1
  10. package/api-report/{sequence.api.md → sequence.alpha.api.md} +71 -244
  11. package/api-report/sequence.beta.api.md +83 -0
  12. package/api-report/sequence.public.api.md +83 -0
  13. package/biome.jsonc +4 -0
  14. package/dist/IntervalCollectionValues.d.ts +1 -1
  15. package/dist/IntervalCollectionValues.d.ts.map +1 -1
  16. package/dist/IntervalCollectionValues.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/intervalCollection.d.ts +1 -1
  21. package/dist/intervalCollection.d.ts.map +1 -1
  22. package/dist/intervalCollection.js +4 -6
  23. package/dist/intervalCollection.js.map +1 -1
  24. package/dist/intervalCollectionMap.d.ts +2 -2
  25. package/dist/intervalCollectionMap.d.ts.map +1 -1
  26. package/dist/intervalCollectionMap.js.map +1 -1
  27. package/dist/intervalCollectionMapInterfaces.d.ts +2 -2
  28. package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -1
  29. package/dist/intervalCollectionMapInterfaces.js.map +1 -1
  30. package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  31. package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
  32. package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
  33. package/dist/intervalIndex/endpointIndex.js.map +1 -1
  34. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  35. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  36. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +0 -3
  37. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  38. package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  39. package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
  40. package/dist/intervalTree.js.map +1 -1
  41. package/dist/intervals/interval.d.ts +1 -1
  42. package/dist/intervals/interval.d.ts.map +1 -1
  43. package/dist/intervals/interval.js.map +1 -1
  44. package/dist/intervals/intervalUtils.d.ts +2 -2
  45. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  46. package/dist/intervals/intervalUtils.js +0 -1
  47. package/dist/intervals/intervalUtils.js.map +1 -1
  48. package/dist/intervals/sequenceInterval.d.ts +1 -1
  49. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  50. package/dist/intervals/sequenceInterval.js +1 -1
  51. package/dist/intervals/sequenceInterval.js.map +1 -1
  52. package/dist/legacy.d.ts +1 -0
  53. package/dist/packageVersion.d.ts +1 -1
  54. package/dist/packageVersion.js +1 -1
  55. package/dist/packageVersion.js.map +1 -1
  56. package/dist/revertibles.d.ts.map +1 -1
  57. package/dist/revertibles.js +3 -3
  58. package/dist/revertibles.js.map +1 -1
  59. package/dist/sequence.d.ts +168 -133
  60. package/dist/sequence.d.ts.map +1 -1
  61. package/dist/sequence.js +59 -240
  62. package/dist/sequence.js.map +1 -1
  63. package/dist/sequenceDeltaEvent.js.map +1 -1
  64. package/dist/sequenceFactory.d.ts +2 -3
  65. package/dist/sequenceFactory.d.ts.map +1 -1
  66. package/dist/sequenceFactory.js.map +1 -1
  67. package/dist/sharedIntervalCollection.d.ts +4 -5
  68. package/dist/sharedIntervalCollection.d.ts.map +1 -1
  69. package/dist/sharedIntervalCollection.js +5 -5
  70. package/dist/sharedIntervalCollection.js.map +1 -1
  71. package/dist/sharedSequence.d.ts +1 -2
  72. package/dist/sharedSequence.d.ts.map +1 -1
  73. package/dist/sharedSequence.js.map +1 -1
  74. package/dist/sharedString.d.ts +3 -3
  75. package/dist/sharedString.d.ts.map +1 -1
  76. package/dist/sharedString.js.map +1 -1
  77. package/lib/IntervalCollectionValues.d.ts +1 -1
  78. package/lib/IntervalCollectionValues.d.ts.map +1 -1
  79. package/lib/IntervalCollectionValues.js +1 -1
  80. package/lib/IntervalCollectionValues.js.map +1 -1
  81. package/lib/index.d.ts +1 -1
  82. package/lib/index.d.ts.map +1 -1
  83. package/lib/index.js +1 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/intervalCollection.d.ts +1 -1
  86. package/lib/intervalCollection.d.ts.map +1 -1
  87. package/lib/intervalCollection.js +4 -6
  88. package/lib/intervalCollection.js.map +1 -1
  89. package/lib/intervalCollectionMap.d.ts +2 -2
  90. package/lib/intervalCollectionMap.d.ts.map +1 -1
  91. package/lib/intervalCollectionMap.js +1 -1
  92. package/lib/intervalCollectionMap.js.map +1 -1
  93. package/lib/intervalCollectionMapInterfaces.d.ts +2 -2
  94. package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -1
  95. package/lib/intervalCollectionMapInterfaces.js.map +1 -1
  96. package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  97. package/lib/intervalIndex/endpointInRangeIndex.js +1 -1
  98. package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
  99. package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
  100. package/lib/intervalIndex/endpointIndex.js.map +1 -1
  101. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  102. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  103. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +0 -3
  104. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  105. package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  106. package/lib/intervalIndex/startpointInRangeIndex.js +1 -1
  107. package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
  108. package/lib/intervalTree.js.map +1 -1
  109. package/lib/intervals/interval.d.ts +1 -1
  110. package/lib/intervals/interval.d.ts.map +1 -1
  111. package/lib/intervals/interval.js.map +1 -1
  112. package/lib/intervals/intervalUtils.d.ts +2 -2
  113. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  114. package/lib/intervals/intervalUtils.js +0 -1
  115. package/lib/intervals/intervalUtils.js.map +1 -1
  116. package/lib/intervals/sequenceInterval.d.ts +1 -1
  117. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  118. package/lib/intervals/sequenceInterval.js +1 -1
  119. package/lib/intervals/sequenceInterval.js.map +1 -1
  120. package/lib/legacy.d.ts +1 -0
  121. package/lib/packageVersion.d.ts +1 -1
  122. package/lib/packageVersion.js +1 -1
  123. package/lib/packageVersion.js.map +1 -1
  124. package/lib/revertibles.d.ts.map +1 -1
  125. package/lib/revertibles.js +3 -3
  126. package/lib/revertibles.js.map +1 -1
  127. package/lib/sequence.d.ts +168 -133
  128. package/lib/sequence.d.ts.map +1 -1
  129. package/lib/sequence.js +42 -223
  130. package/lib/sequence.js.map +1 -1
  131. package/lib/sequenceDeltaEvent.js.map +1 -1
  132. package/lib/sequenceFactory.d.ts +2 -3
  133. package/lib/sequenceFactory.d.ts.map +1 -1
  134. package/lib/sequenceFactory.js.map +1 -1
  135. package/lib/sharedIntervalCollection.d.ts +4 -5
  136. package/lib/sharedIntervalCollection.d.ts.map +1 -1
  137. package/lib/sharedIntervalCollection.js +2 -2
  138. package/lib/sharedIntervalCollection.js.map +1 -1
  139. package/lib/sharedSequence.d.ts +1 -2
  140. package/lib/sharedSequence.d.ts.map +1 -1
  141. package/lib/sharedSequence.js.map +1 -1
  142. package/lib/sharedString.d.ts +3 -3
  143. package/lib/sharedString.d.ts.map +1 -1
  144. package/lib/sharedString.js.map +1 -1
  145. package/lib/tsdoc-metadata.json +1 -1
  146. package/package.json +77 -30
  147. package/src/IntervalCollectionValues.ts +8 -3
  148. package/src/index.ts +5 -1
  149. package/src/intervalCollection.ts +29 -18
  150. package/src/intervalCollectionMap.ts +6 -4
  151. package/src/intervalCollectionMapInterfaces.ts +2 -2
  152. package/src/intervalIndex/endpointInRangeIndex.ts +28 -22
  153. package/src/intervalIndex/endpointIndex.ts +3 -1
  154. package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -2
  155. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +0 -3
  156. package/src/intervalIndex/startpointInRangeIndex.ts +26 -20
  157. package/src/intervals/interval.ts +12 -9
  158. package/src/intervals/intervalUtils.ts +13 -5
  159. package/src/intervals/sequenceInterval.ts +2 -2
  160. package/src/packageVersion.ts +1 -1
  161. package/src/revertibles.ts +15 -11
  162. package/src/sequence.ts +302 -277
  163. package/src/sequenceFactory.ts +3 -5
  164. package/src/sharedIntervalCollection.ts +12 -6
  165. package/src/sharedSequence.ts +5 -2
  166. package/src/sharedString.ts +11 -4
  167. package/tsconfig.json +2 -0
  168. package/tsdoc.json +4 -0
@@ -1 +1 @@
1
- {"version":3,"file":"intervalCollectionMap.js","sourceRoot":"","sources":["../src/intervalCollectionMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAEjE,kEAA6D;AAG7D,0EAAwE;AAExE,+EAAmG;AACnG,mEAKiC;AAkBjC,SAAS,cAAc,CAAC,EAAW;IAClC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,IAAI,IAAI,MAAM,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC;AACnF,CAAC;AA6BD;;;;;;GAMG;AACH,MAAa,qBAAqB;IACjC;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACvB,CAAC;IA0CD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,EACtB,MAA+B,EAC/B,eAAyC,EAClC,EAAE;YACT,MAAM,EAAE,GAAkB;gBACzB,GAAG;gBACH,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE;oBACN,MAAM;oBACN,KAAK,EAAE,MAAM;iBACb;aACD,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;YAExC,MAAM,KAAK,GAAkB,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9E,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACjB,CAAC;CACD;AAlTD,sDAkTC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { ValueType } from \"@fluidframework/shared-object-base/internal\";\n\nimport { IntervalCollectionTypeLocalValue, makeSerializable } from \"./IntervalCollectionValues.js\";\nimport {\n\ttype IntervalCollection,\n\treservedIntervalIdKey,\n\ttoOptionalSequencePlace,\n\ttoSequencePlace,\n} from \"./intervalCollection.js\";\nimport {\n\tIIntervalCollectionType,\n\tIIntervalCollectionTypeOperationValue,\n\tIMapMessageLocalMetadata,\n\tISerializableIntervalCollection,\n\tISharedDefaultMapEvents,\n\tIValueChanged,\n\t// eslint-disable-next-line import/no-deprecated\n\tIValueOpEmitter,\n\tSequenceOptions,\n} from \"./intervalCollectionMapInterfaces.js\";\nimport {\n\ttype ISerializableInterval,\n\tIntervalDeltaOpType,\n\tSerializedIntervalDelta,\n} from \"./intervals/index.js\";\n\nfunction isMapOperation(op: unknown): op is IMapOperation {\n\treturn typeof op === \"object\" && op !== null && \"type\" in op && op.type === \"act\";\n}\n\n/**\n * Description of a map delta operation\n */\nexport interface IMapOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"act\";\n\n\t/**\n\t * Map key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Value of the operation, specific to the value type.\n\t */\n\tvalue: IIntervalCollectionTypeOperationValue;\n}\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n\t[key: string]: ISerializableIntervalCollection;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class IntervalCollectionMap<T extends ISerializableInterval> {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.data.size;\n\t}\n\n\t/**\n\t * Mapping of op types to message handlers.\n\t */\n\tprivate readonly messageHandler = {\n\t\tprocess: (\n\t\t\top: IMapOperation,\n\t\t\tlocal: boolean,\n\t\t\tmessage: ISequencedDocumentMessage,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => {\n\t\t\tconst localValue = this.data.get(op.key) ?? this.createCore(op.key, local);\n\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\tconst previousValue = localValue.value;\n\t\t\tconst translatedValue = op.value.value as any;\n\t\t\thandler.process(previousValue, translatedValue, local, message, localOpMetadata);\n\t\t\tconst event: IValueChanged = { key: op.key, previousValue };\n\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n\t\t},\n\t\tsubmit: (op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t},\n\t\tresubmit: (op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\tconst localValue = this.data.get(op.key);\n\n\t\t\tassert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\n\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\tconst rebased = handler.rebase(localValue.value, op.value, localOpMetadata);\n\t\t\tif (rebased !== undefined) {\n\t\t\t\tconst { rebasedOp, rebasedLocalOpMetadata } = rebased;\n\t\t\t\tthis.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);\n\t\t\t}\n\t\t},\n\t};\n\n\t/**\n\t * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, IntervalCollectionTypeLocalValue<T>>();\n\n\t/**\n\t * Create a new default map.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param type - The value type to create at values of this map\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tconstructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (\n\t\t\top: IMapOperation,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => void,\n\t\tprivate readonly type: IIntervalCollectionType<T>,\n\t\tprivate readonly options?: Partial<SequenceOptions>,\n\t\tpublic readonly eventEmitter = new TypedEventEmitter<ISharedDefaultMapEvents>(),\n\t) {}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.data.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<any> {\n\t\tconst localValuesIterator = this.data.values();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<any> {\n\t\t\t\tconst nextVal = localValuesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: nextVal.value.value, done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get(key: string): IntervalCollection<T> {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue.value;\n\t}\n\n\tpublic getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n\t\t});\n\t\treturn serializableMapData;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\treturn JSON.stringify(this.getSerializableStorage(serializer));\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t *\n\t * @param serialized - A JSON string containing serialized map data\n\t */\n\tpublic populate(serialized: string): void {\n\t\tconst parsed = this.serializer.parse(serialized) as IMapDataObjectSerializable;\n\n\t\tfor (const [key, serializable] of Object.entries(parsed)) {\n\t\t\t// Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n\t\t\t// These collections should be empty, and ValueTypes are no longer supported.\n\t\t\tif (\n\t\t\t\tserializable.type === ValueType[ValueType.Plain] ||\n\t\t\t\tserializable.type === ValueType[ValueType.Shared]\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with\n\t\t\t// \"intervalCollections/\". This would burden users trying to iterate the collection and\n\t\t\t// access its value, as well as those trying to match a create message to its underlying\n\t\t\t// collection. See https://github.com/microsoft/FluidFramework/issues/10557 for more context.\n\t\t\tconst normalizedKey = key.startsWith(\"intervalCollections/\") ? key.substring(20) : key;\n\n\t\t\tconst localValue = {\n\t\t\t\tkey: normalizedKey,\n\t\t\t\tvalue: this.makeLocal(key, serializable),\n\t\t\t};\n\n\t\t\tthis.data.set(localValue.key, localValue.value);\n\t\t}\n\t}\n\n\t/**\n\t * Submit the given op if a handler is registered.\n\t * @param op - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(op: unknown, localOpMetadata: IMapMessageLocalMetadata): boolean {\n\t\tif (isMapOperation(op)) {\n\t\t\tthis.messageHandler.resubmit(op, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryApplyStashedOp(op: unknown): boolean {\n\t\tif (isMapOperation(op)) {\n\t\t\tconst { value, key } = op;\n\t\t\tconst map = this.get(key);\n\n\t\t\tswitch (value.opName) {\n\t\t\t\tcase \"add\": {\n\t\t\t\t\tmap.add({\n\t\t\t\t\t\t// Todo: we should improve typing so we know add ops always have start and end\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tstart: toSequencePlace(value.value.start!, value.value.startSide),\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tend: toSequencePlace(value.value.end!, value.value.endSide),\n\t\t\t\t\t\tprops: value.value.properties,\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tcase \"change\": {\n\t\t\t\t\tconst { [reservedIntervalIdKey]: id, ...props } = value.value.properties ?? {};\n\t\t\t\t\tmap.change(id, {\n\t\t\t\t\t\tstart: toOptionalSequencePlace(value.value.start, value.value.startSide),\n\t\t\t\t\t\tend: toOptionalSequencePlace(value.value.end, value.value.endSide),\n\t\t\t\t\t\tprops,\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tcase \"delete\": {\n\t\t\t\t\tconst { [reservedIntervalIdKey]: id } = value.value.properties ?? {};\n\t\t\t\t\tmap.removeIntervalById(id);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(\"unknown ops should not be stashed\");\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was processed, false otherwise.\n\t */\n\tpublic tryProcessMessage(\n\t\top: unknown,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tif (isMapOperation(op)) {\n\t\t\tthis.messageHandler.process(\n\t\t\t\top,\n\t\t\t\tlocal,\n\t\t\t\tmessage,\n\t\t\t\tlocalOpMetadata as IMapMessageLocalMetadata,\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Initializes a default ValueType at the provided key.\n\t * Should be used when a map operation incurs creation.\n\t * @param key - The key being initialized\n\t * @param local - Whether the message originated from the local client\n\t */\n\tprivate createCore(key: string, local: boolean): IntervalCollectionTypeLocalValue<T> {\n\t\tconst localValue = new IntervalCollectionTypeLocalValue(\n\t\t\tthis.type.factory.load(this.makeMapValueOpEmitter(key), undefined, this.options),\n\t\t\tthis.type,\n\t\t);\n\t\tconst previousValue = this.data.get(key);\n\t\tthis.data.set(key, localValue);\n\t\tconst event: IValueChanged = { key, previousValue };\n\t\tthis.eventEmitter.emit(\"create\", event, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n\n\t/**\n\t * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n\t * have the information we need to create a real object, but will not be the real object yet. For example,\n\t * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's\n\t * job is to convert that information into a real object for local usage.\n\t * @param key - The key that the caller intends to store the local value into (used for ops later). But\n\t * doesn't actually store the local value into that key. So better not lie!\n\t * @param serializable - The remote information that we can convert into a real object\n\t * @returns The local value that was produced\n\t */\n\tprivate makeLocal(\n\t\tkey: string,\n\t\tserializable: ISerializableIntervalCollection,\n\t): IntervalCollectionTypeLocalValue<T> {\n\t\tassert(\n\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t);\n\n\t\tconst localValue = this.type.factory.load(\n\t\t\tthis.makeMapValueOpEmitter(key),\n\t\t\tserializable.value,\n\t\t\tthis.options,\n\t\t);\n\t\treturn new IntervalCollectionTypeLocalValue(localValue, this.type);\n\t}\n\n\t/**\n\t * Create an emitter for a value type to emit ops from the given key.\n\t * @param key - The key of the map that the value type will be stored on\n\t * @returns A value op emitter for the given key\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tprivate makeMapValueOpEmitter(key: string): IValueOpEmitter {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tconst emit: IValueOpEmitter[\"emit\"] = (\n\t\t\topName: IntervalDeltaOpType,\n\t\t\tpreviousValue: unknown,\n\t\t\tparams: SerializedIntervalDelta,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t): void => {\n\t\t\tconst op: IMapOperation = {\n\t\t\t\tkey,\n\t\t\t\ttype: \"act\",\n\t\t\t\tvalue: {\n\t\t\t\t\topName,\n\t\t\t\t\tvalue: params,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tthis.submitMessage(op, localOpMetadata);\n\n\t\t\tconst event: IValueChanged = { key, previousValue };\n\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n\t\t};\n\n\t\treturn { emit };\n\t}\n}\n"]}
1
+ {"version":3,"file":"intervalCollectionMap.js","sourceRoot":"","sources":["../src/intervalCollectionMap.ts"],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AK,oBAAS,CAAC,oBAAS,CAAC,KAAK,CAAC;YAC/C,YAAY,CAAC,IAAI,KAAK,oBAAS,CAAC,oBAAS,CAAC,MAAM,CAAC,EAClD,KAAK,CAAC,8CAA8C,CACpD,CAAC;QAEF,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CACxC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAC/B,YAAY,CAAC,KAAK,EAClB,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,OAAO,IAAI,8DAAgC,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,gDAAgD;IACxC,qBAAqB,CAAC,GAAW;QACxC,gDAAgD;QAChD,MAAM,IAAI,GAA4B,CACrC,MAA2B,EAC3B,aAAsB,EACtB,MAA+B,EAC/B,eAAyC,EAClC,EAAE;YACT,MAAM,EAAE,GAAkB;gBACzB,GAAG;gBACH,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE;oBACN,MAAM;oBACN,KAAK,EAAE,MAAM;iBACb;aACD,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;YAExC,MAAM,KAAK,GAAkB,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9E,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACjB,CAAC;CACD;AAlTD,sDAkTC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { ValueType, IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\n\nimport {\n\tIntervalCollectionTypeLocalValue,\n\tmakeSerializable,\n} from \"./IntervalCollectionValues.js\";\nimport {\n\ttype IntervalCollection,\n\treservedIntervalIdKey,\n\ttoOptionalSequencePlace,\n\ttoSequencePlace,\n} from \"./intervalCollection.js\";\nimport {\n\tIIntervalCollectionType,\n\tIIntervalCollectionTypeOperationValue,\n\tIMapMessageLocalMetadata,\n\tISerializableIntervalCollection,\n\tISharedDefaultMapEvents,\n\tIValueChanged,\n\t// eslint-disable-next-line import/no-deprecated\n\tIValueOpEmitter,\n\tSequenceOptions,\n} from \"./intervalCollectionMapInterfaces.js\";\nimport {\n\ttype ISerializableInterval,\n\tIntervalDeltaOpType,\n\tSerializedIntervalDelta,\n} from \"./intervals/index.js\";\n\nfunction isMapOperation(op: unknown): op is IMapOperation {\n\treturn typeof op === \"object\" && op !== null && \"type\" in op && op.type === \"act\";\n}\n\n/**\n * Description of a map delta operation\n */\nexport interface IMapOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"act\";\n\n\t/**\n\t * Map key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Value of the operation, specific to the value type.\n\t */\n\tvalue: IIntervalCollectionTypeOperationValue;\n}\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n\t[key: string]: ISerializableIntervalCollection;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class IntervalCollectionMap<T extends ISerializableInterval> {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.data.size;\n\t}\n\n\t/**\n\t * Mapping of op types to message handlers.\n\t */\n\tprivate readonly messageHandler = {\n\t\tprocess: (\n\t\t\top: IMapOperation,\n\t\t\tlocal: boolean,\n\t\t\tmessage: ISequencedDocumentMessage,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => {\n\t\t\tconst localValue = this.data.get(op.key) ?? this.createCore(op.key, local);\n\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\tconst previousValue = localValue.value;\n\t\t\tconst translatedValue = op.value.value as any;\n\t\t\thandler.process(previousValue, translatedValue, local, message, localOpMetadata);\n\t\t\tconst event: IValueChanged = { key: op.key, previousValue };\n\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n\t\t},\n\t\tsubmit: (op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t},\n\t\tresubmit: (op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\tconst localValue = this.data.get(op.key);\n\n\t\t\tassert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\n\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\tconst rebased = handler.rebase(localValue.value, op.value, localOpMetadata);\n\t\t\tif (rebased !== undefined) {\n\t\t\t\tconst { rebasedOp, rebasedLocalOpMetadata } = rebased;\n\t\t\t\tthis.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);\n\t\t\t}\n\t\t},\n\t};\n\n\t/**\n\t * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, IntervalCollectionTypeLocalValue<T>>();\n\n\t/**\n\t * Create a new default map.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param type - The value type to create at values of this map\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tconstructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (\n\t\t\top: IMapOperation,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => void,\n\t\tprivate readonly type: IIntervalCollectionType<T>,\n\t\tprivate readonly options?: Partial<SequenceOptions>,\n\t\tpublic readonly eventEmitter = new TypedEventEmitter<ISharedDefaultMapEvents>(),\n\t) {}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.data.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<any> {\n\t\tconst localValuesIterator = this.data.values();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<any> {\n\t\t\t\tconst nextVal = localValuesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: nextVal.value.value, done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get(key: string): IntervalCollection<T> {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue.value;\n\t}\n\n\tpublic getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n\t\t});\n\t\treturn serializableMapData;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\treturn JSON.stringify(this.getSerializableStorage(serializer));\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t *\n\t * @param serialized - A JSON string containing serialized map data\n\t */\n\tpublic populate(serialized: string): void {\n\t\tconst parsed = this.serializer.parse(serialized) as IMapDataObjectSerializable;\n\n\t\tfor (const [key, serializable] of Object.entries(parsed)) {\n\t\t\t// Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n\t\t\t// These collections should be empty, and ValueTypes are no longer supported.\n\t\t\tif (\n\t\t\t\tserializable.type === ValueType[ValueType.Plain] ||\n\t\t\t\tserializable.type === ValueType[ValueType.Shared]\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with\n\t\t\t// \"intervalCollections/\". This would burden users trying to iterate the collection and\n\t\t\t// access its value, as well as those trying to match a create message to its underlying\n\t\t\t// collection. See https://github.com/microsoft/FluidFramework/issues/10557 for more context.\n\t\t\tconst normalizedKey = key.startsWith(\"intervalCollections/\") ? key.substring(20) : key;\n\n\t\t\tconst localValue = {\n\t\t\t\tkey: normalizedKey,\n\t\t\t\tvalue: this.makeLocal(key, serializable),\n\t\t\t};\n\n\t\t\tthis.data.set(localValue.key, localValue.value);\n\t\t}\n\t}\n\n\t/**\n\t * Submit the given op if a handler is registered.\n\t * @param op - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(op: unknown, localOpMetadata: IMapMessageLocalMetadata): boolean {\n\t\tif (isMapOperation(op)) {\n\t\t\tthis.messageHandler.resubmit(op, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryApplyStashedOp(op: unknown): boolean {\n\t\tif (isMapOperation(op)) {\n\t\t\tconst { value, key } = op;\n\t\t\tconst map = this.get(key);\n\n\t\t\tswitch (value.opName) {\n\t\t\t\tcase \"add\": {\n\t\t\t\t\tmap.add({\n\t\t\t\t\t\t// Todo: we should improve typing so we know add ops always have start and end\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tstart: toSequencePlace(value.value.start!, value.value.startSide),\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tend: toSequencePlace(value.value.end!, value.value.endSide),\n\t\t\t\t\t\tprops: value.value.properties,\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tcase \"change\": {\n\t\t\t\t\tconst { [reservedIntervalIdKey]: id, ...props } = value.value.properties ?? {};\n\t\t\t\t\tmap.change(id, {\n\t\t\t\t\t\tstart: toOptionalSequencePlace(value.value.start, value.value.startSide),\n\t\t\t\t\t\tend: toOptionalSequencePlace(value.value.end, value.value.endSide),\n\t\t\t\t\t\tprops,\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tcase \"delete\": {\n\t\t\t\t\tconst { [reservedIntervalIdKey]: id } = value.value.properties ?? {};\n\t\t\t\t\tmap.removeIntervalById(id);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(\"unknown ops should not be stashed\");\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was processed, false otherwise.\n\t */\n\tpublic tryProcessMessage(\n\t\top: unknown,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tif (isMapOperation(op)) {\n\t\t\tthis.messageHandler.process(\n\t\t\t\top,\n\t\t\t\tlocal,\n\t\t\t\tmessage,\n\t\t\t\tlocalOpMetadata as IMapMessageLocalMetadata,\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Initializes a default ValueType at the provided key.\n\t * Should be used when a map operation incurs creation.\n\t * @param key - The key being initialized\n\t * @param local - Whether the message originated from the local client\n\t */\n\tprivate createCore(key: string, local: boolean): IntervalCollectionTypeLocalValue<T> {\n\t\tconst localValue = new IntervalCollectionTypeLocalValue(\n\t\t\tthis.type.factory.load(this.makeMapValueOpEmitter(key), undefined, this.options),\n\t\t\tthis.type,\n\t\t);\n\t\tconst previousValue = this.data.get(key);\n\t\tthis.data.set(key, localValue);\n\t\tconst event: IValueChanged = { key, previousValue };\n\t\tthis.eventEmitter.emit(\"create\", event, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n\n\t/**\n\t * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n\t * have the information we need to create a real object, but will not be the real object yet. For example,\n\t * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's\n\t * job is to convert that information into a real object for local usage.\n\t * @param key - The key that the caller intends to store the local value into (used for ops later). But\n\t * doesn't actually store the local value into that key. So better not lie!\n\t * @param serializable - The remote information that we can convert into a real object\n\t * @returns The local value that was produced\n\t */\n\tprivate makeLocal(\n\t\tkey: string,\n\t\tserializable: ISerializableIntervalCollection,\n\t): IntervalCollectionTypeLocalValue<T> {\n\t\tassert(\n\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t);\n\n\t\tconst localValue = this.type.factory.load(\n\t\t\tthis.makeMapValueOpEmitter(key),\n\t\t\tserializable.value,\n\t\t\tthis.options,\n\t\t);\n\t\treturn new IntervalCollectionTypeLocalValue(localValue, this.type);\n\t}\n\n\t/**\n\t * Create an emitter for a value type to emit ops from the given key.\n\t * @param key - The key of the map that the value type will be stored on\n\t * @returns A value op emitter for the given key\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tprivate makeMapValueOpEmitter(key: string): IValueOpEmitter {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tconst emit: IValueOpEmitter[\"emit\"] = (\n\t\t\topName: IntervalDeltaOpType,\n\t\t\tpreviousValue: unknown,\n\t\t\tparams: SerializedIntervalDelta,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t): void => {\n\t\t\tconst op: IMapOperation = {\n\t\t\t\tkey,\n\t\t\t\ttype: \"act\",\n\t\t\t\tvalue: {\n\t\t\t\t\topName,\n\t\t\t\t\tvalue: params,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tthis.submitMessage(op, localOpMetadata);\n\n\t\t\tconst event: IValueChanged = { key, previousValue };\n\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n\t\t};\n\n\t\treturn { emit };\n\t}\n}\n"]}
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IEventThisPlaceHolder } from "@fluidframework/core-interfaces";
6
- import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
- import { ISharedObjectEvents } from "@fluidframework/shared-object-base";
6
+ import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
7
+ import { ISharedObjectEvents } from "@fluidframework/shared-object-base/internal";
8
8
  import type { IntervalCollection } from "./intervalCollection.js";
9
9
  import { type ISerializableInterval, ISerializedInterval, IntervalDeltaOpType, IntervalOpType, SerializedIntervalDelta } from "./intervals/index.js";
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"intervalCollectionMapInterfaces.d.ts","sourceRoot":"","sources":["../src/intervalCollectionMapInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACN,KAAK,qBAAqB,EAC1B,mBA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;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,qCAAqC;IACrD;;OAEG;IACH,MAAM,EAAE,mBAAmB,CAAC;IAE5B;;OAEG;IACH,KAAK,EAAE,uBAAuB,CAAC;CAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"intervalCollectionMapInterfaces.js","sourceRoot":"","sources":["../src/intervalCollectionMapInterfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEventThisPlaceHolder } from \"@fluidframework/core-interfaces\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\nimport type { IntervalCollection } from \"./intervalCollection.js\";\nimport {\n\ttype ISerializableInterval,\n\tISerializedInterval,\n\tIntervalDeltaOpType,\n\tIntervalOpType,\n\tSerializedIntervalDelta,\n} from \"./intervals/index.js\";\n\n/**\n * Type of \"valueChanged\" event parameter.\n */\nexport interface IValueChanged {\n\t/**\n\t * The key storing the value that changed.\n\t */\n\tkey: string;\n\n\t/**\n\t * The value that was stored at the key prior to the change.\n\t */\n\tpreviousValue: any;\n}\n\n/**\n * Value types are given an IValueOpEmitter to emit their ops through the container type that holds them.\n * @internal\n * @deprecated - will be remove from public api as there is no public used of this type\n */\nexport interface IValueOpEmitter {\n\t/**\n\t * Called by the value type to emit a value type operation through the container type holding it.\n\t * @param opName - Name of the emitted operation\n\t * @param previousValue - JSONable previous value as defined by the value type @deprecated unused\n\t * @param params - JSONable params for the operation as defined by the value type\n\t * @param localOpMetadata - JSONable local metadata which should be submitted with the op\n\t */\n\temit(\n\t\topName: IntervalOpType,\n\t\tpreviousValue: undefined,\n\t\tparams: SerializedIntervalDelta,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t): void;\n}\n\n/**\n * @internal\n */\nexport interface IMapMessageLocalMetadata {\n\tlocalSeq: number;\n}\n\n/**\n * Optional flags that configure options for sequence DDSs\n * @internal\n */\nexport interface SequenceOptions {\n\t/**\n\t * Enable the ability to use interval APIs that rely on positions before and\n\t * after individual characters, referred to as \"sides\". See {@link SequencePlace}\n\t * for additional context.\n\t *\n\t * This flag must be enabled to pass instances of {@link SequencePlace} to\n\t * any IIntervalCollection API.\n\t *\n\t * Also see the feature flag `mergeTreeReferencesCanSlideToEndpoint` to allow\n\t * endpoints to slide to the special endpoint segments.\n\t *\n\t * The default value is false.\n\t */\n\tintervalStickinessEnabled: boolean;\n\t/**\n\t * Enable the ability for interval endpoints to slide to the special endpoint\n\t * segments that exist before and after the bounds of the string. This is\n\t * primarily useful for workflows involving interval stickiness, and it is\n\t * suggested to enable both this flag and `intervalStickinessEnabled` at the\n\t * same time.\n\t *\n\t * The default value is false.\n\t */\n\tmergeTreeReferencesCanSlideToEndpoint: boolean;\n\t[key: string]: boolean;\n}\n\n/**\n * A value factory is used to serialize/deserialize value types to a map\n * @alpha\n */\nexport interface IIntervalCollectionFactory<T extends ISerializableInterval> {\n\t/**\n\t * Create a new value type. Used both in creation of new value types, as well as in loading existing ones\n\t * from remote.\n\t * @param emitter - Emitter object that the created value type will use to emit operations\n\t * @param raw - Initialization parameters as defined by the value type\n\t * @returns The new value type\n\t */\n\tload(\n\t\temitter: IValueOpEmitter,\n\t\traw: any,\n\t\toptions?: Partial<SequenceOptions>,\n\t): IntervalCollection<T>;\n\n\t/**\n\t * Given a value type, provides a JSONable form of its data to be used for snapshotting. This data must be\n\t * loadable using the load method of its factory.\n\t * @param value - The value type to serialize\n\t * @returns The JSONable form of the value type\n\t */\n\tstore(value: IntervalCollection<T>): any;\n}\n\n/**\n * Defines an operation that a value type is able to handle.\n * @alpha\n */\nexport interface IIntervalCollectionOperation<T extends ISerializableInterval> {\n\t/**\n\t * Performs the actual processing on the incoming operation.\n\t * @param value - The current value stored at the given key, which should be the value type\n\t * @param params - The params on the incoming operation\n\t * @param local - Whether the operation originated from this client\n\t * @param message - The operation itself\n\t * @param localOpMetadata - any local metadata submitted by `IValueOpEmitter.emit`.\n\t */\n\tprocess(\n\t\tvalue: IntervalCollection<T>,\n\t\tparams: ISerializedInterval,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata | undefined,\n\t): void;\n\n\t/**\n\t * Rebases an `op` on `value` from its original perspective (ref/local seq) to the current\n\t * perspective. Should be invoked on reconnection.\n\t * @param value - The current value stored at the given key, which should be the value type.\n\t * @param op - The op to be rebased.\n\t * @param localOpMetadata - Any local metadata that was originally submitted with the op.\n\t * @returns A rebased version of the op and any local metadata that should be submitted with it.\n\t */\n\trebase(\n\t\tvalue: IntervalCollection<T>,\n\t\top: IIntervalCollectionTypeOperationValue,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t):\n\t\t| {\n\t\t\t\trebasedOp: IIntervalCollectionTypeOperationValue;\n\t\t\t\trebasedLocalOpMetadata: IMapMessageLocalMetadata;\n\t\t }\n\t\t| undefined;\n}\n\n/**\n * Defines a value type that can be registered on a container type.\n */\nexport interface IIntervalCollectionType<T extends ISerializableInterval> {\n\t/**\n\t * Name of the value type.\n\t */\n\tname: string;\n\n\t/**\n\t * Factory method used to convert to/from a JSON form of the type.\n\t */\n\tfactory: IIntervalCollectionFactory<T>;\n\n\t/**\n\t * Operations that can be applied to the value type.\n\t */\n\tops: Map<IntervalOpType, IIntervalCollectionOperation<T>>;\n}\n\nexport interface ISharedDefaultMapEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"valueChanged\" | \"create\",\n\t\tlistener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void,\n\t): void;\n}\n\n/**\n * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use\n * ISerializableValue.type to understand whether they're storing a Plain JS object, a SharedObject, or a value type.\n * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with\n * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to\n * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)\n * and ops (set).\n *\n * The DefaultMap implementation for sequence has been specialized to only support a single ValueType, which serializes\n * and deserializes via .store() and .load().\n */\nexport interface ISerializableIntervalCollection {\n\t/**\n\t * A type annotation to help indicate how the value serializes.\n\t */\n\ttype: string;\n\n\t/**\n\t * The JSONable representation of the value.\n\t */\n\tvalue: any;\n}\n\nexport interface ISerializedIntervalCollection {\n\t/**\n\t * A type annotation to help indicate how the value serializes.\n\t */\n\ttype: string;\n\n\t/**\n\t * String representation of the value.\n\t */\n\tvalue: string | undefined;\n}\n\n/**\n * ValueTypes handle ops slightly differently from SharedObjects or plain JS objects. Since the Map/Directory doesn't\n * know how to handle the ValueType's ops, those ops are instead passed along to the ValueType for processing.\n * IValueTypeOperationValue is that passed-along op. The opName on it is the ValueType-specific operation and the\n * value is whatever params the ValueType needs to complete that operation. Similar to ISerializableValue, it is\n * serializable via JSON.stringify/parse but differs in that it has no equivalency with an in-memory value - rather\n * it just describes an operation to be applied to an already-in-memory value.\n * @alpha\n */\nexport interface IIntervalCollectionTypeOperationValue {\n\t/**\n\t * The name of the operation.\n\t */\n\topName: IntervalDeltaOpType;\n\n\t/**\n\t * The payload that is submitted along with the operation.\n\t */\n\tvalue: SerializedIntervalDelta;\n}\n"]}
1
+ {"version":3,"file":"intervalCollectionMapInterfaces.js","sourceRoot":"","sources":["../src/intervalCollectionMapInterfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEventThisPlaceHolder } from \"@fluidframework/core-interfaces\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { ISharedObjectEvents } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { IntervalCollection } from \"./intervalCollection.js\";\nimport {\n\ttype ISerializableInterval,\n\tISerializedInterval,\n\tIntervalDeltaOpType,\n\tIntervalOpType,\n\tSerializedIntervalDelta,\n} from \"./intervals/index.js\";\n\n/**\n * Type of \"valueChanged\" event parameter.\n */\nexport interface IValueChanged {\n\t/**\n\t * The key storing the value that changed.\n\t */\n\tkey: string;\n\n\t/**\n\t * The value that was stored at the key prior to the change.\n\t */\n\tpreviousValue: any;\n}\n\n/**\n * Value types are given an IValueOpEmitter to emit their ops through the container type that holds them.\n * @internal\n * @deprecated - will be remove from public api as there is no public used of this type\n */\nexport interface IValueOpEmitter {\n\t/**\n\t * Called by the value type to emit a value type operation through the container type holding it.\n\t * @param opName - Name of the emitted operation\n\t * @param previousValue - JSONable previous value as defined by the value type @deprecated unused\n\t * @param params - JSONable params for the operation as defined by the value type\n\t * @param localOpMetadata - JSONable local metadata which should be submitted with the op\n\t */\n\temit(\n\t\topName: IntervalOpType,\n\t\tpreviousValue: undefined,\n\t\tparams: SerializedIntervalDelta,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t): void;\n}\n\n/**\n * @internal\n */\nexport interface IMapMessageLocalMetadata {\n\tlocalSeq: number;\n}\n\n/**\n * Optional flags that configure options for sequence DDSs\n * @internal\n */\nexport interface SequenceOptions {\n\t/**\n\t * Enable the ability to use interval APIs that rely on positions before and\n\t * after individual characters, referred to as \"sides\". See {@link SequencePlace}\n\t * for additional context.\n\t *\n\t * This flag must be enabled to pass instances of {@link SequencePlace} to\n\t * any IIntervalCollection API.\n\t *\n\t * Also see the feature flag `mergeTreeReferencesCanSlideToEndpoint` to allow\n\t * endpoints to slide to the special endpoint segments.\n\t *\n\t * The default value is false.\n\t */\n\tintervalStickinessEnabled: boolean;\n\t/**\n\t * Enable the ability for interval endpoints to slide to the special endpoint\n\t * segments that exist before and after the bounds of the string. This is\n\t * primarily useful for workflows involving interval stickiness, and it is\n\t * suggested to enable both this flag and `intervalStickinessEnabled` at the\n\t * same time.\n\t *\n\t * The default value is false.\n\t */\n\tmergeTreeReferencesCanSlideToEndpoint: boolean;\n\t[key: string]: boolean;\n}\n\n/**\n * A value factory is used to serialize/deserialize value types to a map\n * @alpha\n */\nexport interface IIntervalCollectionFactory<T extends ISerializableInterval> {\n\t/**\n\t * Create a new value type. Used both in creation of new value types, as well as in loading existing ones\n\t * from remote.\n\t * @param emitter - Emitter object that the created value type will use to emit operations\n\t * @param raw - Initialization parameters as defined by the value type\n\t * @returns The new value type\n\t */\n\tload(\n\t\temitter: IValueOpEmitter,\n\t\traw: any,\n\t\toptions?: Partial<SequenceOptions>,\n\t): IntervalCollection<T>;\n\n\t/**\n\t * Given a value type, provides a JSONable form of its data to be used for snapshotting. This data must be\n\t * loadable using the load method of its factory.\n\t * @param value - The value type to serialize\n\t * @returns The JSONable form of the value type\n\t */\n\tstore(value: IntervalCollection<T>): any;\n}\n\n/**\n * Defines an operation that a value type is able to handle.\n * @alpha\n */\nexport interface IIntervalCollectionOperation<T extends ISerializableInterval> {\n\t/**\n\t * Performs the actual processing on the incoming operation.\n\t * @param value - The current value stored at the given key, which should be the value type\n\t * @param params - The params on the incoming operation\n\t * @param local - Whether the operation originated from this client\n\t * @param message - The operation itself\n\t * @param localOpMetadata - any local metadata submitted by `IValueOpEmitter.emit`.\n\t */\n\tprocess(\n\t\tvalue: IntervalCollection<T>,\n\t\tparams: ISerializedInterval,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata | undefined,\n\t): void;\n\n\t/**\n\t * Rebases an `op` on `value` from its original perspective (ref/local seq) to the current\n\t * perspective. Should be invoked on reconnection.\n\t * @param value - The current value stored at the given key, which should be the value type.\n\t * @param op - The op to be rebased.\n\t * @param localOpMetadata - Any local metadata that was originally submitted with the op.\n\t * @returns A rebased version of the op and any local metadata that should be submitted with it.\n\t */\n\trebase(\n\t\tvalue: IntervalCollection<T>,\n\t\top: IIntervalCollectionTypeOperationValue,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t):\n\t\t| {\n\t\t\t\trebasedOp: IIntervalCollectionTypeOperationValue;\n\t\t\t\trebasedLocalOpMetadata: IMapMessageLocalMetadata;\n\t\t }\n\t\t| undefined;\n}\n\n/**\n * Defines a value type that can be registered on a container type.\n */\nexport interface IIntervalCollectionType<T extends ISerializableInterval> {\n\t/**\n\t * Name of the value type.\n\t */\n\tname: string;\n\n\t/**\n\t * Factory method used to convert to/from a JSON form of the type.\n\t */\n\tfactory: IIntervalCollectionFactory<T>;\n\n\t/**\n\t * Operations that can be applied to the value type.\n\t */\n\tops: Map<IntervalOpType, IIntervalCollectionOperation<T>>;\n}\n\nexport interface ISharedDefaultMapEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"valueChanged\" | \"create\",\n\t\tlistener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void,\n\t): void;\n}\n\n/**\n * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use\n * ISerializableValue.type to understand whether they're storing a Plain JS object, a SharedObject, or a value type.\n * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with\n * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to\n * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)\n * and ops (set).\n *\n * The DefaultMap implementation for sequence has been specialized to only support a single ValueType, which serializes\n * and deserializes via .store() and .load().\n */\nexport interface ISerializableIntervalCollection {\n\t/**\n\t * A type annotation to help indicate how the value serializes.\n\t */\n\ttype: string;\n\n\t/**\n\t * The JSONable representation of the value.\n\t */\n\tvalue: any;\n}\n\nexport interface ISerializedIntervalCollection {\n\t/**\n\t * A type annotation to help indicate how the value serializes.\n\t */\n\ttype: string;\n\n\t/**\n\t * String representation of the value.\n\t */\n\tvalue: string | undefined;\n}\n\n/**\n * ValueTypes handle ops slightly differently from SharedObjects or plain JS objects. Since the Map/Directory doesn't\n * know how to handle the ValueType's ops, those ops are instead passed along to the ValueType for processing.\n * IValueTypeOperationValue is that passed-along op. The opName on it is the ValueType-specific operation and the\n * value is whatever params the ValueType needs to complete that operation. Similar to ISerializableValue, it is\n * serializable via JSON.stringify/parse but differs in that it has no equivalency with an in-memory value - rather\n * it just describes an operation to be applied to an already-in-memory value.\n * @alpha\n */\nexport interface IIntervalCollectionTypeOperationValue {\n\t/**\n\t * The name of the operation.\n\t */\n\topName: IntervalDeltaOpType;\n\n\t/**\n\t * The payload that is submitted along with the operation.\n\t */\n\tvalue: SerializedIntervalDelta;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"endpointInRangeIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/endpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAgC,MAAM,qCAAqC,CAAC;AAE3F,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EAErB,gBAAgB,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB,CAAC,SAAS,SAAS,qBAAqB,CAC7E,SAAQ,aAAa,CAAC,SAAS,CAAC;IAChC;;OAEG;IACH,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC;CAC1E;AAED,qBAAa,oBAAoB,CAAC,SAAS,SAAS,qBAAqB,CACxE,YAAW,qBAAqB,CAAC,SAAS,CAAC;IAK1C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJzB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAGZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC;IAyB/C,GAA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,CAAC;AACpF,CAAC;AALD,gEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { Client, PropertyAction, RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tIntervalType,\n\tSequenceInterval,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex } from \"./intervalIndex.js\";\nimport { HasComparisonOverride, compareOverrideables, forceCompare } from \"./intervalIndexUtils.js\";\n\n/**\n * Collection of intervals.\n *\n * Provide additional APIs to support efficiently querying a collection of intervals whose endpoints fall within a specified range.\n * @internal\n */\nexport interface IEndpointInRangeIndex<TInterval extends ISerializableInterval>\n\textends IntervalIndex<TInterval> {\n\t/**\n\t * @returns an array of all intervals contained in this collection whose endpoints locate in the range [start, end] (includes both ends)\n\t */\n\tfindIntervalsWithEndpointInRange(start: number, end: number): TInterval[];\n}\n\nexport class EndpointInRangeIndex<TInterval extends ISerializableInterval>\n\timplements IEndpointInRangeIndex<TInterval>\n{\n\tprivate readonly intervalTree;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly helpers: IIntervalHelpers<TInterval>,\n\t) {\n\t\tthis.intervalTree = new RedBlackTree<TInterval, TInterval>((a: TInterval, b: TInterval) => {\n\t\t\tconst compareEndsResult = a.compareEnd(b);\n\t\t\tif (compareEndsResult !== 0) {\n\t\t\t\treturn compareEndsResult;\n\t\t\t}\n\n\t\t\tconst overrideablesComparison = compareOverrideables(\n\t\t\t\ta as Partial<HasComparisonOverride>,\n\t\t\t\tb as Partial<HasComparisonOverride>,\n\t\t\t);\n\t\t\tif (overrideablesComparison !== 0) {\n\t\t\t\treturn overrideablesComparison;\n\t\t\t}\n\n\t\t\tconst aId = a.getIntervalId();\n\t\t\tconst bId = b.getIntervalId();\n\t\t\tif (aId !== undefined && bId !== undefined) {\n\t\t\t\treturn aId.localeCompare(bId);\n\t\t\t}\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\tpublic add(interval: TInterval): void {\n\t\tthis.intervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: TInterval): void {\n\t\tthis.intervalTree.remove(interval);\n\t}\n\n\tpublic findIntervalsWithEndpointInRange(start: number, end: number): TInterval[] {\n\t\tif (start <= 0 || start > end || this.intervalTree.isEmpty()) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results: TInterval[] = [];\n\t\tconst action: PropertyAction<TInterval, TInterval> = (node) => {\n\t\t\tresults.push(node.data);\n\t\t\treturn true;\n\t\t};\n\n\t\tconst transientStartInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tstart,\n\t\t\tstart,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\tconst transientEndInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tend,\n\t\t\tend,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\t// Add comparison overrides to the transient intervals\n\t\t(transientStartInterval as Partial<HasComparisonOverride>)[forceCompare] = -1;\n\t\t(transientEndInterval as Partial<HasComparisonOverride>)[forceCompare] = 1;\n\n\t\tthis.intervalTree.mapRange(action, results, transientStartInterval, transientEndInterval);\n\t\treturn results;\n\t}\n}\n\n/**\n * @internal\n */\nexport function createEndpointInRangeIndex(\n\tsharedString: ISharedString,\n): IEndpointInRangeIndex<SequenceInterval> {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new EndpointInRangeIndex<SequenceInterval>(client, sequenceIntervalHelpers);\n}\n"]}
1
+ {"version":3,"file":"endpointInRangeIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/endpointInRangeIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAEzC,kEAA2F;AAE3F,oDAM+B;AAI/B,mEAIiC;AAgBjC,M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AAE,CAAC;QAChC,MAAM,MAAM,GAAyC,CAAC,IAAI,EAAE,EAAE;YAC7D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;QAEF,MAAM,sBAAsB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CACjD,WAAW,EACX,KAAK,EACL,KAAK,EACL,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QAEF,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAC/C,WAAW,EACX,GAAG,EACH,GAAG,EACH,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QAEF,sDAAsD;QACrD,sBAAyD,CAAC,oCAAY,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7E,oBAAuD,CAAC,oCAAY,CAAC,GAAG,CAAC,CAAC;QAE3E,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;QAC1F,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AA3ED,oDA2EC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CACzC,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,oBAAoB,CAAmB,MAAM,EAAE,kCAAuB,CAAC,CAAC;AACpF,CAAC;AALD,gEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { Client, PropertyAction, RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tIntervalType,\n\tSequenceInterval,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex } from \"./intervalIndex.js\";\nimport {\n\tHasComparisonOverride,\n\tcompareOverrideables,\n\tforceCompare,\n} from \"./intervalIndexUtils.js\";\n\n/**\n * Collection of intervals.\n *\n * Provide additional APIs to support efficiently querying a collection of intervals whose endpoints fall within a specified range.\n * @internal\n */\nexport interface IEndpointInRangeIndex<TInterval extends ISerializableInterval>\n\textends IntervalIndex<TInterval> {\n\t/**\n\t * @returns an array of all intervals contained in this collection whose endpoints locate in the range [start, end] (includes both ends)\n\t */\n\tfindIntervalsWithEndpointInRange(start: number, end: number): TInterval[];\n}\n\nexport class EndpointInRangeIndex<TInterval extends ISerializableInterval>\n\timplements IEndpointInRangeIndex<TInterval>\n{\n\tprivate readonly intervalTree;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly helpers: IIntervalHelpers<TInterval>,\n\t) {\n\t\tthis.intervalTree = new RedBlackTree<TInterval, TInterval>(\n\t\t\t(a: TInterval, b: TInterval) => {\n\t\t\t\tconst compareEndsResult = a.compareEnd(b);\n\t\t\t\tif (compareEndsResult !== 0) {\n\t\t\t\t\treturn compareEndsResult;\n\t\t\t\t}\n\n\t\t\t\tconst overrideablesComparison = compareOverrideables(\n\t\t\t\t\ta as Partial<HasComparisonOverride>,\n\t\t\t\t\tb as Partial<HasComparisonOverride>,\n\t\t\t\t);\n\t\t\t\tif (overrideablesComparison !== 0) {\n\t\t\t\t\treturn overrideablesComparison;\n\t\t\t\t}\n\n\t\t\t\tconst aId = a.getIntervalId();\n\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\tif (aId !== undefined && bId !== undefined) {\n\t\t\t\t\treturn aId.localeCompare(bId);\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic add(interval: TInterval): void {\n\t\tthis.intervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: TInterval): void {\n\t\tthis.intervalTree.remove(interval);\n\t}\n\n\tpublic findIntervalsWithEndpointInRange(start: number, end: number): TInterval[] {\n\t\tif (start <= 0 || start > end || this.intervalTree.isEmpty()) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results: TInterval[] = [];\n\t\tconst action: PropertyAction<TInterval, TInterval> = (node) => {\n\t\t\tresults.push(node.data);\n\t\t\treturn true;\n\t\t};\n\n\t\tconst transientStartInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tstart,\n\t\t\tstart,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\tconst transientEndInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tend,\n\t\t\tend,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\t// Add comparison overrides to the transient intervals\n\t\t(transientStartInterval as Partial<HasComparisonOverride>)[forceCompare] = -1;\n\t\t(transientEndInterval as Partial<HasComparisonOverride>)[forceCompare] = 1;\n\n\t\tthis.intervalTree.mapRange(action, results, transientStartInterval, transientEndInterval);\n\t\treturn results;\n\t}\n}\n\n/**\n * @internal\n */\nexport function createEndpointInRangeIndex(\n\tsharedString: ISharedString,\n): IEndpointInRangeIndex<SequenceInterval> {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new EndpointInRangeIndex<SequenceInterval>(client, sequenceIntervalHelpers);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"endpointIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/endpointIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAgB,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EAErB,gBAAgB,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,SAAS,SAAS,qBAAqB,CACtE,SAAQ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ClC,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAC5C,WAAW,EACX,GAAG,EACH,GAAG,EACH,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC7D,IAAI,MAAM,EAAE;YACX,OAAO,MAAM,CAAC,IAAI,CAAC;SACnB;IACF,CAAC;IAEM,YAAY,CAAC,GAAW;QAC9B,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAC5C,WAAW,EACX,GAAG,EACH,GAAG,EACH,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC5D,IAAI,MAAM,EAAE;YACX,OAAO,MAAM,CAAC,IAAI,CAAC;SACnB;IACF,CAAC;IAEM,GAAG,CAAC,QAAmB;QAC7B,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAEM,MAAM,CAAC,QAAmB;QAChC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;CACD;AA/CD,sCA+CC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,YAA2B;IAC9D,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,aAAa,CAAmB,MAAM,EAAE,kCAAuB,CAAC,CAAC;AAC7E,CAAC;AAHD,kDAGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { Client, RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tIntervalType,\n\tSequenceInterval,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex } from \"./intervalIndex.js\";\n\n/**\n * @internal\n */\nexport interface IEndpointIndex<TInterval extends ISerializableInterval>\n\textends IntervalIndex<TInterval> {\n\t/**\n\t * @returns the previous interval based on the given position number.\n\t * If no such interval exists in this index, returns `undefined`\n\t */\n\tpreviousInterval(pos: number): TInterval | undefined;\n\n\t/**\n\t * @returns the next interval based on the given position number.\n\t * If no such interval exists in this index, returns `undefined`\n\t */\n\tnextInterval(pos: number): TInterval | undefined;\n}\n\nexport class EndpointIndex<TInterval extends ISerializableInterval>\n\timplements IEndpointIndex<TInterval>\n{\n\tprivate readonly endIntervalTree: RedBlackTree<TInterval, TInterval>;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly helpers: IIntervalHelpers<TInterval>,\n\t) {\n\t\tthis.endIntervalTree = new RedBlackTree<TInterval, TInterval>((a, b) => a.compareEnd(b));\n\t}\n\n\tpublic previousInterval(pos: number): TInterval | undefined {\n\t\tconst transientInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tpos,\n\t\t\tpos,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\t\tconst rbNode = this.endIntervalTree.floor(transientInterval);\n\t\tif (rbNode) {\n\t\t\treturn rbNode.data;\n\t\t}\n\t}\n\n\tpublic nextInterval(pos: number): TInterval | undefined {\n\t\tconst transientInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tpos,\n\t\t\tpos,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\t\tconst rbNode = this.endIntervalTree.ceil(transientInterval);\n\t\tif (rbNode) {\n\t\t\treturn rbNode.data;\n\t\t}\n\t}\n\n\tpublic add(interval: TInterval): void {\n\t\tthis.endIntervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: TInterval): void {\n\t\tthis.endIntervalTree.remove(interval);\n\t}\n}\n\n/**\n * @internal\n */\nexport function createEndpointIndex(sharedString: ISharedString): IEndpointIndex<SequenceInterval> {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new EndpointIndex<SequenceInterval>(client, sequenceIntervalHelpers);\n}\n"]}
1
+ {"version":3,"file":"endpointIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/endpointIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAEzC,kEAA2E;AAE3E,oDAM+B;AAuB/B,MAAa,aAAa;IAKzB,YACkB,MAAc,EACd,OAAoC;QADpC,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAA6B;QAErD,IAAI,CAAC,eAAe,GAAG,IAAI,uBAAY,CAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;IAEM,gBAAgB,CAAC,GAAW;QAClC,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAC5C,WAAW,EACX,GAAG,EACH,GAAG,EACH,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC7D,IAAI,MAAM,EAAE,CAAC;YACZ,OAAO,MAAM,CAAC,IAAI,CAAC;QACpB,CAAC;IACF,CAAC;IAEM,YAAY,CAAC,GAAW;QAC9B,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAC5C,WAAW,EACX,GAAG,EACH,GAAG,EACH,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC5D,IAAI,MAAM,EAAE,CAAC;YACZ,OAAO,MAAM,CAAC,IAAI,CAAC;QACpB,CAAC;IACF,CAAC;IAEM,GAAG,CAAC,QAAmB;QAC7B,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAEM,MAAM,CAAC,QAAmB;QAChC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;CACD;AA/CD,sCA+CC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAClC,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,aAAa,CAAmB,MAAM,EAAE,kCAAuB,CAAC,CAAC;AAC7E,CAAC;AALD,kDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { Client, RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tIntervalType,\n\tSequenceInterval,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex } from \"./intervalIndex.js\";\n\n/**\n * @internal\n */\nexport interface IEndpointIndex<TInterval extends ISerializableInterval>\n\textends IntervalIndex<TInterval> {\n\t/**\n\t * @returns the previous interval based on the given position number.\n\t * If no such interval exists in this index, returns `undefined`\n\t */\n\tpreviousInterval(pos: number): TInterval | undefined;\n\n\t/**\n\t * @returns the next interval based on the given position number.\n\t * If no such interval exists in this index, returns `undefined`\n\t */\n\tnextInterval(pos: number): TInterval | undefined;\n}\n\nexport class EndpointIndex<TInterval extends ISerializableInterval>\n\timplements IEndpointIndex<TInterval>\n{\n\tprivate readonly endIntervalTree: RedBlackTree<TInterval, TInterval>;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly helpers: IIntervalHelpers<TInterval>,\n\t) {\n\t\tthis.endIntervalTree = new RedBlackTree<TInterval, TInterval>((a, b) => a.compareEnd(b));\n\t}\n\n\tpublic previousInterval(pos: number): TInterval | undefined {\n\t\tconst transientInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tpos,\n\t\t\tpos,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\t\tconst rbNode = this.endIntervalTree.floor(transientInterval);\n\t\tif (rbNode) {\n\t\t\treturn rbNode.data;\n\t\t}\n\t}\n\n\tpublic nextInterval(pos: number): TInterval | undefined {\n\t\tconst transientInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tpos,\n\t\t\tpos,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\t\tconst rbNode = this.endIntervalTree.ceil(transientInterval);\n\t\tif (rbNode) {\n\t\t\treturn rbNode.data;\n\t\t}\n\t}\n\n\tpublic add(interval: TInterval): void {\n\t\tthis.endIntervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: TInterval): void {\n\t\tthis.endIntervalTree.remove(interval);\n\t}\n}\n\n/**\n * @internal\n */\nexport function createEndpointIndex(\n\tsharedString: ISharedString,\n): IEndpointIndex<SequenceInterval> {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new EndpointIndex<SequenceInterval>(client, sequenceIntervalHelpers);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"overlappingIntervalsIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/overlappingIntervalsIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,oEAA6E;AAC7E,wDAAgE;AAChE,oDAM+B;AA2B/B,MAAa,yBAAyB;IAOrC,YAAY,MAAc,EAAE,OAAoC;QAJ7C,iBAAY,GAAG,IAAI,8BAAY,EAAa,CAAC;QAK/D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;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Content":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { Client } from \"@fluidframework/merge-tree/internal\";\n\nimport { SequencePlace, endpointPosAndSide } from \"../intervalCollection.js\";\nimport { IntervalNode, IntervalTree } from \"../intervalTree.js\";\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tIntervalType,\n\tSequenceInterval,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex } from \"./intervalIndex.js\";\n\n/**\n * @alpha\n */\nexport interface IOverlappingIntervalsIndex<TInterval extends ISerializableInterval>\n\textends IntervalIndex<TInterval> {\n\t/**\n\t * @returns an array of all intervals contained in this collection that overlap the range\n\t * `[start end]`.\n\t */\n\tfindOverlappingIntervals(start: SequencePlace, end: SequencePlace): TInterval[];\n\n\t/**\n\t * Gathers the interval results based on specified parameters.\n\t */\n\tgatherIterationResults(\n\t\tresults: TInterval[],\n\t\titeratesForward: boolean,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t): void;\n}\n\nexport class OverlappingIntervalsIndex<TInterval extends ISerializableInterval>\n\timplements IOverlappingIntervalsIndex<TInterval>\n{\n\tprotected readonly intervalTree = new IntervalTree<TInterval>();\n\tprotected readonly client: Client;\n\tprotected readonly helpers: IIntervalHelpers<TInterval>;\n\n\tconstructor(client: Client, helpers: IIntervalHelpers<TInterval>) {\n\t\tthis.client = client;\n\t\tthis.helpers = helpers;\n\t}\n\n\tpublic map(fn: (interval: TInterval) => void) {\n\t\tthis.intervalTree.map(fn);\n\t}\n\n\tpublic mapUntil(fn: (interval: TInterval) => boolean) {\n\t\tthis.intervalTree.mapUntil(fn);\n\t}\n\n\tpublic gatherIterationResults(\n\t\tresults: TInterval[],\n\t\titeratesForward: boolean,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t): void {\n\t\tif (this.intervalTree.intervals.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (start === undefined && end === undefined) {\n\t\t\t// No start/end provided. Gather the whole tree in the specified order.\n\t\t\tif (iteratesForward) {\n\t\t\t\tthis.intervalTree.map((interval: TInterval) => {\n\t\t\t\t\tresults.push(interval);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.intervalTree.mapBackward((interval: TInterval) => {\n\t\t\t\t\tresults.push(interval);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tconst transientInterval: TInterval = this.helpers.create(\n\t\t\t\t\"transient\",\n\t\t\t\tstart ?? \"start\",\n\t\t\t\tend ?? \"end\",\n\t\t\t\tthis.client,\n\t\t\t\tIntervalType.Transient,\n\t\t\t);\n\n\t\t\tif (start === undefined) {\n\t\t\t\t// Only end position provided. Since the tree is not sorted by end position,\n\t\t\t\t// walk the whole tree in the specified order, gathering intervals that match the end.\n\t\t\t\tif (iteratesForward) {\n\t\t\t\t\tthis.intervalTree.map((interval: TInterval) => {\n\t\t\t\t\t\tif (transientInterval.compareEnd(interval) === 0) {\n\t\t\t\t\t\t\tresults.push(interval);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthis.intervalTree.mapBackward((interval: TInterval) => {\n\t\t\t\t\t\tif (transientInterval.compareEnd(interval) === 0) {\n\t\t\t\t\t\t\tresults.push(interval);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Start and (possibly) end provided. Walk the subtrees that may contain\n\t\t\t\t// this start position.\n\t\t\t\tconst compareFn =\n\t\t\t\t\tend === undefined\n\t\t\t\t\t\t? (node: IntervalNode<TInterval>) => {\n\t\t\t\t\t\t\t\treturn transientInterval.compareStart(node.key);\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: (node: IntervalNode<TInterval>) => {\n\t\t\t\t\t\t\t\treturn transientInterval.compare(node.key);\n\t\t\t\t\t\t };\n\t\t\t\tconst continueLeftFn = (cmpResult: number) => cmpResult <= 0;\n\t\t\t\tconst continueRightFn = (cmpResult: number) => cmpResult >= 0;\n\t\t\t\tconst actionFn = (node: IntervalNode<TInterval>) => {\n\t\t\t\t\tresults.push(node.key);\n\t\t\t\t};\n\n\t\t\t\tif (iteratesForward) {\n\t\t\t\t\tthis.intervalTree.intervals.walkExactMatchesForward(\n\t\t\t\t\t\tcompareFn,\n\t\t\t\t\t\tactionFn,\n\t\t\t\t\t\tcontinueLeftFn,\n\t\t\t\t\t\tcontinueRightFn,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.intervalTree.intervals.walkExactMatchesBackward(\n\t\t\t\t\t\tcompareFn,\n\t\t\t\t\t\tactionFn,\n\t\t\t\t\t\tcontinueLeftFn,\n\t\t\t\t\t\tcontinueRightFn,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic findOverlappingIntervals(start: SequencePlace, end: SequencePlace): TInterval[] {\n\t\tconst { startPos, endPos } = endpointPosAndSide(start, end);\n\n\t\tif (\n\t\t\tstartPos === undefined ||\n\t\t\tendPos === undefined ||\n\t\t\t(typeof startPos === \"number\" && typeof endPos === \"number\" && endPos < startPos) ||\n\t\t\t(startPos === \"end\" && endPos !== \"end\") ||\n\t\t\t(startPos !== \"start\" && endPos === \"start\") ||\n\t\t\tthis.intervalTree.intervals.isEmpty()\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\t\tconst transientInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tstart,\n\t\t\tend,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\tconst overlappingIntervalNodes = this.intervalTree.match(transientInterval);\n\t\treturn overlappingIntervalNodes.map((node) => node.key);\n\t}\n\n\tpublic remove(interval: TInterval) {\n\t\tthis.intervalTree.removeExisting(interval);\n\t}\n\n\tpublic add(interval: TInterval) {\n\t\tthis.intervalTree.put(interval);\n\t}\n}\n\n/**\n * @alpha\n */\nexport function createOverlappingIntervalsIndex(\n\tsharedString: ISharedString,\n): IOverlappingIntervalsIndex<SequenceInterval> {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new OverlappingIntervalsIndex<SequenceInterval>(client, sequenceIntervalHelpers);\n}\n"]}
1
+ {"version":3,"file":"overlappingIntervalsIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/overlappingIntervalsIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,oEAA6E;AAC7E,wDAAgE;AAChE,oDAM+B;AA2B/B,MAAa,yBAAyB;IAOrC,YAAY,MAAc,EAAE,OAAoC;QAJ7C,iBAAY,GAAG,IAAI,8BAAY,EAAa,CAAC;QAK/D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAEM,GAAG,CAAC,EAAiC;QAC3C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAEM,QAAQ,CAAC,EAAoC;QACnD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IAEM,sBAAsB,CAC5B,OAAoB,EACpB,eAAwB,EACxB,KAAqB,EACrB,GAAmB;QAEnB,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3C,OAAO;QACR,CAAC;QAED,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YAC9C,uEAAuE;YACvE,IAAI,eAAe,EAAE,CAAC;gBACrB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,QAAmB,EAAE,EAAE;oBAC7C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACxB,CAAC,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,YAAY,C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C,OAAO,CAAC,MAAM,CAC5C,WAAW,EACX,KAAK,EACL,GAAG,EACH,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QAEF,MAAM,wBAAwB,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC5E,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,CAAC;IAEM,MAAM,CAAC,QAAmB;QAChC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,GAAG,CAAC,QAAmB;QAC7B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACD;AAtID,8DAsIC;AAED;;GAEG;AACH,SAAgB,+BAA+B,CAC9C,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,yBAAyB,CAAmB,MAAM,EAAE,kCAAuB,CAAC,CAAC;AACzF,CAAC;AALD,0EAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { Client } from \"@fluidframework/merge-tree/internal\";\n\nimport { SequencePlace, endpointPosAndSide } from \"../intervalCollection.js\";\nimport { IntervalNode, IntervalTree } from \"../intervalTree.js\";\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tIntervalType,\n\tSequenceInterval,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex } from \"./intervalIndex.js\";\n\n/**\n * @alpha\n */\nexport interface IOverlappingIntervalsIndex<TInterval extends ISerializableInterval>\n\textends IntervalIndex<TInterval> {\n\t/**\n\t * @returns an array of all intervals contained in this collection that overlap the range\n\t * `[start end]`.\n\t */\n\tfindOverlappingIntervals(start: SequencePlace, end: SequencePlace): TInterval[];\n\n\t/**\n\t * Gathers the interval results based on specified parameters.\n\t */\n\tgatherIterationResults(\n\t\tresults: TInterval[],\n\t\titeratesForward: boolean,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t): void;\n}\n\nexport class OverlappingIntervalsIndex<TInterval extends ISerializableInterval>\n\timplements IOverlappingIntervalsIndex<TInterval>\n{\n\tprotected readonly intervalTree = new IntervalTree<TInterval>();\n\tprotected readonly client: Client;\n\tprotected readonly helpers: IIntervalHelpers<TInterval>;\n\n\tconstructor(client: Client, helpers: IIntervalHelpers<TInterval>) {\n\t\tthis.client = client;\n\t\tthis.helpers = helpers;\n\t}\n\n\tpublic map(fn: (interval: TInterval) => void) {\n\t\tthis.intervalTree.map(fn);\n\t}\n\n\tpublic mapUntil(fn: (interval: TInterval) => boolean) {\n\t\tthis.intervalTree.mapUntil(fn);\n\t}\n\n\tpublic gatherIterationResults(\n\t\tresults: TInterval[],\n\t\titeratesForward: boolean,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t): void {\n\t\tif (this.intervalTree.intervals.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (start === undefined && end === undefined) {\n\t\t\t// No start/end provided. Gather the whole tree in the specified order.\n\t\t\tif (iteratesForward) {\n\t\t\t\tthis.intervalTree.map((interval: TInterval) => {\n\t\t\t\t\tresults.push(interval);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.intervalTree.mapBackward((interval: TInterval) => {\n\t\t\t\t\tresults.push(interval);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tconst transientInterval: TInterval = this.helpers.create(\n\t\t\t\t\"transient\",\n\t\t\t\tstart ?? \"start\",\n\t\t\t\tend ?? \"end\",\n\t\t\t\tthis.client,\n\t\t\t\tIntervalType.Transient,\n\t\t\t);\n\n\t\t\tif (start === undefined) {\n\t\t\t\t// Only end position provided. Since the tree is not sorted by end position,\n\t\t\t\t// walk the whole tree in the specified order, gathering intervals that match the end.\n\t\t\t\tif (iteratesForward) {\n\t\t\t\t\tthis.intervalTree.map((interval: TInterval) => {\n\t\t\t\t\t\tif (transientInterval.compareEnd(interval) === 0) {\n\t\t\t\t\t\t\tresults.push(interval);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthis.intervalTree.mapBackward((interval: TInterval) => {\n\t\t\t\t\t\tif (transientInterval.compareEnd(interval) === 0) {\n\t\t\t\t\t\t\tresults.push(interval);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Start and (possibly) end provided. Walk the subtrees that may contain\n\t\t\t\t// this start position.\n\t\t\t\tconst compareFn =\n\t\t\t\t\tend === undefined\n\t\t\t\t\t\t? (node: IntervalNode<TInterval>) => {\n\t\t\t\t\t\t\t\treturn transientInterval.compareStart(node.key);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: (node: IntervalNode<TInterval>) => {\n\t\t\t\t\t\t\t\treturn transientInterval.compare(node.key);\n\t\t\t\t\t\t\t};\n\t\t\t\tconst continueLeftFn = (cmpResult: number) => cmpResult <= 0;\n\t\t\t\tconst continueRightFn = (cmpResult: number) => cmpResult >= 0;\n\t\t\t\tconst actionFn = (node: IntervalNode<TInterval>) => {\n\t\t\t\t\tresults.push(node.key);\n\t\t\t\t};\n\n\t\t\t\tif (iteratesForward) {\n\t\t\t\t\tthis.intervalTree.intervals.walkExactMatchesForward(\n\t\t\t\t\t\tcompareFn,\n\t\t\t\t\t\tactionFn,\n\t\t\t\t\t\tcontinueLeftFn,\n\t\t\t\t\t\tcontinueRightFn,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.intervalTree.intervals.walkExactMatchesBackward(\n\t\t\t\t\t\tcompareFn,\n\t\t\t\t\t\tactionFn,\n\t\t\t\t\t\tcontinueLeftFn,\n\t\t\t\t\t\tcontinueRightFn,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic findOverlappingIntervals(start: SequencePlace, end: SequencePlace): TInterval[] {\n\t\tconst { startPos, endPos } = endpointPosAndSide(start, end);\n\n\t\tif (\n\t\t\tstartPos === undefined ||\n\t\t\tendPos === undefined ||\n\t\t\t(typeof startPos === \"number\" && typeof endPos === \"number\" && endPos < startPos) ||\n\t\t\t(startPos === \"end\" && endPos !== \"end\") ||\n\t\t\t(startPos !== \"start\" && endPos === \"start\") ||\n\t\t\tthis.intervalTree.intervals.isEmpty()\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\t\tconst transientInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tstart,\n\t\t\tend,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\tconst overlappingIntervalNodes = this.intervalTree.match(transientInterval);\n\t\treturn overlappingIntervalNodes.map((node) => node.key);\n\t}\n\n\tpublic remove(interval: TInterval) {\n\t\tthis.intervalTree.removeExisting(interval);\n\t}\n\n\tpublic add(interval: TInterval) {\n\t\tthis.intervalTree.put(interval);\n\t}\n}\n\n/**\n * @alpha\n */\nexport function createOverlappingIntervalsIndex(\n\tsharedString: ISharedString,\n): IOverlappingIntervalsIndex<SequenceInterval> {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new OverlappingIntervalsIndex<SequenceInterval>(client, sequenceIntervalHelpers);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"overlappingSequenceIntervalsIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/overlappingSequenceIntervalsIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkBH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAkDvE;;GAEG;AACH,wBAAgB,uCAAuC,CACtD,YAAY,EAAE,aAAa,GACzB,uBAAuB,CAAC,WAAW,CAGrC"}
1
+ {"version":3,"file":"overlappingSequenceIntervalsIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/overlappingSequenceIntervalsIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkBH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AA+CvE;;GAEG;AACH,wBAAgB,uCAAuC,CACtD,YAAY,EAAE,aAAa,GACzB,uBAAuB,CAAC,WAAW,CAGrC"}
@@ -9,9 +9,6 @@ exports.createOverlappingSequenceIntervalsIndex = void 0;
9
9
  const internal_1 = require("@fluidframework/merge-tree/internal");
10
10
  const index_js_1 = require("../intervals/index.js");
11
11
  const overlappingIntervalsIndex_js_1 = require("./overlappingIntervalsIndex.js");
12
- /**
13
- * @public
14
- */
15
12
  class OverlappingSequenceIntervalsIndex extends overlappingIntervalsIndex_js_1.OverlappingIntervalsIndex {
16
13
  constructor(client) {
17
14
  super(client, index_js_1.sequenceIntervalHelpers);
@@ -1 +1 @@
1
- {"version":3,"file":"overlappingSequenceIntervalsIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/overlappingSequenceIntervalsIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAEzC,kEAM6C;AAE7C,oDAK+B;AAG/B,iFAA2E;AAG3E;;GAEG;AACH,MAAM,iCACL,SAAQ,wDAA2C;IAGnD,YAAY,MAAc;QACzB,KAAK,CAAC,MAAM,EAAE,kCAAuB,CAAC,CAAC;IACxC,CAAC;IAEM,gCAAgC,CACtC,WAA0E,EAC1E,SAAwE;QAExE,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE;YAC1C,OAAO,EAAE,CAAC;SACV;QAED,MAAM,SAAS,GAAG,IAAA,4CAAiC,EAClD,IAAI,CAAC,MAAM,EACX,WAAW,EACX,wBAAa,CAAC,SAAS,CACvB,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,4CAAiC,EAChD,IAAI,CAAC,MAAM,EACX,SAAS,EACT,wBAAa,CAAC,SAAS,CACvB,CAAC;QAEF,IAAI,IAAA,oCAAyB,EAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;YACtD,OAAO,EAAE,CAAC;SACV;QAED,MAAM,iBAAiB,GAAG,IAAI,2BAAgB,CAC7C,IAAI,CAAC,MAAM,EACX,SAAS,EACT,OAAO,EACP,uBAAY,CAAC,SAAS,EACtB,EAAE,CAAC,iCAAsB,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,CAC3C,CAAC;QAEF,MAAM,wBAAwB,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC5E,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,CAAC;CACD;AAED;;GAEG;AACH,SAAgB,uCAAuC,CACtD,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,iCAAiC,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC;AALD,0FAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport {\n\tClient,\n\tISegment,\n\tReferenceType,\n\tcompareReferencePositions,\n\treservedRangeLabelsKey,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport {\n\tIntervalType,\n\tSequenceInterval,\n\tcreatePositionReferenceFromSegoff,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { OverlappingIntervalsIndex } from \"./overlappingIntervalsIndex.js\";\nimport { SequenceIntervalIndexes } from \"./sequenceIntervalIndexes.js\";\n\n/**\n * @public\n */\nclass OverlappingSequenceIntervalsIndex\n\textends OverlappingIntervalsIndex<SequenceInterval>\n\timplements SequenceIntervalIndexes.Overlapping\n{\n\tconstructor(client: Client) {\n\t\tsuper(client, sequenceIntervalHelpers);\n\t}\n\n\tpublic findOverlappingIntervalsBySegoff(\n\t\tstartSegoff: { segment: ISegment | undefined; offset: number | undefined },\n\t\tendSegoff: { segment: ISegment | undefined; offset: number | undefined },\n\t): Iterable<SequenceInterval> {\n\t\tif (this.intervalTree.intervals.isEmpty()) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst startLref = createPositionReferenceFromSegoff(\n\t\t\tthis.client,\n\t\t\tstartSegoff,\n\t\t\tReferenceType.Transient,\n\t\t);\n\n\t\tconst endLref = createPositionReferenceFromSegoff(\n\t\t\tthis.client,\n\t\t\tendSegoff,\n\t\t\tReferenceType.Transient,\n\t\t);\n\n\t\tif (compareReferencePositions(startLref, endLref) > 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst transientInterval = new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tstartLref,\n\t\t\tendLref,\n\t\t\tIntervalType.Transient,\n\t\t\t{ [reservedRangeLabelsKey]: [\"transient\"] },\n\t\t);\n\n\t\tconst overlappingIntervalNodes = this.intervalTree.match(transientInterval);\n\t\treturn overlappingIntervalNodes.map((node) => node.key);\n\t}\n}\n\n/**\n * @internal\n */\nexport function createOverlappingSequenceIntervalsIndex(\n\tsharedString: ISharedString,\n): SequenceIntervalIndexes.Overlapping {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new OverlappingSequenceIntervalsIndex(client);\n}\n"]}
1
+ {"version":3,"file":"overlappingSequenceIntervalsIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/overlappingSequenceIntervalsIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAEzC,kEAM6C;AAE7C,oDAK+B;AAG/B,iFAA2E;AAG3E,MAAM,iCACL,SAAQ,wDAA2C;IAGnD,YAAY,MAAc;QACzB,KAAK,CAAC,MAAM,EAAE,kCAAuB,CAAC,CAAC;IACxC,CAAC;IAEM,gCAAgC,CACtC,WAA0E,EAC1E,SAAwE;QAExE,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3C,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,SAAS,GAAG,IAAA,4CAAiC,EAClD,IAAI,CAAC,MAAM,EACX,WAAW,EACX,wBAAa,CAAC,SAAS,CACvB,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,4CAAiC,EAChD,IAAI,CAAC,MAAM,EACX,SAAS,EACT,wBAAa,CAAC,SAAS,CACvB,CAAC;QAEF,IAAI,IAAA,oCAAyB,EAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACvD,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,iBAAiB,GAAG,IAAI,2BAAgB,CAC7C,IAAI,CAAC,MAAM,EACX,SAAS,EACT,OAAO,EACP,uBAAY,CAAC,SAAS,EACtB,EAAE,CAAC,iCAAsB,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,CAC3C,CAAC;QAEF,MAAM,wBAAwB,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC5E,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,CAAC;CACD;AAED;;GAEG;AACH,SAAgB,uCAAuC,CACtD,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,iCAAiC,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC;AALD,0FAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport {\n\tClient,\n\tISegment,\n\tReferenceType,\n\tcompareReferencePositions,\n\treservedRangeLabelsKey,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport {\n\tIntervalType,\n\tSequenceInterval,\n\tcreatePositionReferenceFromSegoff,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { OverlappingIntervalsIndex } from \"./overlappingIntervalsIndex.js\";\nimport { SequenceIntervalIndexes } from \"./sequenceIntervalIndexes.js\";\n\nclass OverlappingSequenceIntervalsIndex\n\textends OverlappingIntervalsIndex<SequenceInterval>\n\timplements SequenceIntervalIndexes.Overlapping\n{\n\tconstructor(client: Client) {\n\t\tsuper(client, sequenceIntervalHelpers);\n\t}\n\n\tpublic findOverlappingIntervalsBySegoff(\n\t\tstartSegoff: { segment: ISegment | undefined; offset: number | undefined },\n\t\tendSegoff: { segment: ISegment | undefined; offset: number | undefined },\n\t): Iterable<SequenceInterval> {\n\t\tif (this.intervalTree.intervals.isEmpty()) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst startLref = createPositionReferenceFromSegoff(\n\t\t\tthis.client,\n\t\t\tstartSegoff,\n\t\t\tReferenceType.Transient,\n\t\t);\n\n\t\tconst endLref = createPositionReferenceFromSegoff(\n\t\t\tthis.client,\n\t\t\tendSegoff,\n\t\t\tReferenceType.Transient,\n\t\t);\n\n\t\tif (compareReferencePositions(startLref, endLref) > 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst transientInterval = new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tstartLref,\n\t\t\tendLref,\n\t\t\tIntervalType.Transient,\n\t\t\t{ [reservedRangeLabelsKey]: [\"transient\"] },\n\t\t);\n\n\t\tconst overlappingIntervalNodes = this.intervalTree.match(transientInterval);\n\t\treturn overlappingIntervalNodes.map((node) => node.key);\n\t}\n}\n\n/**\n * @internal\n */\nexport function createOverlappingSequenceIntervalsIndex(\n\tsharedString: ISharedString,\n): SequenceIntervalIndexes.Overlapping {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new OverlappingSequenceIntervalsIndex(client);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"startpointInRangeIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/startpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAgC,MAAM,qCAAqC,CAAC;AAE3F,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EAErB,gBAAgB,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB,CAAC,SAAS,SAAS,qBAAqB,CAC/E,SAAQ,aAAa,CAAC,SAAS,CAAC;IAChC;;OAEG;IACH,kCAAkC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC;CAC5E;AAED,qBAAa,sBAAsB,CAAC,SAAS,SAAS,qBAAqB,CAC1E,YAAW,uBAAuB,CAAC,SAAS,CAAC;IAK5C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJzB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAGZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC;IAwB/C,GAAG,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI;IAI9B,MAAM,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI;IAIjC,kCAAkC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE;CAiClF;AACD;;GAEG;AACH,wBAAgB,4BAA4B,CAC3C,YAAY,EAAE,aAAa,GACzB,uBAAuB,CAAC,gBAAgB,CAAC,CAG3C"}
1
+ {"version":3,"file":"startpointInRangeIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/startpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAgC,MAAM,qCAAqC,CAAC;AAE3F,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EAErB,gBAAgB,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOnD;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB,CAAC,SAAS,SAAS,qBAAqB,CAC/E,SAAQ,aAAa,CAAC,SAAS,CAAC;IAChC;;OAEG;IACH,kCAAkC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC;CAC5E;AAED,qBAAa,sBAAsB,CAAC,SAAS,SAAS,qBAAqB,CAC1E,YAAW,uBAAuB,CAAC,SAAS,CAAC;IAK5C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJzB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAGZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC;IA0B/C,GAAG,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI;IAI9B,MAAM,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI;IAIjC,kCAAkC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE;CAiClF;AACD;;GAEG;AACH,wBAAgB,4BAA4B,CAC3C,YAAY,EAAE,aAAa,GACzB,uBAAuB,CAAC,gBAAgB,CAAC,CAG3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"startpointInRangeIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/startpointInRangeIndex.ts"],"names":[],"mappings":";AAAA;;;GAG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;SACV;QACD,MAAM,OAAO,GAAgB,EAAE,CAAC;QAChC,MAAM,MAAM,GAAyC,CAAC,IAAI,EAAE,EAAE;YAC7D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;QAEF,MAAM,sBAAsB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CACjD,WAAW,EACX,KAAK,EACL,KAAK,EACL,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QAEF,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAC/C,WAAW,EACX,GAAG,EACH,GAAG,EACH,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QAEF,sDAAsD;QACrD,sBAAyD,CAAC,oCAAY,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7E,oBAAuD,CAAC,oCAAY,CAAC,GAAG,CAAC,CAAC;QAE3E,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;QAC1F,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AAxED,wDAwEC;AACD;;GAEG;AACH,SAAgB,4BAA4B,CAC3C,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,sBAAsB,CAAmB,MAAM,EAAE,kCAAuB,CAAC,CAAC;AACtF,CAAC;AALD,oEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { Client, PropertyAction, RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tIntervalType,\n\tSequenceInterval,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex } from \"./intervalIndex.js\";\nimport { HasComparisonOverride, compareOverrideables, forceCompare } from \"./intervalIndexUtils.js\";\n\n/**\n * Collection of intervals.\n *\n * Provide additional APIs to support efficiently querying a collection of intervals whose startpoints fall within a specified range.\n * @internal\n */\nexport interface IStartpointInRangeIndex<TInterval extends ISerializableInterval>\n\textends IntervalIndex<TInterval> {\n\t/**\n\t * @returns an array of all intervals contained in this collection whose startpoints locate in the range [start, end] (includes both ends)\n\t */\n\tfindIntervalsWithStartpointInRange(start: number, end: number): TInterval[];\n}\n\nexport class StartpointInRangeIndex<TInterval extends ISerializableInterval>\n\timplements IStartpointInRangeIndex<TInterval>\n{\n\tprivate readonly intervalTree;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly helpers: IIntervalHelpers<TInterval>,\n\t) {\n\t\tthis.intervalTree = new RedBlackTree<TInterval, TInterval>((a: TInterval, b: TInterval) => {\n\t\t\tconst compareStartsResult = a.compareStart(b);\n\t\t\tif (compareStartsResult !== 0) {\n\t\t\t\treturn compareStartsResult;\n\t\t\t}\n\n\t\t\tconst overrideablesComparison = compareOverrideables(\n\t\t\t\ta as Partial<HasComparisonOverride>,\n\t\t\t\tb as Partial<HasComparisonOverride>,\n\t\t\t);\n\t\t\tif (overrideablesComparison !== 0) {\n\t\t\t\treturn overrideablesComparison;\n\t\t\t}\n\t\t\tconst aId = a.getIntervalId();\n\t\t\tconst bId = b.getIntervalId();\n\t\t\tif (aId !== undefined && bId !== undefined) {\n\t\t\t\treturn aId.localeCompare(bId);\n\t\t\t}\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\tpublic add(interval: TInterval): void {\n\t\tthis.intervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: TInterval): void {\n\t\tthis.intervalTree.remove(interval);\n\t}\n\n\tpublic findIntervalsWithStartpointInRange(start: number, end: number): TInterval[] {\n\t\tif (start <= 0 || start > end || this.intervalTree.isEmpty()) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results: TInterval[] = [];\n\t\tconst action: PropertyAction<TInterval, TInterval> = (node) => {\n\t\t\tresults.push(node.data);\n\t\t\treturn true;\n\t\t};\n\n\t\tconst transientStartInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tstart,\n\t\t\tstart,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\tconst transientEndInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tend,\n\t\t\tend,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\t// Add comparison overrides to the transient intervals\n\t\t(transientStartInterval as Partial<HasComparisonOverride>)[forceCompare] = -1;\n\t\t(transientEndInterval as Partial<HasComparisonOverride>)[forceCompare] = 1;\n\n\t\tthis.intervalTree.mapRange(action, results, transientStartInterval, transientEndInterval);\n\t\treturn results;\n\t}\n}\n/**\n * @internal\n */\nexport function createStartpointInRangeIndex(\n\tsharedString: ISharedString,\n): IStartpointInRangeIndex<SequenceInterval> {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new StartpointInRangeIndex<SequenceInterval>(client, sequenceIntervalHelpers);\n}\n"]}
1
+ {"version":3,"file":"startpointInRangeIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/startpointInRangeIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAEzC,kEAA2F;AAE3F,oDAM+B;AAI/B,mEAIiC;AAgBjC,MAAa,sBAAsB;IAKlC,YACkB,MAAc,EACd,OAAoC;QADpC,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAA6B;QAErD,IAAI,CAAC,YAAY,GAAG,IAAI,uBAAY,CACnC,CAAC,CAAY,EAAE,CAAY,EAAE,EAAE;YAC9B,MAAM,mBAAmB,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC9C,IAAI,mBAAmB,KAAK,CAAC,EAAE,CA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B,CAAC;QAEF,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAC/C,WAAW,EACX,GAAG,EACH,GAAG,EACH,IAAI,CAAC,MAAM,EACX,uBAAY,CAAC,SAAS,CACtB,CAAC;QAEF,sDAAsD;QACrD,sBAAyD,CAAC,oCAAY,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7E,oBAAuD,CAAC,oCAAY,CAAC,GAAG,CAAC,CAAC;QAE3E,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;QAC1F,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AA1ED,wDA0EC;AACD;;GAEG;AACH,SAAgB,4BAA4B,CAC3C,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,sBAAsB,CAAmB,MAAM,EAAE,kCAAuB,CAAC,CAAC;AACtF,CAAC;AALD,oEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { Client, PropertyAction, RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tIntervalType,\n\tSequenceInterval,\n\tsequenceIntervalHelpers,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex } from \"./intervalIndex.js\";\nimport {\n\tHasComparisonOverride,\n\tcompareOverrideables,\n\tforceCompare,\n} from \"./intervalIndexUtils.js\";\n\n/**\n * Collection of intervals.\n *\n * Provide additional APIs to support efficiently querying a collection of intervals whose startpoints fall within a specified range.\n * @internal\n */\nexport interface IStartpointInRangeIndex<TInterval extends ISerializableInterval>\n\textends IntervalIndex<TInterval> {\n\t/**\n\t * @returns an array of all intervals contained in this collection whose startpoints locate in the range [start, end] (includes both ends)\n\t */\n\tfindIntervalsWithStartpointInRange(start: number, end: number): TInterval[];\n}\n\nexport class StartpointInRangeIndex<TInterval extends ISerializableInterval>\n\timplements IStartpointInRangeIndex<TInterval>\n{\n\tprivate readonly intervalTree;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly helpers: IIntervalHelpers<TInterval>,\n\t) {\n\t\tthis.intervalTree = new RedBlackTree<TInterval, TInterval>(\n\t\t\t(a: TInterval, b: TInterval) => {\n\t\t\t\tconst compareStartsResult = a.compareStart(b);\n\t\t\t\tif (compareStartsResult !== 0) {\n\t\t\t\t\treturn compareStartsResult;\n\t\t\t\t}\n\n\t\t\t\tconst overrideablesComparison = compareOverrideables(\n\t\t\t\t\ta as Partial<HasComparisonOverride>,\n\t\t\t\t\tb as Partial<HasComparisonOverride>,\n\t\t\t\t);\n\t\t\t\tif (overrideablesComparison !== 0) {\n\t\t\t\t\treturn overrideablesComparison;\n\t\t\t\t}\n\t\t\t\tconst aId = a.getIntervalId();\n\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\tif (aId !== undefined && bId !== undefined) {\n\t\t\t\t\treturn aId.localeCompare(bId);\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic add(interval: TInterval): void {\n\t\tthis.intervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: TInterval): void {\n\t\tthis.intervalTree.remove(interval);\n\t}\n\n\tpublic findIntervalsWithStartpointInRange(start: number, end: number): TInterval[] {\n\t\tif (start <= 0 || start > end || this.intervalTree.isEmpty()) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results: TInterval[] = [];\n\t\tconst action: PropertyAction<TInterval, TInterval> = (node) => {\n\t\t\tresults.push(node.data);\n\t\t\treturn true;\n\t\t};\n\n\t\tconst transientStartInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tstart,\n\t\t\tstart,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\tconst transientEndInterval = this.helpers.create(\n\t\t\t\"transient\",\n\t\t\tend,\n\t\t\tend,\n\t\t\tthis.client,\n\t\t\tIntervalType.Transient,\n\t\t);\n\n\t\t// Add comparison overrides to the transient intervals\n\t\t(transientStartInterval as Partial<HasComparisonOverride>)[forceCompare] = -1;\n\t\t(transientEndInterval as Partial<HasComparisonOverride>)[forceCompare] = 1;\n\n\t\tthis.intervalTree.mapRange(action, results, transientStartInterval, transientEndInterval);\n\t\treturn results;\n\t}\n}\n/**\n * @internal\n */\nexport function createStartpointInRangeIndex(\n\tsharedString: ISharedString,\n): IStartpointInRangeIndex<SequenceInterval> {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new StartpointInRangeIndex<SequenceInterval>(client, sequenceIntervalHelpers);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"intervalTree.js","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAM6C;AAQ7C,MAAM,gBAAgB,GAAG,CAAC,CAAY,EAAE,CAAY,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAItE,MAAa,YAAY;IAAzB;QAGQ,cAAS,GAAG,IAAI,uBAAY,CAA2B,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAwEvF,CAAC;IAtEO,MAAM,CAAC,CAAI;QACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAEM,cAAc,CAAC,CAAI;QACzB,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IAEM,GAAG,CAAC,CAAI;QACd,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAEM,GAAG,CAAC,EAAkB;QAC5B,MAAM,OAAO,GAA4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AClC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SACvF;aAAM;YACN,IAAI,IAAI,CAAC,IAAI,EAAE;gBACd,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACzD;iBAAM,IAAI,IAAI,CAAC,KAAK,EAAE;gBACtB,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC1D;iBAAM;gBACN,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;aACpC;SACD;IACF,CAAC;CACD;AA3ED,oCA2EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIRBAugmentation,\n\tIRBMatcher,\n\tRBNode,\n\tRBNodeActions,\n\tRedBlackTree,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { IInterval } from \"./intervals/index.js\";\n\nexport interface AugmentedIntervalNode {\n\tminmax: IInterval;\n}\n\nconst intervalComparer = (a: IInterval, b: IInterval) => a.compare(b);\n\nexport type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;\n\nexport class IntervalTree<T extends IInterval>\n\timplements IRBAugmentation<T, AugmentedIntervalNode>, IRBMatcher<T, AugmentedIntervalNode>\n{\n\tpublic intervals = new RedBlackTree<T, AugmentedIntervalNode>(intervalComparer, this);\n\n\tpublic remove(x: T) {\n\t\tthis.intervals.remove(x);\n\t}\n\n\tpublic removeExisting(x: T) {\n\t\tthis.intervals.removeExisting(x);\n\t}\n\n\tpublic put(x: T) {\n\t\tthis.intervals.put(x, { minmax: x.clone() });\n\t}\n\n\tpublic map(fn: (x: T) => void) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\tfn(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walk(actions);\n\t}\n\n\tpublic mapUntil(fn: (X: T) => boolean) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\treturn fn(node.key);\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walk(actions);\n\t}\n\n\tpublic mapBackward(fn: (x: T) => void) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\tfn(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walkBackward(actions);\n\t}\n\n\t// TODO: toString()\n\tpublic match(x: T) {\n\t\treturn this.intervals.gather(x, this);\n\t}\n\n\tpublic matchNode(node: IntervalNode<T> | undefined, key: T) {\n\t\treturn !!node && node.key.overlaps(key);\n\t}\n\n\tpublic continueSubtree(node: IntervalNode<T> | undefined, key: T) {\n\t\treturn !!node && node.data.minmax.overlaps(key);\n\t}\n\n\tpublic update(node: IntervalNode<T>) {\n\t\tif (node.left && node.right) {\n\t\t\tnode.data.minmax = node.key.union(node.left.data.minmax.union(node.right.data.minmax));\n\t\t} else {\n\t\t\tif (node.left) {\n\t\t\t\tnode.data.minmax = node.key.union(node.left.data.minmax);\n\t\t\t} else if (node.right) {\n\t\t\t\tnode.data.minmax = node.key.union(node.right.data.minmax);\n\t\t\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CAAC,MAAM,CAAC,CAAC;YAC1D,CAAC;iBAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACrC,CAAC;QACF,CAAC;IACF,CAAC;CACD;AA3ED,oCA2EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIRBAugmentation,\n\tIRBMatcher,\n\tRBNode,\n\tRBNodeActions,\n\tRedBlackTree,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { IInterval } from \"./intervals/index.js\";\n\nexport interface AugmentedIntervalNode {\n\tminmax: IInterval;\n}\n\nconst intervalComparer = (a: IInterval, b: IInterval) => a.compare(b);\n\nexport type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;\n\nexport class IntervalTree<T extends IInterval>\n\timplements IRBAugmentation<T, AugmentedIntervalNode>, IRBMatcher<T, AugmentedIntervalNode>\n{\n\tpublic intervals = new RedBlackTree<T, AugmentedIntervalNode>(intervalComparer, this);\n\n\tpublic remove(x: T) {\n\t\tthis.intervals.remove(x);\n\t}\n\n\tpublic removeExisting(x: T) {\n\t\tthis.intervals.removeExisting(x);\n\t}\n\n\tpublic put(x: T) {\n\t\tthis.intervals.put(x, { minmax: x.clone() });\n\t}\n\n\tpublic map(fn: (x: T) => void) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\tfn(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walk(actions);\n\t}\n\n\tpublic mapUntil(fn: (X: T) => boolean) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\treturn fn(node.key);\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walk(actions);\n\t}\n\n\tpublic mapBackward(fn: (x: T) => void) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\tfn(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walkBackward(actions);\n\t}\n\n\t// TODO: toString()\n\tpublic match(x: T) {\n\t\treturn this.intervals.gather(x, this);\n\t}\n\n\tpublic matchNode(node: IntervalNode<T> | undefined, key: T) {\n\t\treturn !!node && node.key.overlaps(key);\n\t}\n\n\tpublic continueSubtree(node: IntervalNode<T> | undefined, key: T) {\n\t\treturn !!node && node.data.minmax.overlaps(key);\n\t}\n\n\tpublic update(node: IntervalNode<T>) {\n\t\tif (node.left && node.right) {\n\t\t\tnode.data.minmax = node.key.union(node.left.data.minmax.union(node.right.data.minmax));\n\t\t} else {\n\t\t\tif (node.left) {\n\t\t\t\tnode.data.minmax = node.key.union(node.left.data.minmax);\n\t\t\t} else if (node.right) {\n\t\t\t\tnode.data.minmax = node.key.union(node.right.data.minmax);\n\t\t\t} else {\n\t\t\t\tnode.data.minmax = node.key.clone();\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
5
6
  import { PropertiesManager, PropertySet } from "@fluidframework/merge-tree/internal";
6
- import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
7
  import { SequencePlace } from "../intervalCollection.js";
8
8
  import { IIntervalHelpers, ISerializableInterval, ISerializedInterval }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IACrF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QACzD,MAAM,IAAI,qBAAU,CACnB,8FAA8F,CAC9F,CAAC;KACF;IAED,MAAM,SAAS,GAAgB,EAAE,CAAC;IAElC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,SAAS,CAAC,iCAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KAC5C;IAED,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;IAC/D,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAEvD,OAAO,IAAI,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC;AAjBD,wCAiBC;AAEY,QAAA,eAAe,GAA+B;IAC1D,MAAM,EAAE,cAAc;CACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tPropertiesManager,\n\tPropertySet,\n\tcreateMap,\n\treservedRangeLabelsKey,\n} from \"@fluidframework/merge-tree/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { SequencePlace, reservedIntervalIdKey } from \"../intervalCollection.js\";\n\nimport { IIntervalHelpers, ISerializableInterval, ISerializedInterval } from \"./intervalUtils.js\";\n\n/**\n * Serializable interval whose endpoints are plain-old numbers.\n * @internal\n */\nexport class Interval implements ISerializableInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet = createMap<any>();\n\n\t/***/\n\tpublic auxProps: PropertySet[] | undefined;\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t */\n\tpublic readonly propertyManager: PropertiesManager = new PropertiesManager();\n\n\tconstructor(\n\t\tpublic start: number,\n\t\tpublic end: number,\n\t\tprops?: PropertySet,\n\t) {\n\t\tif (props) {\n\t\t\tthis.addProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\tconst id = this.properties?.[reservedIntervalIdKey];\n\t\tassert(id !== undefined, 0x5e1 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * @returns an array containing any auxiliary property sets added with `addPropertySet`.\n\t */\n\tpublic getAdditionalPropertySets(): PropertySet[] {\n\t\treturn this.auxProps ?? [];\n\t}\n\n\t/**\n\t * Adds an auxiliary set of properties to this interval.\n\t * These properties can be recovered using `getAdditionalPropertySets`\n\t * @param props - set of properties to add\n\t * @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`\n\t * (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.\n\t * This functionality seems half-baked.\n\t */\n\tpublic addPropertySet(props: PropertySet) {\n\t\tif (this.auxProps === undefined) {\n\t\t\tthis.auxProps = [];\n\t\t}\n\t\tthis.auxProps.push(props);\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: this.end,\n\t\t\tintervalType: 0,\n\t\t\tsequenceNumber: 0,\n\t\t\tstart: this.start,\n\t\t};\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = { ...this.properties };\n\t\t}\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone() {\n\t\treturn new Interval(this.start, this.end, this.properties);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: Interval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: Interval) {\n\t\treturn this.start - b.start;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: Interval) {\n\t\treturn this.end - b.end;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: Interval) {\n\t\tconst result = this.start <= b.end && this.end >= b.start;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t */\n\tpublic union(b: Interval) {\n\t\treturn new Interval(\n\t\t\tMath.min(this.start, b.start),\n\t\t\tMath.max(this.end, b.end),\n\t\t\tthis.properties,\n\t\t);\n\t}\n\n\tpublic getProperties() {\n\t\treturn this.properties;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.addProperties}\n\t */\n\tpublic addProperties(\n\t\tnewProps: PropertySet,\n\t\tcollaborating: boolean = false,\n\t\tseq?: number,\n\t): PropertySet | undefined {\n\t\tif (newProps) {\n\t\t\treturn this.propertyManager.addProperties(\n\t\t\t\tthis.properties,\n\t\t\t\tnewProps,\n\t\t\t\tseq,\n\t\t\t\tcollaborating,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t\top?: ISequencedDocumentMessage,\n\t) {\n\t\tif (typeof start === \"string\" || typeof end === \"string\") {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"The start and end positions of a plain interval may not be on the special endpoint segments.\",\n\t\t\t);\n\t\t}\n\n\t\tconst startPos = typeof start === \"number\" ? start : start?.pos ?? this.start;\n\t\tconst endPos = typeof end === \"number\" ? end : end?.pos ?? this.end;\n\n\t\tif (this.start === startPos && this.end === endPos) {\n\t\t\t// Return undefined to indicate that no change is necessary.\n\t\t\treturn;\n\t\t}\n\t\tconst newInterval = new Interval(startPos, endPos);\n\t\tif (this.properties) {\n\t\t\tthis.propertyManager.copyTo(\n\t\t\t\tthis.properties,\n\t\t\t\tnewInterval.properties,\n\t\t\t\tnewInterval.propertyManager,\n\t\t\t);\n\t\t}\n\t\treturn newInterval;\n\t}\n}\n\nexport function createInterval(label: string, start: SequencePlace, end: SequencePlace): Interval {\n\tif (typeof start === \"string\" || typeof end === \"string\") {\n\t\tthrow new UsageError(\n\t\t\t\"The start and end positions of a plain interval may not be on the special endpoint segments.\",\n\t\t);\n\t}\n\n\tconst rangeProp: PropertySet = {};\n\n\tif (label && label.length > 0) {\n\t\trangeProp[reservedRangeLabelsKey] = [label];\n\t}\n\n\tconst startPos = typeof start === \"number\" ? start : start.pos;\n\tconst endPos = typeof end === \"number\" ? end : end.pos;\n\n\treturn new Interval(startPos, endPos, rangeProp);\n}\n\nexport const intervalHelpers: IIntervalHelpers<Interval> = {\n\tcreate: createInterval,\n};\n"]}
1
+ {"version":3,"file":"interval.js","sourceRoot":"","sources":["../../src/intervals/interval.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAEzC,kEAA6D;AAE7D,kEAK6C;AAC7C,uEAAsE;AAEtE,oEAAgF;AAQhF;;;GAG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slint-disable import/no-deprecated */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tPropertiesManager,\n\tPropertySet,\n\tcreateMap,\n\treservedRangeLabelsKey,\n} from \"@fluidframework/merge-tree/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { SequencePlace, reservedIntervalIdKey } from \"../intervalCollection.js\";\n\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tISerializedInterval,\n} from \"./intervalUtils.js\";\n\n/**\n * Serializable interval whose endpoints are plain-old numbers.\n * @internal\n */\nexport class Interval implements ISerializableInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet = createMap<any>();\n\n\t/***/\n\tpublic auxProps: PropertySet[] | undefined;\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t */\n\tpublic readonly propertyManager: PropertiesManager = new PropertiesManager();\n\n\tconstructor(\n\t\tpublic start: number,\n\t\tpublic end: number,\n\t\tprops?: PropertySet,\n\t) {\n\t\tif (props) {\n\t\t\tthis.addProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\tconst id = this.properties?.[reservedIntervalIdKey];\n\t\tassert(id !== undefined, 0x5e1 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * @returns an array containing any auxiliary property sets added with `addPropertySet`.\n\t */\n\tpublic getAdditionalPropertySets(): PropertySet[] {\n\t\treturn this.auxProps ?? [];\n\t}\n\n\t/**\n\t * Adds an auxiliary set of properties to this interval.\n\t * These properties can be recovered using `getAdditionalPropertySets`\n\t * @param props - set of properties to add\n\t * @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`\n\t * (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.\n\t * This functionality seems half-baked.\n\t */\n\tpublic addPropertySet(props: PropertySet) {\n\t\tif (this.auxProps === undefined) {\n\t\t\tthis.auxProps = [];\n\t\t}\n\t\tthis.auxProps.push(props);\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: this.end,\n\t\t\tintervalType: 0,\n\t\t\tsequenceNumber: 0,\n\t\t\tstart: this.start,\n\t\t};\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = { ...this.properties };\n\t\t}\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone() {\n\t\treturn new Interval(this.start, this.end, this.properties);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: Interval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: Interval) {\n\t\treturn this.start - b.start;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: Interval) {\n\t\treturn this.end - b.end;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: Interval) {\n\t\tconst result = this.start <= b.end && this.end >= b.start;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t */\n\tpublic union(b: Interval) {\n\t\treturn new Interval(\n\t\t\tMath.min(this.start, b.start),\n\t\t\tMath.max(this.end, b.end),\n\t\t\tthis.properties,\n\t\t);\n\t}\n\n\tpublic getProperties() {\n\t\treturn this.properties;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.addProperties}\n\t */\n\tpublic addProperties(\n\t\tnewProps: PropertySet,\n\t\tcollaborating: boolean = false,\n\t\tseq?: number,\n\t): PropertySet | undefined {\n\t\tif (newProps) {\n\t\t\treturn this.propertyManager.addProperties(this.properties, newProps, seq, collaborating);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t\top?: ISequencedDocumentMessage,\n\t) {\n\t\tif (typeof start === \"string\" || typeof end === \"string\") {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"The start and end positions of a plain interval may not be on the special endpoint segments.\",\n\t\t\t);\n\t\t}\n\n\t\tconst startPos = typeof start === \"number\" ? start : start?.pos ?? this.start;\n\t\tconst endPos = typeof end === \"number\" ? end : end?.pos ?? this.end;\n\n\t\tif (this.start === startPos && this.end === endPos) {\n\t\t\t// Return undefined to indicate that no change is necessary.\n\t\t\treturn;\n\t\t}\n\t\tconst newInterval = new Interval(startPos, endPos);\n\t\tif (this.properties) {\n\t\t\tthis.propertyManager.copyTo(\n\t\t\t\tthis.properties,\n\t\t\t\tnewInterval.properties,\n\t\t\t\tnewInterval.propertyManager,\n\t\t\t);\n\t\t}\n\t\treturn newInterval;\n\t}\n}\n\nexport function createInterval(\n\tlabel: string,\n\tstart: SequencePlace,\n\tend: SequencePlace,\n): Interval {\n\tif (typeof start === \"string\" || typeof end === \"string\") {\n\t\tthrow new UsageError(\n\t\t\t\"The start and end positions of a plain interval may not be on the special endpoint segments.\",\n\t\t);\n\t}\n\n\tconst rangeProp: PropertySet = {};\n\n\tif (label && label.length > 0) {\n\t\trangeProp[reservedRangeLabelsKey] = [label];\n\t}\n\n\tconst startPos = typeof start === \"number\" ? start : start.pos;\n\tconst endPos = typeof end === \"number\" ? end : end.pos;\n\n\treturn new Interval(startPos, endPos, rangeProp);\n}\n\nexport const intervalHelpers: IIntervalHelpers<Interval> = {\n\tcreate: createInterval,\n};\n"]}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
5
6
  import { Client, PropertiesManager, PropertySet, SlidingPreference } from "@fluidframework/merge-tree/internal";
6
- import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
7
  import { SequencePlace, Side } from "../intervalCollection.js";
8
8
  /**
9
9
  * Basic interval abstraction
@@ -86,7 +86,7 @@ export declare enum IntervalType {
86
86
  * See `packages\dds\merge-tree\docs\REFERENCEPOSITIONS.md` for details
87
87
  * SlideOnRemove is the default interval behavior and does not need to be specified.
88
88
  */
89
- SlideOnRemove = 2,
89
+ SlideOnRemove = 2,// SlideOnRemove is default behavior - all intervals are SlideOnRemove
90
90
  /**
91
91
  * A temporary interval, used internally
92
92
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"intervalUtils.d.ts","sourceRoot":"","sources":["../../src/intervals/intervalUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,MAAM,EACN,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB;;OAEG;IACH,KAAK,IAAI,SAAS,CAAC;IACnB;;;;;;OAMG;IACH,O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,YAAY,EAC1B,EAAE,CAAC,EAAE,yBAAyB,EAC9B,YAAY,CAAC,EAAE,OAAO,EACtB,qBAAqB,CAAC,EAAE,OAAO,GAC7B,SAAS,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;;;OAIG;;IAGH;;OAEG;;CAEM,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE9F,wBAAgB,+BAA+B,CAC9C,UAAU,EAAE,kBAAkB,GAC5B,iBAAiB,CAKnB;AAED,wBAAgB,6BAA6B,CAC5C,UAAU,EAAE,kBAAkB,GAC5B,iBAAiB,CAKnB"}
@@ -5,7 +5,6 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.endReferenceSlidingPreference = exports.startReferenceSlidingPreference = exports.IntervalStickiness = exports.IntervalType = exports.IntervalOpType = exports.IntervalDeltaOpType = void 0;
8
- /* eslint-disable no-bitwise */
9
8
  const internal_1 = require("@fluidframework/merge-tree/internal");
10
9
  /**
11
10
  * Values are used in persisted formats (ops).