@fluidframework/sequence 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.2.0.0.245554
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/{.eslintrc.js → .eslintrc.cjs} +4 -1
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor.json +1 -1
- package/api-report/sequence.api.md +15 -27
- package/dist/{localValues.d.ts → IntervalCollectionValues.d.ts} +13 -12
- package/dist/IntervalCollectionValues.d.ts.map +1 -0
- package/dist/{localValues.js → IntervalCollectionValues.js} +4 -4
- package/dist/IntervalCollectionValues.js.map +1 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -42
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +28 -22
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +59 -110
- package/dist/intervalCollection.js.map +1 -1
- package/dist/{defaultMap.d.ts → intervalCollectionMap.d.ts} +18 -57
- package/dist/intervalCollectionMap.d.ts.map +1 -0
- package/dist/{defaultMap.js → intervalCollectionMap.js} +77 -129
- package/dist/intervalCollectionMap.js.map +1 -0
- package/{lib/defaultMapInterfaces.d.mts → dist/intervalCollectionMapInterfaces.d.ts} +16 -22
- package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -0
- package/dist/{defaultMapInterfaces.js → intervalCollectionMapInterfaces.js} +1 -1
- package/dist/intervalCollectionMapInterfaces.js.map +1 -0
- package/dist/intervalIndex/endpointInRangeIndex.d.ts +3 -3
- package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.js +8 -8
- package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/dist/intervalIndex/endpointIndex.d.ts +3 -3
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointIndex.js +4 -4
- package/dist/intervalIndex/endpointIndex.js.map +1 -1
- package/dist/intervalIndex/idIntervalIndex.d.ts +2 -2
- package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -1
- package/dist/intervalIndex/idIntervalIndex.js +2 -2
- package/dist/intervalIndex/idIntervalIndex.js.map +1 -1
- package/dist/intervalIndex/index.d.ts +8 -8
- package/dist/intervalIndex/index.d.ts.map +1 -1
- package/dist/intervalIndex/index.js +16 -16
- package/dist/intervalIndex/index.js.map +1 -1
- package/dist/intervalIndex/intervalIndex.d.ts +1 -1
- package/dist/intervalIndex/intervalIndex.d.ts.map +1 -1
- package/dist/intervalIndex/intervalIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +7 -10
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js +12 -13
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +2 -2
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +7 -7
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.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 +3 -3
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.js +8 -8
- package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/dist/intervalTree.d.ts +1 -1
- package/dist/intervalTree.d.ts.map +1 -1
- package/dist/intervalTree.js.map +1 -1
- package/dist/intervals/index.d.ts +3 -3
- package/dist/intervals/index.d.ts.map +1 -1
- package/dist/intervals/index.js +16 -16
- package/dist/intervals/index.js.map +1 -1
- package/dist/intervals/interval.d.ts +2 -2
- package/dist/intervals/interval.d.ts.map +1 -1
- package/dist/intervals/interval.js +2 -2
- package/dist/intervals/interval.js.map +1 -1
- package/dist/intervals/intervalUtils.d.ts +3 -3
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js +1 -1
- package/dist/intervals/intervalUtils.js.map +1 -1
- package/dist/intervals/sequenceInterval.d.ts +2 -2
- package/dist/intervals/sequenceInterval.d.ts.map +1 -1
- package/dist/intervals/sequenceInterval.js +22 -23
- package/dist/intervals/sequenceInterval.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/revertibles.d.ts +12 -12
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +26 -26
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence-alpha.d.ts +172 -13
- package/dist/sequence-beta.d.ts +2 -0
- package/dist/sequence-public.d.ts +2 -0
- package/dist/sequence-untrimmed.d.ts +73 -14
- package/dist/sequence.d.ts +48 -5
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +103 -29
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceFactory.d.ts +4 -1
- package/dist/sequenceFactory.d.ts.map +1 -1
- package/dist/sequenceFactory.js +8 -5
- package/dist/sequenceFactory.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts +2 -2
- package/dist/sharedIntervalCollection.d.ts.map +1 -1
- package/dist/sharedIntervalCollection.js +5 -5
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedSequence.d.ts +1 -1
- package/dist/sharedSequence.d.ts.map +1 -1
- package/dist/sharedSequence.js +2 -2
- package/dist/sharedSequence.js.map +1 -1
- package/dist/sharedString.d.ts +2 -2
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +6 -6
- package/dist/sharedString.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/{localValues.d.mts → IntervalCollectionValues.d.ts} +13 -12
- package/lib/IntervalCollectionValues.d.ts.map +1 -0
- package/lib/{localValues.mjs → IntervalCollectionValues.js} +2 -2
- package/lib/IntervalCollectionValues.js.map +1 -0
- package/lib/{index.d.mts → index.d.ts} +24 -12
- package/lib/index.d.ts.map +1 -0
- package/lib/{index.mjs → index.js} +11 -11
- package/lib/index.js.map +1 -0
- package/lib/{intervalCollection.d.mts → intervalCollection.d.ts} +29 -23
- package/lib/intervalCollection.d.ts.map +1 -0
- package/lib/{intervalCollection.mjs → intervalCollection.js} +23 -74
- package/lib/intervalCollection.js.map +1 -0
- package/lib/{defaultMap.d.mts → intervalCollectionMap.d.ts} +18 -57
- package/lib/intervalCollectionMap.d.ts.map +1 -0
- package/lib/{defaultMap.mjs → intervalCollectionMap.js} +75 -127
- package/lib/intervalCollectionMap.js.map +1 -0
- package/{dist/defaultMapInterfaces.d.ts → lib/intervalCollectionMapInterfaces.d.ts} +16 -22
- package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -0
- package/lib/{intervalIndex/sequenceIntervalIndexes.mjs → intervalCollectionMapInterfaces.js} +1 -1
- package/lib/intervalCollectionMapInterfaces.js.map +1 -0
- package/lib/intervalIndex/{endpointInRangeIndex.d.mts → endpointInRangeIndex.d.ts} +4 -4
- package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
- package/lib/intervalIndex/{endpointInRangeIndex.mjs → endpointInRangeIndex.js} +3 -3
- package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -0
- package/lib/intervalIndex/{endpointIndex.d.mts → endpointIndex.d.ts} +4 -4
- package/lib/intervalIndex/endpointIndex.d.ts.map +1 -0
- package/lib/intervalIndex/{endpointIndex.mjs → endpointIndex.js} +2 -2
- package/lib/intervalIndex/endpointIndex.js.map +1 -0
- package/lib/intervalIndex/{idIntervalIndex.d.mts → idIntervalIndex.d.ts} +3 -3
- package/lib/intervalIndex/idIntervalIndex.d.ts.map +1 -0
- package/lib/intervalIndex/{idIntervalIndex.mjs → idIntervalIndex.js} +2 -2
- package/lib/intervalIndex/idIntervalIndex.js.map +1 -0
- package/lib/intervalIndex/{index.d.mts → index.d.ts} +9 -9
- package/lib/intervalIndex/index.d.ts.map +1 -0
- package/lib/intervalIndex/{index.mjs → index.js} +7 -7
- package/lib/intervalIndex/index.js.map +1 -0
- package/lib/intervalIndex/{intervalIndex.d.mts → intervalIndex.d.ts} +2 -2
- package/lib/intervalIndex/intervalIndex.d.ts.map +1 -0
- package/lib/intervalIndex/{intervalIndex.mjs → intervalIndex.js} +1 -1
- package/lib/intervalIndex/intervalIndex.js.map +1 -0
- package/lib/intervalIndex/{intervalIndexUtils.d.mts → intervalIndexUtils.d.ts} +1 -1
- package/lib/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
- package/lib/intervalIndex/{intervalIndexUtils.mjs → intervalIndexUtils.js} +1 -1
- package/lib/intervalIndex/intervalIndexUtils.js.map +1 -0
- package/lib/intervalIndex/{overlappingIntervalsIndex.d.mts → overlappingIntervalsIndex.d.ts} +8 -11
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -0
- package/lib/intervalIndex/{overlappingIntervalsIndex.mjs → overlappingIntervalsIndex.js} +8 -9
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -0
- package/lib/intervalIndex/{overlappingSequenceIntervalsIndex.d.mts → overlappingSequenceIntervalsIndex.d.ts} +3 -3
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -0
- package/lib/intervalIndex/{overlappingSequenceIntervalsIndex.mjs → overlappingSequenceIntervalsIndex.js} +3 -3
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -0
- package/lib/intervalIndex/{sequenceIntervalIndexes.d.mts → sequenceIntervalIndexes.d.ts} +3 -3
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -0
- package/lib/{defaultMapInterfaces.mjs → intervalIndex/sequenceIntervalIndexes.js} +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -0
- package/lib/intervalIndex/{startpointInRangeIndex.d.mts → startpointInRangeIndex.d.ts} +4 -4
- package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
- package/lib/intervalIndex/{startpointInRangeIndex.mjs → startpointInRangeIndex.js} +3 -3
- package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -0
- package/lib/{intervalTree.d.mts → intervalTree.d.ts} +2 -2
- package/lib/intervalTree.d.ts.map +1 -0
- package/lib/{intervalTree.mjs → intervalTree.js} +1 -1
- package/lib/intervalTree.js.map +1 -0
- package/lib/intervals/{index.d.mts → index.d.ts} +4 -4
- package/lib/intervals/index.d.ts.map +1 -0
- package/lib/intervals/{index.mjs → index.js} +4 -4
- package/lib/intervals/index.js.map +1 -0
- package/lib/intervals/{interval.d.mts → interval.d.ts} +3 -3
- package/lib/intervals/{interval.d.mts.map → interval.d.ts.map} +1 -1
- package/lib/intervals/{interval.mjs → interval.js} +2 -2
- package/lib/intervals/interval.js.map +1 -0
- package/lib/intervals/{intervalUtils.d.mts → intervalUtils.d.ts} +4 -4
- package/lib/intervals/intervalUtils.d.ts.map +1 -0
- package/lib/intervals/{intervalUtils.mjs → intervalUtils.js} +3 -2
- package/lib/intervals/intervalUtils.js.map +1 -0
- package/lib/intervals/{sequenceInterval.d.mts → sequenceInterval.d.ts} +3 -3
- package/lib/intervals/sequenceInterval.d.ts.map +1 -0
- package/lib/intervals/{sequenceInterval.mjs → sequenceInterval.js} +5 -4
- package/lib/intervals/{sequenceInterval.mjs.map → sequenceInterval.js.map} +1 -1
- package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
- package/lib/packageVersion.js.map +1 -0
- package/lib/{revertibles.d.mts → revertibles.d.ts} +13 -13
- package/lib/revertibles.d.ts.map +1 -0
- package/lib/{revertibles.mjs → revertibles.js} +11 -10
- package/lib/revertibles.js.map +1 -0
- package/lib/{sequence-alpha.d.mts → sequence-alpha.d.ts} +185 -13
- package/lib/{sequence-beta.d.mts → sequence-beta.d.ts} +15 -0
- package/lib/{sequence-public.d.mts → sequence-public.d.ts} +15 -0
- package/lib/{sequence-untrimmed.d.mts → sequence-untrimmed.d.ts} +86 -14
- package/lib/{sequence.d.mts → sequence.d.ts} +49 -6
- package/lib/sequence.d.ts.map +1 -0
- package/lib/{sequence.mjs → sequence.js} +100 -29
- package/lib/sequence.js.map +1 -0
- package/lib/{sequenceDeltaEvent.d.mts → sequenceDeltaEvent.d.ts} +1 -1
- package/lib/sequenceDeltaEvent.d.ts.map +1 -0
- package/lib/{sequenceDeltaEvent.mjs → sequenceDeltaEvent.js} +1 -1
- package/lib/sequenceDeltaEvent.js.map +1 -0
- package/lib/{sequenceFactory.d.mts → sequenceFactory.d.ts} +5 -2
- package/lib/sequenceFactory.d.ts.map +1 -0
- package/lib/{sequenceFactory.mjs → sequenceFactory.js} +6 -3
- package/lib/sequenceFactory.js.map +1 -0
- package/lib/{sharedIntervalCollection.d.mts → sharedIntervalCollection.d.ts} +3 -3
- package/lib/sharedIntervalCollection.d.ts.map +1 -0
- package/lib/{sharedIntervalCollection.mjs → sharedIntervalCollection.js} +5 -5
- package/lib/sharedIntervalCollection.js.map +1 -0
- package/lib/{sharedSequence.d.mts → sharedSequence.d.ts} +2 -2
- package/lib/sharedSequence.d.ts.map +1 -0
- package/lib/{sharedSequence.mjs → sharedSequence.js} +2 -2
- package/lib/sharedSequence.js.map +1 -0
- package/lib/{sharedString.d.mts → sharedString.d.ts} +3 -3
- package/lib/sharedString.d.ts.map +1 -0
- package/lib/{sharedString.mjs → sharedString.js} +3 -3
- package/lib/sharedString.js.map +1 -0
- package/lib/test/collections.intervalTree.js +73 -0
- package/lib/test/collections.intervalTree.js.map +1 -0
- package/lib/test/createSnapshotFiles.js +15 -0
- package/lib/test/createSnapshotFiles.js.map +1 -0
- package/lib/test/dirname.cjs +16 -0
- package/lib/test/dirname.cjs.map +1 -0
- package/lib/test/endpointInRangeIndex.spec.js +182 -0
- package/lib/test/endpointInRangeIndex.spec.js.map +1 -0
- package/lib/test/fuzz/fuzzUtils.js +362 -0
- package/lib/test/fuzz/fuzzUtils.js.map +1 -0
- package/lib/test/fuzz/intervalCollection.fuzz.spec.js +87 -0
- package/lib/test/fuzz/intervalCollection.fuzz.spec.js.map +1 -0
- package/lib/test/fuzz/intervalRevertibles.fuzz.spec.js +128 -0
- package/lib/test/fuzz/intervalRevertibles.fuzz.spec.js.map +1 -0
- package/lib/test/fuzz/sharedString.fuzz.spec.js +91 -0
- package/lib/test/fuzz/sharedString.fuzz.spec.js.map +1 -0
- package/lib/test/generateSharedStrings.js +138 -0
- package/lib/test/generateSharedStrings.js.map +1 -0
- package/lib/test/intervalCollection.detached.spec.js +126 -0
- package/lib/test/intervalCollection.detached.spec.js.map +1 -0
- package/lib/test/intervalCollection.events.spec.js +491 -0
- package/lib/test/intervalCollection.events.spec.js.map +1 -0
- package/lib/test/intervalCollection.perf.spec.js +88 -0
- package/lib/test/intervalCollection.perf.spec.js.map +1 -0
- package/lib/test/intervalCollection.snapshot.spec.js +171 -0
- package/lib/test/intervalCollection.snapshot.spec.js.map +1 -0
- package/lib/test/intervalCollection.spec.js +1660 -0
- package/lib/test/intervalCollection.spec.js.map +1 -0
- package/lib/test/intervalIndexTestUtils.js +49 -0
- package/lib/test/intervalIndexTestUtils.js.map +1 -0
- package/lib/test/intervalRebasing.spec.js +589 -0
- package/lib/test/intervalRebasing.spec.js.map +1 -0
- package/lib/test/intervalStashedOps.spec.js +142 -0
- package/lib/test/intervalStashedOps.spec.js.map +1 -0
- package/lib/test/intervalTestUtils.js +81 -0
- package/lib/test/intervalTestUtils.js.map +1 -0
- package/lib/test/marshalling.spec.js +55 -0
- package/lib/test/marshalling.spec.js.map +1 -0
- package/lib/test/memory/sharedSequence.spec.js +82 -0
- package/lib/test/memory/sharedSequence.spec.js.map +1 -0
- package/lib/test/memory/sharedString.spec.js +134 -0
- package/lib/test/memory/sharedString.spec.js.map +1 -0
- package/lib/test/overlappingSequenceIntervalsIndex.spec.js +348 -0
- package/lib/test/overlappingSequenceIntervalsIndex.spec.js.map +1 -0
- package/lib/test/partialLoad.spec.js +211 -0
- package/lib/test/partialLoad.spec.js.map +1 -0
- package/lib/test/rebasing.spec.js +81 -0
- package/lib/test/rebasing.spec.js.map +1 -0
- package/lib/test/reentrancy.spec.js +174 -0
- package/lib/test/reentrancy.spec.js.map +1 -0
- package/lib/test/revertibles.spec.js +971 -0
- package/lib/test/revertibles.spec.js.map +1 -0
- package/lib/test/sequenceDeltaEvent.spec.js +2144 -0
- package/lib/test/sequenceDeltaEvent.spec.js.map +1 -0
- package/lib/test/sharedIntervalCollection.spec.js +159 -0
- package/lib/test/sharedIntervalCollection.spec.js.map +1 -0
- package/lib/test/sharedString.spec.js +532 -0
- package/lib/test/sharedString.spec.js.map +1 -0
- package/lib/test/snapshotEmptyProps.spec.js +45 -0
- package/lib/test/snapshotEmptyProps.spec.js.map +1 -0
- package/lib/test/snapshotVersion.spec.js +149 -0
- package/lib/test/snapshotVersion.spec.js.map +1 -0
- package/lib/test/startpointInRangeIndex.spec.js +182 -0
- package/lib/test/startpointInRangeIndex.spec.js.map +1 -0
- package/lib/test/subSequence.spec.js +92 -0
- package/lib/test/subSequence.spec.js.map +1 -0
- package/lib/test/types/validateSequencePrevious.generated.js +162 -0
- package/lib/test/types/validateSequencePrevious.generated.js.map +1 -0
- package/lib/test/v1IntervalCollectionHelpers.js +93 -0
- package/lib/test/v1IntervalCollectionHelpers.js.map +1 -0
- package/package.json +66 -60
- package/src/{localValues.ts → IntervalCollectionValues.ts} +23 -17
- package/src/index.ts +15 -11
- package/src/intervalCollection.ts +73 -106
- package/src/{defaultMap.ts → intervalCollectionMap.ts} +120 -211
- package/src/{defaultMapInterfaces.ts → intervalCollectionMapInterfaces.ts} +24 -23
- package/src/intervalIndex/endpointInRangeIndex.ts +4 -4
- package/src/intervalIndex/endpointIndex.ts +3 -3
- package/src/intervalIndex/idIntervalIndex.ts +3 -4
- package/src/intervalIndex/index.ts +8 -8
- package/src/intervalIndex/intervalIndex.ts +1 -1
- package/src/intervalIndex/overlappingIntervalsIndex.ts +10 -11
- package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +4 -4
- package/src/intervalIndex/sequenceIntervalIndexes.ts +2 -2
- package/src/intervalIndex/startpointInRangeIndex.ts +4 -4
- package/src/intervalTree.ts +1 -1
- package/src/intervals/index.ts +3 -3
- package/src/intervals/interval.ts +2 -4
- package/src/intervals/intervalUtils.ts +3 -3
- package/src/intervals/sequenceInterval.ts +3 -4
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +13 -13
- package/src/sequence.ts +128 -50
- package/src/sequenceFactory.ts +5 -2
- package/src/sharedIntervalCollection.ts +7 -11
- package/src/sharedSequence.ts +1 -1
- package/src/sharedString.ts +2 -2
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/dist/defaultMap.d.ts.map +0 -1
- package/dist/defaultMap.js.map +0 -1
- package/dist/defaultMapInterfaces.d.ts.map +0 -1
- package/dist/defaultMapInterfaces.js.map +0 -1
- package/dist/localValues.d.ts.map +0 -1
- package/dist/localValues.js.map +0 -1
- package/lib/defaultMap.d.mts.map +0 -1
- package/lib/defaultMap.mjs.map +0 -1
- package/lib/defaultMapInterfaces.d.mts.map +0 -1
- package/lib/defaultMapInterfaces.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs.map +0 -1
- package/lib/intervalCollection.d.mts.map +0 -1
- package/lib/intervalCollection.mjs.map +0 -1
- package/lib/intervalIndex/endpointInRangeIndex.d.mts.map +0 -1
- package/lib/intervalIndex/endpointInRangeIndex.mjs.map +0 -1
- package/lib/intervalIndex/endpointIndex.d.mts.map +0 -1
- package/lib/intervalIndex/endpointIndex.mjs.map +0 -1
- package/lib/intervalIndex/idIntervalIndex.d.mts.map +0 -1
- package/lib/intervalIndex/idIntervalIndex.mjs.map +0 -1
- package/lib/intervalIndex/index.d.mts.map +0 -1
- package/lib/intervalIndex/index.mjs.map +0 -1
- package/lib/intervalIndex/intervalIndex.d.mts.map +0 -1
- package/lib/intervalIndex/intervalIndex.mjs.map +0 -1
- package/lib/intervalIndex/intervalIndexUtils.d.mts.map +0 -1
- package/lib/intervalIndex/intervalIndexUtils.mjs.map +0 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.mts.map +0 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.mjs.map +0 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts.map +0 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs.map +0 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.mts.map +0 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.mjs.map +0 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.mts.map +0 -1
- package/lib/intervalIndex/startpointInRangeIndex.mjs.map +0 -1
- package/lib/intervalTree.d.mts.map +0 -1
- package/lib/intervalTree.mjs.map +0 -1
- package/lib/intervals/index.d.mts.map +0 -1
- package/lib/intervals/index.mjs.map +0 -1
- package/lib/intervals/interval.mjs.map +0 -1
- package/lib/intervals/intervalUtils.d.mts.map +0 -1
- package/lib/intervals/intervalUtils.mjs.map +0 -1
- package/lib/intervals/sequenceInterval.d.mts.map +0 -1
- package/lib/localValues.d.mts.map +0 -1
- package/lib/localValues.mjs.map +0 -1
- package/lib/packageVersion.d.mts.map +0 -1
- package/lib/packageVersion.mjs.map +0 -1
- package/lib/revertibles.d.mts.map +0 -1
- package/lib/revertibles.mjs.map +0 -1
- package/lib/sequence.d.mts.map +0 -1
- package/lib/sequence.mjs.map +0 -1
- package/lib/sequenceDeltaEvent.d.mts.map +0 -1
- package/lib/sequenceDeltaEvent.mjs.map +0 -1
- package/lib/sequenceFactory.d.mts.map +0 -1
- package/lib/sequenceFactory.mjs.map +0 -1
- package/lib/sharedIntervalCollection.d.mts.map +0 -1
- package/lib/sharedIntervalCollection.mjs.map +0 -1
- package/lib/sharedSequence.d.mts.map +0 -1
- package/lib/sharedSequence.mjs.map +0 -1
- package/lib/sharedString.d.mts.map +0 -1
- package/lib/sharedString.mjs.map +0 -1
|
@@ -5,66 +5,41 @@
|
|
|
5
5
|
|
|
6
6
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
8
|
-
import {
|
|
9
|
-
IFluidSerializer,
|
|
10
|
-
makeHandlesSerializable,
|
|
11
|
-
parseHandles,
|
|
12
|
-
ValueType,
|
|
13
|
-
} from "@fluidframework/shared-object-base";
|
|
8
|
+
import { IFluidSerializer, ValueType } from "@fluidframework/shared-object-base";
|
|
14
9
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
15
10
|
import { assert } from "@fluidframework/core-utils";
|
|
16
|
-
import { makeSerializable,
|
|
11
|
+
import { makeSerializable, IntervalCollectionTypeLocalValue } from "./IntervalCollectionValues.js";
|
|
17
12
|
import {
|
|
18
|
-
|
|
19
|
-
ISerializedValue,
|
|
13
|
+
ISerializableIntervalCollection,
|
|
20
14
|
IValueChanged,
|
|
21
15
|
// eslint-disable-next-line import/no-deprecated
|
|
22
16
|
IValueOpEmitter,
|
|
23
|
-
|
|
17
|
+
IIntervalCollectionType,
|
|
24
18
|
ISharedDefaultMapEvents,
|
|
25
19
|
IMapMessageLocalMetadata,
|
|
26
20
|
SequenceOptions,
|
|
27
|
-
|
|
28
|
-
} from "./
|
|
29
|
-
import {
|
|
21
|
+
IIntervalCollectionTypeOperationValue,
|
|
22
|
+
} from "./intervalCollectionMapInterfaces.js";
|
|
23
|
+
import {
|
|
24
|
+
SerializedIntervalDelta,
|
|
25
|
+
IntervalDeltaOpType,
|
|
26
|
+
type ISerializableInterval,
|
|
27
|
+
} from "./intervals/index.js";
|
|
28
|
+
import {
|
|
29
|
+
toSequencePlace,
|
|
30
|
+
toOptionalSequencePlace,
|
|
31
|
+
reservedIntervalIdKey,
|
|
32
|
+
type IntervalCollection,
|
|
33
|
+
} from "./intervalCollection.js";
|
|
30
34
|
|
|
31
35
|
function isMapOperation(op: unknown): op is IMapOperation {
|
|
32
36
|
return typeof op === "object" && op !== null && "type" in op && op.type === "act";
|
|
33
37
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Defines the means to process and submit a given op on a map.
|
|
36
|
-
*/
|
|
37
|
-
interface IMapMessageHandler {
|
|
38
|
-
/**
|
|
39
|
-
* Apply the given operation.
|
|
40
|
-
* @param op - The map operation to apply
|
|
41
|
-
* @param local - Whether the message originated from the local client
|
|
42
|
-
* @param message - The full message. Not provided for stashed ops.
|
|
43
|
-
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
44
|
-
* For messages from a remote client, this will be undefined.
|
|
45
|
-
*/
|
|
46
|
-
process(
|
|
47
|
-
op: IMapOperation,
|
|
48
|
-
local: boolean,
|
|
49
|
-
message: ISequencedDocumentMessage | undefined,
|
|
50
|
-
localOpMetadata: IMapMessageLocalMetadata,
|
|
51
|
-
): void;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Communicate the operation to remote clients.
|
|
55
|
-
* @param op - The map operation to submit
|
|
56
|
-
*/
|
|
57
|
-
submit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;
|
|
58
|
-
|
|
59
|
-
resubmit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;
|
|
60
|
-
|
|
61
|
-
getStashedOpLocalMetadata(op: IMapOperation): IMapMessageLocalMetadata;
|
|
62
|
-
}
|
|
63
38
|
|
|
64
39
|
/**
|
|
65
|
-
*
|
|
40
|
+
* Description of a map delta operation
|
|
66
41
|
*/
|
|
67
|
-
export interface
|
|
42
|
+
export interface IMapOperation {
|
|
68
43
|
/**
|
|
69
44
|
* String identifier of the operation type.
|
|
70
45
|
*/
|
|
@@ -77,26 +52,15 @@ export interface IMapValueTypeOperation {
|
|
|
77
52
|
|
|
78
53
|
/**
|
|
79
54
|
* Value of the operation, specific to the value type.
|
|
80
|
-
* @alpha
|
|
81
55
|
*/
|
|
82
|
-
value:
|
|
56
|
+
value: IIntervalCollectionTypeOperationValue;
|
|
83
57
|
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Description of a map delta operation
|
|
87
|
-
*/
|
|
88
|
-
export type IMapOperation = IMapValueTypeOperation;
|
|
89
|
-
|
|
90
58
|
/**
|
|
91
59
|
* Defines the in-memory object structure to be used for the conversion to/from serialized.
|
|
92
60
|
* Directly used in JSON.stringify, direct result from JSON.parse
|
|
93
61
|
*/
|
|
94
62
|
export interface IMapDataObjectSerializable {
|
|
95
|
-
[key: string]:
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface IMapDataObjectSerialized {
|
|
99
|
-
[key: string]: ISerializedValue;
|
|
63
|
+
[key: string]: ISerializableIntervalCollection;
|
|
100
64
|
}
|
|
101
65
|
|
|
102
66
|
/**
|
|
@@ -106,7 +70,7 @@ export interface IMapDataObjectSerialized {
|
|
|
106
70
|
* Creation of values is implicit on access (either via `get` or a remote op application referring to
|
|
107
71
|
* a collection that wasn't previously known)
|
|
108
72
|
*/
|
|
109
|
-
export class
|
|
73
|
+
export class IntervalCollectionMap<T extends ISerializableInterval> {
|
|
110
74
|
/**
|
|
111
75
|
* The number of key/value pairs stored in the map.
|
|
112
76
|
*/
|
|
@@ -117,12 +81,42 @@ export class DefaultMap<T> {
|
|
|
117
81
|
/**
|
|
118
82
|
* Mapping of op types to message handlers.
|
|
119
83
|
*/
|
|
120
|
-
private readonly
|
|
84
|
+
private readonly messageHandler = {
|
|
85
|
+
process: (
|
|
86
|
+
op: IMapOperation,
|
|
87
|
+
local: boolean,
|
|
88
|
+
message: ISequencedDocumentMessage,
|
|
89
|
+
localOpMetadata: IMapMessageLocalMetadata,
|
|
90
|
+
) => {
|
|
91
|
+
const localValue = this.data.get(op.key) ?? this.createCore(op.key, local);
|
|
92
|
+
const handler = localValue.getOpHandler(op.value.opName);
|
|
93
|
+
const previousValue = localValue.value;
|
|
94
|
+
const translatedValue = op.value.value as any;
|
|
95
|
+
handler.process(previousValue, translatedValue, local, message, localOpMetadata);
|
|
96
|
+
const event: IValueChanged = { key: op.key, previousValue };
|
|
97
|
+
this.eventEmitter.emit("valueChanged", event, local, message, this.eventEmitter);
|
|
98
|
+
},
|
|
99
|
+
submit: (op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata) => {
|
|
100
|
+
this.submitMessage(op, localOpMetadata);
|
|
101
|
+
},
|
|
102
|
+
resubmit: (op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata) => {
|
|
103
|
+
const localValue = this.data.get(op.key);
|
|
104
|
+
|
|
105
|
+
assert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
|
|
106
|
+
|
|
107
|
+
const handler = localValue.getOpHandler(op.value.opName);
|
|
108
|
+
const rebased = handler.rebase(localValue.value, op.value, localOpMetadata);
|
|
109
|
+
if (rebased !== undefined) {
|
|
110
|
+
const { rebasedOp, rebasedLocalOpMetadata } = rebased;
|
|
111
|
+
this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
};
|
|
121
115
|
|
|
122
116
|
/**
|
|
123
117
|
* The in-memory data the map is storing.
|
|
124
118
|
*/
|
|
125
|
-
private readonly data = new Map<string,
|
|
119
|
+
private readonly data = new Map<string, IntervalCollectionTypeLocalValue<T>>();
|
|
126
120
|
|
|
127
121
|
/**
|
|
128
122
|
* Create a new default map.
|
|
@@ -136,15 +130,13 @@ export class DefaultMap<T> {
|
|
|
136
130
|
private readonly serializer: IFluidSerializer,
|
|
137
131
|
private readonly handle: IFluidHandle,
|
|
138
132
|
private readonly submitMessage: (
|
|
139
|
-
op:
|
|
133
|
+
op: IMapOperation,
|
|
140
134
|
localOpMetadata: IMapMessageLocalMetadata,
|
|
141
135
|
) => void,
|
|
142
|
-
private readonly type:
|
|
136
|
+
private readonly type: IIntervalCollectionType<T>,
|
|
143
137
|
private readonly options?: Partial<SequenceOptions>,
|
|
144
138
|
public readonly eventEmitter = new TypedEventEmitter<ISharedDefaultMapEvents>(),
|
|
145
|
-
) {
|
|
146
|
-
this.messageHandlers = this.getMessageHandlers();
|
|
147
|
-
}
|
|
139
|
+
) {}
|
|
148
140
|
|
|
149
141
|
/**
|
|
150
142
|
* Get an iterator over the keys in this map.
|
|
@@ -154,26 +146,6 @@ export class DefaultMap<T> {
|
|
|
154
146
|
return this.data.keys();
|
|
155
147
|
}
|
|
156
148
|
|
|
157
|
-
/**
|
|
158
|
-
* Get an iterator over the entries in this map.
|
|
159
|
-
* @returns The iterator
|
|
160
|
-
*/
|
|
161
|
-
public entries(): IterableIterator<[string, any]> {
|
|
162
|
-
const localEntriesIterator = this.data.entries();
|
|
163
|
-
const iterator = {
|
|
164
|
-
next(): IteratorResult<[string, any]> {
|
|
165
|
-
const nextVal = localEntriesIterator.next();
|
|
166
|
-
return nextVal.done
|
|
167
|
-
? { value: undefined, done: true }
|
|
168
|
-
: { value: [nextVal.value[0], nextVal.value[1].value], done: false }; // Unpack the stored value
|
|
169
|
-
},
|
|
170
|
-
[Symbol.iterator]() {
|
|
171
|
-
return this;
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
return iterator;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
149
|
/**
|
|
178
150
|
* Get an iterator over the values in this map.
|
|
179
151
|
* @returns The iterator
|
|
@@ -193,56 +165,15 @@ export class DefaultMap<T> {
|
|
|
193
165
|
};
|
|
194
166
|
return iterator;
|
|
195
167
|
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Get an iterator over the entries in this map.
|
|
199
|
-
* @returns The iterator
|
|
200
|
-
*/
|
|
201
|
-
public [Symbol.iterator](): IterableIterator<[string, any]> {
|
|
202
|
-
return this.entries();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Executes the given callback on each entry in the map.
|
|
207
|
-
* @param callbackFn - Callback function
|
|
208
|
-
*/
|
|
209
|
-
public forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {
|
|
210
|
-
this.data.forEach((localValue, key, m) => {
|
|
211
|
-
callbackFn(localValue.value, key, m);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
168
|
/**
|
|
216
169
|
* {@inheritDoc ISharedMap.get}
|
|
217
170
|
*/
|
|
218
|
-
public get(key: string): T {
|
|
171
|
+
public get(key: string): IntervalCollection<T> {
|
|
219
172
|
const localValue = this.data.get(key) ?? this.createCore(key, true);
|
|
220
173
|
|
|
221
174
|
return localValue.value;
|
|
222
175
|
}
|
|
223
176
|
|
|
224
|
-
/**
|
|
225
|
-
* Check if a key exists in the map.
|
|
226
|
-
* @param key - The key to check
|
|
227
|
-
* @returns True if the key exists, false otherwise
|
|
228
|
-
*/
|
|
229
|
-
public has(key: string): boolean {
|
|
230
|
-
return this.data.has(key);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Serializes the data stored in the shared map to a JSON string
|
|
235
|
-
* @param serializer - The serializer to use to serialize handles in its values.
|
|
236
|
-
* @returns A JSON string containing serialized map data
|
|
237
|
-
*/
|
|
238
|
-
public getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {
|
|
239
|
-
const serializableMapData: IMapDataObjectSerialized = {};
|
|
240
|
-
this.data.forEach((localValue, key) => {
|
|
241
|
-
serializableMapData[key] = localValue.makeSerialized(serializer, this.handle);
|
|
242
|
-
});
|
|
243
|
-
return serializableMapData;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
177
|
public getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {
|
|
247
178
|
const serializableMapData: IMapDataObjectSerializable = {};
|
|
248
179
|
this.data.forEach((localValue, key) => {
|
|
@@ -257,10 +188,13 @@ export class DefaultMap<T> {
|
|
|
257
188
|
|
|
258
189
|
/**
|
|
259
190
|
* Populate the kernel with the given map data.
|
|
260
|
-
*
|
|
191
|
+
*
|
|
192
|
+
* @param serialized - A JSON string containing serialized map data
|
|
261
193
|
*/
|
|
262
|
-
public
|
|
263
|
-
|
|
194
|
+
public populate(serialized: string): void {
|
|
195
|
+
const parsed = this.serializer.parse(serialized) as IMapDataObjectSerializable;
|
|
196
|
+
|
|
197
|
+
for (const [key, serializable] of Object.entries(parsed)) {
|
|
264
198
|
// Back-compat: legacy documents may have handles to an intervalCollection map kernel.
|
|
265
199
|
// These collections should be empty, and ValueTypes are no longer supported.
|
|
266
200
|
if (
|
|
@@ -285,10 +219,6 @@ export class DefaultMap<T> {
|
|
|
285
219
|
}
|
|
286
220
|
}
|
|
287
221
|
|
|
288
|
-
public populate(json: string): void {
|
|
289
|
-
this.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
222
|
/**
|
|
293
223
|
* Submit the given op if a handler is registered.
|
|
294
224
|
* @param op - The operation to attempt to submit
|
|
@@ -297,25 +227,50 @@ export class DefaultMap<T> {
|
|
|
297
227
|
* also sent if we are asked to resubmit the message.
|
|
298
228
|
* @returns True if the operation was submitted, false otherwise.
|
|
299
229
|
*/
|
|
300
|
-
public tryResubmitMessage(
|
|
301
|
-
op
|
|
302
|
-
|
|
303
|
-
): boolean {
|
|
304
|
-
const type: string = op.type;
|
|
305
|
-
const handler = this.messageHandlers.get(type);
|
|
306
|
-
if (handler !== undefined) {
|
|
307
|
-
handler.resubmit(op, localOpMetadata);
|
|
230
|
+
public tryResubmitMessage(op: unknown, localOpMetadata: IMapMessageLocalMetadata): boolean {
|
|
231
|
+
if (isMapOperation(op)) {
|
|
232
|
+
this.messageHandler.resubmit(op, localOpMetadata);
|
|
308
233
|
return true;
|
|
309
234
|
}
|
|
310
235
|
return false;
|
|
311
236
|
}
|
|
312
237
|
|
|
313
|
-
public
|
|
314
|
-
if (isMapOperation(op)
|
|
315
|
-
|
|
316
|
-
|
|
238
|
+
public tryApplyStashedOp(op: unknown): boolean {
|
|
239
|
+
if (isMapOperation(op)) {
|
|
240
|
+
const { value, key } = op;
|
|
241
|
+
const map = this.get(key);
|
|
242
|
+
|
|
243
|
+
switch (value.opName) {
|
|
244
|
+
case "add": {
|
|
245
|
+
map.add({
|
|
246
|
+
// Todo: we should improve typing so we know add ops always have start and end
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
248
|
+
start: toSequencePlace(value.value.start!, value.value.startSide),
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
250
|
+
end: toSequencePlace(value.value.end!, value.value.endSide),
|
|
251
|
+
props: value.value.properties,
|
|
252
|
+
});
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
case "change": {
|
|
256
|
+
const { [reservedIntervalIdKey]: id, ...props } = value.value.properties ?? {};
|
|
257
|
+
map.change(id, {
|
|
258
|
+
start: toOptionalSequencePlace(value.value.start, value.value.startSide),
|
|
259
|
+
end: toOptionalSequencePlace(value.value.end, value.value.endSide),
|
|
260
|
+
props,
|
|
261
|
+
});
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
case "delete": {
|
|
265
|
+
const { [reservedIntervalIdKey]: id } = value.value.properties ?? {};
|
|
266
|
+
map.removeIntervalById(id);
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
default:
|
|
270
|
+
throw new Error("unknown ops should not be stashed");
|
|
271
|
+
}
|
|
317
272
|
}
|
|
318
|
-
return
|
|
273
|
+
return false;
|
|
319
274
|
}
|
|
320
275
|
|
|
321
276
|
/**
|
|
@@ -327,14 +282,18 @@ export class DefaultMap<T> {
|
|
|
327
282
|
* @returns True if the operation was processed, false otherwise.
|
|
328
283
|
*/
|
|
329
284
|
public tryProcessMessage(
|
|
330
|
-
op:
|
|
285
|
+
op: unknown,
|
|
331
286
|
local: boolean,
|
|
332
|
-
message: ISequencedDocumentMessage
|
|
287
|
+
message: ISequencedDocumentMessage,
|
|
333
288
|
localOpMetadata: unknown,
|
|
334
289
|
): boolean {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
290
|
+
if (isMapOperation(op)) {
|
|
291
|
+
this.messageHandler.process(
|
|
292
|
+
op,
|
|
293
|
+
local,
|
|
294
|
+
message,
|
|
295
|
+
localOpMetadata as IMapMessageLocalMetadata,
|
|
296
|
+
);
|
|
338
297
|
return true;
|
|
339
298
|
}
|
|
340
299
|
return false;
|
|
@@ -346,8 +305,8 @@ export class DefaultMap<T> {
|
|
|
346
305
|
* @param key - The key being initialized
|
|
347
306
|
* @param local - Whether the message originated from the local client
|
|
348
307
|
*/
|
|
349
|
-
private createCore(key: string, local: boolean):
|
|
350
|
-
const localValue = new
|
|
308
|
+
private createCore(key: string, local: boolean): IntervalCollectionTypeLocalValue<T> {
|
|
309
|
+
const localValue = new IntervalCollectionTypeLocalValue(
|
|
351
310
|
this.type.factory.load(this.makeMapValueOpEmitter(key), undefined, this.options),
|
|
352
311
|
this.type,
|
|
353
312
|
);
|
|
@@ -368,74 +327,26 @@ export class DefaultMap<T> {
|
|
|
368
327
|
* @param serializable - The remote information that we can convert into a real object
|
|
369
328
|
* @returns The local value that was produced
|
|
370
329
|
*/
|
|
371
|
-
private makeLocal(
|
|
330
|
+
private makeLocal(
|
|
331
|
+
key: string,
|
|
332
|
+
serializable: ISerializableIntervalCollection,
|
|
333
|
+
): IntervalCollectionTypeLocalValue<T> {
|
|
372
334
|
assert(
|
|
373
335
|
serializable.type !== ValueType[ValueType.Plain] &&
|
|
374
336
|
serializable.type !== ValueType[ValueType.Shared],
|
|
375
337
|
0x2e1 /* "Support for plain value types removed." */,
|
|
376
338
|
);
|
|
377
339
|
|
|
378
|
-
serializable.value = parseHandles(serializable.value, this.serializer);
|
|
379
340
|
const localValue = this.type.factory.load(
|
|
380
341
|
this.makeMapValueOpEmitter(key),
|
|
381
342
|
serializable.value,
|
|
382
343
|
this.options,
|
|
383
344
|
);
|
|
384
|
-
return new
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Get the message handlers for the map.
|
|
389
|
-
* @returns A map of string op names to IMapMessageHandlers for those ops
|
|
390
|
-
*/
|
|
391
|
-
private getMessageHandlers() {
|
|
392
|
-
const messageHandlers = new Map<string, IMapMessageHandler>();
|
|
393
|
-
// Ops with type "act" describe actions taken by custom value type handlers of whatever item is
|
|
394
|
-
// being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has
|
|
395
|
-
// stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone
|
|
396
|
-
// watching for manipulations of that item.
|
|
397
|
-
messageHandlers.set("act", {
|
|
398
|
-
process: (op: IMapValueTypeOperation, local, message, localOpMetadata) => {
|
|
399
|
-
const localValue = this.data.get(op.key) ?? this.createCore(op.key, local);
|
|
400
|
-
const handler = localValue.getOpHandler(op.value.opName);
|
|
401
|
-
const previousValue = localValue.value;
|
|
402
|
-
const translatedValue = parseHandles(op.value.value, this.serializer);
|
|
403
|
-
handler.process(previousValue, translatedValue, local, message, localOpMetadata);
|
|
404
|
-
const event: IValueChanged = { key: op.key, previousValue };
|
|
405
|
-
this.eventEmitter.emit("valueChanged", event, local, message, this.eventEmitter);
|
|
406
|
-
},
|
|
407
|
-
submit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {
|
|
408
|
-
this.submitMessage(op, localOpMetadata);
|
|
409
|
-
},
|
|
410
|
-
resubmit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {
|
|
411
|
-
const localValue = this.data.get(op.key);
|
|
412
|
-
|
|
413
|
-
assert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
|
|
414
|
-
|
|
415
|
-
const handler = localValue.getOpHandler(op.value.opName);
|
|
416
|
-
const rebased = handler.rebase(localValue.value, op.value, localOpMetadata);
|
|
417
|
-
if (rebased !== undefined) {
|
|
418
|
-
const { rebasedOp, rebasedLocalOpMetadata } = rebased;
|
|
419
|
-
this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
|
|
420
|
-
}
|
|
421
|
-
},
|
|
422
|
-
getStashedOpLocalMetadata: (op: IMapValueTypeOperation): IMapMessageLocalMetadata => {
|
|
423
|
-
const localValue = this.data.get(op.key) ?? this.createCore(op.key, true);
|
|
424
|
-
assert(
|
|
425
|
-
localValue !== undefined,
|
|
426
|
-
0x879 /* Local value expected on applying stashed op */,
|
|
427
|
-
);
|
|
428
|
-
const handler = localValue.getOpHandler(op.value.opName);
|
|
429
|
-
return handler.applyStashedOp(localValue.value, op.value);
|
|
430
|
-
},
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
return messageHandlers;
|
|
345
|
+
return new IntervalCollectionTypeLocalValue(localValue, this.type);
|
|
434
346
|
}
|
|
435
347
|
|
|
436
348
|
/**
|
|
437
349
|
* Create an emitter for a value type to emit ops from the given key.
|
|
438
|
-
* @alpha
|
|
439
350
|
* @param key - The key of the map that the value type will be stored on
|
|
440
351
|
* @returns A value op emitter for the given key
|
|
441
352
|
*/
|
|
@@ -448,14 +359,12 @@ export class DefaultMap<T> {
|
|
|
448
359
|
params: SerializedIntervalDelta,
|
|
449
360
|
localOpMetadata: IMapMessageLocalMetadata,
|
|
450
361
|
): void => {
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
const op: IMapValueTypeOperation = {
|
|
362
|
+
const op: IMapOperation = {
|
|
454
363
|
key,
|
|
455
364
|
type: "act",
|
|
456
365
|
value: {
|
|
457
366
|
opName,
|
|
458
|
-
value:
|
|
367
|
+
value: params,
|
|
459
368
|
},
|
|
460
369
|
};
|
|
461
370
|
|
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
IntervalOpType,
|
|
12
12
|
SerializedIntervalDelta,
|
|
13
13
|
IntervalDeltaOpType,
|
|
14
|
-
|
|
14
|
+
type ISerializableInterval,
|
|
15
|
+
} from "./intervals/index.js";
|
|
16
|
+
import type { IntervalCollection } from "./intervalCollection.js";
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Type of "valueChanged" event parameter.
|
|
@@ -92,32 +94,34 @@ export interface SequenceOptions {
|
|
|
92
94
|
* A value factory is used to serialize/deserialize value types to a map
|
|
93
95
|
* @alpha
|
|
94
96
|
*/
|
|
95
|
-
export interface
|
|
97
|
+
export interface IIntervalCollectionFactory<T extends ISerializableInterval> {
|
|
96
98
|
/**
|
|
97
99
|
* Create a new value type. Used both in creation of new value types, as well as in loading existing ones
|
|
98
100
|
* from remote.
|
|
99
101
|
* @param emitter - Emitter object that the created value type will use to emit operations
|
|
100
102
|
* @param raw - Initialization parameters as defined by the value type
|
|
101
103
|
* @returns The new value type
|
|
102
|
-
* @alpha
|
|
103
104
|
*/
|
|
104
|
-
load(
|
|
105
|
+
load(
|
|
106
|
+
emitter: IValueOpEmitter,
|
|
107
|
+
raw: any,
|
|
108
|
+
options?: Partial<SequenceOptions>,
|
|
109
|
+
): IntervalCollection<T>;
|
|
105
110
|
|
|
106
111
|
/**
|
|
107
112
|
* Given a value type, provides a JSONable form of its data to be used for snapshotting. This data must be
|
|
108
113
|
* loadable using the load method of its factory.
|
|
109
114
|
* @param value - The value type to serialize
|
|
110
115
|
* @returns The JSONable form of the value type
|
|
111
|
-
* @alpha
|
|
112
116
|
*/
|
|
113
|
-
store(value: T): any;
|
|
117
|
+
store(value: IntervalCollection<T>): any;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
/**
|
|
117
121
|
* Defines an operation that a value type is able to handle.
|
|
118
122
|
* @alpha
|
|
119
123
|
*/
|
|
120
|
-
export interface
|
|
124
|
+
export interface IIntervalCollectionOperation<T extends ISerializableInterval> {
|
|
121
125
|
/**
|
|
122
126
|
* Performs the actual processing on the incoming operation.
|
|
123
127
|
* @param value - The current value stored at the given key, which should be the value type
|
|
@@ -125,10 +129,9 @@ export interface IValueOperation<T> {
|
|
|
125
129
|
* @param local - Whether the operation originated from this client
|
|
126
130
|
* @param message - The operation itself
|
|
127
131
|
* @param localOpMetadata - any local metadata submitted by `IValueOpEmitter.emit`.
|
|
128
|
-
* @alpha
|
|
129
132
|
*/
|
|
130
133
|
process(
|
|
131
|
-
value: T
|
|
134
|
+
value: IntervalCollection<T>,
|
|
132
135
|
params: ISerializedInterval,
|
|
133
136
|
local: boolean,
|
|
134
137
|
message: ISequencedDocumentMessage | undefined,
|
|
@@ -144,37 +147,35 @@ export interface IValueOperation<T> {
|
|
|
144
147
|
* @returns A rebased version of the op and any local metadata that should be submitted with it.
|
|
145
148
|
*/
|
|
146
149
|
rebase(
|
|
147
|
-
value: T
|
|
148
|
-
op:
|
|
150
|
+
value: IntervalCollection<T>,
|
|
151
|
+
op: IIntervalCollectionTypeOperationValue,
|
|
149
152
|
localOpMetadata: IMapMessageLocalMetadata,
|
|
150
153
|
):
|
|
151
|
-
| {
|
|
154
|
+
| {
|
|
155
|
+
rebasedOp: IIntervalCollectionTypeOperationValue;
|
|
156
|
+
rebasedLocalOpMetadata: IMapMessageLocalMetadata;
|
|
157
|
+
}
|
|
152
158
|
| undefined;
|
|
153
|
-
|
|
154
|
-
applyStashedOp(value: T, op: IValueTypeOperationValue): IMapMessageLocalMetadata;
|
|
155
159
|
}
|
|
156
160
|
|
|
157
161
|
/**
|
|
158
162
|
* Defines a value type that can be registered on a container type.
|
|
159
163
|
*/
|
|
160
|
-
export interface
|
|
164
|
+
export interface IIntervalCollectionType<T extends ISerializableInterval> {
|
|
161
165
|
/**
|
|
162
166
|
* Name of the value type.
|
|
163
|
-
* @alpha
|
|
164
167
|
*/
|
|
165
168
|
name: string;
|
|
166
169
|
|
|
167
170
|
/**
|
|
168
171
|
* Factory method used to convert to/from a JSON form of the type.
|
|
169
|
-
* @alpha
|
|
170
172
|
*/
|
|
171
|
-
factory:
|
|
173
|
+
factory: IIntervalCollectionFactory<T>;
|
|
172
174
|
|
|
173
175
|
/**
|
|
174
176
|
* Operations that can be applied to the value type.
|
|
175
|
-
* @alpha
|
|
176
177
|
*/
|
|
177
|
-
ops: Map<IntervalOpType,
|
|
178
|
+
ops: Map<IntervalOpType, IIntervalCollectionOperation<T>>;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
export interface ISharedDefaultMapEvents extends ISharedObjectEvents {
|
|
@@ -195,7 +196,7 @@ export interface ISharedDefaultMapEvents extends ISharedObjectEvents {
|
|
|
195
196
|
* The DefaultMap implementation for sequence has been specialized to only support a single ValueType, which serializes
|
|
196
197
|
* and deserializes via .store() and .load().
|
|
197
198
|
*/
|
|
198
|
-
export interface
|
|
199
|
+
export interface ISerializableIntervalCollection {
|
|
199
200
|
/**
|
|
200
201
|
* A type annotation to help indicate how the value serializes.
|
|
201
202
|
*/
|
|
@@ -207,7 +208,7 @@ export interface ISerializableValue {
|
|
|
207
208
|
value: any;
|
|
208
209
|
}
|
|
209
210
|
|
|
210
|
-
export interface
|
|
211
|
+
export interface ISerializedIntervalCollection {
|
|
211
212
|
/**
|
|
212
213
|
* A type annotation to help indicate how the value serializes.
|
|
213
214
|
*/
|
|
@@ -228,7 +229,7 @@ export interface ISerializedValue {
|
|
|
228
229
|
* it just describes an operation to be applied to an already-in-memory value.
|
|
229
230
|
* @alpha
|
|
230
231
|
*/
|
|
231
|
-
export interface
|
|
232
|
+
export interface IIntervalCollectionTypeOperationValue {
|
|
232
233
|
/**
|
|
233
234
|
* The name of the operation.
|
|
234
235
|
*/
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
IntervalType,
|
|
12
12
|
SequenceInterval,
|
|
13
13
|
sequenceIntervalHelpers,
|
|
14
|
-
} from "../intervals";
|
|
15
|
-
import { SharedString } from "../sharedString";
|
|
16
|
-
import { IntervalIndex } from "./intervalIndex";
|
|
17
|
-
import { HasComparisonOverride, compareOverrideables, forceCompare } from "./intervalIndexUtils";
|
|
14
|
+
} from "../intervals/index.js";
|
|
15
|
+
import { SharedString } from "../sharedString.js";
|
|
16
|
+
import { IntervalIndex } from "./intervalIndex.js";
|
|
17
|
+
import { HasComparisonOverride, compareOverrideables, forceCompare } from "./intervalIndexUtils.js";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Collection of intervals.
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
IntervalType,
|
|
12
12
|
SequenceInterval,
|
|
13
13
|
sequenceIntervalHelpers,
|
|
14
|
-
} from "../intervals";
|
|
15
|
-
import { SharedString } from "../sharedString";
|
|
16
|
-
import { IntervalIndex } from "./intervalIndex";
|
|
14
|
+
} from "../intervals/index.js";
|
|
15
|
+
import { SharedString } from "../sharedString.js";
|
|
16
|
+
import { IntervalIndex } from "./intervalIndex.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @internal
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils";
|
|
7
|
-
import { ISerializableInterval } from "../intervals";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const reservedIntervalIdKey = "intervalId";
|
|
7
|
+
import { ISerializableInterval } from "../intervals/index.js";
|
|
8
|
+
import { reservedIntervalIdKey } from "../intervalCollection.js";
|
|
9
|
+
import { IntervalIndex } from "./intervalIndex.js";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* @internal
|