@fluidframework/sequence 2.32.0 → 2.33.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 (78) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/api-report/sequence.legacy.alpha.api.md +39 -39
  3. package/dist/intervalCollection.d.ts +14 -9
  4. package/dist/intervalCollection.d.ts.map +1 -1
  5. package/dist/intervalCollection.js +137 -77
  6. package/dist/intervalCollection.js.map +1 -1
  7. package/dist/intervalCollectionMap.d.ts +5 -4
  8. package/dist/intervalCollectionMap.d.ts.map +1 -1
  9. package/dist/intervalCollectionMap.js +25 -50
  10. package/dist/intervalCollectionMap.js.map +1 -1
  11. package/dist/intervalCollectionMapInterfaces.d.ts +22 -15
  12. package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -1
  13. package/dist/intervalCollectionMapInterfaces.js.map +1 -1
  14. package/dist/intervalIndex/intervalIndex.d.ts +1 -1
  15. package/dist/intervalIndex/intervalIndex.js.map +1 -1
  16. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +1 -1
  17. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  18. package/dist/intervals/sequenceInterval.d.ts +3 -3
  19. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  20. package/dist/intervals/sequenceInterval.js +10 -9
  21. package/dist/intervals/sequenceInterval.js.map +1 -1
  22. package/dist/packageVersion.d.ts +1 -1
  23. package/dist/packageVersion.js +1 -1
  24. package/dist/packageVersion.js.map +1 -1
  25. package/dist/sequence.d.ts +4 -0
  26. package/dist/sequence.d.ts.map +1 -1
  27. package/dist/sequence.js +10 -0
  28. package/dist/sequence.js.map +1 -1
  29. package/dist/sharedIntervalCollection.d.ts +1 -1
  30. package/dist/sharedIntervalCollection.js.map +1 -1
  31. package/dist/sharedString.d.ts +0 -4
  32. package/dist/sharedString.d.ts.map +1 -1
  33. package/dist/sharedString.js +0 -11
  34. package/dist/sharedString.js.map +1 -1
  35. package/lib/intervalCollection.d.ts +14 -9
  36. package/lib/intervalCollection.d.ts.map +1 -1
  37. package/lib/intervalCollection.js +138 -78
  38. package/lib/intervalCollection.js.map +1 -1
  39. package/lib/intervalCollectionMap.d.ts +5 -4
  40. package/lib/intervalCollectionMap.d.ts.map +1 -1
  41. package/lib/intervalCollectionMap.js +26 -51
  42. package/lib/intervalCollectionMap.js.map +1 -1
  43. package/lib/intervalCollectionMapInterfaces.d.ts +22 -15
  44. package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -1
  45. package/lib/intervalCollectionMapInterfaces.js.map +1 -1
  46. package/lib/intervalIndex/intervalIndex.d.ts +1 -1
  47. package/lib/intervalIndex/intervalIndex.js.map +1 -1
  48. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +1 -1
  49. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  50. package/lib/intervals/sequenceInterval.d.ts +3 -3
  51. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  52. package/lib/intervals/sequenceInterval.js +10 -9
  53. package/lib/intervals/sequenceInterval.js.map +1 -1
  54. package/lib/packageVersion.d.ts +1 -1
  55. package/lib/packageVersion.js +1 -1
  56. package/lib/packageVersion.js.map +1 -1
  57. package/lib/sequence.d.ts +4 -0
  58. package/lib/sequence.d.ts.map +1 -1
  59. package/lib/sequence.js +10 -0
  60. package/lib/sequence.js.map +1 -1
  61. package/lib/sharedIntervalCollection.d.ts +1 -1
  62. package/lib/sharedIntervalCollection.js.map +1 -1
  63. package/lib/sharedString.d.ts +0 -4
  64. package/lib/sharedString.d.ts.map +1 -1
  65. package/lib/sharedString.js +0 -11
  66. package/lib/sharedString.js.map +1 -1
  67. package/lib/tsdoc-metadata.json +1 -1
  68. package/package.json +18 -20
  69. package/src/intervalCollection.ts +188 -96
  70. package/src/intervalCollectionMap.ts +31 -60
  71. package/src/intervalCollectionMapInterfaces.ts +34 -29
  72. package/src/intervalIndex/intervalIndex.ts +1 -1
  73. package/src/intervalIndex/overlappingIntervalsIndex.ts +1 -1
  74. package/src/intervals/sequenceInterval.ts +14 -2
  75. package/src/packageVersion.ts +1 -1
  76. package/src/sequence.ts +15 -0
  77. package/src/sharedIntervalCollection.ts +1 -1
  78. package/src/sharedString.ts +0 -11
@@ -6,8 +6,7 @@ import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
7
  import { ValueType } from "@fluidframework/shared-object-base/internal";
8
8
  import { makeSerializable } from "./IntervalCollectionValues.js";
9
- import { IntervalCollection, opsMap, toOptionalSequencePlace, toSequencePlace, } from "./intervalCollection.js";
10
- import { getSerializedProperties } from "./intervals/index.js";
9
+ import { IntervalCollection, } from "./intervalCollection.js";
11
10
  function isMapOperation(op) {
12
11
  return typeof op === "object" && op !== null && "type" in op && op.type === "act";
13
12
  }
@@ -113,59 +112,37 @@ export class IntervalCollectionMap {
113
112
  }
114
113
  /**
115
114
  * Submit the given op if a handler is registered.
116
- * @param op - The operation to attempt to submit
115
+ * @param content - The operation to attempt to submit
117
116
  * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime
118
117
  * and not sent to the server. This will be sent back when this message is received back from the server. This is
119
118
  * also sent if we are asked to resubmit the message.
120
119
  * @returns True if the operation was submitted, false otherwise.
121
120
  */
