@fluidframework/merge-tree 2.42.0 → 2.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/client.d.ts +7 -5
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +17 -14
  5. package/dist/client.js.map +1 -1
  6. package/dist/collections/list.d.ts +95 -5
  7. package/dist/collections/list.d.ts.map +1 -1
  8. package/dist/collections/list.js +67 -5
  9. package/dist/collections/list.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +3 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/mergeTree.d.ts +9 -9
  15. package/dist/mergeTree.d.ts.map +1 -1
  16. package/dist/mergeTree.js +18 -10
  17. package/dist/mergeTree.js.map +1 -1
  18. package/dist/perspective.d.ts +1 -1
  19. package/dist/perspective.d.ts.map +1 -1
  20. package/dist/perspective.js +2 -2
  21. package/dist/perspective.js.map +1 -1
  22. package/dist/revertibles.js +1 -1
  23. package/dist/revertibles.js.map +1 -1
  24. package/dist/test/beastTest.spec.js +1 -1
  25. package/dist/test/beastTest.spec.js.map +1 -1
  26. package/dist/test/client.annotateMarker.spec.js +1 -1
  27. package/dist/test/client.annotateMarker.spec.js.map +1 -1
  28. package/dist/test/client.applyMsg.spec.js +21 -21
  29. package/dist/test/client.applyMsg.spec.js.map +1 -1
  30. package/dist/test/client.attributionFarm.spec.js +1 -1
  31. package/dist/test/client.attributionFarm.spec.js.map +1 -1
  32. package/dist/test/client.getPosition.spec.js +1 -0
  33. package/dist/test/client.getPosition.spec.js.map +1 -1
  34. package/dist/test/client.localReference.spec.js +62 -48
  35. package/dist/test/client.localReference.spec.js.map +1 -1
  36. package/dist/test/client.localReferenceFarm.spec.js +1 -0
  37. package/dist/test/client.localReferenceFarm.spec.js.map +1 -1
  38. package/dist/test/client.rollback.spec.js +8 -6
  39. package/dist/test/client.rollback.spec.js.map +1 -1
  40. package/dist/test/mergeTree.annotate.spec.js +25 -25
  41. package/dist/test/mergeTree.annotate.spec.js.map +1 -1
  42. package/dist/test/mergeTree.markRangeRemoved.spec.js +1 -1
  43. package/dist/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
  44. package/dist/test/obliterate.spec.js +4 -4
  45. package/dist/test/obliterate.spec.js.map +1 -1
  46. package/dist/test/resetPendingSegmentsToOp.spec.js +4 -4
  47. package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  48. package/dist/test/snapshot.utils.js +1 -1
  49. package/dist/test/snapshot.utils.js.map +1 -1
  50. package/dist/test/sortedSegmentSet.spec.js +3 -3
  51. package/dist/test/sortedSegmentSet.spec.js.map +1 -1
  52. package/dist/test/testClient.js +3 -3
  53. package/dist/test/testClient.js.map +1 -1
  54. package/dist/test/tracking.spec.js +7 -7
  55. package/dist/test/tracking.spec.js.map +1 -1
  56. package/dist/test/wordUnitTests.spec.js.map +1 -1
  57. package/lib/client.d.ts +7 -5
  58. package/lib/client.d.ts.map +1 -1
  59. package/lib/client.js +18 -15
  60. package/lib/client.js.map +1 -1
  61. package/lib/collections/list.d.ts +95 -5
  62. package/lib/collections/list.d.ts.map +1 -1
  63. package/lib/collections/list.js +67 -5
  64. package/lib/collections/list.js.map +1 -1
  65. package/lib/index.d.ts +1 -1
  66. package/lib/index.d.ts.map +1 -1
  67. package/lib/index.js +1 -1
  68. package/lib/index.js.map +1 -1
  69. package/lib/mergeTree.d.ts +9 -9
  70. package/lib/mergeTree.d.ts.map +1 -1
  71. package/lib/mergeTree.js +18 -10
  72. package/lib/mergeTree.js.map +1 -1
  73. package/lib/perspective.d.ts +1 -1
  74. package/lib/perspective.d.ts.map +1 -1
  75. package/lib/perspective.js +2 -2
  76. package/lib/perspective.js.map +1 -1
  77. package/lib/revertibles.js +1 -1
  78. package/lib/revertibles.js.map +1 -1
  79. package/lib/test/beastTest.spec.js +1 -1
  80. package/lib/test/beastTest.spec.js.map +1 -1
  81. package/lib/test/client.annotateMarker.spec.js +1 -1
  82. package/lib/test/client.annotateMarker.spec.js.map +1 -1
  83. package/lib/test/client.applyMsg.spec.js +21 -21
  84. package/lib/test/client.applyMsg.spec.js.map +1 -1
  85. package/lib/test/client.attributionFarm.spec.js +1 -1
  86. package/lib/test/client.attributionFarm.spec.js.map +1 -1
  87. package/lib/test/client.getPosition.spec.js +1 -0
  88. package/lib/test/client.getPosition.spec.js.map +1 -1
  89. package/lib/test/client.localReference.spec.js +62 -48
  90. package/lib/test/client.localReference.spec.js.map +1 -1
  91. package/lib/test/client.localReferenceFarm.spec.js +1 -0
  92. package/lib/test/client.localReferenceFarm.spec.js.map +1 -1
  93. package/lib/test/client.rollback.spec.js +8 -6
  94. package/lib/test/client.rollback.spec.js.map +1 -1
  95. package/lib/test/mergeTree.annotate.spec.js +25 -25
  96. package/lib/test/mergeTree.annotate.spec.js.map +1 -1
  97. package/lib/test/mergeTree.markRangeRemoved.spec.js +1 -1
  98. package/lib/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
  99. package/lib/test/obliterate.spec.js +4 -4
  100. package/lib/test/obliterate.spec.js.map +1 -1
  101. package/lib/test/resetPendingSegmentsToOp.spec.js +4 -4
  102. package/lib/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  103. package/lib/test/snapshot.utils.js +1 -1
  104. package/lib/test/snapshot.utils.js.map +1 -1
  105. package/lib/test/sortedSegmentSet.spec.js +3 -3
  106. package/lib/test/sortedSegmentSet.spec.js.map +1 -1
  107. package/lib/test/testClient.js +3 -3
  108. package/lib/test/testClient.js.map +1 -1
  109. package/lib/test/tracking.spec.js +7 -7
  110. package/lib/test/tracking.spec.js.map +1 -1
  111. package/lib/test/wordUnitTests.spec.js.map +1 -1
  112. package/package.json +18 -18
  113. package/src/client.ts +44 -28
  114. package/src/collections/list.ts +101 -5
  115. package/src/index.ts +3 -0
  116. package/src/mergeTree.ts +33 -27
  117. package/src/perspective.ts +6 -1
  118. package/src/revertibles.ts +1 -1
@@ -2,47 +2,137 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /**
6
+ * Represents a node in a doubly linked list.
7
+ * @internal
8
+ */
5
9
  export interface ListNode<T> {
10
+ /**
11
+ * The list this node belongs to, or undefined if not attached.
12
+ */
6
13
  readonly list: DoublyLinkedList<T> | undefined;
14
+ /**
15
+ * The data value stored in this node.
16
+ */
7
17
  readonly data: T;
18
+ /**
19
+ * The next node in the list, or undefined if this is the last node.
20
+ */
8
21
  readonly next: ListNode<T> | undefined;
22
+ /**
23
+ * The previous node in the list, or undefined if this is the first node.
24
+ */
9
25
  readonly prev: ListNode<T> | undefined;
26
+ /**
27
+ * Removes this node from its list.
28
+ * @returns The removed node, or undefined if not in a list.
29
+ */
30
+ remove(): ListNode<T> | undefined;
10
31
  }
32
+ /**
33
+ * Represents a range of nodes in a doubly linked list.
34
+ * @internal
35
+ */
11
36
  export interface ListNodeRange<T> {
37
+ /**
38
+ * The first node in the range.
39
+ */
12
40
  first: ListNode<T>;
41
+ /**
42
+ * The last node in the range.
43
+ */
13
44
  last: ListNode<T>;
14
45
  }
