@fluidframework/sequence 2.0.0-internal.7.4.0 → 2.0.0-internal.7.4.2
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/dist/{defaultMap.js → defaultMap.cjs} +2 -2
- package/dist/defaultMap.cjs.map +1 -0
- package/{lib/intervalIndex/intervalIndex.js → dist/defaultMapInterfaces.cjs} +1 -1
- package/dist/defaultMapInterfaces.cjs.map +1 -0
- package/dist/{index.js → index.cjs} +11 -11
- package/dist/index.cjs.map +1 -0
- package/dist/{intervalCollection.js → intervalCollection.cjs} +3 -3
- package/dist/intervalCollection.cjs.map +1 -0
- package/dist/intervalIndex/{endpointInRangeIndex.js → endpointInRangeIndex.cjs} +3 -3
- package/dist/intervalIndex/endpointInRangeIndex.cjs.map +1 -0
- package/{lib/intervalIndex/endpointIndex.js → dist/intervalIndex/endpointIndex.cjs} +2 -2
- package/dist/intervalIndex/endpointIndex.cjs.map +1 -0
- package/dist/intervalIndex/{idIntervalIndex.js → idIntervalIndex.cjs} +1 -1
- package/dist/intervalIndex/idIntervalIndex.cjs.map +1 -0
- package/{lib/intervalIndex/index.js → dist/intervalIndex/index.cjs} +7 -7
- package/dist/intervalIndex/index.cjs.map +1 -0
- package/dist/intervalIndex/{intervalIndex.js → intervalIndex.cjs} +1 -1
- package/dist/intervalIndex/intervalIndex.cjs.map +1 -0
- package/{lib/intervalIndex/intervalIndexUtils.js → dist/intervalIndex/intervalIndexUtils.cjs} +1 -1
- package/dist/intervalIndex/intervalIndexUtils.cjs.map +1 -0
- package/{lib/intervalIndex/overlappingIntervalsIndex.js → dist/intervalIndex/overlappingIntervalsIndex.cjs} +4 -4
- package/dist/intervalIndex/overlappingIntervalsIndex.cjs.map +1 -0
- package/{lib/intervalIndex/overlappingSequenceIntervalsIndex.js → dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs} +3 -3
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs.map +1 -0
- package/dist/intervalIndex/{sequenceIntervalIndexes.js → sequenceIntervalIndexes.cjs} +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.cjs.map +1 -0
- package/{lib/intervalIndex/startpointInRangeIndex.js → dist/intervalIndex/startpointInRangeIndex.cjs} +3 -3
- package/dist/intervalIndex/startpointInRangeIndex.cjs.map +1 -0
- package/{lib/intervalTree.js → dist/intervalTree.cjs} +1 -1
- package/dist/intervalTree.cjs.map +1 -0
- package/{lib/intervals/index.js → dist/intervals/index.cjs} +4 -4
- package/dist/intervals/index.cjs.map +1 -0
- package/{lib/intervals/interval.js → dist/intervals/interval.cjs} +1 -1
- package/dist/intervals/interval.cjs.map +1 -0
- package/{lib/intervals/intervalUtils.js → dist/intervals/intervalUtils.cjs} +1 -1
- package/dist/intervals/intervalUtils.cjs.map +1 -0
- package/{lib/intervals/sequenceInterval.js → dist/intervals/sequenceInterval.cjs} +3 -3
- package/dist/intervals/sequenceInterval.cjs.map +1 -0
- package/dist/{localValues.js → localValues.cjs} +1 -1
- package/dist/localValues.cjs.map +1 -0
- package/{lib/packageVersion.js → dist/packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/{lib/revertibles.js → dist/revertibles.cjs} +3 -3
- package/dist/revertibles.cjs.map +1 -0
- package/dist/{sequence.js → sequence.cjs} +4 -4
- package/dist/sequence.cjs.map +1 -0
- package/{lib/sequenceDeltaEvent.js → dist/sequenceDeltaEvent.cjs} +1 -1
- package/dist/sequenceDeltaEvent.cjs.map +1 -0
- package/dist/{sequenceFactory.js → sequenceFactory.cjs} +3 -3
- package/dist/sequenceFactory.cjs.map +1 -0
- package/{lib/sharedIntervalCollection.js → dist/sharedIntervalCollection.cjs} +4 -4
- package/dist/sharedIntervalCollection.cjs.map +1 -0
- package/{lib/sharedSequence.js → dist/sharedSequence.cjs} +2 -2
- package/dist/sharedSequence.cjs.map +1 -0
- package/{lib/sharedString.js → dist/sharedString.cjs} +3 -3
- package/dist/sharedString.cjs.map +1 -0
- package/lib/{defaultMap.d.ts → defaultMap.d.mts} +1 -1
- package/lib/defaultMap.d.mts.map +1 -0
- package/lib/{defaultMap.js → defaultMap.mjs} +19 -23
- package/lib/defaultMap.mjs.map +1 -0
- package/lib/{defaultMapInterfaces.d.ts → defaultMapInterfaces.d.mts} +1 -1
- package/lib/defaultMapInterfaces.d.mts.map +1 -0
- package/lib/defaultMapInterfaces.mjs +6 -0
- package/lib/{defaultMapInterfaces.js.map → defaultMapInterfaces.mjs.map} +1 -1
- package/lib/{index.d.ts → index.d.mts} +11 -23
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +15 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{intervalCollection.d.ts → intervalCollection.d.mts} +3 -3
- package/lib/intervalCollection.d.mts.map +1 -0
- package/lib/{intervalCollection.js → intervalCollection.mjs} +118 -133
- package/lib/intervalCollection.mjs.map +1 -0
- package/lib/intervalIndex/{endpointInRangeIndex.d.ts → endpointInRangeIndex.d.mts} +3 -3
- package/lib/intervalIndex/endpointInRangeIndex.d.mts.map +1 -0
- package/lib/intervalIndex/{endpointInRangeIndex.js → endpointInRangeIndex.mjs} +13 -18
- package/lib/intervalIndex/endpointInRangeIndex.mjs.map +1 -0
- package/lib/intervalIndex/{endpointIndex.d.ts → endpointIndex.d.mts} +3 -3
- package/lib/intervalIndex/endpointIndex.d.mts.map +1 -0
- package/{dist/intervalIndex/endpointIndex.js → lib/intervalIndex/endpointIndex.mjs} +9 -14
- package/lib/intervalIndex/endpointIndex.mjs.map +1 -0
- package/lib/intervalIndex/{idIntervalIndex.d.ts → idIntervalIndex.d.mts} +2 -2
- package/lib/intervalIndex/idIntervalIndex.d.mts.map +1 -0
- package/lib/intervalIndex/{idIntervalIndex.js → idIntervalIndex.mjs} +5 -9
- package/lib/intervalIndex/idIntervalIndex.mjs.map +1 -0
- package/lib/intervalIndex/{index.d.ts → index.d.mts} +8 -8
- package/lib/intervalIndex/index.d.mts.map +1 -0
- package/lib/intervalIndex/index.mjs +11 -0
- package/{dist/intervalIndex/index.js.map → lib/intervalIndex/index.mjs.map} +1 -1
- package/lib/intervalIndex/{intervalIndex.d.ts → intervalIndex.d.mts} +1 -1
- package/lib/intervalIndex/intervalIndex.d.mts.map +1 -0
- package/lib/intervalIndex/intervalIndex.mjs +6 -0
- package/{dist/intervalIndex/intervalIndex.js.map → lib/intervalIndex/intervalIndex.mjs.map} +1 -1
- package/{dist/intervalIndex/intervalIndexUtils.js → lib/intervalIndex/intervalIndexUtils.mjs} +5 -9
- package/lib/intervalIndex/intervalIndexUtils.mjs.map +1 -0
- package/lib/intervalIndex/{overlappingIntervalsIndex.d.ts → overlappingIntervalsIndex.d.mts} +5 -5
- package/lib/intervalIndex/overlappingIntervalsIndex.d.mts.map +1 -0
- package/{dist/intervalIndex/overlappingIntervalsIndex.js → lib/intervalIndex/overlappingIntervalsIndex.mjs} +11 -16
- package/lib/intervalIndex/overlappingIntervalsIndex.mjs.map +1 -0
- package/lib/intervalIndex/{overlappingSequenceIntervalsIndex.d.ts → overlappingSequenceIntervalsIndex.d.mts} +2 -2
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts.map +1 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs +37 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs.map +1 -0
- package/lib/intervalIndex/{sequenceIntervalIndexes.d.ts → sequenceIntervalIndexes.d.mts} +2 -2
- package/lib/intervalIndex/sequenceIntervalIndexes.d.mts.map +1 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.mjs +6 -0
- package/{dist/intervalIndex/sequenceIntervalIndexes.js.map → lib/intervalIndex/sequenceIntervalIndexes.mjs.map} +1 -1
- package/lib/intervalIndex/{startpointInRangeIndex.d.ts → startpointInRangeIndex.d.mts} +3 -3
- package/lib/intervalIndex/startpointInRangeIndex.d.mts.map +1 -0
- package/{dist/intervalIndex/startpointInRangeIndex.js → lib/intervalIndex/startpointInRangeIndex.mjs} +13 -18
- package/lib/intervalIndex/startpointInRangeIndex.mjs.map +1 -0
- package/lib/{intervalTree.d.ts → intervalTree.d.mts} +1 -1
- package/lib/intervalTree.d.mts.map +1 -0
- package/{dist/intervalTree.js → lib/intervalTree.mjs} +5 -10
- package/lib/intervalTree.mjs.map +1 -0
- package/lib/intervals/{index.d.ts → index.d.mts} +3 -3
- package/lib/intervals/index.d.mts.map +1 -0
- package/lib/intervals/index.mjs +8 -0
- package/lib/intervals/index.mjs.map +1 -0
- package/lib/intervals/{interval.d.ts → interval.d.mts} +2 -2
- package/lib/intervals/{interval.d.ts.map → interval.d.mts.map} +1 -1
- package/{dist/intervals/interval.js → lib/intervals/interval.mjs} +14 -19
- package/lib/intervals/interval.mjs.map +1 -0
- package/lib/intervals/{intervalUtils.d.ts → intervalUtils.d.mts} +1 -1
- package/lib/intervals/intervalUtils.d.mts.map +1 -0
- package/{dist/intervals/intervalUtils.js → lib/intervals/intervalUtils.mjs} +14 -21
- package/lib/intervals/intervalUtils.mjs.map +1 -0
- package/lib/intervals/{sequenceInterval.d.ts → sequenceInterval.d.mts} +2 -2
- package/lib/intervals/sequenceInterval.d.mts.map +1 -0
- package/{dist/intervals/sequenceInterval.js → lib/intervals/sequenceInterval.mjs} +60 -68
- package/lib/intervals/sequenceInterval.mjs.map +1 -0
- package/lib/{localValues.d.ts → localValues.d.mts} +2 -2
- package/lib/localValues.d.mts.map +1 -0
- package/lib/{localValues.js → localValues.mjs} +5 -10
- package/lib/localValues.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/packageVersion.mjs +9 -0
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{revertibles.d.ts → revertibles.d.mts} +3 -3
- package/lib/revertibles.d.mts.map +1 -0
- package/{dist/revertibles.js → lib/revertibles.mjs} +60 -72
- package/lib/revertibles.mjs.map +1 -0
- package/lib/{sequence.d.ts → sequence.d.mts} +4 -4
- package/lib/sequence.d.mts.map +1 -0
- package/lib/{sequence.js → sequence.mjs} +40 -46
- package/lib/sequence.mjs.map +1 -0
- package/lib/sequenceDeltaEvent.d.mts.map +1 -0
- package/{dist/sequenceDeltaEvent.js → lib/sequenceDeltaEvent.mjs} +8 -15
- package/lib/sequenceDeltaEvent.mjs.map +1 -0
- package/lib/{sequenceFactory.d.ts → sequenceFactory.d.mts} +1 -1
- package/lib/sequenceFactory.d.mts.map +1 -0
- package/lib/{sequenceFactory.js → sequenceFactory.mjs} +10 -14
- package/lib/sequenceFactory.mjs.map +1 -0
- package/lib/{sharedIntervalCollection.d.ts → sharedIntervalCollection.d.mts} +2 -2
- package/lib/sharedIntervalCollection.d.mts.map +1 -0
- package/{dist/sharedIntervalCollection.js → lib/sharedIntervalCollection.mjs} +14 -19
- package/lib/sharedIntervalCollection.mjs.map +1 -0
- package/lib/{sharedSequence.d.ts → sharedSequence.d.mts} +1 -1
- package/lib/sharedSequence.d.mts.map +1 -0
- package/{dist/sharedSequence.js → lib/sharedSequence.mjs} +7 -12
- package/lib/sharedSequence.mjs.map +1 -0
- package/lib/{sharedString.d.ts → sharedString.d.mts} +2 -2
- package/lib/sharedString.d.mts.map +1 -0
- package/{dist/sharedString.js → lib/sharedString.mjs} +17 -22
- package/lib/sharedString.mjs.map +1 -0
- package/package.json +38 -23
- package/sequence.test-files.tar +0 -0
- package/src/packageVersion.ts +1 -1
- package/tsc-multi.test.json +10 -0
- package/dist/defaultMap.js.map +0 -1
- package/dist/defaultMapInterfaces.js +0 -7
- package/dist/defaultMapInterfaces.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/intervalCollection.js.map +0 -1
- package/dist/intervalIndex/endpointInRangeIndex.js.map +0 -1
- package/dist/intervalIndex/endpointIndex.js.map +0 -1
- package/dist/intervalIndex/idIntervalIndex.js.map +0 -1
- package/dist/intervalIndex/index.js +0 -24
- package/dist/intervalIndex/intervalIndexUtils.js.map +0 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +0 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +0 -41
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +0 -1
- package/dist/intervalIndex/startpointInRangeIndex.js.map +0 -1
- package/dist/intervalTree.js.map +0 -1
- package/dist/intervals/index.js +0 -23
- package/dist/intervals/index.js.map +0 -1
- package/dist/intervals/interval.js.map +0 -1
- package/dist/intervals/intervalUtils.js.map +0 -1
- package/dist/intervals/sequenceInterval.js.map +0 -1
- package/dist/localValues.js.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/dist/revertibles.js.map +0 -1
- package/dist/sequence.js.map +0 -1
- package/dist/sequenceDeltaEvent.js.map +0 -1
- package/dist/sequenceFactory.js.map +0 -1
- package/dist/sharedIntervalCollection.js.map +0 -1
- package/dist/sharedSequence.js.map +0 -1
- package/dist/sharedString.js.map +0 -1
- package/lib/defaultMap.d.ts.map +0 -1
- package/lib/defaultMap.js.map +0 -1
- package/lib/defaultMapInterfaces.d.ts.map +0 -1
- package/lib/defaultMapInterfaces.js +0 -7
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -50
- package/lib/index.js.map +0 -1
- package/lib/intervalCollection.d.ts.map +0 -1
- package/lib/intervalCollection.js.map +0 -1
- package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +0 -1
- package/lib/intervalIndex/endpointInRangeIndex.js.map +0 -1
- package/lib/intervalIndex/endpointIndex.d.ts.map +0 -1
- package/lib/intervalIndex/endpointIndex.js.map +0 -1
- package/lib/intervalIndex/idIntervalIndex.d.ts.map +0 -1
- package/lib/intervalIndex/idIntervalIndex.js.map +0 -1
- package/lib/intervalIndex/index.d.ts.map +0 -1
- package/lib/intervalIndex/index.js.map +0 -1
- package/lib/intervalIndex/intervalIndex.d.ts.map +0 -1
- package/lib/intervalIndex/intervalIndex.js.map +0 -1
- package/lib/intervalIndex/intervalIndexUtils.js.map +0 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +0 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +0 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +0 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +0 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +0 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.js +0 -7
- package/lib/intervalIndex/sequenceIntervalIndexes.js.map +0 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +0 -1
- package/lib/intervalIndex/startpointInRangeIndex.js.map +0 -1
- package/lib/intervalTree.d.ts.map +0 -1
- package/lib/intervalTree.js.map +0 -1
- package/lib/intervals/index.d.ts.map +0 -1
- package/lib/intervals/index.js.map +0 -1
- package/lib/intervals/interval.js.map +0 -1
- package/lib/intervals/intervalUtils.d.ts.map +0 -1
- package/lib/intervals/intervalUtils.js.map +0 -1
- package/lib/intervals/sequenceInterval.d.ts.map +0 -1
- package/lib/intervals/sequenceInterval.js.map +0 -1
- package/lib/localValues.d.ts.map +0 -1
- package/lib/localValues.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/revertibles.d.ts.map +0 -1
- package/lib/revertibles.js.map +0 -1
- package/lib/sequence.d.ts.map +0 -1
- package/lib/sequence.js.map +0 -1
- package/lib/sequenceDeltaEvent.d.ts.map +0 -1
- package/lib/sequenceDeltaEvent.js.map +0 -1
- package/lib/sequenceFactory.d.ts.map +0 -1
- package/lib/sequenceFactory.js.map +0 -1
- package/lib/sharedIntervalCollection.d.ts.map +0 -1
- package/lib/sharedIntervalCollection.js.map +0 -1
- package/lib/sharedSequence.d.ts.map +0 -1
- package/lib/sharedSequence.js.map +0 -1
- package/lib/sharedString.d.ts.map +0 -1
- package/lib/sharedString.js.map +0 -1
- package/tsconfig.esnext.json +0 -6
- /package/lib/intervalIndex/{intervalIndexUtils.d.ts → intervalIndexUtils.d.mts} +0 -0
- /package/lib/intervalIndex/{intervalIndexUtils.d.ts.map → intervalIndexUtils.d.mts.map} +0 -0
- /package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +0 -0
- /package/lib/{sequence-alpha.d.ts → sequence-alpha.d.mts} +0 -0
- /package/lib/{sequence-beta.d.ts → sequence-beta.d.mts} +0 -0
- /package/lib/{sequence-public.d.ts → sequence-public.d.mts} +0 -0
- /package/lib/{sequence-untrimmed.d.ts → sequence-untrimmed.d.mts} +0 -0
- /package/lib/{sequenceDeltaEvent.d.ts → sequenceDeltaEvent.d.mts} +0 -0
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*!
|
|
3
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
3
|
* Licensed under the MIT License.
|
|
5
4
|
*/
|
|
6
5
|
var _a;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const defaultMap_1 = require("./defaultMap");
|
|
14
|
-
const packageVersion_1 = require("./packageVersion");
|
|
6
|
+
import { bufferToString } from "@fluid-internal/client-utils";
|
|
7
|
+
import { MessageType } from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { createSingleBlobSummary, SharedObject, } from "@fluidframework/shared-object-base";
|
|
9
|
+
import { IntervalCollectionValueType, } from "./intervalCollection.mjs";
|
|
10
|
+
import { DefaultMap } from "./defaultMap.mjs";
|
|
11
|
+
import { pkgVersion } from "./packageVersion.mjs";
|
|
15
12
|
const snapshotFileName = "header";
|
|
16
13
|
/**
|
|
17
14
|
* The factory that defines the SharedIntervalCollection.
|
|
18
15
|
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
19
16
|
* @internal
|
|
20
17
|
*/
|
|
21
|
-
class SharedIntervalCollectionFactory {
|
|
18
|
+
export class SharedIntervalCollectionFactory {
|
|
22
19
|
get type() {
|
|
23
20
|
return SharedIntervalCollectionFactory.Type;
|
|
24
21
|
}
|
|
@@ -39,18 +36,17 @@ class SharedIntervalCollectionFactory {
|
|
|
39
36
|
return map;
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
exports.SharedIntervalCollectionFactory = SharedIntervalCollectionFactory;
|
|
43
39
|
SharedIntervalCollectionFactory.Type = "https://graph.microsoft.com/types/sharedIntervalCollection";
|
|
44
40
|
SharedIntervalCollectionFactory.Attributes = {
|
|
45
41
|
type: SharedIntervalCollectionFactory.Type,
|
|
46
42
|
snapshotFormatVersion: "0.1",
|
|
47
|
-
packageVersion:
|
|
43
|
+
packageVersion: pkgVersion,
|
|
48
44
|
};
|
|
49
45
|
/**
|
|
50
46
|
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
51
47
|
* @internal
|
|
52
48
|
*/
|
|
53
|
-
class SharedIntervalCollection extends
|
|
49
|
+
export class SharedIntervalCollection extends SharedObject {
|
|
54
50
|
/**
|
|
55
51
|
* Create a SharedIntervalCollection
|
|
56
52
|
*
|
|
@@ -76,7 +72,7 @@ class SharedIntervalCollection extends shared_object_base_1.SharedObject {
|
|
|
76
72
|
constructor(id, runtime, attributes) {
|
|
77
73
|
super(id, runtime, attributes, "fluid_sharedIntervalCollection_");
|
|
78
74
|
this[_a] = "SharedIntervalCollection";
|
|
79
|
-
this.intervalCollections = new
|
|
75
|
+
this.intervalCollections = new DefaultMap(this.serializer, this.handle, (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata), new IntervalCollectionValueType(), runtime.options);
|
|
80
76
|
}
|
|
81
77
|
getIntervalCollection(label) {
|
|
82
78
|
const realLabel = this.getIntervalCollectionPath(label);
|
|
@@ -84,7 +80,7 @@ class SharedIntervalCollection extends shared_object_base_1.SharedObject {
|
|
|
84
80
|
return sharedCollection;
|
|
85
81
|
}
|
|
86
82
|
summarizeCore(serializer) {
|
|
87
|
-
return
|
|
83
|
+
return createSingleBlobSummary(snapshotFileName, this.intervalCollections.serialize(serializer));
|
|
88
84
|
}
|
|
89
85
|
reSubmitCore(content, localOpMetadata) {
|
|
90
86
|
this.intervalCollections.tryResubmitMessage(content, localOpMetadata);
|
|
@@ -95,11 +91,11 @@ class SharedIntervalCollection extends shared_object_base_1.SharedObject {
|
|
|
95
91
|
*/
|
|
96
92
|
async loadCore(storage) {
|
|
97
93
|
const blob = await storage.readBlob(snapshotFileName);
|
|
98
|
-
const header =
|
|
94
|
+
const header = bufferToString(blob, "utf8");
|
|
99
95
|
this.intervalCollections.populate(header);
|
|
100
96
|
}
|
|
101
97
|
processCore(message, local, localOpMetadata) {
|
|
102
|
-
if (message.type ===
|
|
98
|
+
if (message.type === MessageType.Operation) {
|
|
103
99
|
this.intervalCollections.tryProcessMessage(message.contents, local, message, localOpMetadata);
|
|
104
100
|
}
|
|
105
101
|
}
|
|
@@ -114,6 +110,5 @@ class SharedIntervalCollection extends shared_object_base_1.SharedObject {
|
|
|
114
110
|
throw new Error("not implemented");
|
|
115
111
|
}
|
|
116
112
|
}
|
|
117
|
-
exports.SharedIntervalCollection = SharedIntervalCollection;
|
|
118
113
|
_a = Symbol.toStringTag;
|
|
119
|
-
//# sourceMappingURL=sharedIntervalCollection.
|
|
114
|
+
//# sourceMappingURL=sharedIntervalCollection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedIntervalCollection.mjs","sourceRoot":"","sources":["../src/sharedIntervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;;OAEI,EAAE,cAAc,EAAE,MAAM,8BAA8B;OAQtD,EAA6B,WAAW,EAAE,MAAM,sCAAsC;OAEtF,EACN,uBAAuB,EAEvB,YAAY,GACZ,MAAM,oCAAoC;OAEpC,EAGN,2BAA2B,GAC3B;OACM,EAAE,UAAU,EAAiB;OAC7B,EAAE,UAAU,EAAE;AAGrB,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;GAIG;AACH,MAAM,OAAO,+BAA+B;IAS3C,IAAW,IAAI;QACd,OAAO,+BAA+B,CAAC,IAAI,CAAC;IAC7C,CAAC;IAED,I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yBAAyB,CAAC,KAAa;QAChD,OAAO,KAAK,CAAC;IACd,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;KA3EiB,MAAM,CAAC,WAAW","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelServices,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { Interval, ISerializableInterval } from \"./intervals\";\nimport {\n\tIntervalCollection,\n\tIIntervalCollection,\n\tIntervalCollectionValueType,\n} from \"./intervalCollection\";\nimport { DefaultMap, IMapOperation } from \"./defaultMap\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IMapMessageLocalMetadata } from \"./defaultMapInterfaces\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * The factory that defines the SharedIntervalCollection.\n * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.\n * @internal\n */\nexport class SharedIntervalCollectionFactory implements IChannelFactory {\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/sharedIntervalCollection\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: SharedIntervalCollectionFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type() {\n\t\treturn SharedIntervalCollectionFactory.Type;\n\t}\n\n\tpublic get attributes() {\n\t\treturn SharedIntervalCollectionFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<SharedIntervalCollection> {\n\t\tconst map = new SharedIntervalCollection(id, runtime, attributes);\n\t\tawait map.load(services);\n\n\t\treturn map;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): SharedIntervalCollection {\n\t\tconst map = new SharedIntervalCollection(id, runtime, this.attributes);\n\t\tmap.initializeLocal();\n\n\t\treturn map;\n\t}\n}\n\n/**\n * @alpha\n */\nexport interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {\n\tgetIntervalCollection(label: string): IIntervalCollection<TInterval>;\n}\n\n/**\n * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.\n * @internal\n */\nexport class SharedIntervalCollection\n\textends SharedObject\n\timplements ISharedIntervalCollection<Interval>\n{\n\t/**\n\t * Create a SharedIntervalCollection\n\t *\n\t * @param runtime - data store runtime the new shared map belongs to\n\t * @param id - optional name of the shared map\n\t * @returns newly create shared map (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(\n\t\t\tid,\n\t\t\tSharedIntervalCollectionFactory.Type,\n\t\t) as SharedIntervalCollection;\n\t}\n\n\t/**\n\t * Get a factory for SharedIntervalCollection to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedIntervalCollection\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new SharedIntervalCollectionFactory();\n\t}\n\n\tpublic readonly [Symbol.toStringTag]: string = \"SharedIntervalCollection\";\n\tprivate readonly intervalCollections: DefaultMap<IntervalCollection<Interval>>;\n\n\t/**\n\t * Constructs a new shared SharedIntervalCollection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tconstructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {\n\t\tsuper(id, runtime, attributes, \"fluid_sharedIntervalCollection_\");\n\t\tthis.intervalCollections = new DefaultMap(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\tnew IntervalCollectionValueType(),\n\t\t\truntime.options,\n\t\t);\n\t}\n\n\tpublic getIntervalCollection(label: string): IIntervalCollection<Interval> {\n\t\tconst realLabel = this.getIntervalCollectionPath(label);\n\t\tconst sharedCollection = this.intervalCollections.get(realLabel);\n\t\treturn sharedCollection;\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(\n\t\t\tsnapshotFileName,\n\t\t\tthis.intervalCollections.serialize(serializer),\n\t\t);\n\t}\n\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown) {\n\t\tthis.intervalCollections.tryResubmitMessage(\n\t\t\tcontent,\n\t\t\tlocalOpMetadata as IMapMessageLocalMetadata,\n\t\t);\n\t}\n\n\tprotected onDisconnect() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService) {\n\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\tconst header = bufferToString(blob, \"utf8\");\n\t\tthis.intervalCollections.populate(header);\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tthis.intervalCollections.tryProcessMessage(\n\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\tlocal,\n\t\t\t\tmessage,\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Creates the full path of the intervalCollection label\n\t * @param label - the incoming label\n\t */\n\tprotected getIntervalCollectionPath(label: string): string {\n\t\treturn label;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { BaseSegment, IJSONSegment, ISegment, PropertySet } from "@fluidframework/merge-tree";
|
|
6
6
|
import { IChannelAttributes, IFluidDataStoreRuntime, Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import { SharedSegmentSequence } from "./sequence";
|
|
7
|
+
import { SharedSegmentSequence } from "./sequence.mjs";
|
|
8
8
|
/**
|
|
9
9
|
* @deprecated IJSONRunSegment will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package
|
|
10
10
|
* @internal
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedSequence.d.ts","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,4BAA4B;OACtF,EACN,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,MAAM,uCAAuC;OACvC,EAAE,qBAAqB,EAAE;AAIhC;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,YAAY;IACvD,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,qBAAa,WAAW,CAAC,CAAC,CAAE,SAAQ,WAAW;IAkB3B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE;IAjB3C,gBAAuB,UAAU,EAAE,MAAM,CAAiB;WAC5C,EAAE,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,IAAI,WAAW,CAAC,GAAG,CAAC;WAGlD,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY;IAWlD,SAAgB,IAAI,SAA0B;gBAE3B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE;IAKpC,YAAY;IAMZ,KAAK,CAAC,KAAK,SAAI,EAAE,GAAG,CAAC,EAAE,MAAM;IAO7B,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAOrC,QAAQ;IAIR,MAAM,CAAC,OAAO,EAAE,QAAQ;IAQxB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAc7C,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAS1C;AAED;;;GAGG;AACH,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAGnE,EAAE,EAAE,MAAM;gBADjB,QAAQ,EAAE,sBAAsB,EACzB,EAAE,EAAE,MAAM,EACjB,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,QAAQ;IAKhD;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,WAAW;IAQxE;;;OAGG;IACI,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAIxC;;OAEG;IACI,YAAY,IAAI,MAAM;IAI7B;;;;;OAKG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE;CAoC/D"}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*!
|
|
3
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
3
|
* Licensed under the MIT License.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const merge_tree_1 = require("@fluidframework/merge-tree");
|
|
10
|
-
const sequence_1 = require("./sequence");
|
|
5
|
+
import { assert } from "@fluidframework/core-utils";
|
|
6
|
+
import { BaseSegment } from "@fluidframework/merge-tree";
|
|
7
|
+
import { SharedSegmentSequence } from "./sequence.mjs";
|
|
11
8
|
const MaxRun = 128;
|
|
12
9
|
/**
|
|
13
10
|
* @deprecated SubSequence will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package
|
|
14
11
|
* @internal
|
|
15
12
|
*/
|
|
16
|
-
class SubSequence extends
|
|
13
|
+
export class SubSequence extends BaseSegment {
|
|
17
14
|
static is(segment) {
|
|
18
15
|
return segment.type === SubSequence.typeString;
|
|
19
16
|
}
|
|
@@ -52,7 +49,7 @@ class SubSequence extends merge_tree_1.BaseSegment {
|
|
|
52
49
|
return this.items.toString();
|
|
53
50
|
}
|
|
54
51
|
append(segment) {
|
|
55
|
-
|
|
52
|
+
assert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);
|
|
56
53
|
super.append(segment);
|
|
57
54
|
this.items = this.items.concat(segment.items);
|
|
58
55
|
}
|
|
@@ -81,13 +78,12 @@ class SubSequence extends merge_tree_1.BaseSegment {
|
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
exports.SubSequence = SubSequence;
|
|
85
81
|
SubSequence.typeString = "SubSequence";
|
|
86
82
|
/**
|
|
87
83
|
* @deprecated SharedSequence will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package
|
|
88
84
|
* @internal
|
|
89
85
|
*/
|
|
90
|
-
class SharedSequence extends
|
|
86
|
+
export class SharedSequence extends SharedSegmentSequence {
|
|
91
87
|
constructor(document, id, attributes, specToSegment) {
|
|
92
88
|
super(document, id, attributes, specToSegment);
|
|
93
89
|
this.id = id;
|
|
@@ -153,5 +149,4 @@ class SharedSequence extends sequence_1.SharedSegmentSequence {
|
|
|
153
149
|
return items;
|
|
154
150
|
}
|
|
155
151
|
}
|
|
156
|
-
|
|
157
|
-
//# sourceMappingURL=sharedSequence.js.map
|
|
152
|
+
//# sourceMappingURL=sharedSequence.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedSequence.mjs","sourceRoot":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AAC;IACzB,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,KAAa,EAAE,GAAY;QAC1C,MAAM,KAAK,GAAsB,EAAE,CAAC;QACpC,IAAI,YAAkC,CAAC;QAEvC,oCAAoC;QACpC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,IAAI,KAAK,EAAE;YACtC,OAAO,KAAK,CAAC;SACb;QAED,IAAI,CAAC,YAAY,CAChB,CAAC,OAAiB,EAAE,EAAE;YACrB,IAAI,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;gBAC5B,IAAI,YAAY,KAAK,SAAS,EAAE;oBAC/B,YAAY,GAAG,OAAO,CAAC;iBACvB;gBACD,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;aAC7B;YACD,OAAO,IAAI,CAAC;QACb,CAAC,EACD,KAAK,EACL,GAAG,CACH,CAAC;QAEF,kEAAkE;QAClE,gEAAgE;QAChE,+DAA+D;QAC/D,iEAAiE;QACjE,aAAa;QACb,IAAI,YAAY,KAAK,SAAS,EAAE;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;SACxD;QACD,IAAI,GAAG,KAAK,SAAS,EAAE;YACtB,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;SAC1B;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { BaseSegment, IJSONSegment, ISegment, PropertySet } from \"@fluidframework/merge-tree\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\n/**\n * @deprecated IJSONRunSegment will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package\n * @internal\n */\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n\titems: Serializable<T>[];\n}\n\n/**\n * @deprecated SubSequence will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package\n * @internal\n */\nexport class SubSequence<T> extends BaseSegment {\n\tpublic static readonly typeString: string = \"SubSequence\";\n\tpublic static is(segment: ISegment): segment is SubSequence<any> {\n\t\treturn segment.type === SubSequence.typeString;\n\t}\n\tpublic static fromJSONObject<U>(spec: Serializable) {\n\t\tif (spec && typeof spec === \"object\" && \"items\" in spec) {\n\t\t\tconst segment = new SubSequence<U>(spec.items);\n\t\t\tif (spec.props) {\n\t\t\t\tsegment.addProperties(spec.props);\n\t\t\t}\n\t\t\treturn segment;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic readonly type = SubSequence.typeString;\n\n\tconstructor(public items: Serializable<T>[]) {\n\t\tsuper();\n\t\tthis.cachedLength = items.length;\n\t}\n\n\tpublic toJSONObject() {\n\t\tconst obj: IJSONRunSegment<T> = { items: this.items };\n\t\tsuper.addSerializedProps(obj);\n\t\treturn obj;\n\t}\n\n\tpublic clone(start = 0, end?: number) {\n\t\tconst clonedItems = this.items.slice(start, end);\n\t\tconst b = new SubSequence(clonedItems);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn (\n\t\t\tSubSequence.is(segment) &&\n\t\t\t(this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun)\n\t\t);\n\t}\n\n\tpublic toString() {\n\t\treturn this.items.toString();\n\t}\n\n\tpublic append(segment: ISegment) {\n\t\tassert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);\n\t\tsuper.append(segment);\n\t\tthis.items = this.items.concat(segment.items);\n\t}\n\n\t// TODO: retain removed items for undo\n\t// returns true if entire run removed\n\tpublic removeRange(start: number, end: number) {\n\t\tlet remnantItems: Serializable<T>[] = [];\n\t\tconst len = this.items.length;\n\t\tif (start > 0) {\n\t\t\tremnantItems = remnantItems.concat(this.items.slice(0, start));\n\t\t}\n\t\tif (end < len) {\n\t\t\tremnantItems = remnantItems.concat(this.items.slice(end));\n\t\t}\n\t\tthis.items = remnantItems;\n\t\tthis.cachedLength = this.items.length;\n\t\treturn this.items.length === 0;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tif (pos > 0) {\n\t\t\tconst remainingItems = this.items.slice(pos);\n\t\t\tthis.items = this.items.slice(0, pos);\n\t\t\tthis.cachedLength = this.items.length;\n\t\t\tconst leafSegment = new SubSequence(remainingItems);\n\t\t\treturn leafSegment;\n\t\t}\n\t}\n}\n\n/**\n * @deprecated SharedSequence will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package\n * @internal\n */\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t\tspecToSegment: (spec: IJSONSegment) => ISegment,\n\t) {\n\t\tsuper(document, id, attributes, specToSegment);\n\t}\n\n\t/**\n\t * @param pos - The position to insert the items at.\n\t * @param items - The items to insert.\n\t * @param props - Optional. Properties to set on the inserted items.\n\t */\n\tpublic insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n\t\tconst segment = new SubSequence<T>(items);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\t\tthis.client.insertSegmentLocal(pos, segment);\n\t}\n\n\t/**\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to remove\n\t */\n\tpublic remove(start: number, end: number) {\n\t\tthis.removeRange(start, end);\n\t}\n\n\t/**\n\t * Returns the total count of items in the sequence\n\t */\n\tpublic getItemCount(): number {\n\t\treturn this.getLength();\n\t}\n\n\t/**\n\t * Gets the items in the specified range\n\t *\n\t * @param start - The inclusive start of the range\n\t * @param end - The exclusive end of the range\n\t */\n\tpublic getItems(start: number, end?: number): Serializable<T>[] {\n\t\tconst items: Serializable<T>[] = [];\n\t\tlet firstSegment: ISegment | undefined;\n\n\t\t// Return if the range is incorrect.\n\t\tif (end !== undefined && end <= start) {\n\t\t\treturn items;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment: ISegment) => {\n\t\t\t\tif (SubSequence.is(segment)) {\n\t\t\t\t\tif (firstSegment === undefined) {\n\t\t\t\t\t\tfirstSegment = segment;\n\t\t\t\t\t}\n\t\t\t\t\titems.push(...segment.items);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\n\t\t// The above call to walkSegments adds all the items in the walked\n\t\t// segments. However, we only want items beginning at |start| in\n\t\t// the first segment. Similarly, if |end| is passed in, we only\n\t\t// want items until |end| in the last segment. Remove the rest of\n\t\t// the items.\n\t\tif (firstSegment !== undefined) {\n\t\t\titems.splice(0, start - this.getPosition(firstSegment));\n\t\t}\n\t\tif (end !== undefined) {\n\t\t\titems.splice(end - start);\n\t\t}\n\t\treturn items;\n\t}\n}\n"]}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ICombiningOp, IMergeTreeInsertMsg, IMergeTreeRemoveMsg, IRelativePosition, ISegment, Marker, PropertySet, ReferencePosition, ReferenceType, TextSegment } from "@fluidframework/merge-tree";
|
|
6
6
|
import { IFluidDataStoreRuntime, IChannelAttributes } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import { SharedSegmentSequence } from "./sequence";
|
|
8
|
-
import { SharedStringFactory } from "./sequenceFactory";
|
|
7
|
+
import { SharedSegmentSequence } from "./sequence.mjs";
|
|
8
|
+
import { SharedStringFactory } from "./sequenceFactory.mjs";
|
|
9
9
|
/**
|
|
10
10
|
* Fluid object interface describing access methods on a SharedString
|
|
11
11
|
* @alpha
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedString.d.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AAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAW3C;;OAEG;IACI,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAWpD,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAWzD;;;OAGG;IACI,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIxD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAOhE;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,GACV;IACF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC1B,CAWA"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*!
|
|
3
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
3
|
* Licensed under the MIT License.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const sequence_1 = require("./sequence");
|
|
10
|
-
const sequenceFactory_1 = require("./sequenceFactory");
|
|
5
|
+
import { Marker, refHasTileLabel, TextSegment, } from "@fluidframework/merge-tree";
|
|
6
|
+
import { SharedSegmentSequence } from "./sequence.mjs";
|
|
7
|
+
import { SharedStringFactory } from "./sequenceFactory.mjs";
|
|
11
8
|
/**
|
|
12
9
|
* The Shared String is a specialized data structure for handling collaborative
|
|
13
10
|
* text. It is based on a more general Sequence data structure but has
|
|
@@ -18,7 +15,7 @@ const sequenceFactory_1 = require("./sequenceFactory");
|
|
|
18
15
|
* image or Fluid object that should be rendered with the text.
|
|
19
16
|
* @alpha
|
|
20
17
|
*/
|
|
21
|
-
class SharedString extends
|
|
18
|
+
export class SharedString extends SharedSegmentSequence {
|
|
22
19
|
/**
|
|
23
20
|
* Create a new shared string.
|
|
24
21
|
* @param runtime - data store runtime the new shared string belongs to
|
|
@@ -26,20 +23,20 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
26
23
|
* @returns newly create shared string (but not attached yet)
|
|
27
24
|
*/
|
|
28
25
|
static create(runtime, id) {
|
|
29
|
-
return runtime.createChannel(id,
|
|
26
|
+
return runtime.createChannel(id, SharedStringFactory.Type);
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* Get a factory for SharedString to register with the data store.
|
|
33
30
|
* @returns a factory that creates and load SharedString
|
|
34
31
|
*/
|
|
35
32
|
static getFactory() {
|
|
36
|
-
return new
|
|
33
|
+
return new SharedStringFactory();
|
|
37
34
|
}
|
|
38
35
|
get ISharedString() {
|
|
39
36
|
return this;
|
|
40
37
|
}
|
|
41
38
|
constructor(document, id, attributes) {
|
|
42
|
-
super(document, id, attributes,
|
|
39
|
+
super(document, id, attributes, SharedStringFactory.segmentFromSpec);
|
|
43
40
|
this.id = id;
|
|
44
41
|
this.mergeTreeTextHelper = this.client.createTextHelper();
|
|
45
42
|
}
|
|
@@ -50,7 +47,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
50
47
|
* @param props - The properties of the marker
|
|
51
48
|
*/
|
|
52
49
|
insertMarkerRelative(relativePos1, refType, props) {
|
|
53
|
-
const segment = new
|
|
50
|
+
const segment = new Marker(refType);
|
|
54
51
|
if (props) {
|
|
55
52
|
segment.addProperties(props);
|
|
56
53
|
}
|
|
@@ -61,7 +58,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
61
58
|
* {@inheritDoc ISharedString.insertMarker}
|
|
62
59
|
*/
|
|
63
60
|
insertMarker(pos, refType, props) {
|
|
64
|
-
const segment = new
|
|
61
|
+
const segment = new Marker(refType);
|
|
65
62
|
if (props) {
|
|
66
63
|
segment.addProperties(props);
|
|
67
64
|
}
|
|
@@ -74,7 +71,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
74
71
|
* @param props - The properties of text
|
|
75
72
|
*/
|
|
76
73
|
insertTextRelative(relativePos1, text, props) {
|
|
77
|
-
const segment = new
|
|
74
|
+
const segment = new TextSegment(text);
|
|
78
75
|
if (props) {
|
|
79
76
|
segment.addProperties(props);
|
|
80
77
|
}
|
|
@@ -85,7 +82,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
85
82
|
* {@inheritDoc ISharedString.insertText}
|
|
86
83
|
*/
|
|
87
84
|
insertText(pos, text, props) {
|
|
88
|
-
const segment = new
|
|
85
|
+
const segment = new TextSegment(text);
|
|
89
86
|
if (props) {
|
|
90
87
|
segment.addProperties(props);
|
|
91
88
|
}
|
|
@@ -99,7 +96,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
99
96
|
* @param props - Optional. The properties of the replacement text
|
|
100
97
|
*/
|
|
101
98
|
replaceText(start, end, text, props) {
|
|
102
|
-
this.replaceRange(start, end,
|
|
99
|
+
this.replaceRange(start, end, TextSegment.make(text, props));
|
|
103
100
|
}
|
|
104
101
|
/**
|
|
105
102
|
* Removes the text in the given range.
|
|
@@ -195,7 +192,6 @@ class SharedString extends sequence_1.SharedSegmentSequence {
|
|
|
195
192
|
}
|
|
196
193
|
}
|
|
197
194
|
}
|
|
198
|
-
exports.SharedString = SharedString;
|
|
199
195
|
/**
|
|
200
196
|
* Splits the text into regions ending with markers with the given `label`.
|
|
201
197
|
* @param sharedString - String to retrieve text and markers from
|
|
@@ -211,21 +207,20 @@ exports.SharedString = SharedString;
|
|
|
211
207
|
* ```
|
|
212
208
|
* @internal
|
|
213
209
|
*/
|
|
214
|
-
function getTextAndMarkers(sharedString, label, start, end) {
|
|
210
|
+
export function getTextAndMarkers(sharedString, label, start, end) {
|
|
215
211
|
const accum = {
|
|
216
212
|
parallelMarkerLabel: label,
|
|
217
213
|
parallelMarkers: [],
|
|
218
214
|
parallelText: [],
|
|
219
215
|
tagsInProgress: [],
|
|
220
|
-
textSegment: new
|
|
216
|
+
textSegment: new TextSegment(""),
|
|
221
217
|
};
|
|
222
218
|
sharedString.walkSegments(gatherTextAndMarkers, start, end, accum);
|
|
223
219
|
return { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };
|
|
224
220
|
}
|
|
225
|
-
exports.getTextAndMarkers = getTextAndMarkers;
|
|
226
221
|
const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumText) => {
|
|
227
222
|
const { placeholder, tagsInProgress, textSegment } = accumText;
|
|
228
|
-
if (
|
|
223
|
+
if (TextSegment.is(segment)) {
|
|
229
224
|
let beginTags = "";
|
|
230
225
|
let endTags = "";
|
|
231
226
|
// TODO: let clients pass in function to get tag
|
|
@@ -289,7 +284,7 @@ const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumT
|
|
|
289
284
|
}
|
|
290
285
|
else {
|
|
291
286
|
const marker = segment;
|
|
292
|
-
if (
|
|
287
|
+
if (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {
|
|
293
288
|
accumText.parallelMarkers.push(marker);
|
|
294
289
|
accumText.parallelText.push(textSegment.text);
|
|
295
290
|
textSegment.text = "";
|
|
@@ -298,4 +293,4 @@ const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumT
|
|
|
298
293
|
}
|
|
299
294
|
return true;
|
|
300
295
|
};
|
|
301
|
-
//# sourceMappingURL=sharedString.
|
|
296
|
+
//# sourceMappingURL=sharedString.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedString.mjs","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAQN,MAAM,EAIN,eAAe,EACf,WAAW,GACX,MAAM,4BAA4B;OAE5B,EAAE,qBAAqB,EAAE;OACzB,EAAE,mBA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AAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;SACpC;aAAM;YACN,MAAM,MAAM,GAAG,OAAiB,CAAC;YACjC,IAAI,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE;gBAC3D,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC9C,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;aACtB;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICombiningOp,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferencePosition,\n\tReferenceType,\n\trefHasTileLabel,\n\tTextSegment,\n} from \"@fluidframework/merge-tree\";\nimport { IFluidDataStoreRuntime, IChannelAttributes } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\nimport { SharedStringFactory } from \"./sequenceFactory\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n * @alpha\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n\t/**\n\t * Inserts the text at the position.\n\t * @param pos - The position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of the text\n\t */\n\tinsertText(pos: number, text: string, props?: PropertySet): void;\n\n\t/**\n\t * Inserts a marker at the position.\n\t * @param pos - The position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tinsertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined;\n\n\t/**\n\t * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n\t */\n\tposFromRelativePos(relativePos: IRelativePosition): number;\n}\n\n/**\n * @alpha\n */\nexport type SharedStringSegment = TextSegment | Marker;\n\n/**\n * The Shared String is a specialized data structure for handling collaborative\n * text. It is based on a more general Sequence data structure but has\n * additional features that make working with text easier.\n *\n * In addition to text, a Shared String can also contain markers. Markers can be\n * used to store metadata at positions within the text, like the details of an\n * image or Fluid object that should be rendered with the text.\n * @alpha\n */\nexport class SharedString\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\t/**\n\t * Create a new shared string.\n\t * @param runtime - data store runtime the new shared string belongs to\n\t * @param id - optional name of the shared string\n\t * @returns newly create shared string (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n\t}\n\n\t/**\n\t * Get a factory for SharedString to register with the data store.\n\t * @returns a factory that creates and load SharedString\n\t */\n\tpublic static getFactory() {\n\t\treturn new SharedStringFactory();\n\t}\n\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\tprivate readonly mergeTreeTextHelper: IMergeTreeTextHelper;\n\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(document, id, attributes, SharedStringFactory.segmentFromSpec as any);\n\t\tthis.mergeTreeTextHelper = this.client.createTextHelper();\n\t}\n\n\t/**\n\t * Inserts a marker at a relative position.\n\t * @param relativePos1 - The relative position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\treturn this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Inserts the text at the position.\n\t * @param relativePos1 - The relative position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tpublic insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Replaces a range with the provided text.\n\t * @param start - The inclusive start of the range to replace\n\t * @param end - The exclusive end of the range to replace\n\t * @param text - The text to replace the range with\n\t * @param props - Optional. The properties of the replacement text\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet) {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * Removes the text in the given range.\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to replace\n\t * @returns the message sent.\n\t */\n\tpublic removeText(start: number, end: number): IMergeTreeRemoveMsg {\n\t\treturn this.removeRange(start, end);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties and calls the callback on consensus.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param consensusCallback - The callback called when consensus is reached\n\t *\n\t * @deprecated We no longer intend to support this functionality and it will\n\t * be removed in a future release. There is no replacement for this\n\t * functionality.\n\t */\n\tpublic annotateMarkerNotifyConsensus(\n\t\tmarker: Marker,\n\t\tprops: PropertySet,\n\t\tcallback: (m: Marker) => void,\n\t) {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.annotateMarkerNotifyConsensus(marker, props, callback),\n\t\t);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp) {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props, combiningOp));\n\t}\n\n\t/**\n\t * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.\n\t * Note that Markers receive `ReferenceType.Tile` by default.\n\t * @deprecated Use `searchForMarker` instead.\n\t * @param startPos - Position at which to start the search\n\t * @param clientId - clientId dictating the perspective to search from\n\t * @param tileLabel - Label of the tile to search for\n\t * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`\n\t */\n\tpublic findTile(\n\t\tstartPos: number | undefined,\n\t\ttileLabel: string,\n\t\tpreceding = true,\n\t):\n\t\t| {\n\t\t\t\ttile: ReferencePosition;\n\t\t\t\tpos: number;\n\t\t }\n\t\t| undefined {\n\t\treturn this.client.findTile(startPos ?? 0, tileLabel, preceding);\n\t}\n\n\t/**\n\t * Searches a string for the nearest marker in either direction to a given start position.\n\t * The search will include the start position, so markers at the start position are valid\n\t * results of the search.\n\t * @param startPos - Position at which to start the search\n\t * @param markerLabel - Label of the marker to search for\n\t * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`\n\t */\n\tpublic searchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards = true,\n\t): Marker | undefined {\n\t\treturn this.client.searchForMarker(startPos, markerLabel, forwards);\n\t}\n\n\t/**\n\t * Retrieve text from the SharedString in string format.\n\t * @param start - The starting index of the text to retrieve, or 0 if omitted.\n\t * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n\t * @returns The requested text content as a string.\n\t */\n\tpublic getText(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tpublic getTextWithPlaceholders(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\" \",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\tpublic getTextRangeWithMarkers(start: number, end: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"*\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided\n\t * id in this `SharedString`.\n\t */\n\tpublic getMarkerFromId(id: string): ISegment | undefined {\n\t\treturn this.client.getMarkerFromId(id);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tif (this.client.rollback !== undefined) {\n\t\t\tthis.client.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t}\n\t}\n}\n\ninterface ITextAndMarkerAccumulator {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n\tparallelMarkerLabel: string;\n\tplaceholder?: string;\n\ttagsInProgress: string[];\n\ttextSegment: TextSegment;\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n * @internal\n */\nexport function getTextAndMarkers(\n\tsharedString: SharedString,\n\tlabel: string,\n\tstart?: number,\n\tend?: number,\n): {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n} {\n\tconst accum: ITextAndMarkerAccumulator = {\n\t\tparallelMarkerLabel: label,\n\t\tparallelMarkers: [],\n\t\tparallelText: [],\n\t\ttagsInProgress: [],\n\t\ttextSegment: new TextSegment(\"\"),\n\t};\n\n\tsharedString.walkSegments(gatherTextAndMarkers, start, end, accum);\n\treturn { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };\n}\n\nconst gatherTextAndMarkers: ISegmentAction<ITextAndMarkerAccumulator> = (\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\taccumText: ITextAndMarkerAccumulator,\n) => {\n\tconst { placeholder, tagsInProgress, textSegment } = accumText;\n\tif (TextSegment.is(segment)) {\n\t\tlet beginTags = \"\";\n\t\tlet endTags = \"\";\n\t\t// TODO: let clients pass in function to get tag\n\t\tconst tags = [] as string[];\n\t\tconst initTags = [] as string[];\n\n\t\tif (segment.properties?.[\"font-weight\"]) {\n\t\t\ttags.push(\"b\");\n\t\t}\n\t\tif (segment.properties?.[\"text-decoration\"]) {\n\t\t\ttags.push(\"u\");\n\t\t}\n\t\tconst remTags = [] as string[];\n\t\tif (tags.length > 0) {\n\t\t\tfor (const tag of tags) {\n\t\t\t\tif (!tagsInProgress.includes(tag)) {\n\t\t\t\t\tbeginTags += `<${tag}>`;\n\t\t\t\t\tinitTags.push(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tif (!tags.includes(accumTag)) {\n\t\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\t\tremTags.push(accumTag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const initTag of initTags.reverse()) {\n\t\t\t\ttagsInProgress.push(initTag);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\tremTags.push(accumTag);\n\t\t\t}\n\t\t}\n\t\tfor (const remTag of remTags) {\n\t\t\tconst remdex = tagsInProgress.indexOf(remTag);\n\t\t\tif (remdex >= 0) {\n\t\t\t\ttagsInProgress.splice(remdex, 1);\n\t\t\t}\n\t\t}\n\t\ttextSegment.text += endTags;\n\t\ttextSegment.text += beginTags;\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else {\n\t\tif (placeholder && placeholder.length > 0) {\n\t\t\tconst placeholderText =\n\t\t\t\tplaceholder === \"*\"\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\t `\\n${segment.toString()}`\n\t\t\t\t\t: placeholder.repeat(segment.cachedLength);\n\t\t\ttextSegment.text += placeholderText;\n\t\t} else {\n\t\t\tconst marker = segment as Marker;\n\t\t\tif (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {\n\t\t\t\taccumText.parallelMarkers.push(marker);\n\t\t\t\taccumText.parallelText.push(textSegment.text);\n\t\t\t\ttextSegment.text = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/sequence",
|
|
3
|
-
"version": "2.0.0-internal.7.4.
|
|
3
|
+
"version": "2.0.0-internal.7.4.2",
|
|
4
4
|
"description": "Distributed sequence",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -11,20 +11,32 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
-
"
|
|
15
|
-
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./lib/index.d.mts",
|
|
18
|
+
"default": "./lib/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"main": "dist/index.cjs",
|
|
27
|
+
"module": "lib/index.mjs",
|
|
16
28
|
"types": "dist/index.d.ts",
|
|
17
29
|
"c8": {
|
|
18
30
|
"all": true,
|
|
19
31
|
"cache-dir": "nyc/.cache",
|
|
20
32
|
"exclude": [
|
|
21
33
|
"src/test/**/*.ts",
|
|
22
|
-
"dist/test
|
|
34
|
+
"dist/test/**/*.?js"
|
|
23
35
|
],
|
|
24
36
|
"exclude-after-remap": false,
|
|
25
37
|
"include": [
|
|
26
38
|
"src/**/*.ts",
|
|
27
|
-
"dist
|
|
39
|
+
"dist/**/*.?js"
|
|
28
40
|
],
|
|
29
41
|
"report-dir": "nyc/report",
|
|
30
42
|
"reporter": [
|
|
@@ -35,30 +47,30 @@
|
|
|
35
47
|
"temp-directory": "nyc/.nyc_output"
|
|
36
48
|
},
|
|
37
49
|
"dependencies": {
|
|
38
|
-
"@fluid-internal/client-utils": ">=2.0.0-internal.7.4.
|
|
39
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.4.
|
|
40
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.7.4.
|
|
41
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-internal.7.4.
|
|
42
|
-
"@fluidframework/merge-tree": ">=2.0.0-internal.7.4.
|
|
50
|
+
"@fluid-internal/client-utils": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
51
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
52
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
53
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
54
|
+
"@fluidframework/merge-tree": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
43
55
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
44
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.7.4.
|
|
45
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.7.4.
|
|
46
|
-
"@fluidframework/shared-object-base": ">=2.0.0-internal.7.4.
|
|
47
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.4.
|
|
56
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
57
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
58
|
+
"@fluidframework/shared-object-base": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
59
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
48
60
|
"uuid": "^9.0.0"
|
|
49
61
|
},
|
|
50
62
|
"devDependencies": {
|
|
51
63
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
52
|
-
"@fluid-private/stochastic-test-utils": ">=2.0.0-internal.7.4.
|
|
53
|
-
"@fluid-private/test-dds-utils": ">=2.0.0-internal.7.4.
|
|
64
|
+
"@fluid-private/stochastic-test-utils": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
65
|
+
"@fluid-private/test-dds-utils": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
54
66
|
"@fluid-tools/benchmark": "^0.48.0",
|
|
55
67
|
"@fluid-tools/build-cli": "^0.28.0",
|
|
56
68
|
"@fluidframework/build-common": "^2.0.3",
|
|
57
69
|
"@fluidframework/build-tools": "^0.28.0",
|
|
58
70
|
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
59
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.4.
|
|
71
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
60
72
|
"@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.0.0-internal.7.2.0",
|
|
61
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.4.
|
|
73
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.4.2 <2.0.0-internal.7.5.0",
|
|
62
74
|
"@microsoft/api-extractor": "^7.38.3",
|
|
63
75
|
"@types/diff": "^3.5.1",
|
|
64
76
|
"@types/mocha": "^9.1.1",
|
|
@@ -74,7 +86,10 @@
|
|
|
74
86
|
"moment": "^2.21.0",
|
|
75
87
|
"prettier": "~3.0.3",
|
|
76
88
|
"random-js": "^2.1.0",
|
|
89
|
+
"renamer": "^4.0.0",
|
|
90
|
+
"replace-in-file": "^6.3.5",
|
|
77
91
|
"rimraf": "^4.4.0",
|
|
92
|
+
"tsc-multi": "^1.1.0",
|
|
78
93
|
"typescript": "~5.1.6"
|
|
79
94
|
},
|
|
80
95
|
"fluidBuild": {
|
|
@@ -104,9 +119,10 @@
|
|
|
104
119
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
105
120
|
"build:compile": "fluid-build . --task compile",
|
|
106
121
|
"build:docs": "fluid-build . --task api",
|
|
107
|
-
"build:esnext": "tsc --
|
|
122
|
+
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
|
|
108
123
|
"build:genver": "gen-version",
|
|
109
|
-
"build:
|
|
124
|
+
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
|
|
125
|
+
"build:test": "tsc-multi --config ./tsc-multi.test.json",
|
|
110
126
|
"check:are-the-types-wrong": "attw --pack",
|
|
111
127
|
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
112
128
|
"ci:build:docs": "api-extractor run",
|
|
@@ -125,12 +141,11 @@
|
|
|
125
141
|
"test:coverage": "c8 npm test",
|
|
126
142
|
"test:memory": "mocha --config src/test/memory/.mocharc.js",
|
|
127
143
|
"test:memory-profiling:report": "mocha --config src/test/memory/.mocharc.js",
|
|
128
|
-
"test:mocha": "mocha --ignore \"dist/test/memory/**/*\" --recursive \"dist/test/**/*.spec
|
|
144
|
+
"test:mocha": "mocha --ignore \"dist/test/memory/**/*\" --recursive \"dist/test/**/*.spec.?js\" -r node_modules/@fluidframework/mocha-test-setup",
|
|
129
145
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
130
146
|
"test:newsnapfiles": "node dist/test/createSnapshotFiles.js",
|
|
131
147
|
"test:stress": "cross-env FUZZ_TEST_COUNT=100 FUZZ_STRESS_RUN=true mocha --ignore \"dist/test/memory/**/*\" --recursive \"dist/test/**/*.fuzz.spec.js\" -r @fluidframework/mocha-test-setup",
|
|
132
|
-
"
|
|
133
|
-
"tsc": "tsc",
|
|
148
|
+
"tsc": "tsc-multi --config ../../../common/build/build-common/tsc-multi.cjs.json",
|
|
134
149
|
"typetests:gen": "fluid-type-test-generator",
|
|
135
150
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
136
151
|
}
|
package/sequence.test-files.tar
CHANGED
|
Binary file
|
package/src/packageVersion.ts
CHANGED