122
- tryResubmitMessage(op, localOpMetadata) {
123
- if (isMapOperation(op)) {
124
- const localValue = this.data.get(op.key);
121
+ tryResubmitMessage(content, localOpMetadata) {
122
+ if (isMapOperation(content)) {
123
+ const { value, key } = content;
124
+ const localValue = this.data.get(key);
125
125
  assert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
126
- const handler = opsMap[op.value.opName];
127
- const rebased = handler.rebase(localValue, op.value, localOpMetadata);
128
- if (rebased !== undefined) {
129
- const { rebasedOp, rebasedLocalOpMetadata } = rebased;
130
- this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
131
- }
126
+ localValue.resubmitMessage(value, localOpMetadata);
132
127
  return true;
133
128
  }
134
129
  return false;
135
130
  }
136
- tryApplyStashedOp(op) {
137
- if (isMapOperation(op)) {
138
- const { value, key } = op;
131
+ tryRollback(content, localOpMetadata) {
132
+ if (isMapOperation(content)) {
133
+ const localValue = this.data.get(content.key);
134
+ assert(localValue !== undefined, 0xb7e /* Local value expected on rollback */);
135
+ localValue.rollback(content.value, localOpMetadata);
136
+ return true;
137
+ }
138
+ return false;
139
+ }
140
+ tryApplyStashedOp(content) {
141
+ if (isMapOperation(content)) {
142
+ const { value, key } = content;
139
143
  const map = this.get(key);
140
- const { id, properties } = getSerializedProperties(value.value);
141
- switch (value.opName) {
142
- case "add": {
143
- map.add({
144
- id,
145
- // Todo: we should improve typing so we know add ops always have start and end
146
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
147
- start: toSequencePlace(value.value.start, value.value.startSide),
148
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
149
- end: toSequencePlace(value.value.end, value.value.endSide),
150
- props: properties,
151
- });
152
- return true;
153
- }
154
- case "change": {
155
- map.change(id, {
156
- start: toOptionalSequencePlace(value.value.start, value.value.startSide),
157
- end: toOptionalSequencePlace(value.value.end, value.value.endSide),
158
- props: properties,
159
- });
160
- return true;
161
- }
162
- case "delete": {
163
- map.removeIntervalById(id);
164
- return true;
165
- }
166
- default:
167
- throw new Error("unknown ops should not be stashed");
168
- }
144
+ map.applyStashedOp(value);
145
+ return true;
169
146
  }
170
147
  return false;
171
148
  }
@@ -184,13 +161,11 @@ export class IntervalCollectionMap {
184
161
  * Therefore, in such cases the caller should typically throw an error, ensuring that this client treats the situation as data corruption
185
162
  * (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate.
186
163
  */
187
- tryProcessMessage(op, local, message, localOpMetadata) {
188
- if (isMapOperation(op)) {
189
- const localValue = this.data.get(op.key) ?? this.createCore(op.key, local);
190
- const handler = opsMap[op.value.opName];
191
- const previousValue = localValue;
192
- const translatedValue = op.value.value;
193
- handler.process(previousValue, translatedValue, local, message, localOpMetadata);
164
+ tryProcessMessage(content, local, message, localOpMetadata) {
165
+ if (isMapOperation(content)) {
166
+ const { value, key } = content;
167
+ const localValue = this.data.get(key) ?? this.createCore(key, local);
168
+ localValue.process(value, local, message, localOpMetadata);
194
169
  return true;
195
170
  }
196
171
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"intervalCollectionMap.js","sourceRoot":"","sources":["../src/intervalCollectionMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAoB,MAAM,6CAA6C,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACN,kBAAkB,EAClB,MAAM,EACN,uBAAuB,EACvB,eAAe,GAGf,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,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;AAiCD;;;;;;GAMG;AACH,MAAM,OAAO,qBAAqB;IACjC;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACvB,CAAC;IAQD,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,YACkB,UAA4B,EAC5B,MAAoB,EACpB,aAGR,EACQ,OAAkC;QANlC,eAAU,GAAV,UAAU,CAAkB;QAC5B,WAAM,GAAN,MAAM,CAAc;QACpB,kBAAa,GAAb,aAAa,CAGrB;QACQ,YAAO,GAAP,OAAO,CAA2B;Q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C3C,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;OAIG;IACK,UAAU,CACjB,GAAW,EACX,KAAc,EACd,mBAAuF;QAEvF,MAAM,UAAU,GAAG,IAAI,kBAAkB,CACxC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YACV,CAAC;gBACA,IAAI,CAAC,aAAa,CACjB;oBACC,GAAG;oBACH,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,EAAE;iBACT,EACD,EAAE,CACF,CAAC;YACH,CAAC;QACF,CAAC,EACD,mBAAmB,IAAI,EAAE,EACzB,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAClF,OAAO,UAAU,CAAC;IACnB,CAAC;CACD","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 type { IEvent, IEventProvider } 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 { makeSerializable } from \"./IntervalCollectionValues.js\";\nimport {\n\tIntervalCollection,\n\topsMap,\n\ttoOptionalSequencePlace,\n\ttoSequencePlace,\n\ttype ISerializedIntervalCollectionV1,\n\ttype ISerializedIntervalCollectionV2,\n} from \"./intervalCollection.js\";\nimport {\n\tIIntervalCollectionTypeOperationValue,\n\tIMapMessageLocalMetadata,\n\tISerializableIntervalCollection,\n\tSequenceOptions,\n} from \"./intervalCollectionMapInterfaces.js\";\nimport { getSerializedProperties } 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\nexport interface IntervalCollectionMapEvents extends IEvent {\n\t(event: \"createIntervalCollection\", listener: (key: string, local: boolean) => void): void;\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 {\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 * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, IntervalCollection>();\n\n\tprivate readonly eventEmitter = new TypedEventEmitter<IntervalCollectionMapEvents>();\n\tpublic get events(): IEventProvider<IntervalCollectionMapEvents> {\n\t\treturn this.eventEmitter;\n\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 options?: Partial<SequenceOptions>,\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, 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 {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(\n\t\t\t\tlocalValue,\n\t\t\t\tserializer,\n\t\t\t\tthis.handle,\n\t\t\t\tthis.options?.intervalSerializationFormat ?? \"2\",\n\t\t\t);\n\t\t});\n\t\treturn JSON.stringify(serializableMapData);\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\tassert(\n\t\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t\t);\n\n\t\t\tthis.createCore(normalizedKey, false, serializable.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\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 = opsMap[op.value.opName];\n\t\t\tconst rebased = handler.rebase(localValue, 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\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\t\t\tconst { id, properties } = getSerializedProperties(value.value);\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\tid,\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: 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\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: properties,\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\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 recognized and thus processed, false otherwise.\n\t *\n\t * @remarks\n\t * When this returns false and the caller doesn't handle the op itself, then the op could be from a different version of this code.\n\t * In such a case, not applying the op would result in this client becoming out of sync with clients that do handle the op\n\t * and could result in data corruption or data loss as well.\n\t * Therefore, in such cases the caller should typically throw an error, ensuring that this client treats the situation as data corruption\n\t * (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate.\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\tconst localValue = this.data.get(op.key) ?? this.createCore(op.key, local);\n\t\t\tconst handler = opsMap[op.value.opName];\n\t\t\tconst previousValue = localValue;\n\t\t\tconst translatedValue = op.value.value as any;\n\t\t\thandler.process(\n\t\t\t\tpreviousValue,\n\t\t\t\ttranslatedValue,\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 */\n\tprivate createCore(\n\t\tkey: string,\n\t\tlocal: boolean,\n\t\tserializedIntervals?: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2,\n\t): IntervalCollection {\n\t\tconst localValue = new IntervalCollection(\n\t\t\t(op, md) => {\n\t\t\t\t{\n\t\t\t\t\tthis.submitMessage(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\ttype: \"act\",\n\t\t\t\t\t\t\tvalue: op,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmd,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\tserializedIntervals ?? [],\n\t\t\tthis.options,\n\t\t);\n\t\tthis.data.set(key, localValue);\n\t\tthis.eventEmitter.emit(\"createIntervalCollection\", key, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n}\n"]}
1
+ {"version":3,"file":"intervalCollectionMap.js","sourceRoot":"","sources":["../src/intervalCollectionMap.ts"],"names":[],"mappings":"AAAA;;;GA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IAAI,CAAC,aAAa,CACjB;oBACC,GAAG;oBACH,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,EAAE;iBACT,EACD,EAAE,CACF,CAAC;YACH,CAAC;QACF,CAAC,EACD,mBAAmB,IAAI,EAAE,EACzB,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAClF,OAAO,UAAU,CAAC;IACnB,CAAC;CACD","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 type { IEvent, IEventProvider } 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 { makeSerializable } from \"./IntervalCollectionValues.js\";\nimport {\n\tIntervalCollection,\n\ttype ISerializedIntervalCollectionV1,\n\ttype ISerializedIntervalCollectionV2,\n} from \"./intervalCollection.js\";\nimport {\n\tIIntervalCollectionTypeOperationValue,\n\tIMapMessageLocalMetadata,\n\tISerializableIntervalCollection,\n\tSequenceOptions,\n} from \"./intervalCollectionMapInterfaces.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\nexport interface IntervalCollectionMapEvents extends IEvent {\n\t(event: \"createIntervalCollection\", listener: (key: string, local: boolean) => void): void;\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 {\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 * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, IntervalCollection>();\n\n\tprivate readonly eventEmitter = new TypedEventEmitter<IntervalCollectionMapEvents>();\n\tpublic get events(): IEventProvider<IntervalCollectionMapEvents> {\n\t\treturn this.eventEmitter;\n\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 options?: Partial<SequenceOptions>,\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, 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 {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(\n\t\t\t\tlocalValue,\n\t\t\t\tserializer,\n\t\t\t\tthis.handle,\n\t\t\t\tthis.options?.intervalSerializationFormat ?? \"2\",\n\t\t\t);\n\t\t});\n\t\treturn JSON.stringify(serializableMapData);\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\tassert(\n\t\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t\t);\n\n\t\t\tthis.createCore(normalizedKey, false, serializable.value);\n\t\t}\n\t}\n\n\t/**\n\t * Submit the given op if a handler is registered.\n\t * @param content - 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(\n\t\tcontent: unknown,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst localValue = this.data.get(key);\n\t\t\tassert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\t\t\tlocalValue.resubmitMessage(value, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryRollback(content: any, localOpMetadata: unknown) {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst localValue = this.data.get(content.key);\n\n\t\t\tassert(localValue !== undefined, 0xb7e /* Local value expected on rollback */);\n\n\t\t\tlocalValue.rollback(content.value, localOpMetadata as IMapMessageLocalMetadata);\n\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryApplyStashedOp(content: unknown): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst map = this.get(key);\n\n\t\t\tmap.applyStashedOp(value);\n\t\t\treturn true;\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 recognized and thus processed, false otherwise.\n\t *\n\t * @remarks\n\t * When this returns false and the caller doesn't handle the op itself, then the op could be from a different version of this code.\n\t * In such a case, not applying the op would result in this client becoming out of sync with clients that do handle the op\n\t * and could result in data corruption or data loss as well.\n\t * Therefore, in such cases the caller should typically throw an error, ensuring that this client treats the situation as data corruption\n\t * (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate.\n\t */\n\tpublic tryProcessMessage(\n\t\tcontent: unknown,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst localValue = this.data.get(key) ?? this.createCore(key, local);\n\t\t\tlocalValue.process(value, local, message, localOpMetadata as IMapMessageLocalMetadata);\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 */\n\tprivate createCore(\n\t\tkey: string,\n\t\tlocal: boolean,\n\t\tserializedIntervals?: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2,\n\t): IntervalCollection {\n\t\tconst localValue = new IntervalCollection(\n\t\t\t(op, md) => {\n\t\t\t\t{\n\t\t\t\t\tthis.submitMessage(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\ttype: \"act\",\n\t\t\t\t\t\t\tvalue: op,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmd,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\tserializedIntervals ?? [],\n\t\t\tthis.options,\n\t\t);\n\t\tthis.data.set(key, localValue);\n\t\tthis.eventEmitter.emit(\"createIntervalCollection\", key, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n}\n"]}
@@ -8,6 +8,7 @@ import type { IntervalCollection, ISerializedIntervalCollectionV1, ISerializedIn
8
8
  import { ISerializedInterval, IntervalDeltaOpType, SerializedIntervalDelta } from "./intervals/index.js";
9
9
  export interface IMapMessageLocalMetadata {
10
10
  localSeq: number;
11
+ previous?: ISerializedInterval;
11
12
  }
12
13
  /**
13
14
  * Optional flags that configure options for sequence DDSs
@@ -47,18 +48,6 @@ export interface IIntervalCollectionOperation {
47
48
  * @param localOpMetadata - any local metadata submitted by `IValueOpEmitter.emit`.
48
49
  */
49
50
  process(value: IntervalCollection, params: ISerializedInterval, local: boolean, message: ISequencedDocumentMessage | undefined, localOpMetadata: IMapMessageLocalMetadata | undefined): void;
50
- /**
51
- * Rebases an `op` on `value` from its original perspective (ref/local seq) to the current
52
- * perspective. Should be invoked on reconnection.
53
- * @param value - The current value stored at the given key, which should be the value type.
54
- * @param op - The op to be rebased.
55
- * @param localOpMetadata - Any local metadata that was originally submitted with the op.
56
- * @returns A rebased version of the op and any local metadata that should be submitted with it.
57
- */
58
- rebase(value: IntervalCollection, op: IIntervalCollectionTypeOperationValue, localOpMetadata: IMapMessageLocalMetadata): {
59
- rebasedOp: IIntervalCollectionTypeOperationValue;
60
- rebasedLocalOpMetadata: IMapMessageLocalMetadata;
61
- } | undefined;
62
51
  }
63
52
  /**
64
53
  * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use
@@ -99,14 +88,32 @@ export interface ISerializedIntervalCollection {
99
88
  * serializable via JSON.stringify/parse but differs in that it has no equivalency with an in-memory value - rather
100
89
  * it just describes an operation to be applied to an already-in-memory value.
101
90
  */
102
- export interface IIntervalCollectionTypeOperationValue {
91
+ export type IIntervalCollectionTypeOperationValue = {
92
+ /**
93
+ * The name of the operation.
94
+ */
95
+ opName: typeof IntervalDeltaOpType.ADD;
96
+ /**
97
+ * The payload that is submitted along with the operation.
98
+ */
99
+ value: ISerializedInterval;
100
+ } | {
103
101
  /**
104
102
  * The name of the operation.
105
103
  */
106
- opName: IntervalDeltaOpType;
104
+ opName: typeof IntervalDeltaOpType.CHANGE;
107
105
  /**
108
106
  * The payload that is submitted along with the operation.
109
107
  */
110
108
  value: SerializedIntervalDelta;
111
- }
109
+ } | {
110
+ /**
111
+ * The name of the operation.
112
+ */
113
+ opName: typeof IntervalDeltaOpType.DELETE;
114
+ /**
115
+ * The payload that is submitted along with the operation.
116
+ */
117
+ value: SerializedIntervalDelta;
118
+ };
112
119
  //# sourceMappingURL=intervalCollectionMapInterfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intervalCollectionMapInterfaces.d.ts","sourceRoot":"","sources":["../src/intervalCollectionMapInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,KAAK,EACX,kBAAkB,EAClB,+BAA+B,EAC/B,+BAA+B,EAC/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,wBAAwB;IACxC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,eAChB,SAAQ,IAAI,CACX,iBAAiB,EACf,uCAAuC,GACvC,2BAA2B,GAC3B,gCAAgC,GAChC,+BAA+B,CACjC;IACD;;;;;;;;;;;;OAYG;IACH,yBAAyB,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,2BAA2B,EAAE,GAAG,GAAG,GAAG,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;;;;;OAOG;IACH,OAAO,CACN,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,yBAAyB,GAAG,SAAS,EAC9C,eAAe,EAAE,wBAAwB,GAAG,SAAS,GACnD,IAAI,CAAC;IAER;;;;;;;OAOG;IACH,MAAM,CACL,KAAK,EAAE,kBAAkB,EACzB,EAAE,EAAE,qCAAqC,EACzC,eAAe,EAAE,wBAAwB,GAEvC;QACA,SAAS,EAAE,qCAAqC,CAAC;QACjD,sBAAsB,EAAE,wBAAwB,CAAC;KAChD,GACD,SAAS,CAAC;CACb;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,+BAA+B;IAC/C;;OAEG;IACH,IAAI,EAAE,gCAAgC,CAAC;IAEvC;;OAEG;IACH,KAAK,EAAE,+BAA+B,GAAG,+BAA+B,CAAC;CACzE;AAED,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qCAAqC;IACrD;;OAEG;IACH,MAAM,EAAE,mBAAmB,CAAC;IAE5B;;OAEG;IACH,KAAK,EAAE,uBAAuB,CAAC;CAC/B"}
1
+ {"version":3,"file":"intervalCollectionMapInterfaces.d.ts","sourceRoot":"","sources":["../src/intervalCollectionMapInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,KAAK,EACX,kBAAkB,EAClB,+BAA+B,EAC/B,+BAA+B,EAC/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,wBAAwB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,eAChB,SAAQ,IAAI,CACX,iBAAiB,EACf,uCAAuC,GACvC,2BAA2B,GAC3B,gCAAgC,GAChC,+BAA+B,CACjC;IACD;;;;;;;;;;;;OAYG;IACH,yBAAyB,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,2BAA2B,EAAE,GAAG,GAAG,GAAG,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;;;;;OAOG;IACH,OAAO,CACN,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,yBAAyB,GAAG,SAAS,EAC9C,eAAe,EAAE,wBAAwB,GAAG,SAAS,GACnD,IAAI,CAAC;CACR;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,+BAA+B;IAC/C;;OAEG;IACH,IAAI,EAAE,gCAAgC,CAAC;IAEvC;;OAEG;IACH,KAAK,EAAE,+BAA+B,GAAG,+BAA+B,CAAC;CACzE;AAED,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,qCAAqC,GAC9C;IACA;;OAEG;IACH,MAAM,EAAE,OAAO,mBAAmB,CAAC,GAAG,CAAC;IAEvC;;OAEG;IACH,KAAK,EAAE,mBAAmB,CAAC;CAC1B,GACD;IACA;;OAEG;IACH,MAAM,EAAE,OAAO,mBAAmB,CAAC,MAAM,CAAC;IAE1C;;OAEG;IACH,KAAK,EAAE,uBAAuB,CAAC;CAC9B,GACD;IACA;;OAEG;IACH,MAAM,EAAE,OAAO,mBAAmB,CAAC,MAAM,CAAC;IAE1C;;OAEG;IACH,KAAK,EAAE,uBAAuB,CAAC;CAC9B,CAAC"}
@@ -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 { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type { IMergeTreeOptions } from \"@fluidframework/merge-tree/internal\";\n\nimport type {\n\tIntervalCollection,\n\tISerializedIntervalCollectionV1,\n\tISerializedIntervalCollectionV2,\n} from \"./intervalCollection.js\";\nimport {\n\tISerializedInterval,\n\tIntervalDeltaOpType,\n\tSerializedIntervalDelta,\n} from \"./intervals/index.js\";\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\textends Pick<\n\t\tIMergeTreeOptions,\n\t\t| \"mergeTreeReferencesCanSlideToEndpoint\"\n\t\t| \"mergeTreeEnableObliterate\"\n\t\t| \"mergeTreeEnableSidedObliterate\"\n\t\t| \"mergeTreeEnableAnnotateAdjust\"\n\t> {\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 @fluidframework/merge-tree#SequencePlace}\n\t * for additional context.\n\t *\n\t * This flag must be enabled to pass instances of {@link @fluidframework/merge-tree#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\n\t/**\n\t * This is for testing, and allows us to output intervals in the older formats.\n\t */\n\tintervalSerializationFormat: \"1\" | \"2\";\n}\n\n/**\n * Defines an operation that a value type is able to handle.\n *\n */\nexport interface IIntervalCollectionOperation {\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,\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,\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 * 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: \"sharedStringIntervalCollection\";\n\n\t/**\n\t * The JSONable representation of the value.\n\t */\n\tvalue: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2;\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 */\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 { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type { IMergeTreeOptions } from \"@fluidframework/merge-tree/internal\";\n\nimport type {\n\tIntervalCollection,\n\tISerializedIntervalCollectionV1,\n\tISerializedIntervalCollectionV2,\n} from \"./intervalCollection.js\";\nimport {\n\tISerializedInterval,\n\tIntervalDeltaOpType,\n\tSerializedIntervalDelta,\n} from \"./intervals/index.js\";\n\nexport interface IMapMessageLocalMetadata {\n\tlocalSeq: number;\n\tprevious?: ISerializedInterval;\n}\n\n/**\n * Optional flags that configure options for sequence DDSs\n * @internal\n */\nexport interface SequenceOptions\n\textends Pick<\n\t\tIMergeTreeOptions,\n\t\t| \"mergeTreeReferencesCanSlideToEndpoint\"\n\t\t| \"mergeTreeEnableObliterate\"\n\t\t| \"mergeTreeEnableSidedObliterate\"\n\t\t| \"mergeTreeEnableAnnotateAdjust\"\n\t> {\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 @fluidframework/merge-tree#SequencePlace}\n\t * for additional context.\n\t *\n\t * This flag must be enabled to pass instances of {@link @fluidframework/merge-tree#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\n\t/**\n\t * This is for testing, and allows us to output intervals in the older formats.\n\t */\n\tintervalSerializationFormat: \"1\" | \"2\";\n}\n\n/**\n * Defines an operation that a value type is able to handle.\n *\n */\nexport interface IIntervalCollectionOperation {\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,\n\t\tparams: ISerializedInterval,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata | undefined,\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: \"sharedStringIntervalCollection\";\n\n\t/**\n\t * The JSONable representation of the value.\n\t */\n\tvalue: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2;\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 */\nexport type IIntervalCollectionTypeOperationValue =\n\t| {\n\t\t\t/**\n\t\t\t * The name of the operation.\n\t\t\t */\n\t\t\topName: typeof IntervalDeltaOpType.ADD;\n\n\t\t\t/**\n\t\t\t * The payload that is submitted along with the operation.\n\t\t\t */\n\t\t\tvalue: ISerializedInterval;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The name of the operation.\n\t\t\t */\n\t\t\topName: typeof IntervalDeltaOpType.CHANGE;\n\n\t\t\t/**\n\t\t\t * The payload that is submitted along with the operation.\n\t\t\t */\n\t\t\tvalue: SerializedIntervalDelta;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The name of the operation.\n\t\t\t */\n\t\t\topName: typeof IntervalDeltaOpType.DELETE;\n\n\t\t\t/**\n\t\t\t * The payload that is submitted along with the operation.\n\t\t\t */\n\t\t\tvalue: SerializedIntervalDelta;\n\t };\n"]}
@@ -14,7 +14,7 @@ import { ISerializableInterval, type SequenceInterval } from "../intervals/index
14
14
  * @legacy
15
15
  * @alpha
16
16
  *
17
- * @remarks The generic version of this interface is no longer used and will be removed. Use {@link SequenceIntervalIndex} instead.
17
+ * @deprecated The generic version of this interface is no longer used and will be removed. Use {@link SequenceIntervalIndex} instead.
18
18
  */
19
19
  export interface IntervalIndex<TInterval extends ISerializableInterval> {
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"intervalIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/intervalIndex.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 { ISerializableInterval, type SequenceInterval } from \"../intervals/index.js\";\n\n/**\n * Collection of intervals.\n *\n * Implementers of this interface will typically implement additional APIs to support efficiently querying a collection\n * of intervals in some manner, for example:\n * - \"find all intervals with start endpoint between these two points\"\n * - \"find all intervals which overlap this range\"\n * etc.\n * @legacy\n * @alpha\n *\n * @remarks The generic version of this interface is no longer used and will be removed. Use {@link SequenceIntervalIndex} instead.\n */\nexport interface IntervalIndex<TInterval extends ISerializableInterval> {\n\t/**\n\t * Adds an interval to the index.\n\t * @remarks Application code should never need to invoke this method on their index for production scenarios:\n\t * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.\n\t */\n\tadd(interval: TInterval): void;\n\n\t/**\n\t * Removes an interval from the index.\n\t * @remarks Application code should never need to invoke this method on their index for production scenarios:\n\t * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.\n\t */\n\tremove(interval: TInterval): void;\n}\n\n/**\n * Collection of intervals.\n *\n * Implementers of this interface will typically implement additional APIs to support efficiently querying a collection\n * of intervals in some manner, for example:\n * - \"find all intervals with start endpoint between these two points\"\n * - \"find all intervals which overlap this range\"\n * etc.\n * @legacy\n * @alpha\n */\nexport interface SequenceIntervalIndex {\n\t/**\n\t * Adds an interval to the index.\n\t * @remarks Application code should never need to invoke this method on their index for production scenarios:\n\t * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.\n\t */\n\tadd(interval: SequenceInterval): void;\n\n\t/**\n\t * Removes an interval from the index.\n\t * @remarks Application code should never need to invoke this method on their index for production scenarios:\n\t * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.\n\t */\n\tremove(interval: SequenceInterval): void;\n}\n"]}
1
+ {"version":3,"file":"intervalIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/intervalIndex.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 { ISerializableInterval, type SequenceInterval } from \"../intervals/index.js\";\n\n/**\n * Collection of intervals.\n *\n * Implementers of this interface will typically implement additional APIs to support efficiently querying a collection\n * of intervals in some manner, for example:\n * - \"find all intervals with start endpoint between these two points\"\n * - \"find all intervals which overlap this range\"\n * etc.\n * @legacy\n * @alpha\n *\n * @deprecated The generic version of this interface is no longer used and will be removed. Use {@link SequenceIntervalIndex} instead.\n */\nexport interface IntervalIndex<TInterval extends ISerializableInterval> {\n\t/**\n\t * Adds an interval to the index.\n\t * @remarks Application code should never need to invoke this method on their index for production scenarios:\n\t * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.\n\t */\n\tadd(interval: TInterval): void;\n\n\t/**\n\t * Removes an interval from the index.\n\t * @remarks Application code should never need to invoke this method on their index for production scenarios:\n\t * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.\n\t */\n\tremove(interval: TInterval): void;\n}\n\n/**\n * Collection of intervals.\n *\n * Implementers of this interface will typically implement additional APIs to support efficiently querying a collection\n * of intervals in some manner, for example:\n * - \"find all intervals with start endpoint between these two points\"\n * - \"find all intervals which overlap this range\"\n * etc.\n * @legacy\n * @alpha\n */\nexport interface SequenceIntervalIndex {\n\t/**\n\t * Adds an interval to the index.\n\t * @remarks Application code should never need to invoke this method on their index for production scenarios:\n\t * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.\n\t */\n\tadd(interval: SequenceInterval): void;\n\n\t/**\n\t * Removes an interval from the index.\n\t * @remarks Application code should never need to invoke this method on their index for production scenarios:\n\t * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.\n\t */\n\tremove(interval: SequenceInterval): void;\n}\n"]}
@@ -12,7 +12,7 @@ import { IntervalIndex, type SequenceIntervalIndex } from "./intervalIndex.js";
12
12
  * Use {@link ISequenceOverlappingIntervalsIndex} instead.
13
13
  * @legacy
14
14
  * @alpha
15
- * @remarks The generic version of this interface is no longer used and will be removed. Use {@link ISequenceOverlappingIntervalsIndex} instead.
15
+ * @deprecated The generic version of this interface is no longer used and will be removed. Use {@link ISequenceOverlappingIntervalsIndex} instead.
16
16
  */
17
17
  export interface IOverlappingIntervalsIndex<TInterval extends ISerializableInterval> extends IntervalIndex<TInterval> {
18
18
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"overlappingIntervalsIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/overlappingIntervalsIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yCAAyC;AAEzC,OAAO,EAGN,kBAAkB,GAClB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAgB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAGN,uBAAuB,GACvB,MAAM,uBAAuB,CAAC;AAqD/B,MAAM,OAAO,yBAAyB;IAIrC,YAAY,MAAc;QAHP,iBAAY,GAAG,IAAI,YAAY,EAAoB,CAAC;QAItE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAEM,GAAG,CAAC,EAAwC;QAClD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAEM,QAAQ,CAAC,EAA2C;QAC1D,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IAEM,sBAAsB,CAC5B,OAA2B,EAC3B,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,G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AS,CAAC,OAAO,EAAE,EACpC,CAAC;YACF,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3E,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,QAA0B;QACvC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,GAAG,CAAC,QAA0B;QACpC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAC9C,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC9C,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 {\n\tClient,\n\tSequencePlace,\n\tendpointPosAndSide,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { IntervalNode, IntervalTree } from \"../intervalTree.js\";\nimport {\n\tISerializableInterval,\n\tSequenceInterval,\n\tcreateTransientInterval,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex, type SequenceIntervalIndex } from \"./intervalIndex.js\";\n\n/**\n * The generic version of this interface is deprecated and will be removed in a future release.\n * Use {@link ISequenceOverlappingIntervalsIndex} instead.\n * @legacy\n * @alpha\n * @remarks The generic version of this interface is no longer used and will be removed. Use {@link ISequenceOverlappingIntervalsIndex} instead.\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\n/**\n * @legacy\n * @alpha\n */\nexport interface ISequenceOverlappingIntervalsIndex extends SequenceIntervalIndex {\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): SequenceInterval[];\n\n\t/**\n\t * Gathers the interval results based on specified parameters.\n\t */\n\tgatherIterationResults(\n\t\tresults: SequenceInterval[],\n\t\titeratesForward: boolean,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t): void;\n}\n\nexport class OverlappingIntervalsIndex implements ISequenceOverlappingIntervalsIndex {\n\tprotected readonly intervalTree = new IntervalTree<SequenceInterval>();\n\tprotected readonly client: Client;\n\n\tconstructor(client: Client) {\n\t\tthis.client = client;\n\t}\n\n\tpublic map(fn: (interval: SequenceInterval) => void) {\n\t\tthis.intervalTree.map(fn);\n\t}\n\n\tpublic mapUntil(fn: (interval: SequenceInterval) => boolean) {\n\t\tthis.intervalTree.mapUntil(fn);\n\t}\n\n\tpublic gatherIterationResults(\n\t\tresults: SequenceInterval[],\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: SequenceInterval) => {\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: SequenceInterval) => {\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: SequenceInterval = createTransientInterval(\n\t\t\t\tstart ?? \"start\",\n\t\t\t\tend ?? \"end\",\n\t\t\t\tthis.client,\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: SequenceInterval) => {\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: SequenceInterval) => {\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<SequenceInterval>) => {\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<SequenceInterval>) => {\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<SequenceInterval>) => {\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(\n\t\tstart: SequencePlace,\n\t\tend: SequencePlace,\n\t): SequenceInterval[] {\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 = createTransientInterval(start, end, this.client);\n\n\t\tconst overlappingIntervalNodes = this.intervalTree.match(transientInterval);\n\t\treturn overlappingIntervalNodes.map((node) => node.key);\n\t}\n\n\tpublic remove(interval: SequenceInterval) {\n\t\tthis.intervalTree.removeExisting(interval);\n\t}\n\n\tpublic add(interval: SequenceInterval) {\n\t\tthis.intervalTree.put(interval);\n\t}\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport function createOverlappingIntervalsIndex(\n\tsharedString: ISharedString,\n): ISequenceOverlappingIntervalsIndex {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new OverlappingIntervalsIndex(client);\n}\n"]}
1
+ {"version":3,"file":"overlapp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CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,CAAC;IAEM,MAAM,CAAC,QAA0B;QACvC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,GAAG,CAAC,QAA0B;QACpC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAC9C,YAA2B;IAE3B,MAAM,MAAM,GAAI,YAA8C,CAAC,MAAM,CAAC;IACtE,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC9C,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 {\n\tClient,\n\tSequencePlace,\n\tendpointPosAndSide,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { IntervalNode, IntervalTree } from \"../intervalTree.js\";\nimport {\n\tISerializableInterval,\n\tSequenceInterval,\n\tcreateTransientInterval,\n} from \"../intervals/index.js\";\nimport { ISharedString } from \"../sharedString.js\";\n\nimport { IntervalIndex, type SequenceIntervalIndex } from \"./intervalIndex.js\";\n\n/**\n * The generic version of this interface is deprecated and will be removed in a future release.\n * Use {@link ISequenceOverlappingIntervalsIndex} instead.\n * @legacy\n * @alpha\n * @deprecated The generic version of this interface is no longer used and will be removed. Use {@link ISequenceOverlappingIntervalsIndex} instead.\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\n/**\n * @legacy\n * @alpha\n */\nexport interface ISequenceOverlappingIntervalsIndex extends SequenceIntervalIndex {\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): SequenceInterval[];\n\n\t/**\n\t * Gathers the interval results based on specified parameters.\n\t */\n\tgatherIterationResults(\n\t\tresults: SequenceInterval[],\n\t\titeratesForward: boolean,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t): void;\n}\n\nexport class OverlappingIntervalsIndex implements ISequenceOverlappingIntervalsIndex {\n\tprotected readonly intervalTree = new IntervalTree<SequenceInterval>();\n\tprotected readonly client: Client;\n\n\tconstructor(client: Client) {\n\t\tthis.client = client;\n\t}\n\n\tpublic map(fn: (interval: SequenceInterval) => void) {\n\t\tthis.intervalTree.map(fn);\n\t}\n\n\tpublic mapUntil(fn: (interval: SequenceInterval) => boolean) {\n\t\tthis.intervalTree.mapUntil(fn);\n\t}\n\n\tpublic gatherIterationResults(\n\t\tresults: SequenceInterval[],\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: SequenceInterval) => {\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: SequenceInterval) => {\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: SequenceInterval = createTransientInterval(\n\t\t\t\tstart ?? \"start\",\n\t\t\t\tend ?? \"end\",\n\t\t\t\tthis.client,\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: SequenceInterval) => {\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: SequenceInterval) => {\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<SequenceInterval>) => {\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<SequenceInterval>) => {\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<SequenceInterval>) => {\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(\n\t\tstart: SequencePlace,\n\t\tend: SequencePlace,\n\t): SequenceInterval[] {\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 = createTransientInterval(start, end, this.client);\n\n\t\tconst overlappingIntervalNodes = this.intervalTree.match(transientInterval);\n\t\treturn overlappingIntervalNodes.map((node) => node.key);\n\t}\n\n\tpublic remove(interval: SequenceInterval) {\n\t\tthis.intervalTree.removeExisting(interval);\n\t}\n\n\tpublic add(interval: SequenceInterval) {\n\t\tthis.intervalTree.put(interval);\n\t}\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport function createOverlappingIntervalsIndex(\n\tsharedString: ISharedString,\n): ISequenceOverlappingIntervalsIndex {\n\tconst client = (sharedString as unknown as { client: Client }).client;\n\treturn new OverlappingIntervalsIndex(client);\n}\n"]}
@@ -124,7 +124,7 @@ export declare class SequenceIntervalClass implements SequenceInterval {
124
124
  * {@inheritDoc ISerializableInterval.properties}
125
125
  */
126
126
  get properties(): Readonly<PropertySet>;
127
- changeProperties(props: PropertySet | undefined, op?: ISequencedDocumentMessage): import("@fluidframework/merge-tree/internal").MapLike<unknown> | undefined;
127
+ changeProperties(props: PropertySet | undefined, op?: ISequencedDocumentMessage, rollback?: boolean): import("@fluidframework/merge-tree/internal").MapLike<unknown> | undefined;
128
128
  /***/
129
129
  get stickiness(): IntervalStickiness;
130
130
  constructor(client: Client, id: string, label: string,
@@ -196,7 +196,7 @@ export declare class SequenceIntervalClass implements SequenceInterval {
196
196
  export declare function createPositionReferenceFromSegoff(client: Client, segoff: {
197
197
  segment: ISegment | undefined;
198
198
  offset: number | undefined;
199
- } | "start" | "end", refType: ReferenceType, op?: ISequencedDocumentMessage, localSeq?: number, fromSnapshot?: boolean, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
199
+ } | "start" | "end", refType: ReferenceType, op?: ISequencedDocumentMessage, localSeq?: number, fromSnapshot?: boolean, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean, rollback?: boolean): LocalReferencePosition;
200
200
  export declare function createTransientInterval(start: SequencePlace | undefined, end: SequencePlace | undefined, client: Client): SequenceIntervalClass;
201
- export declare function createSequenceInterval(label: string, id: string, start: SequencePlace | undefined, end: SequencePlace | undefined, client: Client, intervalType: IntervalType, op?: ISequencedDocumentMessage, fromSnapshot?: boolean, useNewSlidingBehavior?: boolean, props?: PropertySet): SequenceIntervalClass;
201
+ export declare function createSequenceInterval(label: string, id: string, start: SequencePlace | undefined, end: SequencePlace | undefined, client: Client, intervalType: IntervalType, op?: ISequencedDocumentMessage, fromSnapshot?: boolean, useNewSlidingBehavior?: boolean, props?: PropertySet, rollback?: boolean): SequenceIntervalClass;
202
202
  //# sourceMappingURL=sequenceInterval.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceInterval.d.ts","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EACN,MAAM,EACN,QAAQ,EACR,sBAAsB,EAEtB,WAAW,EACX,aAAa,EACb,iBAAiB,EASjB,aAAa,EACb,IAAI,EAOJ,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EACN,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,YAA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S,EAChC,GAAG,EAAE,aAAa,GAAG,SAAS,EAC9B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,EAAE,CAAC,EAAE,yBAAyB,EAC9B,YAAY,CAAC,EAAE,OAAO,EACtB,qBAAqB,GAAE,OAAe,EACtC,KAAK,CAAC,EAAE,WAAW,EACnB,QAAQ,CAAC,EAAE,OAAO,GAChB,qBAAqB,CA6EvB"}
@@ -52,12 +52,12 @@ export class SequenceIntervalClass {
52
52
  get properties() {
53
53
  return __classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").properties;
54
54
  }
55
- changeProperties(props, op) {
55
+ changeProperties(props, op, rollback) {
56
56
  if (props !== undefined) {
57
57
  __classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").propertyManager ??= new PropertiesManager();
58
58
  return __classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").propertyManager.handleProperties({ props }, __classPrivateFieldGet(this, _SequenceIntervalClass_props, "f"), this.client.getCollabWindow().collaborating
59
59
  ? (op?.sequenceNumber ?? UnassignedSequenceNumber)
60
- : UniversalSequenceNumber, op?.minimumSequenceNumber ?? UniversalSequenceNumber, this.client.getCollabWindow().collaborating);
60
+ : UniversalSequenceNumber, op?.minimumSequenceNumber ?? UniversalSequenceNumber, this.client.getCollabWindow().collaborating, rollback);
61
61
  }
62
62
  }
63
63
  /***/
@@ -288,7 +288,7 @@ export class SequenceIntervalClass {
288
288
  }
289
289
  }
290
290
  _SequenceIntervalClass_props = new WeakMap();
291
- export function createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference, canSlideToEndpoint) {
291
+ export function createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference, canSlideToEndpoint, rollback) {
292
292
  if (segoff === "start" || segoff === "end") {
293
293
  return client.createLocalReferencePosition(segoff, undefined, refType, undefined, slidingPreference, canSlideToEndpoint);
294
294
  }
@@ -304,12 +304,13 @@ export function createPositionReferenceFromSegoff(client, segoff, refType, op, l
304
304
  if (!op &&
305
305
  !localSeq &&
306
306
  !fromSnapshot &&
307
- !refTypeIncludesFlag(refType, ReferenceType.Transient)) {
307
+ !refTypeIncludesFlag(refType, ReferenceType.Transient) &&
308
+ !rollback) {
308
309
  throw new UsageError("Non-transient references need segment");
309
310
  }
310
311
  return createDetachedLocalReferencePosition(slidingPreference, refType);
311
312
  }
312
- function createPositionReference(client, pos, refType, op, fromSnapshot, localSeq, slidingPreference, exclusive = false, useNewSlidingBehavior = false) {
313
+ function createPositionReference(client, pos, refType, op, fromSnapshot, localSeq, slidingPreference, exclusive = false, useNewSlidingBehavior = false, rollback) {
313
314
  let segoff;
314
315
  if (op) {
315
316
  assert((refType & ReferenceType.SlideOnRemove) !== 0, 0x2f5 /* op create references must be SlideOnRemove */);
@@ -331,12 +332,12 @@ function createPositionReference(client, pos, refType, op, fromSnapshot, localSe
331
332
  ? pos
332
333
  : client.getContainingSegment(pos, undefined, localSeq);
333
334
  }
334
- return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference, exclusive);
335
+ return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference, exclusive, rollback);
335
336
  }
336
337
  export function createTransientInterval(start, end, client) {
337
338
  return createSequenceInterval("transient", uuid(), start, end, client, IntervalType.Transient);
338
339
  }
339
- export function createSequenceInterval(label, id, start, end, client, intervalType, op, fromSnapshot, useNewSlidingBehavior = false, props) {
340
+ export function createSequenceInterval(label, id, start, end, client, intervalType, op, fromSnapshot, useNewSlidingBehavior = false, props, rollback) {
340
341
  const { startPos, startSide, endPos, endSide } = endpointPosAndSide(start ?? "start", end ?? "end");
341
342
  assert(startPos !== undefined &&
342
343
  endPos !== undefined &&
@@ -362,8 +363,8 @@ export function createSequenceInterval(label, id, start, end, client, intervalTy
362
363
  endRefType |= ReferenceType.StayOnRemove;
363
364
  }
364
365
  }
365
- const startLref = createPositionReference(client, startPos, beginRefType, op, fromSnapshot, undefined, startReferenceSlidingPreference(stickiness), startReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD, useNewSlidingBehavior);
366
- const endLref = createPositionReference(client, endPos, endRefType, op, fromSnapshot, undefined, endReferenceSlidingPreference(stickiness), endReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD, useNewSlidingBehavior);
366
+ const startLref = createPositionReference(client, startPos, beginRefType, op, fromSnapshot, undefined, startReferenceSlidingPreference(stickiness), startReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD, useNewSlidingBehavior, rollback);
367
+ const endLref = createPositionReference(client, endPos, endRefType, op, fromSnapshot, undefined, endReferenceSlidingPreference(stickiness), endReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD, useNewSlidingBehavior, rollback);
367
368
  const rangeProp = {
368
369
  [reservedRangeLabelsKey]: [label],
369
370
  };