@fluidframework/sequence 2.90.0 → 2.92.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.
- package/CHANGELOG.md +8 -0
- package/dist/IntervalCollectionValues.d.ts +3 -3
- package/dist/IntervalCollectionValues.d.ts.map +1 -1
- package/dist/IntervalCollectionValues.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +6 -5
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +10 -9
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalCollectionMap.d.ts +4 -5
- package/dist/intervalCollectionMap.d.ts.map +1 -1
- package/dist/intervalCollectionMap.js +3 -3
- package/dist/intervalCollectionMap.js.map +1 -1
- package/dist/intervalCollectionMapInterfaces.d.ts +3 -3
- package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -1
- package/dist/intervalCollectionMapInterfaces.js.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.d.ts +2 -2
- package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/dist/intervalIndex/endpointIndex.d.ts +2 -2
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointIndex.js.map +1 -1
- package/dist/intervalIndex/index.d.ts +7 -7
- package/dist/intervalIndex/index.d.ts.map +1 -1
- package/dist/intervalIndex/index.js.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +3 -3
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +2 -2
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.d.ts +2 -2
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/dist/intervalTree.d.ts +3 -2
- package/dist/intervalTree.d.ts.map +1 -1
- package/dist/intervalTree.js.map +1 -1
- package/dist/intervals/index.d.ts +2 -2
- package/dist/intervals/index.d.ts.map +1 -1
- package/dist/intervals/index.js.map +1 -1
- package/dist/intervals/intervalUtils.d.ts +2 -1
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js +0 -1
- package/dist/intervals/intervalUtils.js.map +1 -1
- package/dist/intervals/sequenceInterval.d.ts +5 -3
- package/dist/intervals/sequenceInterval.d.ts.map +1 -1
- package/dist/intervals/sequenceInterval.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/revertibles.d.ts +5 -4
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +26 -20
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence.d.ts +8 -6
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +9 -10
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +2 -1
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +2 -2
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sequenceFactory.d.ts +3 -2
- package/dist/sequenceFactory.d.ts.map +1 -1
- package/dist/sequenceFactory.js +3 -2
- package/dist/sequenceFactory.js.map +1 -1
- package/dist/sharedSequence.d.ts +3 -2
- package/dist/sharedSequence.d.ts.map +1 -1
- package/dist/sharedSequence.js.map +1 -1
- package/dist/sharedString.d.ts +3 -2
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js.map +1 -1
- package/eslint.config.mts +16 -4
- package/internal.d.ts +1 -1
- package/legacy.d.ts +1 -1
- package/lib/IntervalCollectionValues.d.ts +3 -3
- package/lib/IntervalCollectionValues.d.ts.map +1 -1
- package/lib/IntervalCollectionValues.js +1 -1
- package/lib/IntervalCollectionValues.js.map +1 -1
- package/lib/index.d.ts +10 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +6 -5
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +10 -9
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalCollectionMap.d.ts +4 -5
- package/lib/intervalCollectionMap.d.ts.map +1 -1
- package/lib/intervalCollectionMap.js +3 -3
- package/lib/intervalCollectionMap.js.map +1 -1
- package/lib/intervalCollectionMapInterfaces.d.ts +3 -3
- package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -1
- package/lib/intervalCollectionMapInterfaces.js.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.d.ts +2 -2
- package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.js +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/lib/intervalIndex/endpointIndex.d.ts +2 -2
- package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointIndex.js.map +1 -1
- package/lib/intervalIndex/index.d.ts +7 -7
- package/lib/intervalIndex/index.d.ts.map +1 -1
- package/lib/intervalIndex/index.js.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +3 -3
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +2 -2
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.ts +2 -2
- package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.js +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/lib/intervalTree.d.ts +3 -2
- package/lib/intervalTree.d.ts.map +1 -1
- package/lib/intervalTree.js +1 -1
- package/lib/intervalTree.js.map +1 -1
- package/lib/intervals/index.d.ts +2 -2
- package/lib/intervals/index.d.ts.map +1 -1
- package/lib/intervals/index.js.map +1 -1
- package/lib/intervals/intervalUtils.d.ts +2 -1
- package/lib/intervals/intervalUtils.d.ts.map +1 -1
- package/lib/intervals/intervalUtils.js +0 -1
- package/lib/intervals/intervalUtils.js.map +1 -1
- package/lib/intervals/sequenceInterval.d.ts +5 -3
- package/lib/intervals/sequenceInterval.d.ts.map +1 -1
- package/lib/intervals/sequenceInterval.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/revertibles.d.ts +5 -4
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +26 -20
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence.d.ts +8 -6
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +11 -12
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +2 -1
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +2 -2
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sequenceFactory.d.ts +3 -2
- package/lib/sequenceFactory.d.ts.map +1 -1
- package/lib/sequenceFactory.js +3 -2
- package/lib/sequenceFactory.js.map +1 -1
- package/lib/sharedSequence.d.ts +3 -2
- package/lib/sharedSequence.d.ts.map +1 -1
- package/lib/sharedSequence.js +1 -1
- package/lib/sharedSequence.js.map +1 -1
- package/lib/sharedString.d.ts +3 -2
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +1 -1
- package/lib/sharedString.js.map +1 -1
- package/package.json +23 -23
- package/src/IntervalCollectionValues.ts +4 -6
- package/src/index.ts +25 -25
- package/src/intervalCollection.ts +25 -20
- package/src/intervalCollectionMap.ts +8 -8
- package/src/intervalCollectionMapInterfaces.ts +4 -4
- package/src/intervalIndex/endpointInRangeIndex.ts +7 -8
- package/src/intervalIndex/endpointIndex.ts +3 -2
- package/src/intervalIndex/index.ts +7 -7
- package/src/intervalIndex/overlappingIntervalsIndex.ts +8 -9
- package/src/intervalIndex/sequenceIntervalIndexes.ts +2 -2
- package/src/intervalIndex/startpointInRangeIndex.ts +7 -8
- package/src/intervalTree.ts +3 -3
- package/src/intervals/index.ts +6 -6
- package/src/intervals/intervalUtils.ts +2 -1
- package/src/intervals/sequenceInterval.ts +7 -6
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +35 -26
- package/src/sequence.ts +25 -26
- package/src/sequenceDeltaEvent.ts +6 -4
- package/src/sequenceFactory.ts +6 -4
- package/src/sharedSequence.ts +3 -7
- package/src/sharedString.ts +3 -5
|
@@ -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,GAGlB,MAAM,yBAAyB,CAAC;AAOjC,SAAS,cAAc,CAAC,EAAW;IAClC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,E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AAE,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\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: (op: IMapOperation, localOpMetadata: unknown) => 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: unknown,\n\t\tsquash: boolean,\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, squash);\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);\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);\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;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACN,kBAAkB,GAGlB,MAAM,yBAAyB,CAAC;AAOjC,SAAS,cAAc,CAAC,EAAW;IACl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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 type { IEvent, IEventProvider, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { ValueType } 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 type {\n\tIIntervalCollectionTypeOperationValue,\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: (op: IMapOperation, localOpMetadata: unknown) => 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\tfor (const [key, localValue] of this.data.entries()) {\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.slice(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: unknown,\n\t\tsquash: boolean,\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, squash);\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);\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);\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"]}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { ListNode } from "@fluidframework/core-utils/internal";
|
|
6
|
-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
7
|
-
import { IMergeTreeOptions } from "@fluidframework/merge-tree/internal";
|
|
6
|
+
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
7
|
+
import type { IMergeTreeOptions } from "@fluidframework/merge-tree/internal";
|
|
8
8
|
import type { IntervalCollection, ISerializedIntervalCollectionV1, ISerializedIntervalCollectionV2 } from "./intervalCollection.js";
|
|
9
|
-
import { ISerializedInterval, IntervalDeltaOpType,
|
|
9
|
+
import type { ISerializedInterval, IntervalDeltaOpType, SequenceIntervalClass, SerializedIntervalDelta } from "./intervals/index.js";
|
|
10
10
|
export interface IntervalAddLocalMetadata {
|
|
11
11
|
type: typeof IntervalDeltaOpType.ADD;
|
|
12
12
|
localSeq: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalCollectionMapInterfaces.d.ts","sourceRoot":"","sources":["../src/intervalCollectionMapInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"intervalCollectionMapInterfaces.d.ts","sourceRoot":"","sources":["../src/intervalCollectionMapInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAC7F,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,KAAK,EACX,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,wBAAwB;IACxC,IAAI,EAAE,OAAO,mBAAmB,CAAC,GAAG,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,QAAQ,CAAC,wBAAwB,GAAG,2BAA2B,CAAC,CAAC;IACvF,QAAQ,EAAE,qB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Eb;;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 type { ListNode } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { 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\
|
|
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 type { ListNode } from \"@fluidframework/core-utils/internal\";\nimport type { 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 type {\n\tISerializedInterval,\n\tIntervalDeltaOpType,\n\tSequenceIntervalClass,\n\tSerializedIntervalDelta,\n} from \"./intervals/index.js\";\n\nexport interface IntervalAddLocalMetadata {\n\ttype: typeof IntervalDeltaOpType.ADD;\n\tlocalSeq: number;\n\tendpointChangesNode?: ListNode<IntervalAddLocalMetadata | IntervalChangeLocalMetadata>;\n\tinterval: SequenceIntervalClass;\n}\nexport interface IntervalChangeLocalMetadata {\n\ttype: typeof IntervalDeltaOpType.CHANGE;\n\tlocalSeq: number;\n\tendpointChangesNode?: ListNode<IntervalChangeLocalMetadata | IntervalChangeLocalMetadata>;\n\tinterval: SequenceIntervalClass;\n}\nexport interface IntervalDeleteLocalMetadata {\n\ttype: typeof IntervalDeltaOpType.DELETE;\n\tlocalSeq: number;\n\tendpointChangesNode?: undefined;\n\tinterval?: undefined;\n}\nexport type IntervalMessageLocalMetadata =\n\t| IntervalAddLocalMetadata\n\t| IntervalChangeLocalMetadata\n\t| IntervalDeleteLocalMetadata;\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: IntervalMessageLocalMetadata | 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"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { SequenceInterval } from "../intervals/index.js";
|
|
5
|
+
import type { SequenceInterval } from "../intervals/index.js";
|
|
6
6
|
import type { ISharedSegmentSequence } from "../sequence.js";
|
|
7
|
-
import { ISharedString } from "../sharedString.js";
|
|
7
|
+
import type { ISharedString } from "../sharedString.js";
|
|
8
8
|
import type { SequenceIntervalIndex } from "./intervalIndex.js";
|
|
9
9
|
/**
|
|
10
10
|
* Collection of intervals.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointInRangeIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/endpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"endpointInRangeIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/endpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhE;;;;;GAKG;AACH,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IACnE;;OAEG;IACH,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAC;CACjF;AAED,qBAAa,oBAAqB,YAAW,qBAAqB;IAGrD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAED,QAAQ,EAAE,sBAAsB,CAAC,GAAG,CAAC;IA0B3D,GAAG,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIrC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIxC,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE;CAyBvF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACzC,YAAY,EAAE,aAAa,GACzB,qBAAqB,CAEvB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { RedBlackTree } from "@fluidframework/merge-tree/internal";
|
|
6
6
|
import { createTransientIntervalFromSequence } from "../intervals/index.js";
|
|
7
|
-
import { compareOverrideables, forceCompare
|
|
7
|
+
import { compareOverrideables, forceCompare } from "./intervalIndexUtils.js";
|
|
8
8
|
export class EndpointInRangeIndex {
|
|
9
9
|
constructor(sequence) {
|
|
10
10
|
this.sequence = sequence;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointInRangeIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/endpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"endpointInRangeIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/endpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGnE,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAM5E,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAe7E,MAAM,OAAO,oBAAoB;IAGhC,YAA6B,QAAqC;QAArC,aAAQ,GAAR,QAAQ,CAA6B;QACjE,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CACnC,CAAC,CAAmB,EAAE,CAAmB,EAAE,EAAE;YAC5C,MAAM,iBAAiB,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC1C,IAAI,iBAAiB,KAAK,CAAC,EAAE,CAAC;gBAC7B,OAAO,iBAAiB,CAAC;YAC1B,CAAC;YAED,MAAM,uBAAuB,GAAG,oBAAoB,CACnD,CAAmC,EACnC,CAAmC,CACnC,CAAC;YACF,IAAI,uBAAuB,KAAK,CAAC,EAAE,CAAC;gBACnC,OAAO,uBAAuB,CAAC;YAChC,CAAC;YAED,MAAM,GAAG,GAAG,CAAC,CAAC,aAAa,EAAE,CAAC;YAC9B,MAAM,GAAG,GAAG,CAAC,CAAC,aAAa,EAAE,CAAC;YAC9B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBAC5C,OAAO,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;YAC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right (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { PropertyAction } from \"@fluidframework/merge-tree/internal\";\nimport { RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport type { SequenceInterval } from \"../intervals/index.js\";\nimport { createTransientIntervalFromSequence } from \"../intervals/index.js\";\nimport type { ISharedSegmentSequence } from \"../sequence.js\";\nimport type { ISharedString } from \"../sharedString.js\";\n\nimport type { SequenceIntervalIndex } from \"./intervalIndex.js\";\nimport type { HasComparisonOverride } from \"./intervalIndexUtils.js\";\nimport { 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 extends SequenceIntervalIndex {\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): SequenceInterval[];\n}\n\nexport class EndpointInRangeIndex implements IEndpointInRangeIndex {\n\tprivate readonly intervalTree;\n\n\tconstructor(private readonly sequence: ISharedSegmentSequence<any>) {\n\t\tthis.intervalTree = new RedBlackTree<SequenceInterval, SequenceInterval>(\n\t\t\t(a: SequenceInterval, b: SequenceInterval) => {\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: SequenceInterval): void {\n\t\tthis.intervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: SequenceInterval): void {\n\t\tthis.intervalTree.remove(interval);\n\t}\n\n\tpublic findIntervalsWithEndpointInRange(start: number, end: number): SequenceInterval[] {\n\t\tif (start <= 0 || start > end || this.intervalTree.isEmpty()) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results: SequenceInterval[] = [];\n\t\tconst action: PropertyAction<SequenceInterval, SequenceInterval> = (node) => {\n\t\t\tresults.push(node.data);\n\t\t\treturn true;\n\t\t};\n\n\t\tconst transientStartInterval = createTransientIntervalFromSequence(\n\t\t\tstart,\n\t\t\tstart,\n\t\t\tthis.sequence,\n\t\t);\n\n\t\tconst transientEndInterval = createTransientIntervalFromSequence(end, end, this.sequence);\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 * Creates an endpoint-in-range index for the provided SharedString.\n *\n * @internal\n */\nexport function createEndpointInRangeIndex(\n\tsharedString: ISharedString,\n): IEndpointInRangeIndex {\n\treturn new EndpointInRangeIndex(sharedString);\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { SequenceInterval } from "../intervals/index.js";
|
|
5
|
+
import type { SequenceInterval } from "../intervals/index.js";
|
|
6
6
|
import type { ISharedSegmentSequence } from "../sequence.js";
|
|
7
|
-
import { ISharedString } from "../sharedString.js";
|
|
7
|
+
import type { ISharedString } from "../sharedString.js";
|
|
8
8
|
import type { SequenceIntervalIndex } from "./intervalIndex.js";
|
|
9
9
|
/**
|
|
10
10
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/endpointIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"endpointIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/endpointIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC5D;;;OAGG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;IAE5D;;;OAGG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CACxD;AAED,qBAAa,aAAc,YAAW,cAAc;IAGvC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmD;gBAEtD,QAAQ,EAAE,sBAAsB,CAAC,GAAG,CAAC;IAM3D,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAQ3D,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAQvD,GAAG,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIrC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;CAG/C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,aAAa,GAAG,cAAc,CAE/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/endpointIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"endpointIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/endpointIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGnE,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAuB5E,MAAM,OAAO,aAAa;IAGzB,YAA6B,QAAqC;QAArC,aAAQ,GAAR,QAAQ,CAA6B;QACjE,IAAI,CAAC,eAAe,GAAG,IAAI,YAAY,CAAqC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACpF,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CACf,CAAC;IACH,CAAC;IAEM,gBAAgB,CAAC,GAAW;QAClC,MAAM,iBAAiB,GAAG,mCAAmC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvF,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,mCAAmC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvF,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,QAA0B;QACpC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAEM,MAAM,CAAC,QAA0B;QACvC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAA2B;IAC9D,OAAO,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport type { SequenceInterval } from \"../intervals/index.js\";\nimport { createTransientIntervalFromSequence } from \"../intervals/index.js\";\nimport type { ISharedSegmentSequence } from \"../sequence.js\";\nimport type { ISharedString } from \"../sharedString.js\";\n\nimport type { SequenceIntervalIndex } from \"./intervalIndex.js\";\n\n/**\n * @internal\n */\nexport interface IEndpointIndex extends SequenceIntervalIndex {\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): SequenceInterval | 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): SequenceInterval | undefined;\n}\n\nexport class EndpointIndex implements IEndpointIndex {\n\tprivate readonly endIntervalTree: RedBlackTree<SequenceInterval, SequenceInterval>;\n\n\tconstructor(private readonly sequence: ISharedSegmentSequence<any>) {\n\t\tthis.endIntervalTree = new RedBlackTree<SequenceInterval, SequenceInterval>((a, b) =>\n\t\t\ta.compareEnd(b),\n\t\t);\n\t}\n\n\tpublic previousInterval(pos: number): SequenceInterval | undefined {\n\t\tconst transientInterval = createTransientIntervalFromSequence(pos, pos, this.sequence);\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): SequenceInterval | undefined {\n\t\tconst transientInterval = createTransientIntervalFromSequence(pos, pos, this.sequence);\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: SequenceInterval): void {\n\t\tthis.endIntervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: SequenceInterval): void {\n\t\tthis.endIntervalTree.remove(interval);\n\t}\n}\n\n/**\n * Creates an endpoint index for the provided SharedString.\n *\n * @internal\n */\nexport function createEndpointIndex(sharedString: ISharedString): IEndpointIndex {\n\treturn new EndpointIndex(sharedString);\n}\n"]}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { SequenceIntervalIndex } from "./intervalIndex.js";
|
|
6
|
-
export { IIdIntervalIndex, createIdIntervalIndex } from "./idIntervalIndex.js";
|
|
7
|
-
export { IEndpointIndex, createEndpointIndex, EndpointIndex } from "./endpointIndex.js";
|
|
8
|
-
export { IEndpointInRangeIndex, createEndpointInRangeIndex, EndpointInRangeIndex, } from "./endpointInRangeIndex.js";
|
|
9
|
-
export { IStartpointInRangeIndex, createStartpointInRangeIndex, StartpointInRangeIndex, } from "./startpointInRangeIndex.js";
|
|
10
|
-
export { SequenceIntervalIndexes } from "./sequenceIntervalIndexes.js";
|
|
11
|
-
export { createOverlappingIntervalsIndex, OverlappingIntervalsIndex, ISequenceOverlappingIntervalsIndex, } from "./overlappingIntervalsIndex.js";
|
|
5
|
+
export type { SequenceIntervalIndex } from "./intervalIndex.js";
|
|
6
|
+
export { type IIdIntervalIndex, createIdIntervalIndex } from "./idIntervalIndex.js";
|
|
7
|
+
export { type IEndpointIndex, createEndpointIndex, EndpointIndex } from "./endpointIndex.js";
|
|
8
|
+
export { type IEndpointInRangeIndex, createEndpointInRangeIndex, EndpointInRangeIndex, } from "./endpointInRangeIndex.js";
|
|
9
|
+
export { type IStartpointInRangeIndex, createStartpointInRangeIndex, StartpointInRangeIndex, } from "./startpointInRangeIndex.js";
|
|
10
|
+
export type { SequenceIntervalIndexes } from "./sequenceIntervalIndexes.js";
|
|
11
|
+
export { createOverlappingIntervalsIndex, OverlappingIntervalsIndex, type ISequenceOverlappingIntervalsIndex, } from "./overlappingIntervalsIndex.js";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,KAAK,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,KAAK,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EACN,KAAK,qBAAqB,EAC1B,0BAA0B,EAC1B,oBAAoB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,sBAAsB,GACtB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EACN,+BAA+B,EAC/B,yBAAyB,EACzB,KAAK,kCAAkC,GACvC,MAAM,gCAAgC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intervalIndex/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intervalIndex/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAyB,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAuB,mBAAmB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAEN,0BAA0B,EAC1B,oBAAoB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,4BAA4B,EAC5B,sBAAsB,GACtB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACN,+BAA+B,EAC/B,yBAAyB,GAEzB,MAAM,gCAAgC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type { SequenceIntervalIndex } from \"./intervalIndex.js\";\nexport { type IIdIntervalIndex, createIdIntervalIndex } from \"./idIntervalIndex.js\";\nexport { type IEndpointIndex, createEndpointIndex, EndpointIndex } from \"./endpointIndex.js\";\nexport {\n\ttype IEndpointInRangeIndex,\n\tcreateEndpointInRangeIndex,\n\tEndpointInRangeIndex,\n} from \"./endpointInRangeIndex.js\";\nexport {\n\ttype IStartpointInRangeIndex,\n\tcreateStartpointInRangeIndex,\n\tStartpointInRangeIndex,\n} from \"./startpointInRangeIndex.js\";\nexport type { SequenceIntervalIndexes } from \"./sequenceIntervalIndexes.js\";\nexport {\n\tcreateOverlappingIntervalsIndex,\n\tOverlappingIntervalsIndex,\n\ttype ISequenceOverlappingIntervalsIndex,\n} from \"./overlappingIntervalsIndex.js\";\n"]}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { SequencePlace } from "@fluidframework/merge-tree/internal";
|
|
5
|
+
import type { SequencePlace } from "@fluidframework/merge-tree/internal";
|
|
6
6
|
import { IntervalTree } from "../intervalTree.js";
|
|
7
|
-
import { SequenceInterval, BaseSequenceInterval } from "../intervals/index.js";
|
|
7
|
+
import type { SequenceInterval, BaseSequenceInterval } from "../intervals/index.js";
|
|
8
8
|
import type { ISharedSegmentSequence } from "../sequence.js";
|
|
9
|
-
import { ISharedString } from "../sharedString.js";
|
|
9
|
+
import type { ISharedString } from "../sharedString.js";
|
|
10
10
|
import type { SequenceIntervalIndex } from "./intervalIndex.js";
|
|
11
11
|
/**
|
|
12
12
|
* @legacy @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlappingIntervalsIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/overlappingIntervalsIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"overlappingIntervalsIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/overlappingIntervalsIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAIzE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEpF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,kCAAmC,SAAQ,qBAAqB;IAChF;;;OAGG;IACH,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,GAAG,gBAAgB,EAAE,CAAC;IAEvF;;OAEG;IACH,sBAAsB,CACrB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,eAAe,EAAE,OAAO,EACxB,KAAK,CAAC,EAAE,aAAa,EACrB,GAAG,CAAC,EAAE,aAAa,GACjB,IAAI,CAAC;CACR;AAED,qBAAa,yBAA0B,YAAW,kCAAkC;IAGvE,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC,GAAG,CAAC;IAFpE,SAAS,CAAC,QAAQ,CAAC,YAAY,qCAA4C;gBAE5C,QAAQ,EAAE,sBAAsB,CAAC,GAAG,CAAC;IAE7D,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI;IAI5C,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,OAAO;IAIpD,sBAAsB,CAC5B,OAAO,EAAE,gBAAgB,EAAE,EAC3B,eAAe,EAAE,OAAO,EACxB,KAAK,CAAC,EAAE,aAAa,EACrB,GAAG,CAAC,EAAE,aAAa,GACjB,IAAI;IA2EA,wBAAwB,CAC9B,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,aAAa,GAChB,gBAAgB,EAAE;IAmBd,MAAM,CAAC,QAAQ,EAAE,oBAAoB;IAIrC,GAAG,CAAC,QAAQ,EAAE,oBAAoB;CAGzC;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC9C,YAAY,EAAE,aAAa,GACzB,kCAAkC,CAEpC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { endpointPosAndSide } from "@fluidframework/merge-tree/internal";
|
|
6
6
|
import { IntervalTree } from "../intervalTree.js";
|
|
7
|
-
import { createTransientIntervalFromSequence
|
|
7
|
+
import { createTransientIntervalFromSequence } from "../intervals/index.js";
|
|
8
8
|
export class OverlappingIntervalsIndex {
|
|
9
9
|
constructor(sequence) {
|
|
10
10
|
this.sequence = sequence;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlappingIntervalsIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/overlappingIntervalsInd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wBAAwB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,CAAC;IAEM,MAAM,CAAC,QAA8B;QAC3C,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,GAAG,CAAC,QAA8B;QACxC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAC9C,YAA2B;IAE3B,OAAO,IAAI,yBAAyB,CAAC,YAAY,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SequencePlace } from \"@fluidframework/merge-tree/internal\";\nimport { endpointPosAndSide } from \"@fluidframework/merge-tree/internal\";\n\nimport type { IntervalNode } from \"../intervalTree.js\";\nimport { IntervalTree } from \"../intervalTree.js\";\nimport type { SequenceInterval, BaseSequenceInterval } from \"../intervals/index.js\";\nimport { createTransientIntervalFromSequence } from \"../intervals/index.js\";\nimport type { ISharedSegmentSequence } from \"../sequence.js\";\nimport type { ISharedString } from \"../sharedString.js\";\n\nimport type { SequenceIntervalIndex } from \"./intervalIndex.js\";\n\n/**\n * @legacy @beta\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<BaseSequenceInterval>();\n\n\tconstructor(protected readonly sequence: ISharedSegmentSequence<any>) {}\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: BaseSequenceInterval = createTransientIntervalFromSequence(\n\t\t\t\tstart ?? \"start\",\n\t\t\t\tend ?? \"end\",\n\t\t\t\tthis.sequence,\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<BaseSequenceInterval>) => {\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<BaseSequenceInterval>) => {\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<BaseSequenceInterval>) => {\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 = createTransientIntervalFromSequence(start, end, this.sequence);\n\n\t\tconst overlappingIntervalNodes = this.intervalTree.match(transientInterval);\n\t\treturn overlappingIntervalNodes.map((node) => node.key);\n\t}\n\n\tpublic remove(interval: BaseSequenceInterval) {\n\t\tthis.intervalTree.removeExisting(interval);\n\t}\n\n\tpublic add(interval: BaseSequenceInterval) {\n\t\tthis.intervalTree.put(interval);\n\t}\n}\n\n/**\n * Creates an overlapping intervals index for the provided SharedString.\n *\n * @legacy @beta\n */\nexport function createOverlappingIntervalsIndex(\n\tsharedString: ISharedString,\n): ISequenceOverlappingIntervalsIndex {\n\treturn new OverlappingIntervalsIndex(sharedString);\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 { ISegment } from "@fluidframework/merge-tree/internal";
|
|
6
|
-
import { SequenceInterval } from "../intervals/index.js";
|
|
5
|
+
import type { ISegment } from "@fluidframework/merge-tree/internal";
|
|
6
|
+
import type { SequenceInterval } from "../intervals/index.js";
|
|
7
7
|
import type { ISequenceOverlappingIntervalsIndex } from "./overlappingIntervalsIndex.js";
|
|
8
8
|
/**
|
|
9
9
|
* This namespace contains specialiazations of indexes which support spatial queries
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequenceIntervalIndexes.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/sequenceIntervalIndexes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"sequenceIntervalIndexes.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/sequenceIntervalIndexes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AAEzF;;;;GAIG;AAEH,yBAAiB,uBAAuB,CAAC;IACxC;;;;;OAKG;IACH,UAAiB,WAAY,SAAQ,kCAAkC;QACtE;;;;WAIG;QACH,gCAAgC,CAC/B,WAAW,EAAE;YAAE,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAC;YAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;SAAE,EAC1E,SAAS,EAAE;YAAE,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAC;YAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;SAAE,GACtE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;KAC9B;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequenceIntervalIndexes.js","sourceRoot":"","sources":["../../src/intervalIndex/sequenceIntervalIndexes.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 { ISegment } from \"@fluidframework/merge-tree/internal\";\n\nimport { SequenceInterval } from \"../intervals/index.js\";\n\nimport type { ISequenceOverlappingIntervalsIndex } from \"./overlappingIntervalsIndex.js\";\n\n/**\n * This namespace contains specialiazations of indexes which support spatial queries\n * specifically for `SequenceInterval`s.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace SequenceIntervalIndexes {\n\t/**\n\t * Collection of intervals.\n\t *\n\t * Provides additional APIs to support efficiently querying a collection of intervals based on segments and offset.\n\t * @internal\n\t */\n\texport interface Overlapping extends ISequenceOverlappingIntervalsIndex {\n\t\t/**\n\t\t * Finds overlapping intervals within the specified range.\n\t\t *\n\t\t * @returns an array of all intervals that overlap with the specified SegOff range (includes both ends)\n\t\t */\n\t\tfindOverlappingIntervalsBySegoff(\n\t\t\tstartSegoff: { segment: ISegment | undefined; offset: number | undefined },\n\t\t\tendSegoff: { segment: ISegment | undefined; offset: number | undefined },\n\t\t): Iterable<SequenceInterval>;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sequenceIntervalIndexes.js","sourceRoot":"","sources":["../../src/intervalIndex/sequenceIntervalIndexes.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 type { ISegment } from \"@fluidframework/merge-tree/internal\";\n\nimport type { SequenceInterval } from \"../intervals/index.js\";\n\nimport type { ISequenceOverlappingIntervalsIndex } from \"./overlappingIntervalsIndex.js\";\n\n/**\n * This namespace contains specialiazations of indexes which support spatial queries\n * specifically for `SequenceInterval`s.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace SequenceIntervalIndexes {\n\t/**\n\t * Collection of intervals.\n\t *\n\t * Provides additional APIs to support efficiently querying a collection of intervals based on segments and offset.\n\t * @internal\n\t */\n\texport interface Overlapping extends ISequenceOverlappingIntervalsIndex {\n\t\t/**\n\t\t * Finds overlapping intervals within the specified range.\n\t\t *\n\t\t * @returns an array of all intervals that overlap with the specified SegOff range (includes both ends)\n\t\t */\n\t\tfindOverlappingIntervalsBySegoff(\n\t\t\tstartSegoff: { segment: ISegment | undefined; offset: number | undefined },\n\t\t\tendSegoff: { segment: ISegment | undefined; offset: number | undefined },\n\t\t): Iterable<SequenceInterval>;\n\t}\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { SequenceInterval } from "../intervals/index.js";
|
|
5
|
+
import type { SequenceInterval } from "../intervals/index.js";
|
|
6
6
|
import type { ISharedSegmentSequence } from "../sequence.js";
|
|
7
|
-
import { ISharedString } from "../sharedString.js";
|
|
7
|
+
import type { ISharedString } from "../sharedString.js";
|
|
8
8
|
import type { SequenceIntervalIndex } from "./intervalIndex.js";
|
|
9
9
|
/**
|
|
10
10
|
* Collection of intervals.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startpointInRangeIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/startpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"startpointInRangeIndex.d.ts","sourceRoot":"","sources":["../../src/intervalIndex/startpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhE;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACrE;;OAEG;IACH,kCAAkC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAC;CACnF;AAED,qBAAa,sBAAuB,YAAW,uBAAuB;IAGzD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAED,QAAQ,EAAE,sBAAsB,CAAC,GAAG,CAAC;IAyB3D,GAAG,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIrC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIxC,kCAAkC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE;CAyBzF;AACD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC3C,YAAY,EAAE,aAAa,GACzB,uBAAuB,CAEzB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { RedBlackTree } from "@fluidframework/merge-tree/internal";
|
|
6
6
|
import { createTransientIntervalFromSequence } from "../intervals/index.js";
|
|
7
|
-
import { compareOverrideables, forceCompare
|
|
7
|
+
import { compareOverrideables, forceCompare } from "./intervalIndexUtils.js";
|
|
8
8
|
export class StartpointInRangeIndex {
|
|
9
9
|
constructor(sequence) {
|
|
10
10
|
this.sequence = sequence;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startpointInRangeIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/startpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"startpointInRangeIndex.js","sourceRoot":"","sources":["../../src/intervalIndex/startpointInRangeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGnE,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAM5E,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAe7E,MAAM,OAAO,sBAAsB;IAGlC,YAA6B,QAAqC;QAArC,aAAQ,GAAR,QAAQ,CAA6B;QACjE,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CACnC,CAAC,CAAmB,EAAE,CAAmB,EAAE,EAAE;YAC5C,MAAM,mBAAmB,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC9C,IAAI,mBAAmB,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAO,mBAAmB,CAAC;YAC5B,CAAC;YAED,MAAM,uBAAuB,GAAG,oBAAoB,CACnD,CAAmC,EACnC,CAAmC,CACnC,CAAC;YACF,IAAI,uBAAuB,KAAK,CAAC,EAAE,CAAC;gBACnC,OAAO,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AI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;QAC1F,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AACD;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC3C,YAA2B;IAE3B,OAAO,IAAI,sBAAsB,CAAC,YAAY,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { PropertyAction } from \"@fluidframework/merge-tree/internal\";\nimport { RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport type { SequenceInterval } from \"../intervals/index.js\";\nimport { createTransientIntervalFromSequence } from \"../intervals/index.js\";\nimport type { ISharedSegmentSequence } from \"../sequence.js\";\nimport type { ISharedString } from \"../sharedString.js\";\n\nimport type { SequenceIntervalIndex } from \"./intervalIndex.js\";\nimport type { HasComparisonOverride } from \"./intervalIndexUtils.js\";\nimport { 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 extends SequenceIntervalIndex {\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): SequenceInterval[];\n}\n\nexport class StartpointInRangeIndex implements IStartpointInRangeIndex {\n\tprivate readonly intervalTree;\n\n\tconstructor(private readonly sequence: ISharedSegmentSequence<any>) {\n\t\tthis.intervalTree = new RedBlackTree<SequenceInterval, SequenceInterval>(\n\t\t\t(a: SequenceInterval, b: SequenceInterval) => {\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: SequenceInterval): void {\n\t\tthis.intervalTree.put(interval, interval);\n\t}\n\n\tpublic remove(interval: SequenceInterval): void {\n\t\tthis.intervalTree.remove(interval);\n\t}\n\n\tpublic findIntervalsWithStartpointInRange(start: number, end: number): SequenceInterval[] {\n\t\tif (start <= 0 || start > end || this.intervalTree.isEmpty()) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results: SequenceInterval[] = [];\n\t\tconst action: PropertyAction<SequenceInterval, SequenceInterval> = (node) => {\n\t\t\tresults.push(node.data);\n\t\t\treturn true;\n\t\t};\n\n\t\tconst transientStartInterval = createTransientIntervalFromSequence(\n\t\t\tstart,\n\t\t\tstart,\n\t\t\tthis.sequence,\n\t\t);\n\n\t\tconst transientEndInterval = createTransientIntervalFromSequence(end, end, this.sequence);\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 * Creates a startpoint-in-range index for the provided SharedString.\n *\n * @internal\n */\nexport function createStartpointInRangeIndex(\n\tsharedString: ISharedString,\n): IStartpointInRangeIndex {\n\treturn new StartpointInRangeIndex(sharedString);\n}\n"]}
|
package/lib/intervalTree.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IRBAugmentation, IRBMatcher, RBNode
|
|
6
|
-
import {
|
|
5
|
+
import type { IRBAugmentation, IRBMatcher, RBNode } from "@fluidframework/merge-tree/internal";
|
|
6
|
+
import { RedBlackTree } from "@fluidframework/merge-tree/internal";
|
|
7
|
+
import type { ISerializableInterval } from "./intervals/index.js";
|
|
7
8
|
export interface AugmentedIntervalNode {
|
|
8
9
|
minmax: ISerializableInterval;
|
|
9
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalTree.d.ts","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"intervalTree.d.ts","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,eAAe,EACf,UAAU,EACV,MAAM,EAEN,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,MAAM,WAAW,qBAAqB;IACrC,MAAM,EAAE,qBAAqB,CAAC;CAC9B;AAID,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,qBAAqB,IAAI,MAAM,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAE7F,qBAAa,YAAY,CAAC,CAAC,SAAS,qBAAqB,CACxD,YAAW,eAAe,CAAC,CAAC,EAAE,qBAAqB,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,qBAAqB,CAAC;IAEnF,SAAS,yCAAsE;IAE/E,MAAM,CAAC,CAAC,EAAE,CAAC;IAIX,cAAc,CAAC,CAAC,EAAE,CAAC;IAInB,GAAG,CAAC,CAAC,EAAE,CAAC;IAIR,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI;IAWtB,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO;IAU9B,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI;IAY9B,KAAK,CAAC,CAAC,EAAE,CAAC;IAIV,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC;IAInD,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC;IAIzD,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;CAanC"}
|
package/lib/intervalTree.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { RedBlackTree
|
|
5
|
+
import { RedBlackTree } from "@fluidframework/merge-tree/internal";
|
|
6
6
|
const intervalComparer = (a, b) => a.compare(b);
|
|
7
7
|
export class IntervalTree {
|
|
8
8
|
constructor() {
|
package/lib/intervalTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalTree.js","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"intervalTree.js","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAQnE,MAAM,gBAAgB,GAAG,CAAC,CAAwB,EAAE,CAAwB,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAI9F,MAAM,OAAO,YAAY;IAAzB;QAGQ,cAAS,GAAG,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AC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIRBAugmentation,\n\tIRBMatcher,\n\tRBNode,\n\tRBNodeActions,\n} from \"@fluidframework/merge-tree/internal\";\nimport { RedBlackTree } from \"@fluidframework/merge-tree/internal\";\n\nimport type { ISerializableInterval } from \"./intervals/index.js\";\n\nexport interface AugmentedIntervalNode {\n\tminmax: ISerializableInterval;\n}\n\nconst intervalComparer = (a: ISerializableInterval, b: ISerializableInterval) => a.compare(b);\n\nexport type IntervalNode<T extends ISerializableInterval> = RBNode<T, AugmentedIntervalNode>;\n\nexport class IntervalTree<T extends ISerializableInterval>\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"]}
|
package/lib/intervals/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { IInterval, ISerializedInterval, ISerializableInterval, IntervalOpType, IntervalType, IntervalDeltaOpType, IntervalStickiness, SerializedIntervalDelta, CompressedSerializedInterval, endReferenceSlidingPreference, startReferenceSlidingPreference, } from "./intervalUtils.js";
|
|
6
|
-
export { SequenceInterval, SequenceIntervalClass, BaseSequenceInterval, createSequenceInterval, createPositionReferenceFromSegoff, createTransientIntervalFromSequence, resolvePositionRef, getSerializedProperties, } from "./sequenceInterval.js";
|
|
5
|
+
export { type IInterval, type ISerializedInterval, type ISerializableInterval, IntervalOpType, IntervalType, IntervalDeltaOpType, IntervalStickiness, type SerializedIntervalDelta, type CompressedSerializedInterval, endReferenceSlidingPreference, startReferenceSlidingPreference, } from "./intervalUtils.js";
|
|
6
|
+
export { type SequenceInterval, SequenceIntervalClass, BaseSequenceInterval, createSequenceInterval, createPositionReferenceFromSegoff, createTransientIntervalFromSequence, resolvePositionRef, getSerializedProperties, } from "./sequenceInterval.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intervals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intervals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,6BAA6B,EAC7B,+BAA+B,GAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,iCAAiC,EACjC,mCAAmC,EACnC,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intervals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAGlB,6BAA6B,EAC7B,+BAA+B,GAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEN,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,iCAAiC,EACjC,mCAAmC,EACnC,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,uBAAuB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intervals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAGlB,6BAA6B,EAC7B,+BAA+B,GAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEN,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,iCAAiC,EACjC,mCAAmC,EACnC,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,uBAAuB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype IInterval,\n\ttype ISerializedInterval,\n\ttype ISerializableInterval,\n\tIntervalOpType,\n\tIntervalType,\n\tIntervalDeltaOpType,\n\tIntervalStickiness,\n\ttype SerializedIntervalDelta,\n\ttype CompressedSerializedInterval,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n} from \"./intervalUtils.js\";\nexport {\n\ttype SequenceInterval,\n\tSequenceIntervalClass,\n\tBaseSequenceInterval,\n\tcreateSequenceInterval,\n\tcreatePositionReferenceFromSegoff,\n\tcreateTransientIntervalFromSequence,\n\tresolvePositionRef,\n\tgetSerializedProperties,\n} from \"./sequenceInterval.js\";\n"]}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { PropertySet
|
|
5
|
+
import type { PropertySet } from "@fluidframework/merge-tree/internal";
|
|
6
|
+
import { SlidingPreference, Side } from "@fluidframework/merge-tree/internal";
|
|
6
7
|
/**
|
|
7
8
|
* Basic interval abstraction
|
|
8
9
|
* @legacy @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalUtils.d.ts","sourceRoot":"","sources":["../../src/intervals/intervalUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"intervalUtils.d.ts","sourceRoot":"","sources":["../../src/intervals/intervalUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE9E;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B;;;;OAIG;IACH,YAAY,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC;;;;OAIG;IACH,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAChC;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAC9B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;CAIjB,CAAC;AACX;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAElF;;GAEG;AACH,oBAAY,YAAY;IACvB,MAAM,IAAM;IAEZ;;;;;OAKG;IACH,aAAa,IAAM,CAAE,sEAAsE;IAE3F;;;OAGG;IACH,SAAS,IAAM;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;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