@fluidframework/sequence 2.0.0-internal.2.0.2 → 2.0.0-internal.2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -14,13 +14,13 @@
14
14
  *
15
15
  * @packageDocumentation
16
16
  */
17
+ export { IMapMessageLocalMetadata, IValueOpEmitter } from "./defaultMapInterfaces";
17
18
  export { DeserializeCallback, IIntervalCollectionEvent, IIntervalHelpers, Interval, IntervalCollection, IntervalCollectionIterator, IntervalLocator, intervalLocatorFromEndpoint, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, ISerializedIntervalCollectionV2, CompressedSerializedInterval, SerializedIntervalDelta, } from "./intervalCollection";
18
- export { IMapMessageLocalMetadata, IValueOpEmitter, } from "./defaultMapInterfaces";
19
- export * from "./sharedString";
20
- export * from "./sequence";
21
- export * from "./sequenceFactory";
22
- export * from "./sequenceDeltaEvent";
23
- export * from "./sharedSequence";
24
- export * from "./sharedIntervalCollection";
25
19
  export { IInterval, IntervalConflictResolver } from "./intervalTree";
20
+ export { ISharedSegmentSequenceEvents, SharedSegmentSequence } from "./sequence";
21
+ export { ISequenceDeltaRange, SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from "./sequenceDeltaEvent";
22
+ export { SharedStringFactory } from "./sequenceFactory";
23
+ export { getTextAndMarkers, ISharedString, SharedString, SharedStringSegment } from "./sharedString";
24
+ export { ISharedIntervalCollection, SharedIntervalCollection, SharedIntervalCollectionFactory, } from "./sharedIntervalCollection";
25
+ export { IJSONRunSegment, SharedSequence, SubSequence } from "./sharedSequence";
26
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EACH,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,QAA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,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EACN,yBAAyB,EACzB,wBAAwB,EACxB,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -3,30 +3,8 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
6
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.SequenceInterval = exports.IntervalType = exports.intervalLocatorFromEndpoint = exports.IntervalCollectionIterator = exports.IntervalCollection = exports.Interval = void 0;
18
- /**
19
- * Supports distributed data structures which are list-like.
20
- *
21
- * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of
22
- * text.
23
- *
24
- * See the package's README for a high-level introduction to `SharedString`'s feature set.
25
- * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for
26
- * working with text.
27
- *
28
- * @packageDocumentation
29
- */
7
+ exports.SubSequence = exports.SharedSequence = exports.SharedIntervalCollectionFactory = exports.SharedIntervalCollection = exports.SharedString = exports.getTextAndMarkers = exports.SharedStringFactory = exports.SequenceMaintenanceEvent = exports.SequenceEvent = exports.SequenceDeltaEvent = exports.SharedSegmentSequence = exports.SequenceInterval = exports.IntervalType = exports.intervalLocatorFromEndpoint = exports.IntervalCollectionIterator = exports.IntervalCollection = exports.Interval = void 0;
30
8
  var intervalCollection_1 = require("./intervalCollection");
31
9
  Object.defineProperty(exports, "Interval", { enumerable: true, get: function () { return intervalCollection_1.Interval; } });
32
10
  Object.defineProperty(exports, "IntervalCollection", { enumerable: true, get: function () { return intervalCollection_1.IntervalCollection; } });
@@ -34,10 +12,21 @@ Object.defineProperty(exports, "IntervalCollectionIterator", { enumerable: true,
34
12
  Object.defineProperty(exports, "intervalLocatorFromEndpoint", { enumerable: true, get: function () { return intervalCollection_1.intervalLocatorFromEndpoint; } });
35
13
  Object.defineProperty(exports, "IntervalType", { enumerable: true, get: function () { return intervalCollection_1.IntervalType; } });
36
14
  Object.defineProperty(exports, "SequenceInterval", { enumerable: true, get: function () { return intervalCollection_1.SequenceInterval; } });
37
- __exportStar(require("./sharedString"), exports);
38
- __exportStar(require("./sequence"), exports);
39
- __exportStar(require("./sequenceFactory"), exports);
40
- __exportStar(require("./sequenceDeltaEvent"), exports);
41
- __exportStar(require("./sharedSequence"), exports);
42
- __exportStar(require("./sharedIntervalCollection"), exports);
15
+ var sequence_1 = require("./sequence");
16
+ Object.defineProperty(exports, "SharedSegmentSequence", { enumerable: true, get: function () { return sequence_1.SharedSegmentSequence; } });
17
+ var sequenceDeltaEvent_1 = require("./sequenceDeltaEvent");
18
+ Object.defineProperty(exports, "SequenceDeltaEvent", { enumerable: true, get: function () { return sequenceDeltaEvent_1.SequenceDeltaEvent; } });
19
+ Object.defineProperty(exports, "SequenceEvent", { enumerable: true, get: function () { return sequenceDeltaEvent_1.SequenceEvent; } });
20
+ Object.defineProperty(exports, "SequenceMaintenanceEvent", { enumerable: true, get: function () { return sequenceDeltaEvent_1.SequenceMaintenanceEvent; } });
21
+ var sequenceFactory_1 = require("./sequenceFactory");
22
+ Object.defineProperty(exports, "SharedStringFactory", { enumerable: true, get: function () { return sequenceFactory_1.SharedStringFactory; } });
23
+ var sharedString_1 = require("./sharedString");
24
+ Object.defineProperty(exports, "getTextAndMarkers", { enumerable: true, get: function () { return sharedString_1.getTextAndMarkers; } });
25
+ Object.defineProperty(exports, "SharedString", { enumerable: true, get: function () { return sharedString_1.SharedString; } });
26
+ var sharedIntervalCollection_1 = require("./sharedIntervalCollection");
27
+ Object.defineProperty(exports, "SharedIntervalCollection", { enumerable: true, get: function () { return sharedIntervalCollection_1.SharedIntervalCollection; } });
28
+ Object.defineProperty(exports, "SharedIntervalCollectionFactory", { enumerable: true, get: function () { return sharedIntervalCollection_1.SharedIntervalCollectionFactory; } });
29
+ var sharedSequence_1 = require("./sharedSequence");
30
+ Object.defineProperty(exports, "SharedSequence", { enumerable: true, get: function () { return sharedSequence_1.SharedSequence; } });
31
+ Object.defineProperty(exports, "SubSequence", { enumerable: true, get: function () { return sharedSequence_1.SubSequence; } });
43
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAEH;;;;;;;;;;;GAWG;AAEH,2DAgB8B;AAZ1B,8GAAA,QAAQ,OAAA;AACR,wHAAA,kBAAkB,OAAA;AAClB,gIAAA,0BAA0B,OAAA;AAE1B,iIAAA,2BAA2B,OAAA;AAC3B,kHAAA,YAAY,OAAA;AAGZ,sHAAA,gBAAgB,OAAA;AASpB,iDAA+B;AAC/B,6CAA2B;AAC3B,oDAAkC;AAClC,uDAAqC;AACrC,mDAAiC;AACjC,6DAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Supports distributed data structures which are list-like.\n *\n * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of\n * text.\n *\n * See the package's README for a high-level introduction to `SharedString`'s feature set.\n * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for\n * working with text.\n *\n * @packageDocumentation\n */\n\nexport {\n DeserializeCallback,\n IIntervalCollectionEvent,\n IIntervalHelpers,\n Interval,\n IntervalCollection,\n IntervalCollectionIterator,\n IntervalLocator,\n intervalLocatorFromEndpoint,\n IntervalType,\n ISerializableInterval,\n ISerializedInterval,\n SequenceInterval,\n ISerializedIntervalCollectionV2,\n CompressedSerializedInterval,\n SerializedIntervalDelta,\n} from \"./intervalCollection\";\nexport {\n IMapMessageLocalMetadata,\n IValueOpEmitter,\n} from \"./defaultMapInterfaces\";\nexport * from \"./sharedString\";\nexport * from \"./sequence\";\nexport * from \"./sequenceFactory\";\nexport * from \"./sequenceDeltaEvent\";\nexport * from \"./sharedSequence\";\nexport * from \"./sharedIntervalCollection\";\nexport { IInterval, IntervalConflictResolver } from \"./intervalTree\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH,2DAgB8B;AAZ1B,8GAAA,QAAQ,OAAA;AACR,wHAAA,kBAAkB,OAAA;AAClB,gIAAA,0BAA0B,OAAA;AAE1B,iIAAA,2BAA2B,OAAA;AAC3B,kHAAA,YAAY,OAAA;AAGZ,sHAAA,gBAAgB,OAAA;AAMpB,uCAAiF;AAA1C,iHAAA,qBAAqB,OAAA;AAC5D,2DAAwH;AAA1F,wHAAA,kBAAkB,OAAA;AAAE,mHAAA,aAAa,OAAA;AAAE,8HAAA,wBAAwB,OAAA;AACzF,qDAAwD;AAA/C,sHAAA,mBAAmB,OAAA;AAC5B,+CAAqG;AAA5F,iHAAA,iBAAiB,OAAA;AAAiB,4GAAA,YAAY,OAAA;AACvD,uEAIoC;AAFnC,oIAAA,wBAAwB,OAAA;AACxB,2IAAA,+BAA+B,OAAA;AAEhC,mDAAgF;AAAtD,gHAAA,cAAc,OAAA;AAAE,6GAAA,WAAW,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Supports distributed data structures which are list-like.\n *\n * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of\n * text.\n *\n * See the package's README for a high-level introduction to `SharedString`'s feature set.\n * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for\n * working with text.\n *\n * @packageDocumentation\n */\nexport { IMapMessageLocalMetadata, IValueOpEmitter } from \"./defaultMapInterfaces\";\nexport {\n DeserializeCallback,\n IIntervalCollectionEvent,\n IIntervalHelpers,\n Interval,\n IntervalCollection,\n IntervalCollectionIterator,\n IntervalLocator,\n intervalLocatorFromEndpoint,\n IntervalType,\n ISerializableInterval,\n ISerializedInterval,\n SequenceInterval,\n ISerializedIntervalCollectionV2,\n CompressedSerializedInterval,\n SerializedIntervalDelta,\n} from \"./intervalCollection\";\nexport { IInterval, IntervalConflictResolver } from \"./intervalTree\";\nexport { ISharedSegmentSequenceEvents, SharedSegmentSequence } from \"./sequence\";\nexport { ISequenceDeltaRange, SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from \"./sequenceDeltaEvent\";\nexport { SharedStringFactory } from \"./sequenceFactory\";\nexport { getTextAndMarkers, ISharedString, SharedString, SharedStringSegment } from \"./sharedString\";\nexport {\n\tISharedIntervalCollection,\n\tSharedIntervalCollection,\n\tSharedIntervalCollectionFactory,\n} from \"./sharedIntervalCollection\";\nexport { IJSONRunSegment, SharedSequence, SubSequence } from \"./sharedSequence\";\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/sequence";
8
- export declare const pkgVersion = "2.0.0-internal.2.0.2";
8
+ export declare const pkgVersion = "2.0.0-internal.2.1.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/sequence";
11
- exports.pkgVersion = "2.0.0-internal.2.0.2";
11
+ exports.pkgVersion = "2.0.0-internal.2.1.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-internal.2.0.2\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-internal.2.1.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedSequence.d.ts","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EACnD,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACjH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,YAAY;IACpD,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B;AAED,qBAAa,WAAW,CA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B,EAAE,EAAE,MAAM,EACjB,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,QAAQ;IAKnD;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,WAAW;IAWxE;;;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;CAmClE"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SharedSequence = exports.SubSequence = void 0;
8
+ const common_utils_1 = require("@fluidframework/common-utils");
8
9
  const merge_tree_1 = require("@fluidframework/merge-tree");
9
10
  const sequence_1 = require("./sequence");
10
11
  const MaxRun = 128;
@@ -47,14 +48,9 @@ class SubSequence extends merge_tree_1.BaseSegment {
47
48
  return this.items.toString();
48
49
  }
49
50
  append(segment) {
50
- if (!SubSequence.is(segment)) {
51
- throw new Error("can only append another run segment");
52
- }
53
- // Note: Must call 'appendLocalRefs' before modifying this segment's length as
54
- // 'this.cachedLength' is used to adjust the offsets of the local refs.
55
- merge_tree_1.LocalReferenceCollection.append(this, segment);
51
+ (0, common_utils_1.assert)(SubSequence.is(segment), 0x448 /* can only append to another run segment */);
52
+ super.append(segment);
56
53
  this.items = this.items.concat(segment.items);
57
- this.cachedLength = this.items.length;
58
54
  }
59
55
  // TODO: retain removed items for undo
60
56
  // returns true if entire run removed
@@ -1 +1 @@
1
- {"version":3,"file":"sharedSequence.js","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAEoC;AAEp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IAED;;OAEG;IACI,YAAY;QACf,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,KAAa,EAAE,GAAY;QACvC,MAAM,KAAK,GAAsB,EAAE,CAAC;QACpC,IAAI,YAAkC,CAAC;QAEvC,oCAAoC;QACpC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,IAAI,KAAK,EAAE;YACnC,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,CAAC,YAAY,CACb,CAAC,OAAiB,EAAE,EAAE;YAClB,IAAI,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;gBACzB,IAAI,YAAY,KAAK,SAAS,EAAE;oBAC5B,YAAY,GAAG,OAAO,CAAC;iBAC1B;gBACD,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;aAChC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,EACD,KAAK,EACL,GAAG,CAAC,CAAC;QAET,kEAAkE;QAClE,gEAAgE;QAChE,+DAA+D;QAC/D,iEAAiE;QACjE,aAAa;QACb,IAAI,YAAY,KAAK,SAAS,EAAE;YAC5B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;SAC3D;QACD,IAAI,GAAG,KAAK,SAAS,EAAE;YACnB,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAlFD,wCAkFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n BaseSegment, IJSONSegment, ISegment, PropertySet, LocalReferenceCollection,\n} from \"@fluidframework/merge-tree\";\nimport { IChannelAttributes, IFluidDataStoreRuntime, Serializable } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n items: Serializable<T>[];\n}\n\nexport class SubSequence<T> extends BaseSegment {\n public static readonly typeString: string = \"SubSequence\";\n public static is(segment: ISegment): segment is SubSequence<any> {\n return segment.type === SubSequence.typeString;\n }\n public static fromJSONObject<U>(spec: Serializable) {\n if (spec && typeof spec === \"object\" && \"items\" in spec) {\n const segment = new SubSequence<U>(spec.items);\n if (spec.props) {\n segment.addProperties(spec.props);\n }\n return segment;\n }\n return undefined;\n }\n\n public readonly type = SubSequence.typeString;\n\n constructor(public items: Serializable<T>[]) {\n super();\n this.cachedLength = items.length;\n }\n\n public toJSONObject() {\n const obj: IJSONRunSegment<T> = { items: this.items };\n super.addSerializedProps(obj);\n return obj;\n }\n\n public clone(start = 0, end?: number) {\n const clonedItems = this.items.slice(start, end);\n const b = new SubSequence(clonedItems);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment): boolean {\n return SubSequence.is(segment)\n && (this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun);\n }\n\n public toString() {\n return this.items.toString();\n }\n\n public append(segment: ISegment) {\n if (!SubSequence.is(segment)) {\n throw new Error(\"can only append another run segment\");\n }\n\n // Note: Must call 'appendLocalRefs' before modifying this segment's length as\n // 'this.cachedLength' is used to adjust the offsets of the local refs.\n LocalReferenceCollection.append(this, segment);\n\n this.items = this.items.concat(segment.items);\n this.cachedLength = this.items.length;\n }\n\n // TODO: retain removed items for undo\n // returns true if entire run removed\n public removeRange(start: number, end: number) {\n let remnantItems: Serializable<T>[] = [];\n const len = this.items.length;\n if (start > 0) {\n remnantItems = remnantItems.concat(this.items.slice(0, start));\n }\n if (end < len) {\n remnantItems = remnantItems.concat(this.items.slice(end));\n }\n this.items = remnantItems;\n this.cachedLength = this.items.length;\n return (this.items.length === 0);\n }\n\n protected createSplitSegmentAt(pos: number) {\n if (pos > 0) {\n const remainingItems = this.items.slice(pos);\n this.items = this.items.slice(0, pos);\n this.cachedLength = this.items.length;\n const leafSegment = new SubSequence(remainingItems);\n return leafSegment;\n }\n }\n}\n\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n constructor(\n document: IFluidDataStoreRuntime,\n public id: string,\n attributes: IChannelAttributes,\n specToSegment: (spec: IJSONSegment) => ISegment,\n ) {\n super(document, id, attributes, specToSegment);\n }\n\n /**\n * @param pos - The position to insert the items at.\n * @param items - The items to insert.\n * @param props - Optional. Properties to set on the inserted items.\n */\n public insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n const segment = new SubSequence<T>(items);\n if (props) {\n segment.addProperties(props);\n }\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to remove\n */\n public remove(start: number, end: number) {\n this.removeRange(start, end);\n }\n\n /**\n * Returns the total count of items in the sequence\n */\n public getItemCount(): number {\n return this.getLength();\n }\n\n /**\n * Gets the items in the specified range\n *\n * @param start - The inclusive start of the range\n * @param end - The exclusive end of the range\n */\n public getItems(start: number, end?: number): Serializable<T>[] {\n const items: Serializable<T>[] = [];\n let firstSegment: ISegment | undefined;\n\n // Return if the range is incorrect.\n if (end !== undefined && end <= start) {\n return items;\n }\n\n this.walkSegments(\n (segment: ISegment) => {\n if (SubSequence.is(segment)) {\n if (firstSegment === undefined) {\n firstSegment = segment;\n }\n items.push(...segment.items);\n }\n return true;\n },\n start,\n end);\n\n // The above call to walkSegments adds all the items in the walked\n // segments. However, we only want items beginning at |start| in\n // the first segment. Similarly, if |end| is passed in, we only\n // want items until |end| in the last segment. Remove the rest of\n // the items.\n if (firstSegment !== undefined) {\n items.splice(0, start - this.getPosition(firstSegment));\n }\n if (end !== undefined) {\n items.splice(end - start);\n }\n return items;\n }\n}\n"]}
1
+ {"version":3,"file":"sharedSequence.js","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":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;;;;OAKG;IACI,QAAQ,CAAC,KAAa,EAAE,GAAY;QACvC,MAAM,KAAK,GAAsB,EAAE,CAAC;QACpC,IAAI,YAAkC,CAAC;QAEvC,oCAAoC;QACpC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,IAAI,KAAK,EAAE;YACnC,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,CAAC,YAAY,CACb,CAAC,OAAiB,EAAE,EAAE;YAClB,IAAI,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;gBACzB,IAAI,YAAY,KAAK,SAAS,EAAE;oBAC5B,YAAY,GAAG,OAAO,CAAC;iBAC1B;gBACD,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;aAChC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,EACD,KAAK,EACL,GAAG,CAAC,CAAC;QAET,kEAAkE;QAClE,gEAAgE;QAChE,+DAA+D;QAC/D,iEAAiE;QACjE,aAAa;QACb,IAAI,YAAY,KAAK,SAAS,EAAE;YAC5B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;SAC3D;QACD,IAAI,GAAG,KAAK,SAAS,EAAE;YACnB,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAlFD,wCAkFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n BaseSegment, IJSONSegment, ISegment, PropertySet,\n} from \"@fluidframework/merge-tree\";\nimport { IChannelAttributes, IFluidDataStoreRuntime, Serializable } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n items: Serializable<T>[];\n}\n\nexport class SubSequence<T> extends BaseSegment {\n public static readonly typeString: string = \"SubSequence\";\n public static is(segment: ISegment): segment is SubSequence<any> {\n return segment.type === SubSequence.typeString;\n }\n public static fromJSONObject<U>(spec: Serializable) {\n if (spec && typeof spec === \"object\" && \"items\" in spec) {\n const segment = new SubSequence<U>(spec.items);\n if (spec.props) {\n segment.addProperties(spec.props);\n }\n return segment;\n }\n return undefined;\n }\n\n public readonly type = SubSequence.typeString;\n\n constructor(public items: Serializable<T>[]) {\n super();\n this.cachedLength = items.length;\n }\n\n public toJSONObject() {\n const obj: IJSONRunSegment<T> = { items: this.items };\n super.addSerializedProps(obj);\n return obj;\n }\n\n public clone(start = 0, end?: number) {\n const clonedItems = this.items.slice(start, end);\n const b = new SubSequence(clonedItems);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment): boolean {\n return SubSequence.is(segment)\n && (this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun);\n }\n\n public toString() {\n return this.items.toString();\n }\n\n public append(segment: ISegment) {\n assert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);\n super.append(segment);\n this.items = this.items.concat(segment.items);\n }\n\n // TODO: retain removed items for undo\n // returns true if entire run removed\n public removeRange(start: number, end: number) {\n let remnantItems: Serializable<T>[] = [];\n const len = this.items.length;\n if (start > 0) {\n remnantItems = remnantItems.concat(this.items.slice(0, start));\n }\n if (end < len) {\n remnantItems = remnantItems.concat(this.items.slice(end));\n }\n this.items = remnantItems;\n this.cachedLength = this.items.length;\n return (this.items.length === 0);\n }\n\n protected createSplitSegmentAt(pos: number) {\n if (pos > 0) {\n const remainingItems = this.items.slice(pos);\n this.items = this.items.slice(0, pos);\n this.cachedLength = this.items.length;\n const leafSegment = new SubSequence(remainingItems);\n return leafSegment;\n }\n }\n}\n\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n constructor(\n document: IFluidDataStoreRuntime,\n public id: string,\n attributes: IChannelAttributes,\n specToSegment: (spec: IJSONSegment) => ISegment,\n ) {\n super(document, id, attributes, specToSegment);\n }\n\n /**\n * @param pos - The position to insert the items at.\n * @param items - The items to insert.\n * @param props - Optional. Properties to set on the inserted items.\n */\n public insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n const segment = new SubSequence<T>(items);\n if (props) {\n segment.addProperties(props);\n }\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to remove\n */\n public remove(start: number, end: number) {\n this.removeRange(start, end);\n }\n\n /**\n * Returns the total count of items in the sequence\n */\n public getItemCount(): number {\n return this.getLength();\n }\n\n /**\n * Gets the items in the specified range\n *\n * @param start - The inclusive start of the range\n * @param end - The exclusive end of the range\n */\n public getItems(start: number, end?: number): Serializable<T>[] {\n const items: Serializable<T>[] = [];\n let firstSegment: ISegment | undefined;\n\n // Return if the range is incorrect.\n if (end !== undefined && end <= start) {\n return items;\n }\n\n this.walkSegments(\n (segment: ISegment) => {\n if (SubSequence.is(segment)) {\n if (firstSegment === undefined) {\n firstSegment = segment;\n }\n items.push(...segment.items);\n }\n return true;\n },\n start,\n end);\n\n // The above call to walkSegments adds all the items in the walked\n // segments. However, we only want items beginning at |start| in\n // the first segment. Similarly, if |end| is passed in, we only\n // want items until |end| in the last segment. Remove the rest of\n // the items.\n if (firstSegment !== undefined) {\n items.splice(0, start - this.getPosition(firstSegment));\n }\n if (end !== undefined) {\n items.splice(end - start);\n }\n return items;\n }\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -14,13 +14,13 @@
14
14
  *
15
15
  * @packageDocumentation
16
16
  */
17
+ export { IMapMessageLocalMetadata, IValueOpEmitter } from "./defaultMapInterfaces";
17
18
  export { DeserializeCallback, IIntervalCollectionEvent, IIntervalHelpers, Interval, IntervalCollection, IntervalCollectionIterator, IntervalLocator, intervalLocatorFromEndpoint, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, ISerializedIntervalCollectionV2, CompressedSerializedInterval, SerializedIntervalDelta, } from "./intervalCollection";
18
- export { IMapMessageLocalMetadata, IValueOpEmitter, } from "./defaultMapInterfaces";
19
- export * from "./sharedString";
20
- export * from "./sequence";
21
- export * from "./sequenceFactory";
22
- export * from "./sequenceDeltaEvent";
23
- export * from "./sharedSequence";
24
- export * from "./sharedIntervalCollection";
25
19
  export { IInterval, IntervalConflictResolver } from "./intervalTree";
20
+ export { ISharedSegmentSequenceEvents, SharedSegmentSequence } from "./sequence";
21
+ export { ISequenceDeltaRange, SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from "./sequenceDeltaEvent";
22
+ export { SharedStringFactory } from "./sequenceFactory";
23
+ export { getTextAndMarkers, ISharedString, SharedString, SharedStringSegment } from "./sharedString";
24
+ export { ISharedIntervalCollection, SharedIntervalCollection, SharedIntervalCollectionFactory, } from "./sharedIntervalCollection";
25
+ export { IJSONRunSegment, SharedSequence, SubSequence } from "./sharedSequence";
26
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EACH,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,+BAA+B,EAC/B,4BAA4B,EAC5B,uBAAuB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,wBAAwB,EACxB,eAAe,GAClB,MAAM,wBAAwB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EACH,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,+BAA+B,EAC/B,4BAA4B,EAC5B,uBAAuB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EACN,yBAAyB,EACzB,wBAAwB,EACxB,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
package/lib/index.js CHANGED
@@ -2,23 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- /**
6
- * Supports distributed data structures which are list-like.
7
- *
8
- * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of
9
- * text.
10
- *
11
- * See the package's README for a high-level introduction to `SharedString`'s feature set.
12
- * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for
13
- * working with text.
14
- *
15
- * @packageDocumentation
16
- */
17
5
  export { Interval, IntervalCollection, IntervalCollectionIterator, intervalLocatorFromEndpoint, IntervalType, SequenceInterval, } from "./intervalCollection";
18
- export * from "./sharedString";
19
- export * from "./sequence";
20
- export * from "./sequenceFactory";
21
- export * from "./sequenceDeltaEvent";
22
- export * from "./sharedSequence";
23
- export * from "./sharedIntervalCollection";
6
+ export { SharedSegmentSequence } from "./sequence";
7
+ export { SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from "./sequenceDeltaEvent";
8
+ export { SharedStringFactory } from "./sequenceFactory";
9
+ export { getTextAndMarkers, SharedString } from "./sharedString";
10
+ export { SharedIntervalCollection, SharedIntervalCollectionFactory, } from "./sharedIntervalCollection";
11
+ export { SharedSequence, SubSequence } from "./sharedSequence";
24
12
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EAIH,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAE1B,2BAA2B,EAC3B,YAAY,EAGZ,gBAAgB,GAInB,MAAM,sBAAsB,CAAC;AAK9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Supports distributed data structures which are list-like.\n *\n * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of\n * text.\n *\n * See the package's README for a high-level introduction to `SharedString`'s feature set.\n * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for\n * working with text.\n *\n * @packageDocumentation\n */\n\nexport {\n DeserializeCallback,\n IIntervalCollectionEvent,\n IIntervalHelpers,\n Interval,\n IntervalCollection,\n IntervalCollectionIterator,\n IntervalLocator,\n intervalLocatorFromEndpoint,\n IntervalType,\n ISerializableInterval,\n ISerializedInterval,\n SequenceInterval,\n ISerializedIntervalCollectionV2,\n CompressedSerializedInterval,\n SerializedIntervalDelta,\n} from \"./intervalCollection\";\nexport {\n IMapMessageLocalMetadata,\n IValueOpEmitter,\n} from \"./defaultMapInterfaces\";\nexport * from \"./sharedString\";\nexport * from \"./sequence\";\nexport * from \"./sequenceFactory\";\nexport * from \"./sequenceDeltaEvent\";\nexport * from \"./sharedSequence\";\nexport * from \"./sharedIntervalCollection\";\nexport { IInterval, IntervalConflictResolver } from \"./intervalTree\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAIH,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAE1B,2BAA2B,EAC3B,YAAY,EAGZ,gBAAgB,GAInB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAgC,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAuB,kBAAkB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAiB,YAAY,EAAuB,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAEN,wBAAwB,EACxB,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAmB,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Supports distributed data structures which are list-like.\n *\n * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of\n * text.\n *\n * See the package's README for a high-level introduction to `SharedString`'s feature set.\n * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for\n * working with text.\n *\n * @packageDocumentation\n */\nexport { IMapMessageLocalMetadata, IValueOpEmitter } from \"./defaultMapInterfaces\";\nexport {\n DeserializeCallback,\n IIntervalCollectionEvent,\n IIntervalHelpers,\n Interval,\n IntervalCollection,\n IntervalCollectionIterator,\n IntervalLocator,\n intervalLocatorFromEndpoint,\n IntervalType,\n ISerializableInterval,\n ISerializedInterval,\n SequenceInterval,\n ISerializedIntervalCollectionV2,\n CompressedSerializedInterval,\n SerializedIntervalDelta,\n} from \"./intervalCollection\";\nexport { IInterval, IntervalConflictResolver } from \"./intervalTree\";\nexport { ISharedSegmentSequenceEvents, SharedSegmentSequence } from \"./sequence\";\nexport { ISequenceDeltaRange, SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from \"./sequenceDeltaEvent\";\nexport { SharedStringFactory } from \"./sequenceFactory\";\nexport { getTextAndMarkers, ISharedString, SharedString, SharedStringSegment } from \"./sharedString\";\nexport {\n\tISharedIntervalCollection,\n\tSharedIntervalCollection,\n\tSharedIntervalCollectionFactory,\n} from \"./sharedIntervalCollection\";\nexport { IJSONRunSegment, SharedSequence, SubSequence } from \"./sharedSequence\";\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/sequence";
8
- export declare const pkgVersion = "2.0.0-internal.2.0.2";
8
+ export declare const pkgVersion = "2.0.0-internal.2.1.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/sequence";
8
- export const pkgVersion = "2.0.0-internal.2.0.2";
8
+ export const pkgVersion = "2.0.0-internal.2.1.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-internal.2.0.2\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-internal.2.1.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedSequence.d.ts","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EACnD,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACjH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,MAAM,WAAW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AAC,CAAE,SAAQ,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAG7D,EAAE,EAAE,MAAM;gBADjB,QAAQ,EAAE,sBAAsB,EACzB,EAAE,EAAE,MAAM,EACjB,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,QAAQ;IAKnD;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,WAAW;IAWxE;;;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;CAmClE"}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { BaseSegment, LocalReferenceCollection, } from "@fluidframework/merge-tree";
5
+ import { assert } from "@fluidframework/common-utils";
6
+ import { BaseSegment, } from "@fluidframework/merge-tree";
6
7
  import { SharedSegmentSequence } from "./sequence";
7
8
  const MaxRun = 128;
8
9
  export class SubSequence extends BaseSegment {
@@ -44,14 +45,9 @@ export class SubSequence extends BaseSegment {
44
45
  return this.items.toString();
45
46
  }
46
47
  append(segment) {
47
- if (!SubSequence.is(segment)) {
48
- throw new Error("can only append another run segment");
49
- }
50
- // Note: Must call 'appendLocalRefs' before modifying this segment's length as
51
- // 'this.cachedLength' is used to adjust the offsets of the local refs.
52
- LocalReferenceCollection.append(this, segment);
48
+ assert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);
49
+ super.append(segment);
53
50
  this.items = this.items.concat(segment.items);
54
- this.cachedLength = this.items.length;
55
51
  }
56
52
  // TODO: retain removed items for undo
57
53
  // returns true if entire run removed
@@ -1 +1 @@
1
- {"version":3,"file":"sharedSequence.js","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,WAAW,EAAuC,wBAAwB,GAC7E,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,GAAG,GAAG,CAAC;AAMnB,MAAM,OAAO,WAAe,SAAQ,WAAW;IAkB3C,YAAmB,KAAwB;QACvC,KAAK,EAAE,CAAC;QADO,UAAK,GAAL,KAAK,CAAmB;QAF3B,SAAI,GAAG,WAAW,CAAC,UAAU,CAAC;QAI1C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;IACrC,CAAC;IAnBM,MAAM,CAAC,EAAE,CAAC,OAAiB;QAC9B,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC;IACnD,CAAC;IACM,MAAM,CAAC,cAAc,CAAI,IAAkB;QAC9C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,EAAE;YACrD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAI,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrC;YACD,OAAO,OAAO,CAAC;SAClB;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IASM,YAAY;QACf,MAAM,GAAG,GAAuB,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACtD,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,GAAG,CAAC;IACf,CAAC;IAEM,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAY;QAChC,MAAM,WAAW,GAAG,IAA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!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n BaseSegment, IJSONSegment, ISegment, PropertySet, LocalReferenceCollection,\n} from \"@fluidframework/merge-tree\";\nimport { IChannelAttributes, IFluidDataStoreRuntime, Serializable } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n items: Serializable<T>[];\n}\n\nexport class SubSequence<T> extends BaseSegment {\n public static readonly typeString: string = \"SubSequence\";\n public static is(segment: ISegment): segment is SubSequence<any> {\n return segment.type === SubSequence.typeString;\n }\n public static fromJSONObject<U>(spec: Serializable) {\n if (spec && typeof spec === \"object\" && \"items\" in spec) {\n const segment = new SubSequence<U>(spec.items);\n if (spec.props) {\n segment.addProperties(spec.props);\n }\n return segment;\n }\n return undefined;\n }\n\n public readonly type = SubSequence.typeString;\n\n constructor(public items: Serializable<T>[]) {\n super();\n this.cachedLength = items.length;\n }\n\n public toJSONObject() {\n const obj: IJSONRunSegment<T> = { items: this.items };\n super.addSerializedProps(obj);\n return obj;\n }\n\n public clone(start = 0, end?: number) {\n const clonedItems = this.items.slice(start, end);\n const b = new SubSequence(clonedItems);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment): boolean {\n return SubSequence.is(segment)\n && (this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun);\n }\n\n public toString() {\n return this.items.toString();\n }\n\n public append(segment: ISegment) {\n if (!SubSequence.is(segment)) {\n throw new Error(\"can only append another run segment\");\n }\n\n // Note: Must call 'appendLocalRefs' before modifying this segment's length as\n // 'this.cachedLength' is used to adjust the offsets of the local refs.\n LocalReferenceCollection.append(this, segment);\n\n this.items = this.items.concat(segment.items);\n this.cachedLength = this.items.length;\n }\n\n // TODO: retain removed items for undo\n // returns true if entire run removed\n public removeRange(start: number, end: number) {\n let remnantItems: Serializable<T>[] = [];\n const len = this.items.length;\n if (start > 0) {\n remnantItems = remnantItems.concat(this.items.slice(0, start));\n }\n if (end < len) {\n remnantItems = remnantItems.concat(this.items.slice(end));\n }\n this.items = remnantItems;\n this.cachedLength = this.items.length;\n return (this.items.length === 0);\n }\n\n protected createSplitSegmentAt(pos: number) {\n if (pos > 0) {\n const remainingItems = this.items.slice(pos);\n this.items = this.items.slice(0, pos);\n this.cachedLength = this.items.length;\n const leafSegment = new SubSequence(remainingItems);\n return leafSegment;\n }\n }\n}\n\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n constructor(\n document: IFluidDataStoreRuntime,\n public id: string,\n attributes: IChannelAttributes,\n specToSegment: (spec: IJSONSegment) => ISegment,\n ) {\n super(document, id, attributes, specToSegment);\n }\n\n /**\n * @param pos - The position to insert the items at.\n * @param items - The items to insert.\n * @param props - Optional. Properties to set on the inserted items.\n */\n public insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n const segment = new SubSequence<T>(items);\n if (props) {\n segment.addProperties(props);\n }\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to remove\n */\n public remove(start: number, end: number) {\n this.removeRange(start, end);\n }\n\n /**\n * Returns the total count of items in the sequence\n */\n public getItemCount(): number {\n return this.getLength();\n }\n\n /**\n * Gets the items in the specified range\n *\n * @param start - The inclusive start of the range\n * @param end - The exclusive end of the range\n */\n public getItems(start: number, end?: number): Serializable<T>[] {\n const items: Serializable<T>[] = [];\n let firstSegment: ISegment | undefined;\n\n // Return if the range is incorrect.\n if (end !== undefined && end <= start) {\n return items;\n }\n\n this.walkSegments(\n (segment: ISegment) => {\n if (SubSequence.is(segment)) {\n if (firstSegment === undefined) {\n firstSegment = segment;\n }\n items.push(...segment.items);\n }\n return true;\n },\n start,\n end);\n\n // The above call to walkSegments adds all the items in the walked\n // segments. However, we only want items beginning at |start| in\n // the first segment. Similarly, if |end| is passed in, we only\n // want items until |end| in the last segment. Remove the rest of\n // the items.\n if (firstSegment !== undefined) {\n items.splice(0, start - this.getPosition(firstSegment));\n }\n if (end !== undefined) {\n items.splice(end - start);\n }\n return items;\n }\n}\n"]}
1
+ {"version":3,"file":"sharedSequence.js","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EACH,WAAW,GACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,GAAG,GAAG,CAAC;AAMnB,MAAM,OAAO,WAAe,SAAQ,WAAW;IAkB3C,YAAmB,KAAwB;QACvC,KAAK,EAAE,CAAC;QADO,UAAK,GAAL,KAAK,CAAmB;QAF3B,SAAI,GAAG,WAAW,CAAC,UAAU,CAAC;QAI1C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;IACrC,CAAC;IAnBM,MAAM,CAAC,EAAE,CAAC,OAAiB;QAC9B,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC;IACnD,CAAC;IACM,MAAM,CAAC,cAAc,CAAI,IAAkB;QAC9C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,EAAE;YACrD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAI,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrC;YACD,OAAO,OAAO,CAAC;SAClB;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IASM,YAAY;QACf,MAAM,GAAG,GAAuB,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACtD,KAAK,CAAC,kBAAkB,C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copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n BaseSegment, IJSONSegment, ISegment, PropertySet,\n} from \"@fluidframework/merge-tree\";\nimport { IChannelAttributes, IFluidDataStoreRuntime, Serializable } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n items: Serializable<T>[];\n}\n\nexport class SubSequence<T> extends BaseSegment {\n public static readonly typeString: string = \"SubSequence\";\n public static is(segment: ISegment): segment is SubSequence<any> {\n return segment.type === SubSequence.typeString;\n }\n public static fromJSONObject<U>(spec: Serializable) {\n if (spec && typeof spec === \"object\" && \"items\" in spec) {\n const segment = new SubSequence<U>(spec.items);\n if (spec.props) {\n segment.addProperties(spec.props);\n }\n return segment;\n }\n return undefined;\n }\n\n public readonly type = SubSequence.typeString;\n\n constructor(public items: Serializable<T>[]) {\n super();\n this.cachedLength = items.length;\n }\n\n public toJSONObject() {\n const obj: IJSONRunSegment<T> = { items: this.items };\n super.addSerializedProps(obj);\n return obj;\n }\n\n public clone(start = 0, end?: number) {\n const clonedItems = this.items.slice(start, end);\n const b = new SubSequence(clonedItems);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment): boolean {\n return SubSequence.is(segment)\n && (this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun);\n }\n\n public toString() {\n return this.items.toString();\n }\n\n public append(segment: ISegment) {\n assert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);\n super.append(segment);\n this.items = this.items.concat(segment.items);\n }\n\n // TODO: retain removed items for undo\n // returns true if entire run removed\n public removeRange(start: number, end: number) {\n let remnantItems: Serializable<T>[] = [];\n const len = this.items.length;\n if (start > 0) {\n remnantItems = remnantItems.concat(this.items.slice(0, start));\n }\n if (end < len) {\n remnantItems = remnantItems.concat(this.items.slice(end));\n }\n this.items = remnantItems;\n this.cachedLength = this.items.length;\n return (this.items.length === 0);\n }\n\n protected createSplitSegmentAt(pos: number) {\n if (pos > 0) {\n const remainingItems = this.items.slice(pos);\n this.items = this.items.slice(0, pos);\n this.cachedLength = this.items.length;\n const leafSegment = new SubSequence(remainingItems);\n return leafSegment;\n }\n }\n}\n\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n constructor(\n document: IFluidDataStoreRuntime,\n public id: string,\n attributes: IChannelAttributes,\n specToSegment: (spec: IJSONSegment) => ISegment,\n ) {\n super(document, id, attributes, specToSegment);\n }\n\n /**\n * @param pos - The position to insert the items at.\n * @param items - The items to insert.\n * @param props - Optional. Properties to set on the inserted items.\n */\n public insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n const segment = new SubSequence<T>(items);\n if (props) {\n segment.addProperties(props);\n }\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to remove\n */\n public remove(start: number, end: number) {\n this.removeRange(start, end);\n }\n\n /**\n * Returns the total count of items in the sequence\n */\n public getItemCount(): number {\n return this.getLength();\n }\n\n /**\n * Gets the items in the specified range\n *\n * @param start - The inclusive start of the range\n * @param end - The exclusive end of the range\n */\n public getItems(start: number, end?: number): Serializable<T>[] {\n const items: Serializable<T>[] = [];\n let firstSegment: ISegment | undefined;\n\n // Return if the range is incorrect.\n if (end !== undefined && end <= start) {\n return items;\n }\n\n this.walkSegments(\n (segment: ISegment) => {\n if (SubSequence.is(segment)) {\n if (firstSegment === undefined) {\n firstSegment = segment;\n }\n items.push(...segment.items);\n }\n return true;\n },\n start,\n end);\n\n // The above call to walkSegments adds all the items in the walked\n // segments. However, we only want items beginning at |start| in\n // the first segment. Similarly, if |end| is passed in, we only\n // want items until |end| in the last segment. Remove the rest of\n // the items.\n if (firstSegment !== undefined) {\n items.splice(0, start - this.getPosition(firstSegment));\n }\n if (end !== undefined) {\n items.splice(end - start);\n }\n return items;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/sequence",
3
- "version": "2.0.0-internal.2.0.2",
3
+ "version": "2.0.0-internal.2.1.0",
4
4
  "description": "Distributed sequence",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -38,11 +38,9 @@
38
38
  "test:mocha": "mocha --ignore 'dist/test/memory/**/*' --recursive 'dist/test/**/*.spec.js' -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
39
39
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
40
40
  "test:newsnapfiles": "node dist/test/createSnapshotFiles.js",
41
- "test:stress": "cross-env FUZZ_TEST_COUNT=100 FUZZ_STRESS_RUN=true npm run test:mocha",
41
+ "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 --unhandled-rejections=strict",
42
42
  "testfarm": "node dist/test/testFarm.js",
43
43
  "tsc": "tsc",
44
- "tsfmt": "tsfmt --verify",
45
- "tsfmt:fix": "tsfmt --replace",
46
44
  "typetests:gen": "fluid-type-validator -g -d ."
47
45
  },
48
46
  "nyc": {
@@ -68,29 +66,30 @@
68
66
  "dependencies": {
69
67
  "@fluidframework/common-definitions": "^0.20.1",
70
68
  "@fluidframework/common-utils": "^1.0.0",
71
- "@fluidframework/container-utils": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
72
- "@fluidframework/core-interfaces": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
73
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
74
- "@fluidframework/merge-tree": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
69
+ "@fluidframework/container-utils": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
70
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
71
+ "@fluidframework/datastore-definitions": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
72
+ "@fluidframework/merge-tree": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
75
73
  "@fluidframework/protocol-definitions": "^1.1.0",
76
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
77
- "@fluidframework/runtime-utils": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
78
- "@fluidframework/shared-object-base": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
79
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
74
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
75
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
76
+ "@fluidframework/shared-object-base": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
77
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
80
78
  "uuid": "^8.3.1"
81
79
  },
82
80
  "devDependencies": {
83
- "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
84
- "@fluid-internal/test-dds-utils": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
81
+ "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
82
+ "@fluid-internal/test-dds-utils": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
85
83
  "@fluid-tools/benchmark": "^0.43.0",
86
- "@fluidframework/build-common": "^1.0.0",
87
- "@fluidframework/build-tools": "^0.4.6000",
88
- "@fluidframework/eslint-config-fluid": "^1.0.0",
84
+ "@fluid-tools/build-cli": "^0.5.0",
85
+ "@fluidframework/build-common": "^1.1.0",
86
+ "@fluidframework/build-tools": "^0.5.0",
87
+ "@fluidframework/eslint-config-fluid": "^1.1.0",
89
88
  "@fluidframework/gitresources": "^0.1038.2000",
90
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
89
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
91
90
  "@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.0.0-internal.2.0.0",
92
91
  "@fluidframework/server-services-client": "^0.1038.2000",
93
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.2.0.2 <2.0.0-internal.3.0.0",
92
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
94
93
  "@microsoft/api-extractor": "^7.22.2",
95
94
  "@rushstack/eslint-config": "^2.5.1",
96
95
  "@types/diff": "^3.5.1",
@@ -106,11 +105,10 @@
106
105
  "nyc": "^15.0.0",
107
106
  "random-js": "^1.0.8",
108
107
  "rimraf": "^2.6.2",
109
- "typescript": "~4.5.5",
110
- "typescript-formatter": "7.1.0"
108
+ "typescript": "~4.5.5"
111
109
  },
112
110
  "typeValidation": {
113
- "version": "2.0.0-internal.2.0.1",
111
+ "version": "2.0.0-internal.2.1.0",
114
112
  "broken": {}
115
113
  }
116
114
  }
package/src/index.ts CHANGED
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * @packageDocumentation
17
17
  */
18
-
18
+ export { IMapMessageLocalMetadata, IValueOpEmitter } from "./defaultMapInterfaces";
19
19
  export {
20
20
  DeserializeCallback,
21
21
  IIntervalCollectionEvent,
@@ -33,14 +33,14 @@ export {
33
33
  CompressedSerializedInterval,
34
34
  SerializedIntervalDelta,
35
35
  } from "./intervalCollection";
36
- export {
37
- IMapMessageLocalMetadata,
38
- IValueOpEmitter,
39
- } from "./defaultMapInterfaces";
40
- export * from "./sharedString";
41
- export * from "./sequence";
42
- export * from "./sequenceFactory";
43
- export * from "./sequenceDeltaEvent";
44
- export * from "./sharedSequence";
45
- export * from "./sharedIntervalCollection";
46
36
  export { IInterval, IntervalConflictResolver } from "./intervalTree";
37
+ export { ISharedSegmentSequenceEvents, SharedSegmentSequence } from "./sequence";
38
+ export { ISequenceDeltaRange, SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from "./sequenceDeltaEvent";
39
+ export { SharedStringFactory } from "./sequenceFactory";
40
+ export { getTextAndMarkers, ISharedString, SharedString, SharedStringSegment } from "./sharedString";
41
+ export {
42
+ ISharedIntervalCollection,
43
+ SharedIntervalCollection,
44
+ SharedIntervalCollectionFactory,
45
+ } from "./sharedIntervalCollection";
46
+ export { IJSONRunSegment, SharedSequence, SubSequence } from "./sharedSequence";
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/sequence";
9
- export const pkgVersion = "2.0.0-internal.2.0.2";
9
+ export const pkgVersion = "2.0.0-internal.2.1.0";
@@ -3,8 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { assert } from "@fluidframework/common-utils";
6
7
  import {
7
- BaseSegment, IJSONSegment, ISegment, PropertySet, LocalReferenceCollection,
8
+ BaseSegment, IJSONSegment, ISegment, PropertySet,
8
9
  } from "@fluidframework/merge-tree";
9
10
  import { IChannelAttributes, IFluidDataStoreRuntime, Serializable } from "@fluidframework/datastore-definitions";
10
11
  import { SharedSegmentSequence } from "./sequence";
@@ -61,16 +62,9 @@ export class SubSequence<T> extends BaseSegment {
61
62
  }
62
63
 
63
64
  public append(segment: ISegment) {
64
- if (!SubSequence.is(segment)) {
65
- throw new Error("can only append another run segment");
66
- }
67
-
68
- // Note: Must call 'appendLocalRefs' before modifying this segment's length as
69
- // 'this.cachedLength' is used to adjust the offsets of the local refs.
70
- LocalReferenceCollection.append(this, segment);
71
-
65
+ assert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);
66
+ super.append(segment);
72
67
  this.items = this.items.concat(segment.items);
73
- this.cachedLength = this.items.length;
74
68
  }
75
69
 
76
70
  // TODO: retain removed items for undo