46
+ /**
47
+ * A doubly linked list implementation with array-like methods and node access.
48
+ * @typeParam T - The type of data stored in the list nodes.
49
+ * @internal
50
+ */
15
51
  export declare class DoublyLinkedList<T> implements Iterable<ListNode<T>>, Partial<ListNodeRange<T>>, Pick<ListNode<T>[], "pop" | "shift" | "length" | "includes"> {
52
+ /**
53
+ * Creates a new doubly linked list optionally initialized with values.
54
+ * @param values - Optional iterable of values to populate the list.
55
+ */
16
56
  constructor(values?: Iterable<T>);
57
+ /**
58
+ * Finds the first node matching the predicate.
59
+ * @param predicate - Function to test each node.
60
+ * @returns The first matching node, or undefined if none found.
61
+ */
17
62
  find(predicate: (value: ListNode<T>, obj: DoublyLinkedList<T>) => unknown): ListNode<T> | undefined;
63
+ /**
64
+ * Returns an iterable that maps each node to a new value.
65
+ * @param callbackfn - Function to produce a new value for each node.
66
+ */
18
67
  map<U>(callbackfn: (value: ListNode<T>) => U): Iterable<U>;
68
+ /**
69
+ * Inserts items after the specified node.
70
+ * @param preceding - The node to insert after.
71
+ * @param items - Items to insert.
72
+ * @returns The range of newly inserted nodes.
73
+ */
19
74
  insertAfter(preceding: ListNode<T>, ...items: T[]): ListNodeRange<T>;
75
+ /**
76
+ * Removes and returns the last node in the list.
77
+ * @returns The removed node, or undefined if the list is empty.
78
+ */
20
79
  pop(): ListNode<T> | undefined;
80
+ /**
81
+ * Appends items to the end of the list.
82
+ * @param items - Items to append.
83
+ * @returns The range of newly inserted nodes.
84
+ */
21
85
  push(...items: T[]): ListNodeRange<T>;
22
86
  /**
23
- * Remove and return the first element
87
+ * Removes and returns the first node in the list.
88
+ * @returns The removed node, or undefined if the list is empty.
24
89
  */
25
90
  shift(): ListNode<T> | undefined;
26
91
  /**
27
- * Insert `items` at start of list
92
+ * Inserts items at the start of the list.
93
+ * @param items - Items to insert.
94
+ * @returns The range of newly inserted nodes.
28
95
  */
29
96
  unshift(...items: T[]): ListNodeRange<T>;
30
97
  /**
31
- * Remove nodes starting at `start` until either the `end` node is reached
32
- * or until `count` nodes have been removed. Returns the removed nodes as
33
- * a separate linked list
98
+ * Removes nodes starting at `start` until `end` or `count` is reached.
99
+ * @param start - The node to start removing from.
100
+ * @param countOrEnd - The number of nodes to remove or the end node.
101
+ * @returns A new list containing the removed nodes.
34
102
  */
35
103
  splice(start: ListNode<T>, countOrEnd?: ListNode<T> | number): DoublyLinkedList<T>;
104
+ /**
105
+ * Checks if the node is in this list.
106
+ * @param node - The node to check.
107
+ * @returns True if the node is in the list.
108
+ */
36
109
  includes(node: ListNode<T> | undefined): node is ListNode<T>;
37
110
  private _includes;
38
111
  private _remove;
112
+ /**
113
+ * Removes the specified node from the list.
114
+ * @param node - The node to remove.
115
+ * @returns The removed node, or undefined if not in the list.
116
+ */
39
117
  remove(node: ListNode<T> | undefined): ListNode<T> | undefined;
40
118
  [Symbol.iterator](): IterableIterator<ListNode<T>>;
41
119
  private _len;
42
120
  private readonly headNode;
121
+ /**
122
+ * The number of nodes in the list.
123
+ */
43
124
  get length(): number;
125
+ /**
126
+ * Whether the list is empty.
127
+ */
44
128
  get empty(): boolean;
129
+ /**
130
+ * The first node in the list, or undefined if empty.
131
+ */
45
132
  get first(): ListNode<T> | undefined;
133
+ /**
134
+ * The last node in the list, or undefined if empty.
135
+ */
46
136
  get last(): ListNode<T> | undefined;
47
137
  }
48
138
  export declare function walkList<T>(list: DoublyLinkedList<T>, visitor: (node: ListNode<T>) => boolean | void, start?: ListNode<T>, forward?: boolean): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/collections/list.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,QAAQ,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACvC;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CAClB;AAiED,qBAAa,gBAAgB,CAAC,CAAC,CAC9B,YACC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAEzB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;gBAEjD,MAAM,CAA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C,KAAK,OAAO,GAAG,IAAI,EAC9C,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EACnB,OAAO,GAAE,OAAc,GACrB,OAAO,CAqBT;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,EAC9B,gBAAgB,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,GAC3C,QAAQ,CAAC,CAAC,CAAC,CAkBb"}
@@ -34,6 +34,9 @@ class DataNode extends HeadNode {
34
34
  this.data = data;
35
35
  this.headNode = headNode;
36
36
  }
37
+ remove() {
38
+ return this.list?.remove(this);
39
+ }
37
40
  }
38
41
  function insertAfter(node, items) {
39
42
  let previousNode = node;
@@ -63,7 +66,16 @@ function insertAfter(node, items) {
63
66
  }
64
67
  return newRange;
65
68
  }
