@codemirror/state 6.1.0 → 6.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +65 -63
- package/dist/index.js +65 -63
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.1.2 (2022-09-21)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue where, when multiple transaction extenders took effect, only the highest-precedence one was actually included in the transaction.
|
|
6
|
+
|
|
7
|
+
## 6.1.1 (2022-08-03)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix a bug in range set span iteration that would cause decorations to be inappropriately split in some situations.
|
|
12
|
+
|
|
1
13
|
## 6.1.0 (2022-06-30)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -31,10 +31,10 @@ class Text {
|
|
|
31
31
|
*/
|
|
32
32
|
replace(from, to, text) {
|
|
33
33
|
let parts = [];
|
|
34
|
-
this.decompose(0, from, parts, 2 /* To */);
|
|
34
|
+
this.decompose(0, from, parts, 2 /* Open.To */);
|
|
35
35
|
if (text.length)
|
|
36
|
-
text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
|
|
37
|
-
this.decompose(to, this.length, parts, 1 /* From */);
|
|
36
|
+
text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);
|
|
37
|
+
this.decompose(to, this.length, parts, 1 /* Open.From */);
|
|
38
38
|
return TextNode.from(parts, this.length - (to - from) + text.length);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -124,7 +124,7 @@ class Text {
|
|
|
124
124
|
throw new RangeError("A document must have at least one line");
|
|
125
125
|
if (text.length == 1 && !text[0])
|
|
126
126
|
return Text.empty;
|
|
127
|
-
return text.length <= 32 /* Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
127
|
+
return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
// Leaves store an array of line strings. There are always line breaks
|
|
@@ -150,10 +150,10 @@ class TextLeaf extends Text {
|
|
|
150
150
|
decompose(from, to, target, open) {
|
|
151
151
|
let text = from <= 0 && to >= this.length ? this
|
|
152
152
|
: new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
|
|
153
|
-
if (open & 1 /* From */) {
|
|
153
|
+
if (open & 1 /* Open.From */) {
|
|
154
154
|
let prev = target.pop();
|
|
155
155
|
let joined = appendText(text.text, prev.text.slice(), 0, text.length);
|
|
156
|
-
if (joined.length <= 32 /* Branch */) {
|
|
156
|
+
if (joined.length <= 32 /* Tree.Branch */) {
|
|
157
157
|
target.push(new TextLeaf(joined, prev.length + text.length));
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
@@ -170,7 +170,7 @@ class TextLeaf extends Text {
|
|
|
170
170
|
return super.replace(from, to, text);
|
|
171
171
|
let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
|
|
172
172
|
let newLen = this.length + text.length - (to - from);
|
|
173
|
-
if (lines.length <= 32 /* Branch */)
|
|
173
|
+
if (lines.length <= 32 /* Tree.Branch */)
|
|
174
174
|
return new TextLeaf(lines, newLen);
|
|
175
175
|
return TextNode.from(TextLeaf.split(lines, []), newLen);
|
|
176
176
|
}
|
|
@@ -196,7 +196,7 @@ class TextLeaf extends Text {
|
|
|
196
196
|
for (let line of text) {
|
|
197
197
|
part.push(line);
|
|
198
198
|
len += line.length + 1;
|
|
199
|
-
if (part.length == 32 /* Branch */) {
|
|
199
|
+
if (part.length == 32 /* Tree.Branch */) {
|
|
200
200
|
target.push(new TextLeaf(part, len));
|
|
201
201
|
part = [];
|
|
202
202
|
len = -1;
|
|
@@ -233,7 +233,7 @@ class TextNode extends Text {
|
|
|
233
233
|
for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
|
|
234
234
|
let child = this.children[i], end = pos + child.length;
|
|
235
235
|
if (from <= end && to >= pos) {
|
|
236
|
-
let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
|
|
236
|
+
let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));
|
|
237
237
|
if (pos >= from && end <= to && !childOpen)
|
|
238
238
|
target.push(child);
|
|
239
239
|
else
|
|
@@ -252,8 +252,8 @@ class TextNode extends Text {
|
|
|
252
252
|
if (from >= pos && to <= end) {
|
|
253
253
|
let updated = child.replace(from - pos, to - pos, text);
|
|
254
254
|
let totalLines = this.lines - child.lines + updated.lines;
|
|
255
|
-
if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
|
|
256
|
-
updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
|
|
255
|
+
if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&
|
|
256
|
+
updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {
|
|
257
257
|
let copy = this.children.slice();
|
|
258
258
|
copy[i] = updated;
|
|
259
259
|
return new TextNode(copy, this.length - (to - from) + text.length);
|
|
@@ -299,13 +299,13 @@ class TextNode extends Text {
|
|
|
299
299
|
let lines = 0;
|
|
300
300
|
for (let ch of children)
|
|
301
301
|
lines += ch.lines;
|
|
302
|
-
if (lines < 32 /* Branch */) {
|
|
302
|
+
if (lines < 32 /* Tree.Branch */) {
|
|
303
303
|
let flat = [];
|
|
304
304
|
for (let ch of children)
|
|
305
305
|
ch.flatten(flat);
|
|
306
306
|
return new TextLeaf(flat, length);
|
|
307
307
|
}
|
|
308
|
-
let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
|
|
308
|
+
let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
|
|
309
309
|
let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
|
|
310
310
|
function add(child) {
|
|
311
311
|
let last;
|
|
@@ -319,7 +319,7 @@ class TextNode extends Text {
|
|
|
319
319
|
}
|
|
320
320
|
else if (child instanceof TextLeaf && currentLines &&
|
|
321
321
|
(last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&
|
|
322
|
-
child.lines + last.lines <= 32 /* Branch */) {
|
|
322
|
+
child.lines + last.lines <= 32 /* Tree.Branch */) {
|
|
323
323
|
currentLines += child.lines;
|
|
324
324
|
currentLen += child.length + 1;
|
|
325
325
|
currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);
|
|
@@ -1316,12 +1316,12 @@ class SelectionRange {
|
|
|
1316
1316
|
The anchor of the range—the side that doesn't move when you
|
|
1317
1317
|
extend it.
|
|
1318
1318
|
*/
|
|
1319
|
-
get anchor() { return this.flags & 16 /* Inverted */ ? this.to : this.from; }
|
|
1319
|
+
get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }
|
|
1320
1320
|
/**
|
|
1321
1321
|
The head of the range, which is moved when the range is
|
|
1322
1322
|
[extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
|
|
1323
1323
|
*/
|
|
1324
|
-
get head() { return this.flags & 16 /* Inverted */ ? this.from : this.to; }
|
|
1324
|
+
get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }
|
|
1325
1325
|
/**
|
|
1326
1326
|
True when `anchor` and `head` are at the same position.
|
|
1327
1327
|
*/
|
|
@@ -1332,13 +1332,13 @@ class SelectionRange {
|
|
|
1332
1332
|
the character before its position, 1 the character after, and 0
|
|
1333
1333
|
means no association.
|
|
1334
1334
|
*/
|
|
1335
|
-
get assoc() { return this.flags & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
|
|
1335
|
+
get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }
|
|
1336
1336
|
/**
|
|
1337
1337
|
The bidirectional text level associated with this cursor, if
|
|
1338
1338
|
any.
|
|
1339
1339
|
*/
|
|
1340
1340
|
get bidiLevel() {
|
|
1341
|
-
let level = this.flags & 3 /* BidiLevelMask */;
|
|
1341
|
+
let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;
|
|
1342
1342
|
return level == 3 ? null : level;
|
|
1343
1343
|
}
|
|
1344
1344
|
/**
|
|
@@ -1348,8 +1348,8 @@ class SelectionRange {
|
|
|
1348
1348
|
lines of different length.
|
|
1349
1349
|
*/
|
|
1350
1350
|
get goalColumn() {
|
|
1351
|
-
let value = this.flags >> 5 /* GoalColumnOffset */;
|
|
1352
|
-
return value == 33554431 /* NoGoalColumn */ ? undefined : value;
|
|
1351
|
+
let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;
|
|
1352
|
+
return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;
|
|
1353
1353
|
}
|
|
1354
1354
|
/**
|
|
1355
1355
|
Map this range through a change, producing a valid range in the
|
|
@@ -1509,17 +1509,17 @@ class EditorSelection {
|
|
|
1509
1509
|
safely ignore the optional arguments in most situations.
|
|
1510
1510
|
*/
|
|
1511
1511
|
static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
|
|
1512
|
-
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
|
|
1512
|
+
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |
|
|
1513
1513
|
(bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
|
|
1514
|
-
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
|
|
1514
|
+
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));
|
|
1515
1515
|
}
|
|
1516
1516
|
/**
|
|
1517
1517
|
Create a selection range.
|
|
1518
1518
|
*/
|
|
1519
1519
|
static range(anchor, head, goalColumn) {
|
|
1520
|
-
let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
|
|
1521
|
-
return head < anchor ? SelectionRange.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
|
|
1522
|
-
: SelectionRange.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
|
|
1520
|
+
let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */;
|
|
1521
|
+
return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | goal | 8 /* RangeFlag.AssocAfter */)
|
|
1522
|
+
: SelectionRange.create(anchor, head, goal | (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0));
|
|
1523
1523
|
}
|
|
1524
1524
|
/**
|
|
1525
1525
|
@internal
|
|
@@ -1592,7 +1592,7 @@ class Facet {
|
|
|
1592
1592
|
Returns an extension that adds the given value to this facet.
|
|
1593
1593
|
*/
|
|
1594
1594
|
of(value) {
|
|
1595
|
-
return new FacetProvider([], this, 0 /* Static */, value);
|
|
1595
|
+
return new FacetProvider([], this, 0 /* Provider.Static */, value);
|
|
1596
1596
|
}
|
|
1597
1597
|
/**
|
|
1598
1598
|
Create an extension that computes a value for the facet from a
|
|
@@ -1606,7 +1606,7 @@ class Facet {
|
|
|
1606
1606
|
compute(deps, get) {
|
|
1607
1607
|
if (this.isStatic)
|
|
1608
1608
|
throw new Error("Can't compute a static facet");
|
|
1609
|
-
return new FacetProvider(deps, this, 1 /* Single */, get);
|
|
1609
|
+
return new FacetProvider(deps, this, 1 /* Provider.Single */, get);
|
|
1610
1610
|
}
|
|
1611
1611
|
/**
|
|
1612
1612
|
Create an extension that computes zero or more values for this
|
|
@@ -1615,7 +1615,7 @@ class Facet {
|
|
|
1615
1615
|
computeN(deps, get) {
|
|
1616
1616
|
if (this.isStatic)
|
|
1617
1617
|
throw new Error("Can't compute a static facet");
|
|
1618
|
-
return new FacetProvider(deps, this, 2 /* Multi */, get);
|
|
1618
|
+
return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);
|
|
1619
1619
|
}
|
|
1620
1620
|
from(field, get) {
|
|
1621
1621
|
if (!get)
|
|
@@ -1638,7 +1638,7 @@ class FacetProvider {
|
|
|
1638
1638
|
var _a;
|
|
1639
1639
|
let getter = this.value;
|
|
1640
1640
|
let compare = this.facet.compareInput;
|
|
1641
|
-
let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
|
|
1641
|
+
let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;
|
|
1642
1642
|
let depDoc = false, depSel = false, depAddrs = [];
|
|
1643
1643
|
for (let dep of this.dependencies) {
|
|
1644
1644
|
if (dep == "doc")
|
|
@@ -1651,14 +1651,14 @@ class FacetProvider {
|
|
|
1651
1651
|
return {
|
|
1652
1652
|
create(state) {
|
|
1653
1653
|
state.values[idx] = getter(state);
|
|
1654
|
-
return 1 /* Changed */;
|
|
1654
|
+
return 1 /* SlotStatus.Changed */;
|
|
1655
1655
|
},
|
|
1656
1656
|
update(state, tr) {
|
|
1657
1657
|
if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {
|
|
1658
1658
|
let newVal = getter(state);
|
|
1659
1659
|
if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
|
|
1660
1660
|
state.values[idx] = newVal;
|
|
1661
|
-
return 1 /* Changed */;
|
|
1661
|
+
return 1 /* SlotStatus.Changed */;
|
|
1662
1662
|
}
|
|
1663
1663
|
}
|
|
1664
1664
|
return 0;
|
|
@@ -1677,7 +1677,7 @@ class FacetProvider {
|
|
|
1677
1677
|
}
|
|
1678
1678
|
}
|
|
1679
1679
|
state.values[idx] = newVal;
|
|
1680
|
-
return 1 /* Changed */;
|
|
1680
|
+
return 1 /* SlotStatus.Changed */;
|
|
1681
1681
|
}
|
|
1682
1682
|
};
|
|
1683
1683
|
}
|
|
@@ -1693,7 +1693,7 @@ function compareArray(a, b, compare) {
|
|
|
1693
1693
|
function ensureAll(state, addrs) {
|
|
1694
1694
|
let changed = false;
|
|
1695
1695
|
for (let addr of addrs)
|
|
1696
|
-
if (ensureAddr(state, addr) & 1 /* Changed */)
|
|
1696
|
+
if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)
|
|
1697
1697
|
changed = true;
|
|
1698
1698
|
return changed;
|
|
1699
1699
|
}
|
|
@@ -1706,7 +1706,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1706
1706
|
let values = [];
|
|
1707
1707
|
for (let i = 0; i < providerAddrs.length; i++) {
|
|
1708
1708
|
let value = getAddr(state, providerAddrs[i]);
|
|
1709
|
-
if (providerTypes[i] == 2 /* Multi */)
|
|
1709
|
+
if (providerTypes[i] == 2 /* Provider.Multi */)
|
|
1710
1710
|
for (let val of value)
|
|
1711
1711
|
values.push(val);
|
|
1712
1712
|
else
|
|
@@ -1719,7 +1719,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1719
1719
|
for (let addr of providerAddrs)
|
|
1720
1720
|
ensureAddr(state, addr);
|
|
1721
1721
|
state.values[idx] = get(state);
|
|
1722
|
-
return 1 /* Changed */;
|
|
1722
|
+
return 1 /* SlotStatus.Changed */;
|
|
1723
1723
|
},
|
|
1724
1724
|
update(state, tr) {
|
|
1725
1725
|
if (!ensureAll(state, dynamic))
|
|
@@ -1728,7 +1728,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1728
1728
|
if (facet.compare(value, state.values[idx]))
|
|
1729
1729
|
return 0;
|
|
1730
1730
|
state.values[idx] = value;
|
|
1731
|
-
return 1 /* Changed */;
|
|
1731
|
+
return 1 /* SlotStatus.Changed */;
|
|
1732
1732
|
},
|
|
1733
1733
|
reconfigure(state, oldState) {
|
|
1734
1734
|
let depChanged = ensureAll(state, providerAddrs);
|
|
@@ -1743,7 +1743,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1743
1743
|
return 0;
|
|
1744
1744
|
}
|
|
1745
1745
|
state.values[idx] = value;
|
|
1746
|
-
return 1 /* Changed */;
|
|
1746
|
+
return 1 /* SlotStatus.Changed */;
|
|
1747
1747
|
}
|
|
1748
1748
|
};
|
|
1749
1749
|
}
|
|
@@ -1793,7 +1793,7 @@ class StateField {
|
|
|
1793
1793
|
return {
|
|
1794
1794
|
create: (state) => {
|
|
1795
1795
|
state.values[idx] = this.create(state);
|
|
1796
|
-
return 1 /* Changed */;
|
|
1796
|
+
return 1 /* SlotStatus.Changed */;
|
|
1797
1797
|
},
|
|
1798
1798
|
update: (state, tr) => {
|
|
1799
1799
|
let oldVal = state.values[idx];
|
|
@@ -1801,7 +1801,7 @@ class StateField {
|
|
|
1801
1801
|
if (this.compareF(oldVal, value))
|
|
1802
1802
|
return 0;
|
|
1803
1803
|
state.values[idx] = value;
|
|
1804
|
-
return 1 /* Changed */;
|
|
1804
|
+
return 1 /* SlotStatus.Changed */;
|
|
1805
1805
|
},
|
|
1806
1806
|
reconfigure: (state, oldState) => {
|
|
1807
1807
|
if (oldState.config.address[this.id] != null) {
|
|
@@ -1809,7 +1809,7 @@ class StateField {
|
|
|
1809
1809
|
return 0;
|
|
1810
1810
|
}
|
|
1811
1811
|
state.values[idx] = this.create(state);
|
|
1812
|
-
return 1 /* Changed */;
|
|
1812
|
+
return 1 /* SlotStatus.Changed */;
|
|
1813
1813
|
}
|
|
1814
1814
|
};
|
|
1815
1815
|
}
|
|
@@ -1918,7 +1918,7 @@ class Configuration {
|
|
|
1918
1918
|
this.facets = facets;
|
|
1919
1919
|
this.statusTemplate = [];
|
|
1920
1920
|
while (this.statusTemplate.length < dynamicSlots.length)
|
|
1921
|
-
this.statusTemplate.push(0 /* Unresolved */);
|
|
1921
|
+
this.statusTemplate.push(0 /* SlotStatus.Unresolved */);
|
|
1922
1922
|
}
|
|
1923
1923
|
staticFacet(facet) {
|
|
1924
1924
|
let addr = this.address[facet.id];
|
|
@@ -1945,7 +1945,7 @@ class Configuration {
|
|
|
1945
1945
|
for (let id in facets) {
|
|
1946
1946
|
let providers = facets[id], facet = providers[0].facet;
|
|
1947
1947
|
let oldProviders = oldFacets && oldFacets[id] || [];
|
|
1948
|
-
if (providers.every(p => p.type == 0 /* Static */)) {
|
|
1948
|
+
if (providers.every(p => p.type == 0 /* Provider.Static */)) {
|
|
1949
1949
|
address[facet.id] = (staticValues.length << 1) | 1;
|
|
1950
1950
|
if (sameArray(oldProviders, providers)) {
|
|
1951
1951
|
staticValues.push(oldState.facet(facet));
|
|
@@ -1957,7 +1957,7 @@ class Configuration {
|
|
|
1957
1957
|
}
|
|
1958
1958
|
else {
|
|
1959
1959
|
for (let p of providers) {
|
|
1960
|
-
if (p.type == 0 /* Static */) {
|
|
1960
|
+
if (p.type == 0 /* Provider.Static */) {
|
|
1961
1961
|
address[p.id] = (staticValues.length << 1) | 1;
|
|
1962
1962
|
staticValues.push(p.value);
|
|
1963
1963
|
}
|
|
@@ -2011,7 +2011,7 @@ function flatten(extension, compartments, newCompartments) {
|
|
|
2011
2011
|
else if (ext instanceof FacetProvider) {
|
|
2012
2012
|
result[prec].push(ext);
|
|
2013
2013
|
if (ext.facet.extensions)
|
|
2014
|
-
inner(ext.facet.extensions,
|
|
2014
|
+
inner(ext.facet.extensions, Prec_.default);
|
|
2015
2015
|
}
|
|
2016
2016
|
else {
|
|
2017
2017
|
let content = ext.extension;
|
|
@@ -2025,16 +2025,16 @@ function flatten(extension, compartments, newCompartments) {
|
|
|
2025
2025
|
}
|
|
2026
2026
|
function ensureAddr(state, addr) {
|
|
2027
2027
|
if (addr & 1)
|
|
2028
|
-
return 2 /* Computed */;
|
|
2028
|
+
return 2 /* SlotStatus.Computed */;
|
|
2029
2029
|
let idx = addr >> 1;
|
|
2030
2030
|
let status = state.status[idx];
|
|
2031
|
-
if (status == 4 /* Computing */)
|
|
2031
|
+
if (status == 4 /* SlotStatus.Computing */)
|
|
2032
2032
|
throw new Error("Cyclic dependency between fields and/or facets");
|
|
2033
|
-
if (status & 2 /* Computed */)
|
|
2033
|
+
if (status & 2 /* SlotStatus.Computed */)
|
|
2034
2034
|
return status;
|
|
2035
|
-
state.status[idx] = 4 /* Computing */;
|
|
2035
|
+
state.status[idx] = 4 /* SlotStatus.Computing */;
|
|
2036
2036
|
let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
|
|
2037
|
-
return state.status[idx] = 2 /* Computed */ | changed;
|
|
2037
|
+
return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;
|
|
2038
2038
|
}
|
|
2039
2039
|
function getAddr(state, addr) {
|
|
2040
2040
|
return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
|
|
@@ -2471,7 +2471,7 @@ function extendTransaction(tr) {
|
|
|
2471
2471
|
for (let i = extenders.length - 1; i >= 0; i--) {
|
|
2472
2472
|
let extension = extenders[i](tr);
|
|
2473
2473
|
if (extension && Object.keys(extension).length)
|
|
2474
|
-
spec = mergeTransaction(
|
|
2474
|
+
spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);
|
|
2475
2475
|
}
|
|
2476
2476
|
return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
|
|
2477
2477
|
}
|
|
@@ -3081,7 +3081,7 @@ class Chunk {
|
|
|
3081
3081
|
}
|
|
3082
3082
|
}
|
|
3083
3083
|
between(offset, from, to, f) {
|
|
3084
|
-
for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
|
|
3084
|
+
for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)
|
|
3085
3085
|
if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
|
|
3086
3086
|
return false;
|
|
3087
3087
|
}
|
|
@@ -3314,7 +3314,7 @@ class RangeSet {
|
|
|
3314
3314
|
*/
|
|
3315
3315
|
static eq(oldSets, newSets, from = 0, to) {
|
|
3316
3316
|
if (to == null)
|
|
3317
|
-
to = 1000000000 /* Far */;
|
|
3317
|
+
to = 1000000000 /* C.Far */;
|
|
3318
3318
|
let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
|
|
3319
3319
|
let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
|
|
3320
3320
|
if (a.length != b.length)
|
|
@@ -3409,8 +3409,8 @@ class RangeSetBuilder {
|
|
|
3409
3409
|
this.chunkPos = [];
|
|
3410
3410
|
this.chunkStart = -1;
|
|
3411
3411
|
this.last = null;
|
|
3412
|
-
this.lastFrom = -1000000000 /* Far */;
|
|
3413
|
-
this.lastTo = -1000000000 /* Far */;
|
|
3412
|
+
this.lastFrom = -1000000000 /* C.Far */;
|
|
3413
|
+
this.lastTo = -1000000000 /* C.Far */;
|
|
3414
3414
|
this.from = [];
|
|
3415
3415
|
this.to = [];
|
|
3416
3416
|
this.value = [];
|
|
@@ -3447,7 +3447,7 @@ class RangeSetBuilder {
|
|
|
3447
3447
|
throw new Error("Ranges must be added sorted by `from` position and `startSide`");
|
|
3448
3448
|
if (diff < 0)
|
|
3449
3449
|
return false;
|
|
3450
|
-
if (this.from.length == 250 /* ChunkSize */)
|
|
3450
|
+
if (this.from.length == 250 /* C.ChunkSize */)
|
|
3451
3451
|
this.finishChunk(true);
|
|
3452
3452
|
if (this.chunkStart < 0)
|
|
3453
3453
|
this.chunkStart = from;
|
|
@@ -3521,7 +3521,7 @@ class LayerCursor {
|
|
|
3521
3521
|
}
|
|
3522
3522
|
get startSide() { return this.value ? this.value.startSide : 0; }
|
|
3523
3523
|
get endSide() { return this.value ? this.value.endSide : 0; }
|
|
3524
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3524
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3525
3525
|
this.chunkIndex = this.rangeIndex = 0;
|
|
3526
3526
|
this.gotoInner(pos, side, false);
|
|
3527
3527
|
return this;
|
|
@@ -3550,7 +3550,7 @@ class LayerCursor {
|
|
|
3550
3550
|
next() {
|
|
3551
3551
|
for (;;) {
|
|
3552
3552
|
if (this.chunkIndex == this.layer.chunk.length) {
|
|
3553
|
-
this.from = this.to = 1000000000 /* Far */;
|
|
3553
|
+
this.from = this.to = 1000000000 /* C.Far */;
|
|
3554
3554
|
this.value = null;
|
|
3555
3555
|
break;
|
|
3556
3556
|
}
|
|
@@ -3604,7 +3604,7 @@ class HeapCursor {
|
|
|
3604
3604
|
return heap.length == 1 ? heap[0] : new HeapCursor(heap);
|
|
3605
3605
|
}
|
|
3606
3606
|
get startSide() { return this.value ? this.value.startSide : 0; }
|
|
3607
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3607
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3608
3608
|
for (let cur of this.heap)
|
|
3609
3609
|
cur.goto(pos, side);
|
|
3610
3610
|
for (let i = this.heap.length >> 1; i >= 0; i--)
|
|
@@ -3622,7 +3622,7 @@ class HeapCursor {
|
|
|
3622
3622
|
}
|
|
3623
3623
|
next() {
|
|
3624
3624
|
if (this.heap.length == 0) {
|
|
3625
|
-
this.from = this.to = 1000000000 /* Far */;
|
|
3625
|
+
this.from = this.to = 1000000000 /* C.Far */;
|
|
3626
3626
|
this.value = null;
|
|
3627
3627
|
this.rank = -1;
|
|
3628
3628
|
}
|
|
@@ -3666,12 +3666,12 @@ class SpanCursor {
|
|
|
3666
3666
|
this.point = null;
|
|
3667
3667
|
this.pointFrom = 0;
|
|
3668
3668
|
this.pointRank = 0;
|
|
3669
|
-
this.to = -1000000000 /* Far */;
|
|
3669
|
+
this.to = -1000000000 /* C.Far */;
|
|
3670
3670
|
this.endSide = 0;
|
|
3671
3671
|
this.openStart = -1;
|
|
3672
3672
|
this.cursor = HeapCursor.from(sets, skip, minPoint);
|
|
3673
3673
|
}
|
|
3674
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3674
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3675
3675
|
this.cursor.goto(pos, side);
|
|
3676
3676
|
this.active.length = this.activeTo.length = this.activeRank.length = 0;
|
|
3677
3677
|
this.minActive = -1;
|
|
@@ -3722,7 +3722,7 @@ class SpanCursor {
|
|
|
3722
3722
|
remove(trackOpen, a);
|
|
3723
3723
|
}
|
|
3724
3724
|
else if (!this.cursor.value) {
|
|
3725
|
-
this.to = this.endSide = 1000000000 /* Far */;
|
|
3725
|
+
this.to = this.endSide = 1000000000 /* C.Far */;
|
|
3726
3726
|
break;
|
|
3727
3727
|
}
|
|
3728
3728
|
else if (this.cursor.from > from) {
|
|
@@ -3734,6 +3734,8 @@ class SpanCursor {
|
|
|
3734
3734
|
let nextVal = this.cursor.value;
|
|
3735
3735
|
if (!nextVal.point) { // Opening a range
|
|
3736
3736
|
this.addActive(trackOpen);
|
|
3737
|
+
if (this.cursor.from < from && this.cursor.to > from)
|
|
3738
|
+
trackExtra++;
|
|
3737
3739
|
this.cursor.next();
|
|
3738
3740
|
}
|
|
3739
3741
|
else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
|
|
@@ -3825,7 +3827,7 @@ function insert(array, index, value) {
|
|
|
3825
3827
|
array[index] = value;
|
|
3826
3828
|
}
|
|
3827
3829
|
function findMinIndex(value, array) {
|
|
3828
|
-
let found = -1, foundPos = 1000000000 /* Far */;
|
|
3830
|
+
let found = -1, foundPos = 1000000000 /* C.Far */;
|
|
3829
3831
|
for (let i = 0; i < array.length; i++)
|
|
3830
3832
|
if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
|
|
3831
3833
|
found = i;
|
package/dist/index.js
CHANGED
|
@@ -27,10 +27,10 @@ class Text {
|
|
|
27
27
|
*/
|
|
28
28
|
replace(from, to, text) {
|
|
29
29
|
let parts = [];
|
|
30
|
-
this.decompose(0, from, parts, 2 /* To */);
|
|
30
|
+
this.decompose(0, from, parts, 2 /* Open.To */);
|
|
31
31
|
if (text.length)
|
|
32
|
-
text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
|
|
33
|
-
this.decompose(to, this.length, parts, 1 /* From */);
|
|
32
|
+
text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);
|
|
33
|
+
this.decompose(to, this.length, parts, 1 /* Open.From */);
|
|
34
34
|
return TextNode.from(parts, this.length - (to - from) + text.length);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -120,7 +120,7 @@ class Text {
|
|
|
120
120
|
throw new RangeError("A document must have at least one line");
|
|
121
121
|
if (text.length == 1 && !text[0])
|
|
122
122
|
return Text.empty;
|
|
123
|
-
return text.length <= 32 /* Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
123
|
+
return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
// Leaves store an array of line strings. There are always line breaks
|
|
@@ -146,10 +146,10 @@ class TextLeaf extends Text {
|
|
|
146
146
|
decompose(from, to, target, open) {
|
|
147
147
|
let text = from <= 0 && to >= this.length ? this
|
|
148
148
|
: new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
|
|
149
|
-
if (open & 1 /* From */) {
|
|
149
|
+
if (open & 1 /* Open.From */) {
|
|
150
150
|
let prev = target.pop();
|
|
151
151
|
let joined = appendText(text.text, prev.text.slice(), 0, text.length);
|
|
152
|
-
if (joined.length <= 32 /* Branch */) {
|
|
152
|
+
if (joined.length <= 32 /* Tree.Branch */) {
|
|
153
153
|
target.push(new TextLeaf(joined, prev.length + text.length));
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
@@ -166,7 +166,7 @@ class TextLeaf extends Text {
|
|
|
166
166
|
return super.replace(from, to, text);
|
|
167
167
|
let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
|
|
168
168
|
let newLen = this.length + text.length - (to - from);
|
|
169
|
-
if (lines.length <= 32 /* Branch */)
|
|
169
|
+
if (lines.length <= 32 /* Tree.Branch */)
|
|
170
170
|
return new TextLeaf(lines, newLen);
|
|
171
171
|
return TextNode.from(TextLeaf.split(lines, []), newLen);
|
|
172
172
|
}
|
|
@@ -192,7 +192,7 @@ class TextLeaf extends Text {
|
|
|
192
192
|
for (let line of text) {
|
|
193
193
|
part.push(line);
|
|
194
194
|
len += line.length + 1;
|
|
195
|
-
if (part.length == 32 /* Branch */) {
|
|
195
|
+
if (part.length == 32 /* Tree.Branch */) {
|
|
196
196
|
target.push(new TextLeaf(part, len));
|
|
197
197
|
part = [];
|
|
198
198
|
len = -1;
|
|
@@ -229,7 +229,7 @@ class TextNode extends Text {
|
|
|
229
229
|
for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
|
|
230
230
|
let child = this.children[i], end = pos + child.length;
|
|
231
231
|
if (from <= end && to >= pos) {
|
|
232
|
-
let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
|
|
232
|
+
let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));
|
|
233
233
|
if (pos >= from && end <= to && !childOpen)
|
|
234
234
|
target.push(child);
|
|
235
235
|
else
|
|
@@ -248,8 +248,8 @@ class TextNode extends Text {
|
|
|
248
248
|
if (from >= pos && to <= end) {
|
|
249
249
|
let updated = child.replace(from - pos, to - pos, text);
|
|
250
250
|
let totalLines = this.lines - child.lines + updated.lines;
|
|
251
|
-
if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
|
|
252
|
-
updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
|
|
251
|
+
if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&
|
|
252
|
+
updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {
|
|
253
253
|
let copy = this.children.slice();
|
|
254
254
|
copy[i] = updated;
|
|
255
255
|
return new TextNode(copy, this.length - (to - from) + text.length);
|
|
@@ -295,13 +295,13 @@ class TextNode extends Text {
|
|
|
295
295
|
let lines = 0;
|
|
296
296
|
for (let ch of children)
|
|
297
297
|
lines += ch.lines;
|
|
298
|
-
if (lines < 32 /* Branch */) {
|
|
298
|
+
if (lines < 32 /* Tree.Branch */) {
|
|
299
299
|
let flat = [];
|
|
300
300
|
for (let ch of children)
|
|
301
301
|
ch.flatten(flat);
|
|
302
302
|
return new TextLeaf(flat, length);
|
|
303
303
|
}
|
|
304
|
-
let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
|
|
304
|
+
let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
|
|
305
305
|
let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
|
|
306
306
|
function add(child) {
|
|
307
307
|
let last;
|
|
@@ -315,7 +315,7 @@ class TextNode extends Text {
|
|
|
315
315
|
}
|
|
316
316
|
else if (child instanceof TextLeaf && currentLines &&
|
|
317
317
|
(last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&
|
|
318
|
-
child.lines + last.lines <= 32 /* Branch */) {
|
|
318
|
+
child.lines + last.lines <= 32 /* Tree.Branch */) {
|
|
319
319
|
currentLines += child.lines;
|
|
320
320
|
currentLen += child.length + 1;
|
|
321
321
|
currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);
|
|
@@ -1311,12 +1311,12 @@ class SelectionRange {
|
|
|
1311
1311
|
The anchor of the range—the side that doesn't move when you
|
|
1312
1312
|
extend it.
|
|
1313
1313
|
*/
|
|
1314
|
-
get anchor() { return this.flags & 16 /* Inverted */ ? this.to : this.from; }
|
|
1314
|
+
get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }
|
|
1315
1315
|
/**
|
|
1316
1316
|
The head of the range, which is moved when the range is
|
|
1317
1317
|
[extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
|
|
1318
1318
|
*/
|
|
1319
|
-
get head() { return this.flags & 16 /* Inverted */ ? this.from : this.to; }
|
|
1319
|
+
get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }
|
|
1320
1320
|
/**
|
|
1321
1321
|
True when `anchor` and `head` are at the same position.
|
|
1322
1322
|
*/
|
|
@@ -1327,13 +1327,13 @@ class SelectionRange {
|
|
|
1327
1327
|
the character before its position, 1 the character after, and 0
|
|
1328
1328
|
means no association.
|
|
1329
1329
|
*/
|
|
1330
|
-
get assoc() { return this.flags & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
|
|
1330
|
+
get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }
|
|
1331
1331
|
/**
|
|
1332
1332
|
The bidirectional text level associated with this cursor, if
|
|
1333
1333
|
any.
|
|
1334
1334
|
*/
|
|
1335
1335
|
get bidiLevel() {
|
|
1336
|
-
let level = this.flags & 3 /* BidiLevelMask */;
|
|
1336
|
+
let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;
|
|
1337
1337
|
return level == 3 ? null : level;
|
|
1338
1338
|
}
|
|
1339
1339
|
/**
|
|
@@ -1343,8 +1343,8 @@ class SelectionRange {
|
|
|
1343
1343
|
lines of different length.
|
|
1344
1344
|
*/
|
|
1345
1345
|
get goalColumn() {
|
|
1346
|
-
let value = this.flags >> 5 /* GoalColumnOffset */;
|
|
1347
|
-
return value == 33554431 /* NoGoalColumn */ ? undefined : value;
|
|
1346
|
+
let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;
|
|
1347
|
+
return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;
|
|
1348
1348
|
}
|
|
1349
1349
|
/**
|
|
1350
1350
|
Map this range through a change, producing a valid range in the
|
|
@@ -1504,17 +1504,17 @@ class EditorSelection {
|
|
|
1504
1504
|
safely ignore the optional arguments in most situations.
|
|
1505
1505
|
*/
|
|
1506
1506
|
static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
|
|
1507
|
-
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
|
|
1507
|
+
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |
|
|
1508
1508
|
(bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
|
|
1509
|
-
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
|
|
1509
|
+
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));
|
|
1510
1510
|
}
|
|
1511
1511
|
/**
|
|
1512
1512
|
Create a selection range.
|
|
1513
1513
|
*/
|
|
1514
1514
|
static range(anchor, head, goalColumn) {
|
|
1515
|
-
let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
|
|
1516
|
-
return head < anchor ? SelectionRange.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
|
|
1517
|
-
: SelectionRange.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
|
|
1515
|
+
let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */;
|
|
1516
|
+
return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | goal | 8 /* RangeFlag.AssocAfter */)
|
|
1517
|
+
: SelectionRange.create(anchor, head, goal | (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0));
|
|
1518
1518
|
}
|
|
1519
1519
|
/**
|
|
1520
1520
|
@internal
|
|
@@ -1587,7 +1587,7 @@ class Facet {
|
|
|
1587
1587
|
Returns an extension that adds the given value to this facet.
|
|
1588
1588
|
*/
|
|
1589
1589
|
of(value) {
|
|
1590
|
-
return new FacetProvider([], this, 0 /* Static */, value);
|
|
1590
|
+
return new FacetProvider([], this, 0 /* Provider.Static */, value);
|
|
1591
1591
|
}
|
|
1592
1592
|
/**
|
|
1593
1593
|
Create an extension that computes a value for the facet from a
|
|
@@ -1601,7 +1601,7 @@ class Facet {
|
|
|
1601
1601
|
compute(deps, get) {
|
|
1602
1602
|
if (this.isStatic)
|
|
1603
1603
|
throw new Error("Can't compute a static facet");
|
|
1604
|
-
return new FacetProvider(deps, this, 1 /* Single */, get);
|
|
1604
|
+
return new FacetProvider(deps, this, 1 /* Provider.Single */, get);
|
|
1605
1605
|
}
|
|
1606
1606
|
/**
|
|
1607
1607
|
Create an extension that computes zero or more values for this
|
|
@@ -1610,7 +1610,7 @@ class Facet {
|
|
|
1610
1610
|
computeN(deps, get) {
|
|
1611
1611
|
if (this.isStatic)
|
|
1612
1612
|
throw new Error("Can't compute a static facet");
|
|
1613
|
-
return new FacetProvider(deps, this, 2 /* Multi */, get);
|
|
1613
|
+
return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);
|
|
1614
1614
|
}
|
|
1615
1615
|
from(field, get) {
|
|
1616
1616
|
if (!get)
|
|
@@ -1633,7 +1633,7 @@ class FacetProvider {
|
|
|
1633
1633
|
var _a;
|
|
1634
1634
|
let getter = this.value;
|
|
1635
1635
|
let compare = this.facet.compareInput;
|
|
1636
|
-
let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
|
|
1636
|
+
let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;
|
|
1637
1637
|
let depDoc = false, depSel = false, depAddrs = [];
|
|
1638
1638
|
for (let dep of this.dependencies) {
|
|
1639
1639
|
if (dep == "doc")
|
|
@@ -1646,14 +1646,14 @@ class FacetProvider {
|
|
|
1646
1646
|
return {
|
|
1647
1647
|
create(state) {
|
|
1648
1648
|
state.values[idx] = getter(state);
|
|
1649
|
-
return 1 /* Changed */;
|
|
1649
|
+
return 1 /* SlotStatus.Changed */;
|
|
1650
1650
|
},
|
|
1651
1651
|
update(state, tr) {
|
|
1652
1652
|
if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {
|
|
1653
1653
|
let newVal = getter(state);
|
|
1654
1654
|
if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
|
|
1655
1655
|
state.values[idx] = newVal;
|
|
1656
|
-
return 1 /* Changed */;
|
|
1656
|
+
return 1 /* SlotStatus.Changed */;
|
|
1657
1657
|
}
|
|
1658
1658
|
}
|
|
1659
1659
|
return 0;
|
|
@@ -1672,7 +1672,7 @@ class FacetProvider {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
}
|
|
1674
1674
|
state.values[idx] = newVal;
|
|
1675
|
-
return 1 /* Changed */;
|
|
1675
|
+
return 1 /* SlotStatus.Changed */;
|
|
1676
1676
|
}
|
|
1677
1677
|
};
|
|
1678
1678
|
}
|
|
@@ -1688,7 +1688,7 @@ function compareArray(a, b, compare) {
|
|
|
1688
1688
|
function ensureAll(state, addrs) {
|
|
1689
1689
|
let changed = false;
|
|
1690
1690
|
for (let addr of addrs)
|
|
1691
|
-
if (ensureAddr(state, addr) & 1 /* Changed */)
|
|
1691
|
+
if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)
|
|
1692
1692
|
changed = true;
|
|
1693
1693
|
return changed;
|
|
1694
1694
|
}
|
|
@@ -1701,7 +1701,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1701
1701
|
let values = [];
|
|
1702
1702
|
for (let i = 0; i < providerAddrs.length; i++) {
|
|
1703
1703
|
let value = getAddr(state, providerAddrs[i]);
|
|
1704
|
-
if (providerTypes[i] == 2 /* Multi */)
|
|
1704
|
+
if (providerTypes[i] == 2 /* Provider.Multi */)
|
|
1705
1705
|
for (let val of value)
|
|
1706
1706
|
values.push(val);
|
|
1707
1707
|
else
|
|
@@ -1714,7 +1714,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1714
1714
|
for (let addr of providerAddrs)
|
|
1715
1715
|
ensureAddr(state, addr);
|
|
1716
1716
|
state.values[idx] = get(state);
|
|
1717
|
-
return 1 /* Changed */;
|
|
1717
|
+
return 1 /* SlotStatus.Changed */;
|
|
1718
1718
|
},
|
|
1719
1719
|
update(state, tr) {
|
|
1720
1720
|
if (!ensureAll(state, dynamic))
|
|
@@ -1723,7 +1723,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1723
1723
|
if (facet.compare(value, state.values[idx]))
|
|
1724
1724
|
return 0;
|
|
1725
1725
|
state.values[idx] = value;
|
|
1726
|
-
return 1 /* Changed */;
|
|
1726
|
+
return 1 /* SlotStatus.Changed */;
|
|
1727
1727
|
},
|
|
1728
1728
|
reconfigure(state, oldState) {
|
|
1729
1729
|
let depChanged = ensureAll(state, providerAddrs);
|
|
@@ -1738,7 +1738,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1738
1738
|
return 0;
|
|
1739
1739
|
}
|
|
1740
1740
|
state.values[idx] = value;
|
|
1741
|
-
return 1 /* Changed */;
|
|
1741
|
+
return 1 /* SlotStatus.Changed */;
|
|
1742
1742
|
}
|
|
1743
1743
|
};
|
|
1744
1744
|
}
|
|
@@ -1788,7 +1788,7 @@ class StateField {
|
|
|
1788
1788
|
return {
|
|
1789
1789
|
create: (state) => {
|
|
1790
1790
|
state.values[idx] = this.create(state);
|
|
1791
|
-
return 1 /* Changed */;
|
|
1791
|
+
return 1 /* SlotStatus.Changed */;
|
|
1792
1792
|
},
|
|
1793
1793
|
update: (state, tr) => {
|
|
1794
1794
|
let oldVal = state.values[idx];
|
|
@@ -1796,7 +1796,7 @@ class StateField {
|
|
|
1796
1796
|
if (this.compareF(oldVal, value))
|
|
1797
1797
|
return 0;
|
|
1798
1798
|
state.values[idx] = value;
|
|
1799
|
-
return 1 /* Changed */;
|
|
1799
|
+
return 1 /* SlotStatus.Changed */;
|
|
1800
1800
|
},
|
|
1801
1801
|
reconfigure: (state, oldState) => {
|
|
1802
1802
|
if (oldState.config.address[this.id] != null) {
|
|
@@ -1804,7 +1804,7 @@ class StateField {
|
|
|
1804
1804
|
return 0;
|
|
1805
1805
|
}
|
|
1806
1806
|
state.values[idx] = this.create(state);
|
|
1807
|
-
return 1 /* Changed */;
|
|
1807
|
+
return 1 /* SlotStatus.Changed */;
|
|
1808
1808
|
}
|
|
1809
1809
|
};
|
|
1810
1810
|
}
|
|
@@ -1913,7 +1913,7 @@ class Configuration {
|
|
|
1913
1913
|
this.facets = facets;
|
|
1914
1914
|
this.statusTemplate = [];
|
|
1915
1915
|
while (this.statusTemplate.length < dynamicSlots.length)
|
|
1916
|
-
this.statusTemplate.push(0 /* Unresolved */);
|
|
1916
|
+
this.statusTemplate.push(0 /* SlotStatus.Unresolved */);
|
|
1917
1917
|
}
|
|
1918
1918
|
staticFacet(facet) {
|
|
1919
1919
|
let addr = this.address[facet.id];
|
|
@@ -1940,7 +1940,7 @@ class Configuration {
|
|
|
1940
1940
|
for (let id in facets) {
|
|
1941
1941
|
let providers = facets[id], facet = providers[0].facet;
|
|
1942
1942
|
let oldProviders = oldFacets && oldFacets[id] || [];
|
|
1943
|
-
if (providers.every(p => p.type == 0 /* Static */)) {
|
|
1943
|
+
if (providers.every(p => p.type == 0 /* Provider.Static */)) {
|
|
1944
1944
|
address[facet.id] = (staticValues.length << 1) | 1;
|
|
1945
1945
|
if (sameArray(oldProviders, providers)) {
|
|
1946
1946
|
staticValues.push(oldState.facet(facet));
|
|
@@ -1952,7 +1952,7 @@ class Configuration {
|
|
|
1952
1952
|
}
|
|
1953
1953
|
else {
|
|
1954
1954
|
for (let p of providers) {
|
|
1955
|
-
if (p.type == 0 /* Static */) {
|
|
1955
|
+
if (p.type == 0 /* Provider.Static */) {
|
|
1956
1956
|
address[p.id] = (staticValues.length << 1) | 1;
|
|
1957
1957
|
staticValues.push(p.value);
|
|
1958
1958
|
}
|
|
@@ -2006,7 +2006,7 @@ function flatten(extension, compartments, newCompartments) {
|
|
|
2006
2006
|
else if (ext instanceof FacetProvider) {
|
|
2007
2007
|
result[prec].push(ext);
|
|
2008
2008
|
if (ext.facet.extensions)
|
|
2009
|
-
inner(ext.facet.extensions,
|
|
2009
|
+
inner(ext.facet.extensions, Prec_.default);
|
|
2010
2010
|
}
|
|
2011
2011
|
else {
|
|
2012
2012
|
let content = ext.extension;
|
|
@@ -2020,16 +2020,16 @@ function flatten(extension, compartments, newCompartments) {
|
|
|
2020
2020
|
}
|
|
2021
2021
|
function ensureAddr(state, addr) {
|
|
2022
2022
|
if (addr & 1)
|
|
2023
|
-
return 2 /* Computed */;
|
|
2023
|
+
return 2 /* SlotStatus.Computed */;
|
|
2024
2024
|
let idx = addr >> 1;
|
|
2025
2025
|
let status = state.status[idx];
|
|
2026
|
-
if (status == 4 /* Computing */)
|
|
2026
|
+
if (status == 4 /* SlotStatus.Computing */)
|
|
2027
2027
|
throw new Error("Cyclic dependency between fields and/or facets");
|
|
2028
|
-
if (status & 2 /* Computed */)
|
|
2028
|
+
if (status & 2 /* SlotStatus.Computed */)
|
|
2029
2029
|
return status;
|
|
2030
|
-
state.status[idx] = 4 /* Computing */;
|
|
2030
|
+
state.status[idx] = 4 /* SlotStatus.Computing */;
|
|
2031
2031
|
let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
|
|
2032
|
-
return state.status[idx] = 2 /* Computed */ | changed;
|
|
2032
|
+
return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;
|
|
2033
2033
|
}
|
|
2034
2034
|
function getAddr(state, addr) {
|
|
2035
2035
|
return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
|
|
@@ -2466,7 +2466,7 @@ function extendTransaction(tr) {
|
|
|
2466
2466
|
for (let i = extenders.length - 1; i >= 0; i--) {
|
|
2467
2467
|
let extension = extenders[i](tr);
|
|
2468
2468
|
if (extension && Object.keys(extension).length)
|
|
2469
|
-
spec = mergeTransaction(
|
|
2469
|
+
spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);
|
|
2470
2470
|
}
|
|
2471
2471
|
return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
|
|
2472
2472
|
}
|
|
@@ -3075,7 +3075,7 @@ class Chunk {
|
|
|
3075
3075
|
}
|
|
3076
3076
|
}
|
|
3077
3077
|
between(offset, from, to, f) {
|
|
3078
|
-
for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
|
|
3078
|
+
for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)
|
|
3079
3079
|
if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
|
|
3080
3080
|
return false;
|
|
3081
3081
|
}
|
|
@@ -3308,7 +3308,7 @@ class RangeSet {
|
|
|
3308
3308
|
*/
|
|
3309
3309
|
static eq(oldSets, newSets, from = 0, to) {
|
|
3310
3310
|
if (to == null)
|
|
3311
|
-
to = 1000000000 /* Far */;
|
|
3311
|
+
to = 1000000000 /* C.Far */;
|
|
3312
3312
|
let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
|
|
3313
3313
|
let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
|
|
3314
3314
|
if (a.length != b.length)
|
|
@@ -3403,8 +3403,8 @@ class RangeSetBuilder {
|
|
|
3403
3403
|
this.chunkPos = [];
|
|
3404
3404
|
this.chunkStart = -1;
|
|
3405
3405
|
this.last = null;
|
|
3406
|
-
this.lastFrom = -1000000000 /* Far */;
|
|
3407
|
-
this.lastTo = -1000000000 /* Far */;
|
|
3406
|
+
this.lastFrom = -1000000000 /* C.Far */;
|
|
3407
|
+
this.lastTo = -1000000000 /* C.Far */;
|
|
3408
3408
|
this.from = [];
|
|
3409
3409
|
this.to = [];
|
|
3410
3410
|
this.value = [];
|
|
@@ -3441,7 +3441,7 @@ class RangeSetBuilder {
|
|
|
3441
3441
|
throw new Error("Ranges must be added sorted by `from` position and `startSide`");
|
|
3442
3442
|
if (diff < 0)
|
|
3443
3443
|
return false;
|
|
3444
|
-
if (this.from.length == 250 /* ChunkSize */)
|
|
3444
|
+
if (this.from.length == 250 /* C.ChunkSize */)
|
|
3445
3445
|
this.finishChunk(true);
|
|
3446
3446
|
if (this.chunkStart < 0)
|
|
3447
3447
|
this.chunkStart = from;
|
|
@@ -3515,7 +3515,7 @@ class LayerCursor {
|
|
|
3515
3515
|
}
|
|
3516
3516
|
get startSide() { return this.value ? this.value.startSide : 0; }
|
|
3517
3517
|
get endSide() { return this.value ? this.value.endSide : 0; }
|
|
3518
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3518
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3519
3519
|
this.chunkIndex = this.rangeIndex = 0;
|
|
3520
3520
|
this.gotoInner(pos, side, false);
|
|
3521
3521
|
return this;
|
|
@@ -3544,7 +3544,7 @@ class LayerCursor {
|
|
|
3544
3544
|
next() {
|
|
3545
3545
|
for (;;) {
|
|
3546
3546
|
if (this.chunkIndex == this.layer.chunk.length) {
|
|
3547
|
-
this.from = this.to = 1000000000 /* Far */;
|
|
3547
|
+
this.from = this.to = 1000000000 /* C.Far */;
|
|
3548
3548
|
this.value = null;
|
|
3549
3549
|
break;
|
|
3550
3550
|
}
|
|
@@ -3598,7 +3598,7 @@ class HeapCursor {
|
|
|
3598
3598
|
return heap.length == 1 ? heap[0] : new HeapCursor(heap);
|
|
3599
3599
|
}
|
|
3600
3600
|
get startSide() { return this.value ? this.value.startSide : 0; }
|
|
3601
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3601
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3602
3602
|
for (let cur of this.heap)
|
|
3603
3603
|
cur.goto(pos, side);
|
|
3604
3604
|
for (let i = this.heap.length >> 1; i >= 0; i--)
|
|
@@ -3616,7 +3616,7 @@ class HeapCursor {
|
|
|
3616
3616
|
}
|
|
3617
3617
|
next() {
|
|
3618
3618
|
if (this.heap.length == 0) {
|
|
3619
|
-
this.from = this.to = 1000000000 /* Far */;
|
|
3619
|
+
this.from = this.to = 1000000000 /* C.Far */;
|
|
3620
3620
|
this.value = null;
|
|
3621
3621
|
this.rank = -1;
|
|
3622
3622
|
}
|
|
@@ -3660,12 +3660,12 @@ class SpanCursor {
|
|
|
3660
3660
|
this.point = null;
|
|
3661
3661
|
this.pointFrom = 0;
|
|
3662
3662
|
this.pointRank = 0;
|
|
3663
|
-
this.to = -1000000000 /* Far */;
|
|
3663
|
+
this.to = -1000000000 /* C.Far */;
|
|
3664
3664
|
this.endSide = 0;
|
|
3665
3665
|
this.openStart = -1;
|
|
3666
3666
|
this.cursor = HeapCursor.from(sets, skip, minPoint);
|
|
3667
3667
|
}
|
|
3668
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3668
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3669
3669
|
this.cursor.goto(pos, side);
|
|
3670
3670
|
this.active.length = this.activeTo.length = this.activeRank.length = 0;
|
|
3671
3671
|
this.minActive = -1;
|
|
@@ -3716,7 +3716,7 @@ class SpanCursor {
|
|
|
3716
3716
|
remove(trackOpen, a);
|
|
3717
3717
|
}
|
|
3718
3718
|
else if (!this.cursor.value) {
|
|
3719
|
-
this.to = this.endSide = 1000000000 /* Far */;
|
|
3719
|
+
this.to = this.endSide = 1000000000 /* C.Far */;
|
|
3720
3720
|
break;
|
|
3721
3721
|
}
|
|
3722
3722
|
else if (this.cursor.from > from) {
|
|
@@ -3728,6 +3728,8 @@ class SpanCursor {
|
|
|
3728
3728
|
let nextVal = this.cursor.value;
|
|
3729
3729
|
if (!nextVal.point) { // Opening a range
|
|
3730
3730
|
this.addActive(trackOpen);
|
|
3731
|
+
if (this.cursor.from < from && this.cursor.to > from)
|
|
3732
|
+
trackExtra++;
|
|
3731
3733
|
this.cursor.next();
|
|
3732
3734
|
}
|
|
3733
3735
|
else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
|
|
@@ -3819,7 +3821,7 @@ function insert(array, index, value) {
|
|
|
3819
3821
|
array[index] = value;
|
|
3820
3822
|
}
|
|
3821
3823
|
function findMinIndex(value, array) {
|
|
3822
|
-
let found = -1, foundPos = 1000000000 /* Far */;
|
|
3824
|
+
let found = -1, foundPos = 1000000000 /* C.Far */;
|
|
3823
3825
|
for (let i = 0; i < array.length; i++)
|
|
3824
3826
|
if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
|
|
3825
3827
|
found = i;
|