69
+ /**
70
+ * A doubly linked list implementation with array-like methods and node access.
71
+ * @typeParam T - The type of data stored in the list nodes.
72
+ * @internal
73
+ */
66
74
  class DoublyLinkedList {
75
+ /**
76
+ * Creates a new doubly linked list optionally initialized with values.
77
+ * @param values - Optional iterable of values to populate the list.
78
+ */
67
79
  constructor(values) {
68
80
  this._len = 0;
69
81
  this.headNode = new HeadNode(this);
@@ -71,6 +83,11 @@ class DoublyLinkedList {
71
83
  this.push(...values);
72
84
  }
73
85
  }
86
+ /**
87
+ * Finds the first node matching the predicate.
88
+ * @param predicate - Function to test each node.
89
+ * @returns The first matching node, or undefined if none found.
90
+ */
74
91
  find(predicate) {
75
92
  let found;
76
93
  walkList(this, (node) => {
@@ -81,6 +98,10 @@ class DoublyLinkedList {
81
98
  });
82
99
  return found;
83
100
  }
101
+ /**
102
+ * Returns an iterable that maps each node to a new value.
103
+ * @param callbackfn - Function to produce a new value for each node.
104
+ */
84
105
  map(callbackfn) {
85
106
  let node = this.first;
86
107
  const iterator = {
@@ -98,6 +119,12 @@ class DoublyLinkedList {
98
119
  };
99
120
  return iterator;
100
121
  }
122
+ /**
123
+ * Inserts items after the specified node.
124
+ * @param preceding - The node to insert after.
125
+ * @param items - Items to insert.
126
+ * @returns The range of newly inserted nodes.
127
+ */
101
128
  insertAfter(preceding, ...items) {
102
129
  if (!this._includes(preceding)) {
103
130
  throw new Error("preceding not in list");
@@ -105,31 +132,44 @@ class DoublyLinkedList {
105
132
  this._len += items.length;
106
133
  return insertAfter(preceding, items);
107
134
  }
135
+ /**
136
+ * Removes and returns the last node in the list.
137
+ * @returns The removed node, or undefined if the list is empty.
138
+ */
108
139
  pop() {
109
140
  return this.remove(this.last);
110
141
  }
142
+ /**
143
+ * Appends items to the end of the list.
144
+ * @param items - Items to append.
145
+ * @returns The range of newly inserted nodes.
146
+ */
111
147
  push(...items) {
112
148
  this._len += items.length;
113
149
  const start = this.headNode._prev;
114
150
  return insertAfter(start, items);
115
151
  }
116
152
  /**
117
- * Remove and return the first element
153
+ * Removes and returns the first node in the list.
154
+ * @returns The removed node, or undefined if the list is empty.
118
155
  */
119
156
  shift() {
120
157
  return this.remove(this.first);
121
158
  }
122
159
  /**
123
- * Insert `items` at start of list
160
+ * Inserts items at the start of the list.
161
+ * @param items - Items to insert.
162
+ * @returns The range of newly inserted nodes.
124
163
  */
125
164
  unshift(...items) {
126
165
  this._len += items.length;
127
166
  return insertAfter(this.headNode, items);
128
167
  }
129
168
  /**
130
- * Remove nodes starting at `start` until either the `end` node is reached
131
- * or until `count` nodes have been removed. Returns the removed nodes as
132
- * a separate linked list
169
+ * Removes nodes starting at `start` until `end` or `count` is reached.
170
+ * @param start - The node to start removing from.
171
+ * @param countOrEnd - The number of nodes to remove or the end node.
172
+ * @returns A new list containing the removed nodes.
133
173
  */
134
174
  splice(start, countOrEnd) {
135
175
  const newList = new DoublyLinkedList();
@@ -151,6 +191,11 @@ class DoublyLinkedList {
151
191
  }, start);
152
192
  return newList;
153
193
  }
194
+ /**
195
+ * Checks if the node is in this list.
196
+ * @param node - The node to check.
197
+ * @returns True if the node is in the list.
198
+ */
154
199
  includes(node) {
155
200
  return this._includes(node);
156
201
  }
@@ -168,6 +213,11 @@ class DoublyLinkedList {
168
213
  }
169
214
  return undefined;
170
215
  }
216
+ /**
217
+ * Removes the specified node from the list.
218
+ * @param node - The node to remove.
219
+ * @returns The removed node, or undefined if not in the list.
220
+ */
171
221
  remove(node) {
172
222
  return this._remove(node);
173
223
  }
@@ -188,15 +238,27 @@ class DoublyLinkedList {
188
238
  };
189
239
  return iterator;
190
240
  }
241
+ /**
242
+ * The number of nodes in the list.
243
+ */
191
244
  get length() {
192
245
  return this._len;
193
246
  }
247
+ /**
248
+ * Whether the list is empty.
249
+ */
194
250
  get empty() {
195
251
  return this._len === 0;
196
252
  }
253
+ /**
254
+ * The first node in the list, or undefined if empty.
255
+ */
197
256
  get first() {
198
257
  return this.headNode.next;
199
258
  }
259
+ /**
260
+ * The last node in the list, or undefined if empty.
261
+ */
200
262
  get last() {
201
263
  return this.headNode.prev;
202
264
  }
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/collections/list.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AActE,MAAM,QAAQ;IAKb,YAAY,IAAqC;QAJ1C,UAAK,GAA8B,IAAI,CAAC;QACxC,UAAK,GAA8B,IAAI,CAAC;QACxC,aAAQ,GAAgB,IAAI,CAAC;QAGnC,IAAI,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACnB,CAAC;IACF,CAAC;IACD,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,IAAI,CAAC,KAAqB,CAAC;IAC/E,CAAC;IACD,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,IAAI,C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G,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;IACnD,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,KAAK,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AA1BD,4BA0BC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CACrC,KAA8B,EAC9B,gBAA6C;IAE7C,IAAI,IAAI,GAA4B,KAAK,CAAC;IAC1C,MAAM,QAAQ,GAAwB;QACrC,IAAI,EAAE,GAAsB,EAAE;YAC7B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,OAAO,GAAG,IAAI,CAAC;gBACrB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;gBACpB,IAAI,gBAAgB,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;oBACxC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBAC7C,CAAC;YACF,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QACzC,CAAC;QACD,CAAC,MAAM,CAAC,QAAQ,CAAC;YAChB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;IACF,OAAO,QAAQ,CAAC;AACjB,CAAC;AArBD,wDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nexport interface ListNode<T> {\n\treadonly list: DoublyLinkedList<T> | undefined;\n\treadonly data: T;\n\treadonly next: ListNode<T> | undefined;\n\treadonly prev: ListNode<T> | undefined;\n}\n\nexport interface ListNodeRange<T> {\n\tfirst: ListNode<T>;\n\tlast: ListNode<T>;\n}\n\nclass HeadNode<T> {\n\tpublic _next: HeadNode<T> | DataNode<T> = this;\n\tpublic _prev: HeadNode<T> | DataNode<T> = this;\n\tpublic headNode: HeadNode<T> = this;\n\tprivate readonly _list?: DoublyLinkedList<T>;\n\tconstructor(list: DoublyLinkedList<T> | undefined) {\n\t\tif (list) {\n\t\t\tthis._list = list;\n\t\t}\n\t}\n\tpublic get next(): DataNode<T> | undefined {\n\t\treturn this._next === this.headNode ? undefined : (this._next as DataNode<T>);\n\t}\n\tpublic get prev(): DataNode<T> | undefined {\n\t\treturn this._prev === this.headNode ? undefined : (this._prev as DataNode<T>);\n\t}\n\tpublic get list(): DoublyLinkedList<T> | undefined {\n\t\treturn this.headNode._list;\n\t}\n}\n\n// The any is needed for use in the remove function, where the nodes are defined with a generic type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst DeadHead = new HeadNode<any>(undefined);\n\nclass DataNode<T> extends HeadNode<T> implements ListNode<T> {\n\tconstructor(\n\t\theadNode: HeadNode<T>,\n\t\tpublic readonly data: T,\n\t) {\n\t\tsuper(undefined);\n\t\tthis.headNode = headNode;\n\t}\n}\n\nfunction insertAfter<T>(node: DataNode<T> | HeadNode<T>, items: T[]): ListNodeRange<T> {\n\tlet previousNode = node;\n\tconst oldNext = previousNode._next;\n\tlet newRange: ListNodeRange<T> | undefined;\n\tfor (const n of items) {\n\t\tconst newNode = new DataNode<T>(node.headNode, n);\n\t\tif (newRange === undefined) {\n\t\t\tnewRange = { first: newNode, last: newNode };\n\t\t} else {\n\t\t\tnewRange.last = newNode;\n\t\t}\n\t\tnewNode._prev = previousNode;\n\t\tpreviousNode._next = newNode;\n\t\tpreviousNode = newNode;\n\t}\n\toldNext._prev = previousNode;\n\tpreviousNode._next = oldNext;\n\t// explicitly prevent newRange from being undefined without casting,\n\t// and without additional conditionals, as this is used in some perf critical areas.\n\t// i could have just asserted, but that throws a non-user friendly error,\n\t// so i went with a more user-friendly error, which describes the\n\t// only condition that could lead to this being undefined in the current code.\n\tif (newRange === undefined) {\n\t\tthrow new UsageError(\"items must not be empty\");\n\t}\n\treturn newRange;\n}\n\nexport class DoublyLinkedList<T>\n\timplements\n\t\tIterable<ListNode<T>>,\n\t\tPartial<ListNodeRange<T>>,\n\t\t// try to match array signature and semantics where possible\n\t\tPick<ListNode<T>[], \"pop\" | \"shift\" | \"length\" | \"includes\">\n{\n\tconstructor(values?: Iterable<T>) {\n\t\tif (values !== undefined) {\n\t\t\tthis.push(...values);\n\t\t}\n\t}\n\n\tfind(\n\t\tpredicate: (value: ListNode<T>, obj: DoublyLinkedList<T>) => unknown,\n\t): ListNode<T> | undefined {\n\t\tlet found: ListNode<T> | undefined;\n\t\twalkList(this, (node) => {\n\t\t\tif (predicate(node, this)) {\n\t\t\t\tfound = node;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn found;\n\t}\n\n\tmap<U>(callbackfn: (value: ListNode<T>) => U): Iterable<U> {\n\t\tlet node = this.first;\n\t\tconst iterator: IterableIterator<U> = {\n\t\t\tnext(): IteratorResult<U> {\n\t\t\t\tif (node === undefined) {\n\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t}\n\t\t\t\tconst rtn = { value: callbackfn(node), done: false };\n\t\t\t\tnode = node.next;\n\t\t\t\treturn rtn;\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\tinsertAfter(preceding: ListNode<T>, ...items: T[]): ListNodeRange<T> {\n\t\tif (!this._includes(preceding)) {\n\t\t\tthrow new Error(\"preceding not in list\");\n\t\t}\n\t\tthis._len += items.length;\n\t\treturn insertAfter(preceding, items);\n\t}\n\n\tpop(): ListNode<T> | undefined {\n\t\treturn this.remove(this.last);\n\t}\n\n\tpush(...items: T[]): ListNodeRange<T> {\n\t\tthis._len += items.length;\n\t\tconst start = this.headNode._prev;\n\t\treturn insertAfter(start, items);\n\t}\n\n\t/**\n\t * Remove and return the first element\n\t */\n\tshift(): ListNode<T> | undefined {\n\t\treturn this.remove(this.first);\n\t}\n\n\t/**\n\t * Insert `items` at start of list\n\t */\n\tunshift(...items: T[]): ListNodeRange<T> {\n\t\tthis._len += items.length;\n\t\treturn insertAfter(this.headNode, items);\n\t}\n\n\t/**\n\t * Remove nodes starting at `start` until either the `end` node is reached\n\t * or until `count` nodes have been removed. Returns the removed nodes as\n\t * a separate linked list\n\t */\n\tsplice(start: ListNode<T>, countOrEnd?: ListNode<T> | number): DoublyLinkedList<T> {\n\t\tconst newList = new DoublyLinkedList<T>();\n\t\twalkList(\n\t\t\tthis,\n\t\t\t(node) => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst removedNode = this._remove(node)!;\n\t\t\t\t// whats special here is we preserve the node\n\t\t\t\t// this allow looking up the old node in the new list\n\t\t\t\t// when something preserves a reference\n\t\t\t\tremovedNode.headNode = newList.headNode;\n\t\t\t\tremovedNode._next = newList.headNode;\n\t\t\t\tremovedNode._prev = newList.headNode._prev;\n\t\t\t\tnewList.headNode._prev._next = removedNode;\n\t\t\t\tnewList.headNode._prev = removedNode;\n\t\t\t\tnewList._len++;\n\t\t\t\tif (node === countOrEnd || newList.length === countOrEnd) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\tstart,\n\t\t);\n\t\treturn newList;\n\t}\n\n\tpublic includes(node: ListNode<T> | undefined): node is ListNode<T> {\n\t\treturn this._includes(node);\n\t}\n\n\tprivate _includes(node: ListNode<T> | undefined): node is DataNode<T> {\n\t\treturn node instanceof DataNode && node.headNode === this.headNode;\n\t}\n\n\tprivate _remove(node: ListNode<T> | undefined): DataNode<T> | undefined {\n\t\tif (this._includes(node)) {\n\t\t\tnode._prev._next = node._next;\n\t\t\tnode._next._prev = node._prev;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tnode.headNode = node._next = node._prev = DeadHead;\n\t\t\tthis._len--;\n\t\t\treturn node;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic remove(node: ListNode<T> | undefined): ListNode<T> | undefined {\n\t\treturn this._remove(node);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<ListNode<T>> {\n\t\tlet value = this.first;\n\t\tconst iterator: IterableIterator<ListNode<T>> = {\n\t\t\tnext(): IteratorResult<ListNode<T>> {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tconst rtn = { value, done: false };\n\t\t\t\t\tvalue = value.next;\n\t\t\t\t\treturn rtn;\n\t\t\t\t}\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\tprivate _len: number = 0;\n\tprivate readonly headNode: HeadNode<T> | DataNode<T> = new HeadNode(this);\n\tpublic get length(): number {\n\t\treturn this._len;\n\t}\n\tpublic get empty(): boolean {\n\t\treturn this._len === 0;\n\t}\n\tpublic get first(): ListNode<T> | undefined {\n\t\treturn this.headNode.next;\n\t}\n\n\tpublic get last(): ListNode<T> | undefined {\n\t\treturn this.headNode.prev;\n\t}\n}\n\nexport function walkList<T>(\n\tlist: DoublyLinkedList<T>,\n\tvisitor: (node: ListNode<T>) => boolean | void,\n\tstart?: ListNode<T>,\n\tforward: boolean = true,\n): boolean {\n\tlet current: ListNode<T> | undefined;\n\tif (start) {\n\t\tif (!list.includes(start)) {\n\t\t\tthrow new UsageError(\"start must be in the provided list\");\n\t\t}\n\t\tcurrent = start;\n\t} else {\n\t\tcurrent = forward ? list.first : list.last;\n\t}\n\t// cache the next node, incase the visitor mutates the list\n\t// need this to support splice\n\tlet next = forward ? current?.next : current?.prev;\n\twhile (current !== undefined) {\n\t\tif (visitor(current) === false) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrent = next;\n\t\tnext = forward ? next?.next : next?.prev;\n\t}\n\treturn true;\n}\n\n/**\n * Creates a lazily evaluated iterable which returns values while the predicate returns true,\n * and stops iterating at the first value where the predicate is false.\n * @param start - the node to start the iteration from\n * @param includePredicate - determine if the current value be included in the iteration or stop if iteration\n */\nexport function iterateListValuesWhile<T>(\n\tstart: ListNode<T> | undefined,\n\tincludePredicate: (n: ListNode<T>) => boolean,\n): Iterable<T> {\n\tlet next: ListNode<T> | undefined = start;\n\tconst iterator: IterableIterator<T> = {\n\t\tnext: (): IteratorResult<T> => {\n\t\t\tif (next !== undefined) {\n\t\t\t\tconst current = next;\n\t\t\t\tnext = current.next;\n\t\t\t\tif (includePredicate(current) === true) {\n\t\t\t\t\treturn { value: current.data, done: false };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { done: true, value: undefined };\n\t\t},\n\t\t[Symbol.iterator]() {\n\t\t\treturn this;\n\t\t},\n\t};\n\treturn iterator;\n}\n"]}
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/collections/list.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AA6CtE,MAAM,QAAQ;IAKb,YAAY,IAAqC;QAJ1C,UAAK,GAA8B,IAAI,CAAC;QACxC,UAAK,GAA8B,IAAI,CAAC;QACxC,aAAQ,GAAgB,IAAI,CAAC;QAGnC,IAAI,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACnB,CAAC;IACF,CAAC;IACD,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,IAAI,CAAC,KAAqB,CAAC;IAC/E,CAAC;IACD,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,QAAQ,CAA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KAAK,EAAE,SAAS,EAAE,CAAC;QACzC,CAAC;QACD,CAAC,MAAM,CAAC,QAAQ,CAAC;YAChB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;IACF,OAAO,QAAQ,CAAC;AACjB,CAAC;AArBD,wDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Represents a node in a doubly linked list.\n * @internal\n */\nexport interface ListNode<T> {\n\t/**\n\t * The list this node belongs to, or undefined if not attached.\n\t */\n\treadonly list: DoublyLinkedList<T> | undefined;\n\t/**\n\t * The data value stored in this node.\n\t */\n\treadonly data: T;\n\t/**\n\t * The next node in the list, or undefined if this is the last node.\n\t */\n\treadonly next: ListNode<T> | undefined;\n\t/**\n\t * The previous node in the list, or undefined if this is the first node.\n\t */\n\treadonly prev: ListNode<T> | undefined;\n\t/**\n\t * Removes this node from its list.\n\t * @returns The removed node, or undefined if not in a list.\n\t */\n\tremove(): ListNode<T> | undefined;\n}\n\n/**\n * Represents a range of nodes in a doubly linked list.\n * @internal\n */\nexport interface ListNodeRange<T> {\n\t/**\n\t * The first node in the range.\n\t */\n\tfirst: ListNode<T>;\n\t/**\n\t * The last node in the range.\n\t */\n\tlast: ListNode<T>;\n}\n\nclass HeadNode<T> {\n\tpublic _next: HeadNode<T> | DataNode<T> = this;\n\tpublic _prev: HeadNode<T> | DataNode<T> = this;\n\tpublic headNode: HeadNode<T> = this;\n\tprivate readonly _list?: DoublyLinkedList<T>;\n\tconstructor(list: DoublyLinkedList<T> | undefined) {\n\t\tif (list) {\n\t\t\tthis._list = list;\n\t\t}\n\t}\n\tpublic get next(): DataNode<T> | undefined {\n\t\treturn this._next === this.headNode ? undefined : (this._next as DataNode<T>);\n\t}\n\tpublic get prev(): DataNode<T> | undefined {\n\t\treturn this._prev === this.headNode ? undefined : (this._prev as DataNode<T>);\n\t}\n\tpublic get list(): DoublyLinkedList<T> | undefined {\n\t\treturn this.headNode._list;\n\t}\n}\n\n// The any is needed for use in the remove function, where the nodes are defined with a generic type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst DeadHead = new HeadNode<any>(undefined);\n\nclass DataNode<T> extends HeadNode<T> implements ListNode<T> {\n\tconstructor(\n\t\theadNode: HeadNode<T>,\n\t\tpublic readonly data: T,\n\t) {\n\t\tsuper(undefined);\n\t\tthis.headNode = headNode;\n\t}\n\tremove(): ListNode<T> | undefined {\n\t\treturn this.list?.remove(this);\n\t}\n}\n\nfunction insertAfter<T>(node: DataNode<T> | HeadNode<T>, items: T[]): ListNodeRange<T> {\n\tlet previousNode = node;\n\tconst oldNext = previousNode._next;\n\tlet newRange: ListNodeRange<T> | undefined;\n\tfor (const n of items) {\n\t\tconst newNode = new DataNode<T>(node.headNode, n);\n\t\tif (newRange === undefined) {\n\t\t\tnewRange = { first: newNode, last: newNode };\n\t\t} else {\n\t\t\tnewRange.last = newNode;\n\t\t}\n\t\tnewNode._prev = previousNode;\n\t\tpreviousNode._next = newNode;\n\t\tpreviousNode = newNode;\n\t}\n\toldNext._prev = previousNode;\n\tpreviousNode._next = oldNext;\n\t// explicitly prevent newRange from being undefined without casting,\n\t// and without additional conditionals, as this is used in some perf critical areas.\n\t// i could have just asserted, but that throws a non-user friendly error,\n\t// so i went with a more user-friendly error, which describes the\n\t// only condition that could lead to this being undefined in the current code.\n\tif (newRange === undefined) {\n\t\tthrow new UsageError(\"items must not be empty\");\n\t}\n\treturn newRange;\n}\n\n/**\n * A doubly linked list implementation with array-like methods and node access.\n * @typeParam T - The type of data stored in the list nodes.\n * @internal\n */\nexport class DoublyLinkedList<T>\n\timplements\n\t\tIterable<ListNode<T>>,\n\t\tPartial<ListNodeRange<T>>,\n\t\t// try to match array signature and semantics where possible\n\t\tPick<ListNode<T>[], \"pop\" | \"shift\" | \"length\" | \"includes\">\n{\n\t/**\n\t * Creates a new doubly linked list optionally initialized with values.\n\t * @param values - Optional iterable of values to populate the list.\n\t */\n\tconstructor(values?: Iterable<T>) {\n\t\tif (values !== undefined) {\n\t\t\tthis.push(...values);\n\t\t}\n\t}\n\n\t/**\n\t * Finds the first node matching the predicate.\n\t * @param predicate - Function to test each node.\n\t * @returns The first matching node, or undefined if none found.\n\t */\n\tfind(\n\t\tpredicate: (value: ListNode<T>, obj: DoublyLinkedList<T>) => unknown,\n\t): ListNode<T> | undefined {\n\t\tlet found: ListNode<T> | undefined;\n\t\twalkList(this, (node) => {\n\t\t\tif (predicate(node, this)) {\n\t\t\t\tfound = node;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn found;\n\t}\n\n\t/**\n\t * Returns an iterable that maps each node to a new value.\n\t * @param callbackfn - Function to produce a new value for each node.\n\t */\n\tmap<U>(callbackfn: (value: ListNode<T>) => U): Iterable<U> {\n\t\tlet node = this.first;\n\t\tconst iterator: IterableIterator<U> = {\n\t\t\tnext(): IteratorResult<U> {\n\t\t\t\tif (node === undefined) {\n\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t}\n\t\t\t\tconst rtn = { value: callbackfn(node), done: false };\n\t\t\t\tnode = node.next;\n\t\t\t\treturn rtn;\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Inserts items after the specified node.\n\t * @param preceding - The node to insert after.\n\t * @param items - Items to insert.\n\t * @returns The range of newly inserted nodes.\n\t */\n\tinsertAfter(preceding: ListNode<T>, ...items: T[]): ListNodeRange<T> {\n\t\tif (!this._includes(preceding)) {\n\t\t\tthrow new Error(\"preceding not in list\");\n\t\t}\n\t\tthis._len += items.length;\n\t\treturn insertAfter(preceding, items);\n\t}\n\n\t/**\n\t * Removes and returns the last node in the list.\n\t * @returns The removed node, or undefined if the list is empty.\n\t */\n\tpop(): ListNode<T> | undefined {\n\t\treturn this.remove(this.last);\n\t}\n\n\t/**\n\t * Appends items to the end of the list.\n\t * @param items - Items to append.\n\t * @returns The range of newly inserted nodes.\n\t */\n\tpush(...items: T[]): ListNodeRange<T> {\n\t\tthis._len += items.length;\n\t\tconst start = this.headNode._prev;\n\t\treturn insertAfter(start, items);\n\t}\n\n\t/**\n\t * Removes and returns the first node in the list.\n\t * @returns The removed node, or undefined if the list is empty.\n\t */\n\tshift(): ListNode<T> | undefined {\n\t\treturn this.remove(this.first);\n\t}\n\n\t/**\n\t * Inserts items at the start of the list.\n\t * @param items - Items to insert.\n\t * @returns The range of newly inserted nodes.\n\t */\n\tunshift(...items: T[]): ListNodeRange<T> {\n\t\tthis._len += items.length;\n\t\treturn insertAfter(this.headNode, items);\n\t}\n\n\t/**\n\t * Removes nodes starting at `start` until `end` or `count` is reached.\n\t * @param start - The node to start removing from.\n\t * @param countOrEnd - The number of nodes to remove or the end node.\n\t * @returns A new list containing the removed nodes.\n\t */\n\tsplice(start: ListNode<T>, countOrEnd?: ListNode<T> | number): DoublyLinkedList<T> {\n\t\tconst newList = new DoublyLinkedList<T>();\n\t\twalkList(\n\t\t\tthis,\n\t\t\t(node) => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst removedNode = this._remove(node)!;\n\t\t\t\t// whats special here is we preserve the node\n\t\t\t\t// this allow looking up the old node in the new list\n\t\t\t\t// when something preserves a reference\n\t\t\t\tremovedNode.headNode = newList.headNode;\n\t\t\t\tremovedNode._next = newList.headNode;\n\t\t\t\tremovedNode._prev = newList.headNode._prev;\n\t\t\t\tnewList.headNode._prev._next = removedNode;\n\t\t\t\tnewList.headNode._prev = removedNode;\n\t\t\t\tnewList._len++;\n\t\t\t\tif (node === countOrEnd || newList.length === countOrEnd) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\tstart,\n\t\t);\n\t\treturn newList;\n\t}\n\n\t/**\n\t * Checks if the node is in this list.\n\t * @param node - The node to check.\n\t * @returns True if the node is in the list.\n\t */\n\tpublic includes(node: ListNode<T> | undefined): node is ListNode<T> {\n\t\treturn this._includes(node);\n\t}\n\n\tprivate _includes(node: ListNode<T> | undefined): node is DataNode<T> {\n\t\treturn node instanceof DataNode && node.headNode === this.headNode;\n\t}\n\n\tprivate _remove(node: ListNode<T> | undefined): DataNode<T> | undefined {\n\t\tif (this._includes(node)) {\n\t\t\tnode._prev._next = node._next;\n\t\t\tnode._next._prev = node._prev;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tnode.headNode = node._next = node._prev = DeadHead;\n\t\t\tthis._len--;\n\t\t\treturn node;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Removes the specified node from the list.\n\t * @param node - The node to remove.\n\t * @returns The removed node, or undefined if not in the list.\n\t */\n\tpublic remove(node: ListNode<T> | undefined): ListNode<T> | undefined {\n\t\treturn this._remove(node);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<ListNode<T>> {\n\t\tlet value = this.first;\n\t\tconst iterator: IterableIterator<ListNode<T>> = {\n\t\t\tnext(): IteratorResult<ListNode<T>> {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tconst rtn = { value, done: false };\n\t\t\t\t\tvalue = value.next;\n\t\t\t\t\treturn rtn;\n\t\t\t\t}\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\tprivate _len: number = 0;\n\tprivate readonly headNode: HeadNode<T> | DataNode<T> = new HeadNode(this);\n\n\t/**\n\t * The number of nodes in the list.\n\t */\n\tpublic get length(): number {\n\t\treturn this._len;\n\t}\n\n\t/**\n\t * Whether the list is empty.\n\t */\n\tpublic get empty(): boolean {\n\t\treturn this._len === 0;\n\t}\n\n\t/**\n\t * The first node in the list, or undefined if empty.\n\t */\n\tpublic get first(): ListNode<T> | undefined {\n\t\treturn this.headNode.next;\n\t}\n\n\t/**\n\t * The last node in the list, or undefined if empty.\n\t */\n\tpublic get last(): ListNode<T> | undefined {\n\t\treturn this.headNode.prev;\n\t}\n}\n\nexport function walkList<T>(\n\tlist: DoublyLinkedList<T>,\n\tvisitor: (node: ListNode<T>) => boolean | void,\n\tstart?: ListNode<T>,\n\tforward: boolean = true,\n): boolean {\n\tlet current: ListNode<T> | undefined;\n\tif (start) {\n\t\tif (!list.includes(start)) {\n\t\t\tthrow new UsageError(\"start must be in the provided list\");\n\t\t}\n\t\tcurrent = start;\n\t} else {\n\t\tcurrent = forward ? list.first : list.last;\n\t}\n\t// cache the next node, incase the visitor mutates the list\n\t// need this to support splice\n\tlet next = forward ? current?.next : current?.prev;\n\twhile (current !== undefined) {\n\t\tif (visitor(current) === false) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrent = next;\n\t\tnext = forward ? next?.next : next?.prev;\n\t}\n\treturn true;\n}\n\n/**\n * Creates a lazily evaluated iterable which returns values while the predicate returns true,\n * and stops iterating at the first value where the predicate is false.\n * @param start - the node to start the iteration from\n * @param includePredicate - determine if the current value be included in the iteration or stop if iteration\n */\nexport function iterateListValuesWhile<T>(\n\tstart: ListNode<T> | undefined,\n\tincludePredicate: (n: ListNode<T>) => boolean,\n): Iterable<T> {\n\tlet next: ListNode<T> | undefined = start;\n\tconst iterator: IterableIterator<T> = {\n\t\tnext: (): IteratorResult<T> => {\n\t\t\tif (next !== undefined) {\n\t\t\t\tconst current = next;\n\t\t\t\tnext = current.next;\n\t\t\t\tif (includePredicate(current) === true) {\n\t\t\t\t\treturn { value: current.data, done: false };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { done: true, value: undefined };\n\t\t},\n\t\t[Symbol.iterator]() {\n\t\t\treturn this;\n\t\t},\n\t};\n\treturn iterator;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  export { IAttributionCollection, IAttributionCollectionSerializer, IAttributionCollectionSpec, SerializedAttributionCollection, SequenceOffsets, } from "./attributionCollection.js";
6
6
  export { createInsertOnlyAttributionPolicy, createPropertyTrackingAttributionPolicyFactory, createPropertyTrackingAndInsertionAttributionPolicyFactory, } from "./attributionPolicy.js";
7
7
  export { Client, IClientEvents } from "./client.js";
8
- export { ConflictAction, Dictionary, IRBAugmentation, IRBMatcher, KeyComparer, Property, PropertyAction, QProperty, RBColor, RBNode, RBNodeActions, RedBlackTree, SortedDictionary, } from "./collections/index.js";
8
+ export { ConflictAction, Dictionary, IRBAugmentation, IRBMatcher, KeyComparer, Property, PropertyAction, QProperty, RBColor, RBNode, RBNodeActions, RedBlackTree, SortedDictionary, DoublyLinkedList, ListNode, ListNodeRange, } from "./collections/index.js";
9
9
  export { UnassignedSequenceNumber, UniversalSequenceNumber } from "./constants.js";
10
10
  export { createDetachedLocalReferencePosition, LocalReferenceCollection, LocalReferencePosition, SlidingPreference, } from "./localReference.js";
11
11
  export { AttributionPolicy, IMergeTreeAttributionOptions, IMergeTreeOptions, IMergeTreeOptionsInternal, getSlideToSegoff, } from "./mergeTree.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,sBAAsB,EACtB,gCAAgC,EAChC,0BAA0B,EAC1B,+BAA+B,EAC/B,eAAe,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,iCAAiC,EACjC,8CAA8C,EAC9C,0DAA0D,GAC1D,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACN,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,SAAS,EACT,OAAO,EACP,MAAM,EACN,aAAa,EACb,YAAY,EACZ,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,C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AChB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,qBAAqB,EACrB,IAAI,EACJ,aAAa,EACb,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACN,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,+BAA+B,GAC/B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kCAAkC,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxF,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -4,8 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.appendToMergeTreeDeltaRevertibles = exports.TextSegment = exports.SortedSegmentSet = exports.SortedSet = exports.endpointPosAndSide = exports.Side = exports.PropertiesManager = exports.copyPropertiesAndManager = exports.reservedTileLabelsKey = exports.reservedRangeLabelsKey = exports.refTypeIncludesFlag = exports.refHasTileLabels = exports.refHasTileLabel = exports.refGetTileLabels = exports.minReferencePosition = exports.maxReferencePosition = exports.DetachedReferencePosition = exports.compareReferencePositions = exports.matchProperties = exports.createMap = exports.addProperties = exports.ReferenceType = exports.MergeTreeDeltaType = exports.createObliterateRangeOp = exports.createRemoveRangeOp = exports.createInsertSegmentOp = exports.createInsertOp = exports.createGroupOp = exports.createAnnotateRangeOp = exports.TrackingGroupCollection = exports.TrackingGroup = exports.reservedMarkerSimpleTypeKey = exports.reservedMarkerIdKey = exports.Marker = exports.segmentIsRemoved = exports.CollaborationWindow = exports.BaseSegment = exports.MergeTreeMaintenanceType = exports.getSlideToSegoff = exports.SlidingPreference = exports.LocalReferenceCollection = exports.createDetachedLocalReferencePosition = exports.UniversalSequenceNumber = exports.UnassignedSequenceNumber = exports.RedBlackTree = exports.RBColor = exports.Client = exports.createPropertyTrackingAndInsertionAttributionPolicyFactory = exports.createPropertyTrackingAttributionPolicyFactory = exports.createInsertOnlyAttributionPolicy = void 0;
8
- exports.createLocalReconnectingPerspective = exports.revertMergeTreeDeltaRevertibles = exports.isMergeTreeDeltaRevertible = exports.discardMergeTreeDeltaRevertible = void 0;
7
+ exports.TextSegment = exports.SortedSegmentSet = exports.SortedSet = exports.endpointPosAndSide = exports.Side = exports.PropertiesManager = exports.copyPropertiesAndManager = exports.reservedTileLabelsKey = exports.reservedRangeLabelsKey = exports.refTypeIncludesFlag = exports.refHasTileLabels = exports.refHasTileLabel = exports.refGetTileLabels = exports.minReferencePosition = exports.maxReferencePosition = exports.DetachedReferencePosition = exports.compareReferencePositions = exports.matchProperties = exports.createMap = exports.addProperties = exports.ReferenceType = exports.MergeTreeDeltaType = exports.createObliterateRangeOp = exports.createRemoveRangeOp = exports.createInsertSegmentOp = exports.createInsertOp = exports.createGroupOp = exports.createAnnotateRangeOp = exports.TrackingGroupCollection = exports.TrackingGroup = exports.reservedMarkerSimpleTypeKey = exports.reservedMarkerIdKey = exports.Marker = exports.segmentIsRemoved = exports.CollaborationWindow = exports.BaseSegment = exports.MergeTreeMaintenanceType = exports.getSlideToSegoff = exports.SlidingPreference = exports.LocalReferenceCollection = exports.createDetachedLocalReferencePosition = exports.UniversalSequenceNumber = exports.UnassignedSequenceNumber = exports.DoublyLinkedList = exports.RedBlackTree = exports.RBColor = exports.Client = exports.createPropertyTrackingAndInsertionAttributionPolicyFactory = exports.createPropertyTrackingAttributionPolicyFactory = exports.createInsertOnlyAttributionPolicy = void 0;
8
+ exports.createLocalReconnectingPerspective = exports.revertMergeTreeDeltaRevertibles = exports.isMergeTreeDeltaRevertible = exports.discardMergeTreeDeltaRevertible = exports.appendToMergeTreeDeltaRevertibles = void 0;
9
9
  var attributionPolicy_js_1 = require("./attributionPolicy.js");
10
10
  Object.defineProperty(exports, "createInsertOnlyAttributionPolicy", { enumerable: true, get: function () { return attributionPolicy_js_1.createInsertOnlyAttributionPolicy; } });
11
11
  Object.defineProperty(exports, "createPropertyTrackingAttributionPolicyFactory", { enumerable: true, get: function () { return attributionPolicy_js_1.createPropertyTrackingAttributionPolicyFactory; } });
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "Client", { enumerable: true, get: function () {
15
15
  var index_js_1 = require("./collections/index.js");
16
16
  Object.defineProperty(exports, "RBColor", { enumerable: true, get: function () { return index_js_1.RBColor; } });
17
17
  Object.defineProperty(exports, "RedBlackTree", { enumerable: true, get: function () { return index_js_1.RedBlackTree; } });
18
+ Object.defineProperty(exports, "DoublyLinkedList", { enumerable: true, get: function () { return index_js_1.DoublyLinkedList; } });
18
19
  var constants_js_1 = require("./constants.js");
19
20
  Object.defineProperty(exports, "UnassignedSequenceNumber", { enumerable: true, get: function () { return constants_js_1.UnassignedSequenceNumber; } });
20
21
  Object.defineProperty(exports, "UniversalSequenceNumber", { enumerable: true, get: function () { return constants_js_1.UniversalSequenceNumber; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AASH,+DAIgC;AAH/B,yIAAA,iCAAiC,OAAA;AACjC,sJAAA,8CAA8C,OAAA;AAC9C,kKAAA,0DAA0D,OAAA;AAE3D,yCAAoD;AAA3C,mGAAA,MAAM,OAAA;AACf,mDAcgC;AAL/B,mGAAA,OAAO,OAAA;AAG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B;AAH3B,wGAAA,IAAI,OAAA;AAEJ,sHAAA,kBAAkB,OAAA;AAEnB,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,6DAA+E;AAAtE,uHAAA,gBAAgB,OAAA;AACzB,mDAAiE;AAAtC,6GAAA,WAAW,OAAA;AACtC,mDAO0B;AANzB,mIAAA,iCAAiC,OAAA;AACjC,iIAAA,+BAA+B,OAAA;AAC/B,4HAAA,0BAA0B,OAAA;AAG1B,iIAAA,+BAA+B,OAAA;AAGhC,mDAAwF;AAA/E,oIAAA,kCAAkC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIAttributionCollection,\n\tIAttributionCollectionSerializer,\n\tIAttributionCollectionSpec,\n\tSerializedAttributionCollection,\n\tSequenceOffsets,\n} from \"./attributionCollection.js\";\nexport {\n\tcreateInsertOnlyAttributionPolicy,\n\tcreatePropertyTrackingAttributionPolicyFactory,\n\tcreatePropertyTrackingAndInsertionAttributionPolicyFactory,\n} from \"./attributionPolicy.js\";\nexport { Client, IClientEvents } from \"./client.js\";\nexport {\n\tConflictAction,\n\tDictionary,\n\tIRBAugmentation,\n\tIRBMatcher,\n\tKeyComparer,\n\tProperty,\n\tPropertyAction,\n\tQProperty,\n\tRBColor,\n\tRBNode,\n\tRBNodeActions,\n\tRedBlackTree,\n\tSortedDictionary,\n} from \"./collections/index.js\";\nexport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nexport {\n\tcreateDetachedLocalReferencePosition,\n\tLocalReferenceCollection,\n\tLocalReferencePosition,\n\tSlidingPreference,\n} from \"./localReference.js\";\nexport {\n\tAttributionPolicy,\n\tIMergeTreeAttributionOptions,\n\tIMergeTreeOptions,\n\tIMergeTreeOptionsInternal,\n\tgetSlideToSegoff,\n} from \"./mergeTree.js\";\nexport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaOperationTypes,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nexport {\n\tBaseSegment,\n\tCollaborationWindow,\n\tIJSONMarkerSegment,\n\tsegmentIsRemoved,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\treservedMarkerIdKey,\n\treservedMarkerSimpleTypeKey,\n\tISegmentInternal,\n} from \"./mergeTreeNodes.js\";\nexport {\n\tTrackable,\n\tTrackingGroup,\n\tITrackingGroup,\n\tTrackingGroupCollection,\n} from \"./mergeTreeTracking.js\";\nexport {\n\tcreateAnnotateRangeOp,\n\tcreateGroupOp,\n\tcreateInsertOp,\n\tcreateInsertSegmentOp,\n\tcreateRemoveRangeOp,\n\tcreateObliterateRangeOp,\n} from \"./opBuilder.js\";\nexport {\n\tAdjustParams,\n\tIJSONSegment,\n\tIMarkerDef,\n\tIMergeTreeAnnotateMsg,\n\tIMergeTreeDelta,\n\tIMergeTreeDeltaOp,\n\tIMergeTreeGroupMsg,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeOp,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIRelativePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tIMergeTreeObliterateMsg,\n\tIMergeTreeObliterateSidedMsg,\n} from \"./ops.js\";\nexport {\n\taddProperties,\n\tcreateMap,\n\tMapLike,\n\tmatchProperties,\n\tPropertySet,\n} from \"./properties.js\";\nexport {\n\tcompareReferencePositions,\n\tDetachedReferencePosition,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\tReferencePosition,\n\trefGetTileLabels,\n\trefHasTileLabel,\n\trefHasTileLabels,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\treservedTileLabelsKey,\n} from \"./referencePositions.js\";\nexport {\n\tPropsOrAdjust,\n\tcopyPropertiesAndManager,\n\tPropertiesManager,\n} from \"./segmentPropertiesManager.js\";\nexport {\n\tInteriorSequencePlace,\n\tSide,\n\tSequencePlace,\n\tendpointPosAndSide,\n} from \"./sequencePlace.js\";\nexport { SortedSet } from \"./sortedSet.js\";\nexport { SortedSegmentSet, SortedSegmentSetItem } from \"./sortedSegmentSet.js\";\nexport { IJSONTextSegment, TextSegment } from \"./textSegment.js\";\nexport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeRevertibleDriver,\n\trevertMergeTreeDeltaRevertibles,\n} from \"./revertibles.js\";\nexport type { OperationStamp } from \"./stamps.js\";\nexport { createLocalReconnectingPerspective, type Perspective } from \"./perspective.js\";\nexport type { IMergeTreeTextHelper } from \"./MergeTreeTextHelper.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AASH,+DAIgC;AAH/B,yIAAA,iCAAiC,OAAA;AACjC,sJAAA,8CAA8C,OAAA;AAC9C,kKAAA,0DAA0D,OAAA;AAE3D,yCAAoD;AAA3C,mGAAA,MAAM,OAAA;AACf,mDAiBgC;AAR/B,mGAAA,OAAO,OAAA;AAGP,wGAAA,YAAY,OAAA;AAEZ,4GAAA,gBAAgB,OAAA;AAIjB,+CAAmF;AAA1E,wHAAA,wBAAwB,OAAA;AAAE,uHAAA,uBAAuB,OAAA;AAC1D,yDAK6B;AAJ5B,yIAAA,oCAAoC,OAAA;AACpC,6HAAA,wBAAwB,OAAA;AAExB,sHAAA,iBAAiB,OAAA;AAElB,+CAMwB;AADvB,gHAAA,gBAAgB,OAAA;AAEjB,yEAQqC;AADpC,qIAAA,wBAAwB,OAAA;AAEzB,yDAW6B;AAV5B,gHAAA,WAAW,OAAA;AACX,wHAAA,mBAAmB,OAAA;AAEnB,qHAAA,gBAAgB,OAAA;AAGhB,2GAAA,MAAM,OAAA;A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ved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIAttributionCollection,\n\tIAttributionCollectionSerializer,\n\tIAttributionCollectionSpec,\n\tSerializedAttributionCollection,\n\tSequenceOffsets,\n} from \"./attributionCollection.js\";\nexport {\n\tcreateInsertOnlyAttributionPolicy,\n\tcreatePropertyTrackingAttributionPolicyFactory,\n\tcreatePropertyTrackingAndInsertionAttributionPolicyFactory,\n} from \"./attributionPolicy.js\";\nexport { Client, IClientEvents } from \"./client.js\";\nexport {\n\tConflictAction,\n\tDictionary,\n\tIRBAugmentation,\n\tIRBMatcher,\n\tKeyComparer,\n\tProperty,\n\tPropertyAction,\n\tQProperty,\n\tRBColor,\n\tRBNode,\n\tRBNodeActions,\n\tRedBlackTree,\n\tSortedDictionary,\n\tDoublyLinkedList,\n\tListNode,\n\tListNodeRange,\n} from \"./collections/index.js\";\nexport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nexport {\n\tcreateDetachedLocalReferencePosition,\n\tLocalReferenceCollection,\n\tLocalReferencePosition,\n\tSlidingPreference,\n} from \"./localReference.js\";\nexport {\n\tAttributionPolicy,\n\tIMergeTreeAttributionOptions,\n\tIMergeTreeOptions,\n\tIMergeTreeOptionsInternal,\n\tgetSlideToSegoff,\n} from \"./mergeTree.js\";\nexport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaOperationTypes,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nexport {\n\tBaseSegment,\n\tCollaborationWindow,\n\tIJSONMarkerSegment,\n\tsegmentIsRemoved,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\treservedMarkerIdKey,\n\treservedMarkerSimpleTypeKey,\n\tISegmentInternal,\n} from \"./mergeTreeNodes.js\";\nexport {\n\tTrackable,\n\tTrackingGroup,\n\tITrackingGroup,\n\tTrackingGroupCollection,\n} from \"./mergeTreeTracking.js\";\nexport {\n\tcreateAnnotateRangeOp,\n\tcreateGroupOp,\n\tcreateInsertOp,\n\tcreateInsertSegmentOp,\n\tcreateRemoveRangeOp,\n\tcreateObliterateRangeOp,\n} from \"./opBuilder.js\";\nexport {\n\tAdjustParams,\n\tIJSONSegment,\n\tIMarkerDef,\n\tIMergeTreeAnnotateMsg,\n\tIMergeTreeDelta,\n\tIMergeTreeDeltaOp,\n\tIMergeTreeGroupMsg,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeOp,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIRelativePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tIMergeTreeObliterateMsg,\n\tIMergeTreeObliterateSidedMsg,\n} from \"./ops.js\";\nexport {\n\taddProperties,\n\tcreateMap,\n\tMapLike,\n\tmatchProperties,\n\tPropertySet,\n} from \"./properties.js\";\nexport {\n\tcompareReferencePositions,\n\tDetachedReferencePosition,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\tReferencePosition,\n\trefGetTileLabels,\n\trefHasTileLabel,\n\trefHasTileLabels,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\treservedTileLabelsKey,\n} from \"./referencePositions.js\";\nexport {\n\tPropsOrAdjust,\n\tcopyPropertiesAndManager,\n\tPropertiesManager,\n} from \"./segmentPropertiesManager.js\";\nexport {\n\tInteriorSequencePlace,\n\tSide,\n\tSequencePlace,\n\tendpointPosAndSide,\n} from \"./sequencePlace.js\";\nexport { SortedSet } from \"./sortedSet.js\";\nexport { SortedSegmentSet, SortedSegmentSetItem } from \"./sortedSegmentSet.js\";\nexport { IJSONTextSegment, TextSegment } from \"./textSegment.js\";\nexport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeRevertibleDriver,\n\trevertMergeTreeDeltaRevertibles,\n} from \"./revertibles.js\";\nexport type { OperationStamp } from \"./stamps.js\";\nexport { createLocalReconnectingPerspective, type Perspective } from \"./perspective.js\";\nexport type { IMergeTreeTextHelper } from \"./MergeTreeTextHelper.js\";\n"]}
@@ -162,12 +162,12 @@ export declare function findRootMergeBlock(segmentOrNode: IMergeNode | undefined
162
162
  * @internal
163
163
  */
164
164
  export declare function getSlideToSegoff(segoff: {
165
- segment: ISegmentInternal | undefined;
166
- offset: number | undefined;
167
- }, slidingPreference?: SlidingPreference, perspective?: Perspective, useNewSlidingBehavior?: boolean): {
168
- segment: ISegmentInternal | undefined;
169
- offset: number | undefined;
170
- };
165
+ segment: ISegmentInternal;
166
+ offset: number;
167
+ } | undefined, slidingPreference?: SlidingPreference, perspective?: Perspective, canSlideToEndpoint?: boolean): {
168
+ segment: ISegmentInternal;
169
+ offset: number;
170
+ } | undefined;
171
171
  /**
172
172
  * @internal
173
173
  */
@@ -223,9 +223,9 @@ export declare class MergeTree {
223
223
  get length(): number | undefined;
224
224
  getPosition(node: IMergeNode, perspective: Perspective): number;
225
225
  getContainingSegment(pos: number, perspective: Perspective): {
226
- segment: ISegmentLeaf | undefined;
227
- offset: number | undefined;
228
- };
226
+ segment: ISegmentLeaf;
227
+ offset: number;
228
+ } | undefined;
229
229
  /**
230
230
  * Slides or removes references from the provided list of segments.
231
231
  *
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTree.d.ts","sourceRoot":"","sources":["../src/mergeTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAU,IAAI,EAAa,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAY,MAAM,wBAAwB,CAAC;AAMpE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,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C,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,WAAW,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,EACZ,UAAU,GAAE,OAAe,EAC3B,qBAAqB,GAAE,WAAyB,GAC9C,IAAI;IAoBP;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,OAAO;CA4Df"}
package/dist/mergeTree.js CHANGED
@@ -140,7 +140,7 @@ exports.findRootMergeBlock = findRootMergeBlock;
140
140
  * This can reduce the number of times the tree needs to be scanned if a range containing many
141
141
  * SlideOnRemove references is removed.
142
142
  */
143
- function getSlideToSegment(segment, slidingPreference = localReference_js_1.SlidingPreference.FORWARD, perspective, cache, useNewSlidingBehavior = false) {
143
+ function getSlideToSegment(segment, slidingPreference = localReference_js_1.SlidingPreference.FORWARD, perspective, cache, canSlideToEndpoint = false) {
144
144
  if (!segment ||
145
145
  perspective.isSegmentPresent(segment) ||
146
146
  segment.endpointType !== undefined) {
@@ -181,7 +181,7 @@ function getSlideToSegment(segment, slidingPreference = localReference_js_1.Slid
181
181
  //
182
182
  // in both of these cases detached may be substituted for one of the special
183
183
  // endpoint segments, if such behavior is enabled
184
- if (!useNewSlidingBehavior) {
184
+ if (!canSlideToEndpoint) {
185
185
  if (slidingPreference === localReference_js_1.SlidingPreference.BACKWARD) {
186
186
  (0, mergeTreeNodeWalk_js_1.forwardExcursion)(segment, goFurtherToFindSlideToSegment);
187
187
  }
@@ -204,15 +204,18 @@ function getSlideToSegment(segment, slidingPreference = localReference_js_1.Slid
204
204
  * @returns segment and offset to slide the reference to
205
205
  * @internal
206
206
  */
207
- function getSlideToSegoff(segoff, slidingPreference = localReference_js_1.SlidingPreference.FORWARD, perspective = perspective_js_1.allAckedChangesPerspective, useNewSlidingBehavior = false) {
208
- if (!(0, mergeTreeNodes_js_1.isSegmentLeaf)(segoff.segment)) {
207
+ function getSlideToSegoff(segoff, slidingPreference = localReference_js_1.SlidingPreference.FORWARD, perspective = perspective_js_1.allAckedChangesPerspective, canSlideToEndpoint = false) {
208
+ if (!(0, mergeTreeNodes_js_1.isSegmentLeaf)(segoff?.segment)) {
209
209
  return segoff;
210
210
  }
211
- const [segment, _] = getSlideToSegment(segoff.segment, slidingPreference, perspective, undefined, useNewSlidingBehavior);
211
+ const [segment, _] = getSlideToSegment(segoff.segment, slidingPreference, perspective, undefined, canSlideToEndpoint);
212
212
  if (segment === segoff.segment) {
213
213
  return segoff;
214
214
  }
215
- const offset = segment && segment.ordinal < segoff.segment.ordinal ? segment.cachedLength - 1 : 0;
215
+ if (segment === undefined) {
216
+ return undefined;
217
+ }
218
+ const offset = segment.ordinal < segoff.segment.ordinal ? segment.cachedLength - 1 : 0;
216
219
  return {
217
220
  segment,
218
221
  offset,
@@ -507,6 +510,9 @@ class MergeTree {
507
510
  return false;
508
511
  };
509
512
  this.nodeMap(perspective, leaf, undefined, pos, pos + 1);
513
+ if (segment === undefined || offset === undefined) {
514
+ return undefined;
515
+ }
510
516
  return { segment, offset };
511
517
  }
512
518
  /**
@@ -751,10 +757,11 @@ class MergeTree {
751
757
  */
752
758
  searchForMarker(startPos, markerLabel, forwards = true) {
753
759
  let foundMarker;
754
- const { segment } = this.getContainingSegment(startPos, this.localPerspective);
755
- if (!(0, mergeTreeNodes_js_1.isSegmentLeaf)(segment)) {
760
+ const segoff = this.getContainingSegment(startPos, this.localPerspective);
761
+ if (!(0, mergeTreeNodes_js_1.isSegmentLeaf)(segoff?.segment)) {
756
762
  return undefined;
757
763
  }
764
+ const { segment } = segoff;
758
765
  (0, mergeTreeNodeWalk_js_1.depthFirstNodeWalk)(segment.parent, segment, (node) => {
759
766
  if (node.isLeaf()) {
760
767
  if (!(0, segmentInfos_js_1.isRemoved)(node) && mergeTreeNodes_js_1.Marker.is(node) && (0, referencePositions_js_1.refHasTileLabel)(node, markerLabel)) {
@@ -1335,8 +1342,9 @@ class MergeTree {
1335
1342
  const localOverlapWithRefs = [];
1336
1343
  const removedSegments = [];
1337
1344
  const createRefFromSequencePlace = (place) => {
1338
- const { segment: placeSeg, offset: placeOffset } = this.getContainingSegment(place.pos, perspective);
1339
- (0, internal_1.assert)((0, mergeTreeNodes_js_1.isSegmentLeaf)(placeSeg) && placeOffset !== undefined, 0xa3f /* segments cannot be undefined */);
1345
+ const segOff = this.getContainingSegment(place.pos, perspective);
1346
+ (0, internal_1.assert)((0, mergeTreeNodes_js_1.isSegmentLeaf)(segOff?.segment), 0xa3f /* segments cannot be undefined */);
1347
+ const { segment: placeSeg, offset: placeOffset } = segOff;
1340
1348
  return this.createLocalReferencePosition(placeSeg, placeOffset, ops_js_1.ReferenceType.StayOnRemove, undefined);
1341
1349
  };
1342
1350
  const obliterate = {