@arach/arc 0.4.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/arc-mcp.mjs +31826 -0
- package/docs/llm.txt +208 -0
- package/lib/MarkupPanel-CroO7O49.js +182 -0
- package/lib/arc.css +1 -1
- package/lib/arc.es.js +31 -27
- package/lib/arc.umd.js +156 -143
- package/lib/index-B4esAiHG.js +1006 -0
- package/lib/index-BtUi_w1W.js +964 -0
- package/lib/index-CI-w1U9t.js +2725 -0
- package/lib/index-CQhCoaVM.js +77 -0
- package/lib/index-CVhUGF67.js +1309 -0
- package/lib/{index-Ctu8395c.js → index-CbEv7M-m.js} +27251 -25424
- package/lib/index-Cg52_-j6.js +959 -0
- package/lib/index-Cmm99d2_.js +1925 -0
- package/lib/index-CnGsbmkP.js +7884 -0
- package/lib/index-CvsZLy9v.js +2344 -0
- package/lib/index-DBTOQDAV.js +1886 -0
- package/lib/index-Ds2bIH9V.js +967 -0
- package/lib/{index-z7-999ZD.js → index-gm9Hs3ZB.js} +1 -1
- package/lib/index.d.ts +79 -8
- package/package.json +33 -6
- package/skills/arc-diagrams/SKILL.md +218 -0
- package/src/types/diagram.ts +197 -0
- package/lib/commands_hudsonkit_false-tNYQZ4nZ.js +0 -5
- package/lib/highlight_hudsonkit_false-CGjCyNxW.js +0 -5
- package/lib/lang-css_hudsonkit_false-oeV3Hq1J.js +0 -5
- package/lib/lang-html_hudsonkit_false-CCxA3CYh.js +0 -5
- package/lib/lang-javascript_hudsonkit_false-SQgz3iJM.js +0 -5
- package/lib/lang-json_hudsonkit_false-BksH8zxC.js +0 -5
- package/lib/lang-markdown_hudsonkit_false-B5TeQsd5.js +0 -5
- package/lib/language_hudsonkit_false-D4r7WoC5.js +0 -5
- package/lib/state_hudsonkit_false-Rl5x6lAJ.js +0 -5
- package/lib/view_hudsonkit_false-Cv9f7Eek.js +0 -5
|
@@ -0,0 +1,1886 @@
|
|
|
1
|
+
import { N as y, e as ee, c as g, f as W, P as Tt, t as u, I as ft, a as j, b as ne, s as re, h as se } from "./index-CvsZLy9v.js";
|
|
2
|
+
import { StateEffect as z, Facet as v, StateField as xt, countColumn as ie, EditorState as O, RangeSetBuilder as nt, RangeSet as St, Prec as Pt, combineConfig as Ct } from "./index-CI-w1U9t.js";
|
|
3
|
+
import { V as R, E as b, g as oe, a as p, S as ut, D as H, G as le, W as At, l as ae } from "./index-CnGsbmkP.js";
|
|
4
|
+
var J;
|
|
5
|
+
const S = /* @__PURE__ */ new y();
|
|
6
|
+
function It(n) {
|
|
7
|
+
return v.define({
|
|
8
|
+
combine: n ? (t) => t.concat(n) : void 0
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const he = /* @__PURE__ */ new y();
|
|
12
|
+
class d {
|
|
13
|
+
/**
|
|
14
|
+
Construct a language object. If you need to invoke this
|
|
15
|
+
directly, first define a data facet with
|
|
16
|
+
[`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
|
|
17
|
+
configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
|
|
18
|
+
to the language's outer syntax node.
|
|
19
|
+
*/
|
|
20
|
+
constructor(t, e, r = [], s = "") {
|
|
21
|
+
this.data = t, this.name = s, O.prototype.hasOwnProperty("tree") || Object.defineProperty(O.prototype, "tree", { get() {
|
|
22
|
+
return m(this);
|
|
23
|
+
} }), this.parser = e, this.extension = [
|
|
24
|
+
T.of(this),
|
|
25
|
+
O.languageData.of((i, o, a) => {
|
|
26
|
+
let l = ct(i, o, a), h = l.type.prop(S);
|
|
27
|
+
if (!h)
|
|
28
|
+
return [];
|
|
29
|
+
let f = i.facet(h), c = l.type.prop(he);
|
|
30
|
+
if (c) {
|
|
31
|
+
let w = l.resolve(o - l.from, a);
|
|
32
|
+
for (let k of c)
|
|
33
|
+
if (k.test(w, i)) {
|
|
34
|
+
let P = i.facet(k.facet);
|
|
35
|
+
return k.type == "replace" ? P : P.concat(f);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return f;
|
|
39
|
+
})
|
|
40
|
+
].concat(r);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
Query whether this language is active at the given position.
|
|
44
|
+
*/
|
|
45
|
+
isActiveAt(t, e, r = -1) {
|
|
46
|
+
return ct(t, e, r).type.prop(S) == this.data;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
Find the document regions that were parsed using this language.
|
|
50
|
+
The returned regions will _include_ any nested languages rooted
|
|
51
|
+
in this language, when those exist.
|
|
52
|
+
*/
|
|
53
|
+
findRegions(t) {
|
|
54
|
+
let e = t.facet(T);
|
|
55
|
+
if (e?.data == this.data)
|
|
56
|
+
return [{ from: 0, to: t.doc.length }];
|
|
57
|
+
if (!e || !e.allowsNesting)
|
|
58
|
+
return [];
|
|
59
|
+
let r = [], s = (i, o) => {
|
|
60
|
+
if (i.prop(S) == this.data) {
|
|
61
|
+
r.push({ from: o, to: o + i.length });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
let a = i.prop(y.mounted);
|
|
65
|
+
if (a) {
|
|
66
|
+
if (a.tree.prop(S) == this.data) {
|
|
67
|
+
if (a.overlay)
|
|
68
|
+
for (let l of a.overlay)
|
|
69
|
+
r.push({ from: l.from + o, to: l.to + o });
|
|
70
|
+
else
|
|
71
|
+
r.push({ from: o, to: o + i.length });
|
|
72
|
+
return;
|
|
73
|
+
} else if (a.overlay) {
|
|
74
|
+
let l = r.length;
|
|
75
|
+
if (s(a.tree, a.overlay[0].from + o), r.length > l)
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (let l = 0; l < i.children.length; l++) {
|
|
80
|
+
let h = i.children[l];
|
|
81
|
+
h instanceof g && s(h, i.positions[l] + o);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return s(m(t), 0), r;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
Indicates whether this language allows nested languages. The
|
|
88
|
+
default implementation returns true.
|
|
89
|
+
*/
|
|
90
|
+
get allowsNesting() {
|
|
91
|
+
return !0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
d.setState = /* @__PURE__ */ z.define();
|
|
95
|
+
function ct(n, t, e) {
|
|
96
|
+
let r = n.facet(T), s = m(n).topNode;
|
|
97
|
+
if (!r || r.allowsNesting)
|
|
98
|
+
for (let i = s; i; i = i.enter(t, e, ft.ExcludeBuffers | ft.EnterBracketed))
|
|
99
|
+
i.type.isTop && (s = i);
|
|
100
|
+
return s;
|
|
101
|
+
}
|
|
102
|
+
class X extends d {
|
|
103
|
+
constructor(t, e, r) {
|
|
104
|
+
super(t, e, [], r), this.parser = e;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
Define a language from a parser.
|
|
108
|
+
*/
|
|
109
|
+
static define(t) {
|
|
110
|
+
let e = It(t.languageData);
|
|
111
|
+
return new X(e, t.parser.configure({
|
|
112
|
+
props: [S.add((r) => r.isTop ? e : void 0)]
|
|
113
|
+
}), t.name);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
Create a new instance of this language with a reconfigured
|
|
117
|
+
version of its parser and optionally a new name.
|
|
118
|
+
*/
|
|
119
|
+
configure(t, e) {
|
|
120
|
+
return new X(this.data, this.parser.configure(t), e || this.name);
|
|
121
|
+
}
|
|
122
|
+
get allowsNesting() {
|
|
123
|
+
return this.parser.hasWrappers();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function m(n) {
|
|
127
|
+
let t = n.field(d.state, !1);
|
|
128
|
+
return t ? t.tree : g.empty;
|
|
129
|
+
}
|
|
130
|
+
function fe(n, t, e = 50) {
|
|
131
|
+
var r;
|
|
132
|
+
let s = (r = n.field(d.state, !1)) === null || r === void 0 ? void 0 : r.context;
|
|
133
|
+
if (!s)
|
|
134
|
+
return null;
|
|
135
|
+
let i = s.viewport;
|
|
136
|
+
s.updateViewport({ from: 0, to: t });
|
|
137
|
+
let o = s.isDone(t) || s.work(e, t) ? s.tree : null;
|
|
138
|
+
return s.updateViewport(i), o;
|
|
139
|
+
}
|
|
140
|
+
function on(n, t = n.doc.length) {
|
|
141
|
+
var e;
|
|
142
|
+
return ((e = n.field(d.state, !1)) === null || e === void 0 ? void 0 : e.context.isDone(t)) || !1;
|
|
143
|
+
}
|
|
144
|
+
function ln(n, t = n.viewport.to, e = 100) {
|
|
145
|
+
let r = fe(n.state, t, e);
|
|
146
|
+
return r != m(n.state) && n.dispatch({}), !!r;
|
|
147
|
+
}
|
|
148
|
+
function an(n) {
|
|
149
|
+
var t;
|
|
150
|
+
return ((t = n.plugin(Mt)) === null || t === void 0 ? void 0 : t.isWorking()) || !1;
|
|
151
|
+
}
|
|
152
|
+
class ue {
|
|
153
|
+
/**
|
|
154
|
+
Create an input object for the given document.
|
|
155
|
+
*/
|
|
156
|
+
constructor(t) {
|
|
157
|
+
this.doc = t, this.cursorPos = 0, this.string = "", this.cursor = t.iter();
|
|
158
|
+
}
|
|
159
|
+
get length() {
|
|
160
|
+
return this.doc.length;
|
|
161
|
+
}
|
|
162
|
+
syncTo(t) {
|
|
163
|
+
return this.string = this.cursor.next(t - this.cursorPos).value, this.cursorPos = t + this.string.length, this.cursorPos - this.string.length;
|
|
164
|
+
}
|
|
165
|
+
chunk(t) {
|
|
166
|
+
return this.syncTo(t), this.string;
|
|
167
|
+
}
|
|
168
|
+
get lineChunks() {
|
|
169
|
+
return !0;
|
|
170
|
+
}
|
|
171
|
+
read(t, e) {
|
|
172
|
+
let r = this.cursorPos - this.string.length;
|
|
173
|
+
return t < r || e >= this.cursorPos ? this.doc.sliceString(t, e) : this.string.slice(t - r, e - r);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
let M = null;
|
|
177
|
+
class A {
|
|
178
|
+
constructor(t, e, r = [], s, i, o, a, l) {
|
|
179
|
+
this.parser = t, this.state = e, this.fragments = r, this.tree = s, this.treeLen = i, this.viewport = o, this.skipped = a, this.scheduleOn = l, this.parse = null, this.tempSkipped = [];
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
@internal
|
|
183
|
+
*/
|
|
184
|
+
static create(t, e, r) {
|
|
185
|
+
return new A(t, e, [], g.empty, 0, r, [], null);
|
|
186
|
+
}
|
|
187
|
+
startParse() {
|
|
188
|
+
return this.parser.startParse(new ue(this.state.doc), this.fragments);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
@internal
|
|
192
|
+
*/
|
|
193
|
+
work(t, e) {
|
|
194
|
+
return e != null && e >= this.state.doc.length && (e = void 0), this.tree != g.empty && this.isDone(e ?? this.state.doc.length) ? (this.takeTree(), !0) : this.withContext(() => {
|
|
195
|
+
var r;
|
|
196
|
+
if (typeof t == "number") {
|
|
197
|
+
let s = Date.now() + t;
|
|
198
|
+
t = () => Date.now() > s;
|
|
199
|
+
}
|
|
200
|
+
for (this.parse || (this.parse = this.startParse()), e != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > e) && e < this.state.doc.length && this.parse.stopAt(e); ; ) {
|
|
201
|
+
let s = this.parse.advance();
|
|
202
|
+
if (s)
|
|
203
|
+
if (this.fragments = this.withoutTempSkipped(W.addTree(s, this.fragments, this.parse.stoppedAt != null)), this.treeLen = (r = this.parse.stoppedAt) !== null && r !== void 0 ? r : this.state.doc.length, this.tree = s, this.parse = null, this.treeLen < (e ?? this.state.doc.length))
|
|
204
|
+
this.parse = this.startParse();
|
|
205
|
+
else
|
|
206
|
+
return !0;
|
|
207
|
+
if (t())
|
|
208
|
+
return !1;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
@internal
|
|
214
|
+
*/
|
|
215
|
+
takeTree() {
|
|
216
|
+
let t, e;
|
|
217
|
+
this.parse && (t = this.parse.parsedPos) >= this.treeLen && ((this.parse.stoppedAt == null || this.parse.stoppedAt > t) && this.parse.stopAt(t), this.withContext(() => {
|
|
218
|
+
for (; !(e = this.parse.advance()); )
|
|
219
|
+
;
|
|
220
|
+
}), this.treeLen = t, this.tree = e, this.fragments = this.withoutTempSkipped(W.addTree(this.tree, this.fragments, !0)), this.parse = null);
|
|
221
|
+
}
|
|
222
|
+
withContext(t) {
|
|
223
|
+
let e = M;
|
|
224
|
+
M = this;
|
|
225
|
+
try {
|
|
226
|
+
return t();
|
|
227
|
+
} finally {
|
|
228
|
+
M = e;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
withoutTempSkipped(t) {
|
|
232
|
+
for (let e; e = this.tempSkipped.pop(); )
|
|
233
|
+
t = dt(t, e.from, e.to);
|
|
234
|
+
return t;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
@internal
|
|
238
|
+
*/
|
|
239
|
+
changes(t, e) {
|
|
240
|
+
let { fragments: r, tree: s, treeLen: i, viewport: o, skipped: a } = this;
|
|
241
|
+
if (this.takeTree(), !t.empty) {
|
|
242
|
+
let l = [];
|
|
243
|
+
if (t.iterChangedRanges((h, f, c, w) => l.push({ fromA: h, toA: f, fromB: c, toB: w })), r = W.applyChanges(r, l), s = g.empty, i = 0, o = { from: t.mapPos(o.from, -1), to: t.mapPos(o.to, 1) }, this.skipped.length) {
|
|
244
|
+
a = [];
|
|
245
|
+
for (let h of this.skipped) {
|
|
246
|
+
let f = t.mapPos(h.from, 1), c = t.mapPos(h.to, -1);
|
|
247
|
+
f < c && a.push({ from: f, to: c });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return new A(this.parser, e, r, s, i, o, a, this.scheduleOn);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
@internal
|
|
255
|
+
*/
|
|
256
|
+
updateViewport(t) {
|
|
257
|
+
if (this.viewport.from == t.from && this.viewport.to == t.to)
|
|
258
|
+
return !1;
|
|
259
|
+
this.viewport = t;
|
|
260
|
+
let e = this.skipped.length;
|
|
261
|
+
for (let r = 0; r < this.skipped.length; r++) {
|
|
262
|
+
let { from: s, to: i } = this.skipped[r];
|
|
263
|
+
s < t.to && i > t.from && (this.fragments = dt(this.fragments, s, i), this.skipped.splice(r--, 1));
|
|
264
|
+
}
|
|
265
|
+
return this.skipped.length >= e ? !1 : (this.reset(), !0);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
@internal
|
|
269
|
+
*/
|
|
270
|
+
reset() {
|
|
271
|
+
this.parse && (this.takeTree(), this.parse = null);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
Notify the parse scheduler that the given region was skipped
|
|
275
|
+
because it wasn't in view, and the parse should be restarted
|
|
276
|
+
when it comes into view.
|
|
277
|
+
*/
|
|
278
|
+
skipUntilInView(t, e) {
|
|
279
|
+
this.skipped.push({ from: t, to: e });
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
Returns a parser intended to be used as placeholder when
|
|
283
|
+
asynchronously loading a nested parser. It'll skip its input and
|
|
284
|
+
mark it as not-really-parsed, so that the next update will parse
|
|
285
|
+
it again.
|
|
286
|
+
|
|
287
|
+
When `until` is given, a reparse will be scheduled when that
|
|
288
|
+
promise resolves.
|
|
289
|
+
*/
|
|
290
|
+
static getSkippingParser(t) {
|
|
291
|
+
return new class extends Tt {
|
|
292
|
+
createParse(e, r, s) {
|
|
293
|
+
let i = s[0].from, o = s[s.length - 1].to;
|
|
294
|
+
return {
|
|
295
|
+
parsedPos: i,
|
|
296
|
+
advance() {
|
|
297
|
+
let l = M;
|
|
298
|
+
if (l) {
|
|
299
|
+
for (let h of s)
|
|
300
|
+
l.tempSkipped.push(h);
|
|
301
|
+
t && (l.scheduleOn = l.scheduleOn ? Promise.all([l.scheduleOn, t]) : t);
|
|
302
|
+
}
|
|
303
|
+
return this.parsedPos = o, new g(j.none, [], [], o - i);
|
|
304
|
+
},
|
|
305
|
+
stoppedAt: null,
|
|
306
|
+
stopAt() {
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}();
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
@internal
|
|
314
|
+
*/
|
|
315
|
+
isDone(t) {
|
|
316
|
+
t = Math.min(t, this.state.doc.length);
|
|
317
|
+
let e = this.fragments;
|
|
318
|
+
return this.treeLen >= t && e.length && e[0].from == 0 && e[0].to >= t;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
Get the context for the current parse, or `null` if no editor
|
|
322
|
+
parse is in progress.
|
|
323
|
+
*/
|
|
324
|
+
static get() {
|
|
325
|
+
return M;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function dt(n, t, e) {
|
|
329
|
+
return W.applyChanges(n, [{ fromA: t, toA: e, fromB: t, toB: e }]);
|
|
330
|
+
}
|
|
331
|
+
class I {
|
|
332
|
+
constructor(t) {
|
|
333
|
+
this.context = t, this.tree = t.tree;
|
|
334
|
+
}
|
|
335
|
+
apply(t) {
|
|
336
|
+
if (!t.docChanged && this.tree == this.context.tree)
|
|
337
|
+
return this;
|
|
338
|
+
let e = this.context.changes(t.changes, t.state), r = this.context.treeLen == t.startState.doc.length ? void 0 : Math.max(t.changes.mapPos(this.context.treeLen), e.viewport.to);
|
|
339
|
+
return e.work(20, r) || e.takeTree(), new I(e);
|
|
340
|
+
}
|
|
341
|
+
static init(t) {
|
|
342
|
+
let e = Math.min(3e3, t.doc.length), r = A.create(t.facet(T).parser, t, { from: 0, to: e });
|
|
343
|
+
return r.work(20, e) || r.takeTree(), new I(r);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
d.state = /* @__PURE__ */ xt.define({
|
|
347
|
+
create: I.init,
|
|
348
|
+
update(n, t) {
|
|
349
|
+
for (let e of t.effects)
|
|
350
|
+
if (e.is(d.setState))
|
|
351
|
+
return e.value;
|
|
352
|
+
return t.startState.facet(T) != t.state.facet(T) ? I.init(t.state) : n.apply(t);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
let Dt = (n) => {
|
|
356
|
+
let t = setTimeout(
|
|
357
|
+
() => n(),
|
|
358
|
+
500
|
|
359
|
+
/* Work.MaxPause */
|
|
360
|
+
);
|
|
361
|
+
return () => clearTimeout(t);
|
|
362
|
+
};
|
|
363
|
+
typeof requestIdleCallback < "u" && (Dt = (n) => {
|
|
364
|
+
let t = -1, e = setTimeout(
|
|
365
|
+
() => {
|
|
366
|
+
t = requestIdleCallback(n, {
|
|
367
|
+
timeout: 400
|
|
368
|
+
/* Work.MinPause */
|
|
369
|
+
});
|
|
370
|
+
},
|
|
371
|
+
100
|
|
372
|
+
/* Work.MinPause */
|
|
373
|
+
);
|
|
374
|
+
return () => t < 0 ? clearTimeout(e) : cancelIdleCallback(t);
|
|
375
|
+
});
|
|
376
|
+
const _ = typeof navigator < "u" && (!((J = navigator.scheduling) === null || J === void 0) && J.isInputPending) ? () => navigator.scheduling.isInputPending() : null, Mt = /* @__PURE__ */ R.fromClass(class {
|
|
377
|
+
constructor(t) {
|
|
378
|
+
this.view = t, this.working = null, this.workScheduled = 0, this.chunkEnd = -1, this.chunkBudget = -1, this.work = this.work.bind(this), this.scheduleWork();
|
|
379
|
+
}
|
|
380
|
+
update(t) {
|
|
381
|
+
let e = this.view.state.field(d.state).context;
|
|
382
|
+
(e.updateViewport(t.view.viewport) || this.view.viewport.to > e.treeLen) && this.scheduleWork(), (t.docChanged || t.selectionSet) && (this.view.hasFocus && (this.chunkBudget += 50), this.scheduleWork()), this.checkAsyncSchedule(e);
|
|
383
|
+
}
|
|
384
|
+
scheduleWork() {
|
|
385
|
+
if (this.working)
|
|
386
|
+
return;
|
|
387
|
+
let { state: t } = this.view, e = t.field(d.state);
|
|
388
|
+
(e.tree != e.context.tree || !e.context.isDone(t.doc.length)) && (this.working = Dt(this.work));
|
|
389
|
+
}
|
|
390
|
+
work(t) {
|
|
391
|
+
this.working = null;
|
|
392
|
+
let e = Date.now();
|
|
393
|
+
if (this.chunkEnd < e && (this.chunkEnd < 0 || this.view.hasFocus) && (this.chunkEnd = e + 3e4, this.chunkBudget = 3e3), this.chunkBudget <= 0)
|
|
394
|
+
return;
|
|
395
|
+
let { state: r, viewport: { to: s } } = this.view, i = r.field(d.state);
|
|
396
|
+
if (i.tree == i.context.tree && i.context.isDone(
|
|
397
|
+
s + 1e5
|
|
398
|
+
/* Work.MaxParseAhead */
|
|
399
|
+
))
|
|
400
|
+
return;
|
|
401
|
+
let o = Date.now() + Math.min(this.chunkBudget, 100, t && !_ ? Math.max(25, t.timeRemaining() - 5) : 1e9), a = i.context.treeLen < s && r.doc.length > s + 1e3, l = i.context.work(() => _ && _() || Date.now() > o, s + (a ? 0 : 1e5));
|
|
402
|
+
this.chunkBudget -= Date.now() - e, (l || this.chunkBudget <= 0) && (i.context.takeTree(), this.view.dispatch({ effects: d.setState.of(new I(i.context)) })), this.chunkBudget > 0 && !(l && !a) && this.scheduleWork(), this.checkAsyncSchedule(i.context);
|
|
403
|
+
}
|
|
404
|
+
checkAsyncSchedule(t) {
|
|
405
|
+
t.scheduleOn && (this.workScheduled++, t.scheduleOn.then(() => this.scheduleWork()).catch((e) => ae(this.view.state, e)).then(() => this.workScheduled--), t.scheduleOn = null);
|
|
406
|
+
}
|
|
407
|
+
destroy() {
|
|
408
|
+
this.working && this.working();
|
|
409
|
+
}
|
|
410
|
+
isWorking() {
|
|
411
|
+
return !!(this.working || this.workScheduled > 0);
|
|
412
|
+
}
|
|
413
|
+
}, {
|
|
414
|
+
eventHandlers: { focus() {
|
|
415
|
+
this.scheduleWork();
|
|
416
|
+
} }
|
|
417
|
+
}), T = /* @__PURE__ */ v.define({
|
|
418
|
+
combine(n) {
|
|
419
|
+
return n.length ? n[0] : null;
|
|
420
|
+
},
|
|
421
|
+
enables: (n) => [
|
|
422
|
+
d.state,
|
|
423
|
+
Mt,
|
|
424
|
+
b.contentAttributes.compute([n], (t) => {
|
|
425
|
+
let e = t.facet(n);
|
|
426
|
+
return e && e.name ? { "data-language": e.name } : {};
|
|
427
|
+
})
|
|
428
|
+
]
|
|
429
|
+
});
|
|
430
|
+
class fn {
|
|
431
|
+
/**
|
|
432
|
+
Create a language support object.
|
|
433
|
+
*/
|
|
434
|
+
constructor(t, e = []) {
|
|
435
|
+
this.language = t, this.support = e, this.extension = [t, e];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
class Ot {
|
|
439
|
+
constructor(t, e, r, s, i, o = void 0) {
|
|
440
|
+
this.name = t, this.alias = e, this.extensions = r, this.filename = s, this.loadFunc = i, this.support = o, this.loading = null;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
Start loading the the language. Will return a promise that
|
|
444
|
+
resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)
|
|
445
|
+
object when the language successfully loads.
|
|
446
|
+
*/
|
|
447
|
+
load() {
|
|
448
|
+
return this.loading || (this.loading = this.loadFunc().then((t) => this.support = t, (t) => {
|
|
449
|
+
throw this.loading = null, t;
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
Create a language description.
|
|
454
|
+
*/
|
|
455
|
+
static of(t) {
|
|
456
|
+
let { load: e, support: r } = t;
|
|
457
|
+
if (!e) {
|
|
458
|
+
if (!r)
|
|
459
|
+
throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");
|
|
460
|
+
e = () => Promise.resolve(r);
|
|
461
|
+
}
|
|
462
|
+
return new Ot(t.name, (t.alias || []).concat(t.name).map((s) => s.toLowerCase()), t.extensions || [], t.filename, e, r);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
Look for a language in the given array of descriptions that
|
|
466
|
+
matches the filename. Will first match
|
|
467
|
+
[`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,
|
|
468
|
+
and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),
|
|
469
|
+
and return the first language that matches.
|
|
470
|
+
*/
|
|
471
|
+
static matchFilename(t, e) {
|
|
472
|
+
for (let s of t)
|
|
473
|
+
if (s.filename && s.filename.test(e))
|
|
474
|
+
return s;
|
|
475
|
+
let r = /\.([^.]+)$/.exec(e);
|
|
476
|
+
if (r) {
|
|
477
|
+
for (let s of t)
|
|
478
|
+
if (s.extensions.indexOf(r[1]) > -1)
|
|
479
|
+
return s;
|
|
480
|
+
}
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
Look for a language whose name or alias matches the the given
|
|
485
|
+
name (case-insensitively). If `fuzzy` is true, and no direct
|
|
486
|
+
matchs is found, this'll also search for a language whose name
|
|
487
|
+
or alias occurs in the string (for names shorter than three
|
|
488
|
+
characters, only when surrounded by non-word characters).
|
|
489
|
+
*/
|
|
490
|
+
static matchLanguageName(t, e, r = !0) {
|
|
491
|
+
e = e.toLowerCase();
|
|
492
|
+
for (let s of t)
|
|
493
|
+
if (s.alias.some((i) => i == e))
|
|
494
|
+
return s;
|
|
495
|
+
if (r)
|
|
496
|
+
for (let s of t)
|
|
497
|
+
for (let i of s.alias) {
|
|
498
|
+
let o = e.indexOf(i);
|
|
499
|
+
if (o > -1 && (i.length > 2 || !/\w/.test(e[o - 1]) && !/\w/.test(e[o + i.length])))
|
|
500
|
+
return s;
|
|
501
|
+
}
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
const ce = /* @__PURE__ */ v.define(), Bt = /* @__PURE__ */ v.define({
|
|
506
|
+
combine: (n) => {
|
|
507
|
+
if (!n.length)
|
|
508
|
+
return " ";
|
|
509
|
+
let t = n[0];
|
|
510
|
+
if (!t || /\S/.test(t) || Array.from(t).some((e) => e != t[0]))
|
|
511
|
+
throw new Error("Invalid indent unit: " + JSON.stringify(n[0]));
|
|
512
|
+
return t;
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
function V(n) {
|
|
516
|
+
let t = n.facet(Bt);
|
|
517
|
+
return t.charCodeAt(0) == 9 ? n.tabSize * t.length : t.length;
|
|
518
|
+
}
|
|
519
|
+
function Lt(n, t) {
|
|
520
|
+
let e = "", r = n.tabSize, s = n.facet(Bt)[0];
|
|
521
|
+
if (s == " ") {
|
|
522
|
+
for (; t >= r; )
|
|
523
|
+
e += " ", t -= r;
|
|
524
|
+
s = " ";
|
|
525
|
+
}
|
|
526
|
+
for (let i = 0; i < t; i++)
|
|
527
|
+
e += s;
|
|
528
|
+
return e;
|
|
529
|
+
}
|
|
530
|
+
function Nt(n, t) {
|
|
531
|
+
n instanceof O && (n = new rt(n));
|
|
532
|
+
for (let r of n.state.facet(ce)) {
|
|
533
|
+
let s = r(n, t);
|
|
534
|
+
if (s !== void 0)
|
|
535
|
+
return s;
|
|
536
|
+
}
|
|
537
|
+
let e = m(n.state);
|
|
538
|
+
return e.length >= t ? de(n, e, t) : null;
|
|
539
|
+
}
|
|
540
|
+
function un(n, t, e) {
|
|
541
|
+
let r = /* @__PURE__ */ Object.create(null), s = new rt(n, { overrideIndentation: (o) => {
|
|
542
|
+
var a;
|
|
543
|
+
return (a = r[o]) !== null && a !== void 0 ? a : -1;
|
|
544
|
+
} }), i = [];
|
|
545
|
+
for (let o = t; o <= e; ) {
|
|
546
|
+
let a = n.doc.lineAt(o);
|
|
547
|
+
o = a.to + 1;
|
|
548
|
+
let l = Nt(s, a.from);
|
|
549
|
+
if (l == null)
|
|
550
|
+
continue;
|
|
551
|
+
/\S/.test(a.text) || (l = 0);
|
|
552
|
+
let h = /^\s*/.exec(a.text)[0], f = Lt(n, l);
|
|
553
|
+
h != f && (r[a.from] = l, i.push({ from: a.from, to: a.from + h.length, insert: f }));
|
|
554
|
+
}
|
|
555
|
+
return n.changes(i);
|
|
556
|
+
}
|
|
557
|
+
class rt {
|
|
558
|
+
/**
|
|
559
|
+
Create an indent context.
|
|
560
|
+
*/
|
|
561
|
+
constructor(t, e = {}) {
|
|
562
|
+
this.state = t, this.options = e, this.unit = V(t);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
Get a description of the line at the given position, taking
|
|
566
|
+
[simulated line
|
|
567
|
+
breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
|
|
568
|
+
into account. If there is such a break at `pos`, the `bias`
|
|
569
|
+
argument determines whether the part of the line line before or
|
|
570
|
+
after the break is used.
|
|
571
|
+
*/
|
|
572
|
+
lineAt(t, e = 1) {
|
|
573
|
+
let r = this.state.doc.lineAt(t), { simulateBreak: s, simulateDoubleBreak: i } = this.options;
|
|
574
|
+
return s != null && s >= r.from && s <= r.to ? i && s == t ? { text: "", from: t } : (e < 0 ? s < t : s <= t) ? { text: r.text.slice(s - r.from), from: s } : { text: r.text.slice(0, s - r.from), from: r.from } : r;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
Get the text directly after `pos`, either the entire line
|
|
578
|
+
or the next 100 characters, whichever is shorter.
|
|
579
|
+
*/
|
|
580
|
+
textAfterPos(t, e = 1) {
|
|
581
|
+
if (this.options.simulateDoubleBreak && t == this.options.simulateBreak)
|
|
582
|
+
return "";
|
|
583
|
+
let { text: r, from: s } = this.lineAt(t, e);
|
|
584
|
+
return r.slice(t - s, Math.min(r.length, t + 100 - s));
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
Find the column for the given position.
|
|
588
|
+
*/
|
|
589
|
+
column(t, e = 1) {
|
|
590
|
+
let { text: r, from: s } = this.lineAt(t, e), i = this.countColumn(r, t - s), o = this.options.overrideIndentation ? this.options.overrideIndentation(s) : -1;
|
|
591
|
+
return o > -1 && (i += o - this.countColumn(r, r.search(/\S|$/))), i;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
Find the column position (taking tabs into account) of the given
|
|
595
|
+
position in the given string.
|
|
596
|
+
*/
|
|
597
|
+
countColumn(t, e = t.length) {
|
|
598
|
+
return ie(t, this.state.tabSize, e);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
Find the indentation column of the line at the given point.
|
|
602
|
+
*/
|
|
603
|
+
lineIndent(t, e = 1) {
|
|
604
|
+
let { text: r, from: s } = this.lineAt(t, e), i = this.options.overrideIndentation;
|
|
605
|
+
if (i) {
|
|
606
|
+
let o = i(s);
|
|
607
|
+
if (o > -1)
|
|
608
|
+
return o;
|
|
609
|
+
}
|
|
610
|
+
return this.countColumn(r, r.search(/\S|$/));
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
Returns the [simulated line
|
|
614
|
+
break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
|
|
615
|
+
for this context, if any.
|
|
616
|
+
*/
|
|
617
|
+
get simulatedBreak() {
|
|
618
|
+
return this.options.simulateBreak || null;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
const Rt = /* @__PURE__ */ new y();
|
|
622
|
+
function de(n, t, e) {
|
|
623
|
+
let r = t.resolveStack(e), s = t.resolveInner(e, -1).resolve(e, 0).enterUnfinishedNodesBefore(e);
|
|
624
|
+
if (s != r.node) {
|
|
625
|
+
let i = [];
|
|
626
|
+
for (let o = s; o && !(o.from < r.node.from || o.to > r.node.to || o.from == r.node.from && o.type == r.node.type); o = o.parent)
|
|
627
|
+
i.push(o);
|
|
628
|
+
for (let o = i.length - 1; o >= 0; o--)
|
|
629
|
+
r = { node: i[o], next: r };
|
|
630
|
+
}
|
|
631
|
+
return Et(r, n, e);
|
|
632
|
+
}
|
|
633
|
+
function Et(n, t, e) {
|
|
634
|
+
for (let r = n; r; r = r.next) {
|
|
635
|
+
let s = ge(r.node);
|
|
636
|
+
if (s)
|
|
637
|
+
return s(st.create(t, e, r));
|
|
638
|
+
}
|
|
639
|
+
return 0;
|
|
640
|
+
}
|
|
641
|
+
function pe(n) {
|
|
642
|
+
return n.pos == n.options.simulateBreak && n.options.simulateDoubleBreak;
|
|
643
|
+
}
|
|
644
|
+
function ge(n) {
|
|
645
|
+
let t = n.type.prop(Rt);
|
|
646
|
+
if (t)
|
|
647
|
+
return t;
|
|
648
|
+
let e = n.firstChild, r;
|
|
649
|
+
if (e && (r = e.type.prop(y.closedBy))) {
|
|
650
|
+
let s = n.lastChild, i = s && r.indexOf(s.name) > -1;
|
|
651
|
+
return (o) => Ft(o, !0, 1, void 0, i && !pe(o) ? s.from : void 0);
|
|
652
|
+
}
|
|
653
|
+
return n.parent == null ? me : null;
|
|
654
|
+
}
|
|
655
|
+
function me() {
|
|
656
|
+
return 0;
|
|
657
|
+
}
|
|
658
|
+
class st extends rt {
|
|
659
|
+
constructor(t, e, r) {
|
|
660
|
+
super(t.state, t.options), this.base = t, this.pos = e, this.context = r;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
The syntax tree node to which the indentation strategy
|
|
664
|
+
applies.
|
|
665
|
+
*/
|
|
666
|
+
get node() {
|
|
667
|
+
return this.context.node;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
@internal
|
|
671
|
+
*/
|
|
672
|
+
static create(t, e, r) {
|
|
673
|
+
return new st(t, e, r);
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
Get the text directly after `this.pos`, either the entire line
|
|
677
|
+
or the next 100 characters, whichever is shorter.
|
|
678
|
+
*/
|
|
679
|
+
get textAfter() {
|
|
680
|
+
return this.textAfterPos(this.pos);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
Get the indentation at the reference line for `this.node`, which
|
|
684
|
+
is the line on which it starts, unless there is a node that is
|
|
685
|
+
_not_ a parent of this node covering the start of that line. If
|
|
686
|
+
so, the line at the start of that node is tried, again skipping
|
|
687
|
+
on if it is covered by another such node.
|
|
688
|
+
*/
|
|
689
|
+
get baseIndent() {
|
|
690
|
+
return this.baseIndentFor(this.node);
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
Get the indentation for the reference line of the given node
|
|
694
|
+
(see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).
|
|
695
|
+
*/
|
|
696
|
+
baseIndentFor(t) {
|
|
697
|
+
let e = this.state.doc.lineAt(t.from);
|
|
698
|
+
for (; ; ) {
|
|
699
|
+
let r = t.resolve(e.from);
|
|
700
|
+
for (; r.parent && r.parent.from == r.from; )
|
|
701
|
+
r = r.parent;
|
|
702
|
+
if (ke(r, t))
|
|
703
|
+
break;
|
|
704
|
+
e = this.state.doc.lineAt(r.from);
|
|
705
|
+
}
|
|
706
|
+
return this.lineIndent(e.from);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
Continue looking for indentations in the node's parent nodes,
|
|
710
|
+
and return the result of that.
|
|
711
|
+
*/
|
|
712
|
+
continue() {
|
|
713
|
+
return Et(this.context.next, this.base, this.pos);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
function ke(n, t) {
|
|
717
|
+
for (let e = t; e; e = e.parent)
|
|
718
|
+
if (n == e)
|
|
719
|
+
return !0;
|
|
720
|
+
return !1;
|
|
721
|
+
}
|
|
722
|
+
function be(n) {
|
|
723
|
+
let t = n.node, e = t.childAfter(t.from), r = t.lastChild;
|
|
724
|
+
if (!e)
|
|
725
|
+
return null;
|
|
726
|
+
let s = n.options.simulateBreak, i = n.state.doc.lineAt(e.from), o = s == null || s <= i.from ? i.to : Math.min(i.to, s);
|
|
727
|
+
for (let a = e.to; ; ) {
|
|
728
|
+
let l = t.childAfter(a);
|
|
729
|
+
if (!l || l == r)
|
|
730
|
+
return null;
|
|
731
|
+
if (!l.type.isSkipped) {
|
|
732
|
+
if (l.from >= o)
|
|
733
|
+
return null;
|
|
734
|
+
let h = /^ */.exec(i.text.slice(e.to - i.from))[0].length;
|
|
735
|
+
return { from: e.from, to: e.to + h };
|
|
736
|
+
}
|
|
737
|
+
a = l.to;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
function cn({ closing: n, align: t = !0, units: e = 1 }) {
|
|
741
|
+
return (r) => Ft(r, t, e, n);
|
|
742
|
+
}
|
|
743
|
+
function Ft(n, t, e, r, s) {
|
|
744
|
+
let i = n.textAfter, o = i.match(/^\s*/)[0].length, a = r && i.slice(o, o + r.length) == r || s == n.pos + o, l = t ? be(n) : null;
|
|
745
|
+
return l ? a ? n.column(l.from) : n.column(l.to) : n.baseIndent + (a ? 0 : n.unit * e);
|
|
746
|
+
}
|
|
747
|
+
const dn = (n) => n.baseIndent;
|
|
748
|
+
function pn({ except: n, units: t = 1 } = {}) {
|
|
749
|
+
return (e) => {
|
|
750
|
+
let r = n && n.test(e.textAfter);
|
|
751
|
+
return e.baseIndent + (r ? 0 : t * e.unit);
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
const we = 200;
|
|
755
|
+
function gn() {
|
|
756
|
+
return O.transactionFilter.of((n) => {
|
|
757
|
+
if (!n.docChanged || !n.isUserEvent("input.type") && !n.isUserEvent("input.complete"))
|
|
758
|
+
return n;
|
|
759
|
+
let t = n.startState.languageDataAt("indentOnInput", n.startState.selection.main.head);
|
|
760
|
+
if (!t.length)
|
|
761
|
+
return n;
|
|
762
|
+
let e = n.newDoc, { head: r } = n.newSelection.main, s = e.lineAt(r);
|
|
763
|
+
if (r > s.from + we)
|
|
764
|
+
return n;
|
|
765
|
+
let i = e.sliceString(s.from, r);
|
|
766
|
+
if (!t.some((h) => h.test(i)))
|
|
767
|
+
return n;
|
|
768
|
+
let { state: o } = n, a = -1, l = [];
|
|
769
|
+
for (let { head: h } of o.selection.ranges) {
|
|
770
|
+
let f = o.doc.lineAt(h);
|
|
771
|
+
if (f.from == a)
|
|
772
|
+
continue;
|
|
773
|
+
a = f.from;
|
|
774
|
+
let c = Nt(o, f.from);
|
|
775
|
+
if (c == null)
|
|
776
|
+
continue;
|
|
777
|
+
let w = /^\s*/.exec(f.text)[0], k = Lt(o, c);
|
|
778
|
+
w != k && l.push({ from: f.from, to: f.from + w.length, insert: k });
|
|
779
|
+
}
|
|
780
|
+
return l.length ? [n, { changes: l, sequential: !0 }] : n;
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
const ye = /* @__PURE__ */ v.define(), ve = /* @__PURE__ */ new y();
|
|
784
|
+
function mn(n) {
|
|
785
|
+
let t = n.firstChild, e = n.lastChild;
|
|
786
|
+
return t && t.to < e.from ? { from: t.to, to: e.type.isError ? n.to : e.from } : null;
|
|
787
|
+
}
|
|
788
|
+
function Te(n, t, e) {
|
|
789
|
+
let r = m(n);
|
|
790
|
+
if (r.length < e)
|
|
791
|
+
return null;
|
|
792
|
+
let s = r.resolveStack(e, 1), i = null;
|
|
793
|
+
for (let o = s; o; o = o.next) {
|
|
794
|
+
let a = o.node;
|
|
795
|
+
if (a.to <= e || a.from > e)
|
|
796
|
+
continue;
|
|
797
|
+
if (i && a.from < t)
|
|
798
|
+
break;
|
|
799
|
+
let l = a.type.prop(ve);
|
|
800
|
+
if (l && (a.to < r.length - 50 || r.length == n.doc.length || !xe(a))) {
|
|
801
|
+
let h = l(a, n);
|
|
802
|
+
h && h.from <= e && h.from >= t && h.to > e && (i = h);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return i;
|
|
806
|
+
}
|
|
807
|
+
function xe(n) {
|
|
808
|
+
let t = n.lastChild;
|
|
809
|
+
return t && t.to == n.to && t.type.isError;
|
|
810
|
+
}
|
|
811
|
+
function B(n, t, e) {
|
|
812
|
+
for (let r of n.facet(ye)) {
|
|
813
|
+
let s = r(n, t, e);
|
|
814
|
+
if (s)
|
|
815
|
+
return s;
|
|
816
|
+
}
|
|
817
|
+
return Te(n, t, e);
|
|
818
|
+
}
|
|
819
|
+
function Wt(n, t) {
|
|
820
|
+
let e = t.mapPos(n.from, 1), r = t.mapPos(n.to, -1);
|
|
821
|
+
return e >= r ? void 0 : { from: e, to: r };
|
|
822
|
+
}
|
|
823
|
+
const E = /* @__PURE__ */ z.define({ map: Wt }), D = /* @__PURE__ */ z.define({ map: Wt });
|
|
824
|
+
function it(n) {
|
|
825
|
+
let t = [];
|
|
826
|
+
for (let { head: e } of n.state.selection.ranges)
|
|
827
|
+
t.some((r) => r.from <= e && r.to >= e) || t.push(n.lineBlockAt(e));
|
|
828
|
+
return t;
|
|
829
|
+
}
|
|
830
|
+
const x = /* @__PURE__ */ xt.define({
|
|
831
|
+
create() {
|
|
832
|
+
return p.none;
|
|
833
|
+
},
|
|
834
|
+
update(n, t) {
|
|
835
|
+
t.isUserEvent("delete") && t.changes.iterChangedRanges((r, s) => n = pt(n, r, s)), n = n.map(t.changes);
|
|
836
|
+
let e = [];
|
|
837
|
+
for (let r of t.effects)
|
|
838
|
+
r.is(E) && !Se(n, r.value.from, r.value.to) ? e.push(r.value) : r.is(D) && (n = n.update({
|
|
839
|
+
filter: (s, i) => r.value.from != s || r.value.to != i,
|
|
840
|
+
filterFrom: r.value.from,
|
|
841
|
+
filterTo: r.value.to
|
|
842
|
+
}));
|
|
843
|
+
if (e.length) {
|
|
844
|
+
let { preparePlaceholder: r } = t.state.facet(lt), s = e.map((i) => (r ? p.replace({ widget: new Oe(r(t.state, i)) }) : gt).range(i.from, i.to));
|
|
845
|
+
n = n.update({ add: s });
|
|
846
|
+
}
|
|
847
|
+
return t.selection && (n = pt(n, t.selection.main.head)), n;
|
|
848
|
+
},
|
|
849
|
+
provide: (n) => b.decorations.from(n),
|
|
850
|
+
toJSON(n, t) {
|
|
851
|
+
let e = [];
|
|
852
|
+
return n.between(0, t.doc.length, (r, s) => {
|
|
853
|
+
e.push(r, s);
|
|
854
|
+
}), e;
|
|
855
|
+
},
|
|
856
|
+
fromJSON(n) {
|
|
857
|
+
if (!Array.isArray(n) || n.length % 2)
|
|
858
|
+
throw new RangeError("Invalid JSON for fold state");
|
|
859
|
+
let t = [];
|
|
860
|
+
for (let e = 0; e < n.length; ) {
|
|
861
|
+
let r = n[e++], s = n[e++];
|
|
862
|
+
if (typeof r != "number" || typeof s != "number")
|
|
863
|
+
throw new RangeError("Invalid JSON for fold state");
|
|
864
|
+
t.push(gt.range(r, s));
|
|
865
|
+
}
|
|
866
|
+
return p.set(t, !0);
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
function pt(n, t, e = t) {
|
|
870
|
+
let r = !1;
|
|
871
|
+
return n.between(t, e, (s, i) => {
|
|
872
|
+
s < e && i > t && (r = !0);
|
|
873
|
+
}), r ? n.update({
|
|
874
|
+
filterFrom: t,
|
|
875
|
+
filterTo: e,
|
|
876
|
+
filter: (s, i) => s >= e || i <= t
|
|
877
|
+
}) : n;
|
|
878
|
+
}
|
|
879
|
+
function kn(n) {
|
|
880
|
+
return n.field(x, !1) || St.empty;
|
|
881
|
+
}
|
|
882
|
+
function L(n, t, e) {
|
|
883
|
+
var r;
|
|
884
|
+
let s = null;
|
|
885
|
+
return (r = n.field(x, !1)) === null || r === void 0 || r.between(t, e, (i, o) => {
|
|
886
|
+
(!s || s.from > i) && (s = { from: i, to: o });
|
|
887
|
+
}), s;
|
|
888
|
+
}
|
|
889
|
+
function Se(n, t, e) {
|
|
890
|
+
let r = !1;
|
|
891
|
+
return n.between(t, t, (s, i) => {
|
|
892
|
+
s == t && i == e && (r = !0);
|
|
893
|
+
}), r;
|
|
894
|
+
}
|
|
895
|
+
function ot(n, t) {
|
|
896
|
+
return n.field(x, !1) ? t : t.concat(z.appendConfig.of(Ut()));
|
|
897
|
+
}
|
|
898
|
+
const Pe = (n) => {
|
|
899
|
+
for (let t of it(n)) {
|
|
900
|
+
let e = B(n.state, t.from, t.to);
|
|
901
|
+
if (e)
|
|
902
|
+
return n.dispatch({ effects: ot(n.state, [E.of(e), $(n, e)]) }), !0;
|
|
903
|
+
}
|
|
904
|
+
return !1;
|
|
905
|
+
}, Ce = (n) => {
|
|
906
|
+
if (!n.state.field(x, !1))
|
|
907
|
+
return !1;
|
|
908
|
+
let t = [];
|
|
909
|
+
for (let e of it(n)) {
|
|
910
|
+
let r = L(n.state, e.from, e.to);
|
|
911
|
+
r && t.push(D.of(r), $(n, r, !1));
|
|
912
|
+
}
|
|
913
|
+
return t.length && n.dispatch({ effects: t }), t.length > 0;
|
|
914
|
+
};
|
|
915
|
+
function $(n, t, e = !0) {
|
|
916
|
+
let r = n.state.doc.lineAt(t.from).number, s = n.state.doc.lineAt(t.to).number;
|
|
917
|
+
return b.announce.of(`${n.state.phrase(e ? "Folded lines" : "Unfolded lines")} ${r} ${n.state.phrase("to")} ${s}.`);
|
|
918
|
+
}
|
|
919
|
+
const Ae = (n) => {
|
|
920
|
+
let { state: t } = n, e = [];
|
|
921
|
+
for (let r = 0; r < t.doc.length; ) {
|
|
922
|
+
let s = n.lineBlockAt(r), i = B(t, s.from, s.to);
|
|
923
|
+
i && e.push(E.of(i)), r = (i ? n.lineBlockAt(i.to) : s).to + 1;
|
|
924
|
+
}
|
|
925
|
+
return e.length && n.dispatch({ effects: ot(n.state, e) }), !!e.length;
|
|
926
|
+
}, Ie = (n) => {
|
|
927
|
+
let t = n.state.field(x, !1);
|
|
928
|
+
if (!t || !t.size)
|
|
929
|
+
return !1;
|
|
930
|
+
let e = [];
|
|
931
|
+
return t.between(0, n.state.doc.length, (r, s) => {
|
|
932
|
+
e.push(D.of({ from: r, to: s }));
|
|
933
|
+
}), n.dispatch({ effects: e }), !0;
|
|
934
|
+
};
|
|
935
|
+
function De(n, t) {
|
|
936
|
+
for (let e = t; ; ) {
|
|
937
|
+
let r = B(n.state, e.from, e.to);
|
|
938
|
+
if (r && r.to > t.from)
|
|
939
|
+
return r;
|
|
940
|
+
if (!e.from)
|
|
941
|
+
return null;
|
|
942
|
+
e = n.lineBlockAt(e.from - 1);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
const bn = (n) => {
|
|
946
|
+
let t = [];
|
|
947
|
+
for (let e of it(n)) {
|
|
948
|
+
let r = L(n.state, e.from, e.to);
|
|
949
|
+
if (r)
|
|
950
|
+
t.push(D.of(r), $(n, r, !1));
|
|
951
|
+
else {
|
|
952
|
+
let s = De(n, e);
|
|
953
|
+
s && t.push(E.of(s), $(n, s));
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
return t.length > 0 && n.dispatch({ effects: ot(n.state, t) }), !!t.length;
|
|
957
|
+
}, wn = [
|
|
958
|
+
{ key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: Pe },
|
|
959
|
+
{ key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: Ce },
|
|
960
|
+
{ key: "Ctrl-Alt-[", run: Ae },
|
|
961
|
+
{ key: "Ctrl-Alt-]", run: Ie }
|
|
962
|
+
], Me = {
|
|
963
|
+
placeholderDOM: null,
|
|
964
|
+
preparePlaceholder: null,
|
|
965
|
+
placeholderText: "…"
|
|
966
|
+
}, lt = /* @__PURE__ */ v.define({
|
|
967
|
+
combine(n) {
|
|
968
|
+
return Ct(n, Me);
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
function Ut(n) {
|
|
972
|
+
let t = [x, Le];
|
|
973
|
+
return n && t.push(lt.of(n)), t;
|
|
974
|
+
}
|
|
975
|
+
function Ht(n, t) {
|
|
976
|
+
let { state: e } = n, r = e.facet(lt), s = (o) => {
|
|
977
|
+
let a = n.lineBlockAt(n.posAtDOM(o.target)), l = L(n.state, a.from, a.to);
|
|
978
|
+
l && n.dispatch({ effects: D.of(l) }), o.preventDefault();
|
|
979
|
+
};
|
|
980
|
+
if (r.placeholderDOM)
|
|
981
|
+
return r.placeholderDOM(n, s, t);
|
|
982
|
+
let i = document.createElement("span");
|
|
983
|
+
return i.textContent = r.placeholderText, i.setAttribute("aria-label", e.phrase("folded code")), i.title = e.phrase("unfold"), i.className = "cm-foldPlaceholder", i.onclick = s, i;
|
|
984
|
+
}
|
|
985
|
+
const gt = /* @__PURE__ */ p.replace({ widget: /* @__PURE__ */ new class extends At {
|
|
986
|
+
toDOM(n) {
|
|
987
|
+
return Ht(n, null);
|
|
988
|
+
}
|
|
989
|
+
}() });
|
|
990
|
+
class Oe extends At {
|
|
991
|
+
constructor(t) {
|
|
992
|
+
super(), this.value = t;
|
|
993
|
+
}
|
|
994
|
+
eq(t) {
|
|
995
|
+
return this.value == t.value;
|
|
996
|
+
}
|
|
997
|
+
toDOM(t) {
|
|
998
|
+
return Ht(t, this.value);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
const Be = {
|
|
1002
|
+
openText: "⌄",
|
|
1003
|
+
closedText: "›",
|
|
1004
|
+
markerDOM: null,
|
|
1005
|
+
domEventHandlers: {},
|
|
1006
|
+
foldingChanged: () => !1
|
|
1007
|
+
};
|
|
1008
|
+
class K extends le {
|
|
1009
|
+
constructor(t, e) {
|
|
1010
|
+
super(), this.config = t, this.open = e;
|
|
1011
|
+
}
|
|
1012
|
+
eq(t) {
|
|
1013
|
+
return this.config == t.config && this.open == t.open;
|
|
1014
|
+
}
|
|
1015
|
+
toDOM(t) {
|
|
1016
|
+
if (this.config.markerDOM)
|
|
1017
|
+
return this.config.markerDOM(this.open);
|
|
1018
|
+
let e = document.createElement("span");
|
|
1019
|
+
return e.textContent = this.open ? this.config.openText : this.config.closedText, e.title = t.state.phrase(this.open ? "Fold line" : "Unfold line"), e;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
function yn(n = {}) {
|
|
1023
|
+
let t = { ...Be, ...n }, e = new K(t, !0), r = new K(t, !1), s = R.fromClass(class {
|
|
1024
|
+
constructor(o) {
|
|
1025
|
+
this.from = o.viewport.from, this.markers = this.buildMarkers(o);
|
|
1026
|
+
}
|
|
1027
|
+
update(o) {
|
|
1028
|
+
(o.docChanged || o.viewportChanged || o.startState.facet(T) != o.state.facet(T) || o.startState.field(x, !1) != o.state.field(x, !1) || m(o.startState) != m(o.state) || t.foldingChanged(o)) && (this.markers = this.buildMarkers(o.view));
|
|
1029
|
+
}
|
|
1030
|
+
buildMarkers(o) {
|
|
1031
|
+
let a = new nt();
|
|
1032
|
+
for (let l of o.viewportLineBlocks) {
|
|
1033
|
+
let h = L(o.state, l.from, l.to) ? r : B(o.state, l.from, l.to) ? e : null;
|
|
1034
|
+
h && a.add(l.from, l.from, h);
|
|
1035
|
+
}
|
|
1036
|
+
return a.finish();
|
|
1037
|
+
}
|
|
1038
|
+
}), { domEventHandlers: i } = t;
|
|
1039
|
+
return [
|
|
1040
|
+
s,
|
|
1041
|
+
oe({
|
|
1042
|
+
class: "cm-foldGutter",
|
|
1043
|
+
markers(o) {
|
|
1044
|
+
var a;
|
|
1045
|
+
return ((a = o.plugin(s)) === null || a === void 0 ? void 0 : a.markers) || St.empty;
|
|
1046
|
+
},
|
|
1047
|
+
initialSpacer() {
|
|
1048
|
+
return new K(t, !1);
|
|
1049
|
+
},
|
|
1050
|
+
domEventHandlers: {
|
|
1051
|
+
...i,
|
|
1052
|
+
click: (o, a, l) => {
|
|
1053
|
+
if (i.click && i.click(o, a, l))
|
|
1054
|
+
return !0;
|
|
1055
|
+
let h = L(o.state, a.from, a.to);
|
|
1056
|
+
if (h)
|
|
1057
|
+
return o.dispatch({ effects: D.of(h) }), !0;
|
|
1058
|
+
let f = B(o.state, a.from, a.to);
|
|
1059
|
+
return f ? (o.dispatch({ effects: E.of(f) }), !0) : !1;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
}),
|
|
1063
|
+
Ut()
|
|
1064
|
+
];
|
|
1065
|
+
}
|
|
1066
|
+
const Le = /* @__PURE__ */ b.baseTheme({
|
|
1067
|
+
".cm-foldPlaceholder": {
|
|
1068
|
+
backgroundColor: "#eee",
|
|
1069
|
+
border: "1px solid #ddd",
|
|
1070
|
+
color: "#888",
|
|
1071
|
+
borderRadius: ".2em",
|
|
1072
|
+
margin: "0 1px",
|
|
1073
|
+
padding: "0 1px",
|
|
1074
|
+
cursor: "pointer"
|
|
1075
|
+
},
|
|
1076
|
+
".cm-foldGutter span": {
|
|
1077
|
+
padding: "0 1px",
|
|
1078
|
+
cursor: "pointer"
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
class G {
|
|
1082
|
+
constructor(t, e) {
|
|
1083
|
+
this.specs = t;
|
|
1084
|
+
let r;
|
|
1085
|
+
function s(a) {
|
|
1086
|
+
let l = ut.newName();
|
|
1087
|
+
return (r || (r = /* @__PURE__ */ Object.create(null)))["." + l] = a, l;
|
|
1088
|
+
}
|
|
1089
|
+
const i = typeof e.all == "string" ? e.all : e.all ? s(e.all) : void 0, o = e.scope;
|
|
1090
|
+
this.scope = o instanceof d ? (a) => a.prop(S) == o.data : o ? (a) => a == o : void 0, this.style = ee(t.map((a) => ({
|
|
1091
|
+
tag: a.tag,
|
|
1092
|
+
class: a.class || s(Object.assign({}, a, { tag: null }))
|
|
1093
|
+
})), {
|
|
1094
|
+
all: i
|
|
1095
|
+
}).style, this.module = r ? new ut(r) : null, this.themeType = e.themeType;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
Create a highlighter style that associates the given styles to
|
|
1099
|
+
the given tags. The specs must be objects that hold a style tag
|
|
1100
|
+
or array of tags in their `tag` property, and either a single
|
|
1101
|
+
`class` property providing a static CSS class (for highlighter
|
|
1102
|
+
that rely on external styling), or a
|
|
1103
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)-style
|
|
1104
|
+
set of CSS properties (which define the styling for those tags).
|
|
1105
|
+
|
|
1106
|
+
The CSS rules created for a highlighter will be emitted in the
|
|
1107
|
+
order of the spec's properties. That means that for elements that
|
|
1108
|
+
have multiple tags associated with them, styles defined further
|
|
1109
|
+
down in the list will have a higher CSS precedence than styles
|
|
1110
|
+
defined earlier.
|
|
1111
|
+
*/
|
|
1112
|
+
static define(t, e) {
|
|
1113
|
+
return new G(t, e || {});
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
const Y = /* @__PURE__ */ v.define(), Vt = /* @__PURE__ */ v.define({
|
|
1117
|
+
combine(n) {
|
|
1118
|
+
return n.length ? [n[0]] : null;
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
function U(n) {
|
|
1122
|
+
let t = n.facet(Y);
|
|
1123
|
+
return t.length ? t : n.facet(Vt);
|
|
1124
|
+
}
|
|
1125
|
+
function vn(n, t) {
|
|
1126
|
+
let e = [Re], r;
|
|
1127
|
+
return n instanceof G && (n.module && e.push(b.styleModule.of(n.module)), r = n.themeType), t?.fallback ? e.push(Vt.of(n)) : r ? e.push(Y.computeN([b.darkTheme], (s) => s.facet(b.darkTheme) == (r == "dark") ? [n] : [])) : e.push(Y.of(n)), e;
|
|
1128
|
+
}
|
|
1129
|
+
function Tn(n, t, e) {
|
|
1130
|
+
let r = U(n), s = null;
|
|
1131
|
+
if (r) {
|
|
1132
|
+
for (let i of r)
|
|
1133
|
+
if (!i.scope || e && i.scope(e)) {
|
|
1134
|
+
let o = i.style(t);
|
|
1135
|
+
o && (s = s ? s + " " + o : o);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return s;
|
|
1139
|
+
}
|
|
1140
|
+
class Ne {
|
|
1141
|
+
constructor(t) {
|
|
1142
|
+
this.markCache = /* @__PURE__ */ Object.create(null), this.tree = m(t.state), this.decorations = this.buildDeco(t, U(t.state)), this.decoratedTo = t.viewport.to;
|
|
1143
|
+
}
|
|
1144
|
+
update(t) {
|
|
1145
|
+
let e = m(t.state), r = U(t.state), s = r != U(t.startState), { viewport: i } = t.view, o = t.changes.mapPos(this.decoratedTo, 1);
|
|
1146
|
+
e.length < i.to && !s && e.type == this.tree.type && o >= i.to ? (this.decorations = this.decorations.map(t.changes), this.decoratedTo = o) : (e != this.tree || t.viewportChanged || s) && (this.tree = e, this.decorations = this.buildDeco(t.view, r), this.decoratedTo = i.to);
|
|
1147
|
+
}
|
|
1148
|
+
buildDeco(t, e) {
|
|
1149
|
+
if (!e || !this.tree.length)
|
|
1150
|
+
return p.none;
|
|
1151
|
+
let r = new nt();
|
|
1152
|
+
for (let { from: s, to: i } of t.visibleRanges)
|
|
1153
|
+
se(this.tree, e, (o, a, l) => {
|
|
1154
|
+
r.add(o, a, this.markCache[l] || (this.markCache[l] = p.mark({ class: l })));
|
|
1155
|
+
}, s, i);
|
|
1156
|
+
return r.finish();
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
const Re = /* @__PURE__ */ Pt.high(/* @__PURE__ */ R.fromClass(Ne, {
|
|
1160
|
+
decorations: (n) => n.decorations
|
|
1161
|
+
})), xn = /* @__PURE__ */ G.define([
|
|
1162
|
+
{
|
|
1163
|
+
tag: u.meta,
|
|
1164
|
+
color: "#404740"
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
tag: u.link,
|
|
1168
|
+
textDecoration: "underline"
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
tag: u.heading,
|
|
1172
|
+
textDecoration: "underline",
|
|
1173
|
+
fontWeight: "bold"
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
tag: u.emphasis,
|
|
1177
|
+
fontStyle: "italic"
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
tag: u.strong,
|
|
1181
|
+
fontWeight: "bold"
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
tag: u.strikethrough,
|
|
1185
|
+
textDecoration: "line-through"
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
tag: u.keyword,
|
|
1189
|
+
color: "#708"
|
|
1190
|
+
},
|
|
1191
|
+
{
|
|
1192
|
+
tag: [u.atom, u.bool, u.url, u.contentSeparator, u.labelName],
|
|
1193
|
+
color: "#219"
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
tag: [u.literal, u.inserted],
|
|
1197
|
+
color: "#164"
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
tag: [u.string, u.deleted],
|
|
1201
|
+
color: "#a11"
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
tag: [u.regexp, u.escape, /* @__PURE__ */ u.special(u.string)],
|
|
1205
|
+
color: "#e40"
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
tag: /* @__PURE__ */ u.definition(u.variableName),
|
|
1209
|
+
color: "#00f"
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
tag: /* @__PURE__ */ u.local(u.variableName),
|
|
1213
|
+
color: "#30a"
|
|
1214
|
+
},
|
|
1215
|
+
{
|
|
1216
|
+
tag: [u.typeName, u.namespace],
|
|
1217
|
+
color: "#085"
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
tag: u.className,
|
|
1221
|
+
color: "#167"
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
tag: [/* @__PURE__ */ u.special(u.variableName), u.macroName],
|
|
1225
|
+
color: "#256"
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
tag: /* @__PURE__ */ u.definition(u.propertyName),
|
|
1229
|
+
color: "#00c"
|
|
1230
|
+
},
|
|
1231
|
+
{
|
|
1232
|
+
tag: u.comment,
|
|
1233
|
+
color: "#940"
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
tag: u.invalid,
|
|
1237
|
+
color: "#f00"
|
|
1238
|
+
}
|
|
1239
|
+
]), Ee = /* @__PURE__ */ b.baseTheme({
|
|
1240
|
+
"&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
|
|
1241
|
+
"&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
|
|
1242
|
+
}), $t = 1e4, jt = "()[]{}", zt = /* @__PURE__ */ v.define({
|
|
1243
|
+
combine(n) {
|
|
1244
|
+
return Ct(n, {
|
|
1245
|
+
afterCursor: !0,
|
|
1246
|
+
brackets: jt,
|
|
1247
|
+
maxScanDistance: $t,
|
|
1248
|
+
renderMatch: Ue
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
}), Fe = /* @__PURE__ */ p.mark({ class: "cm-matchingBracket" }), We = /* @__PURE__ */ p.mark({ class: "cm-nonmatchingBracket" });
|
|
1252
|
+
function Ue(n) {
|
|
1253
|
+
let t = [], e = n.matched ? Fe : We;
|
|
1254
|
+
return t.push(e.range(n.start.from, n.start.to)), n.end && t.push(e.range(n.end.from, n.end.to)), t;
|
|
1255
|
+
}
|
|
1256
|
+
function mt(n) {
|
|
1257
|
+
let t = [], e = n.facet(zt);
|
|
1258
|
+
for (let r of n.selection.ranges) {
|
|
1259
|
+
if (!r.empty)
|
|
1260
|
+
continue;
|
|
1261
|
+
let s = F(n, r.head, -1, e) || r.head > 0 && F(n, r.head - 1, 1, e) || e.afterCursor && (F(n, r.head, 1, e) || r.head < n.doc.length && F(n, r.head + 1, -1, e));
|
|
1262
|
+
s && (t = t.concat(e.renderMatch(s, n)));
|
|
1263
|
+
}
|
|
1264
|
+
return p.set(t, !0);
|
|
1265
|
+
}
|
|
1266
|
+
const He = /* @__PURE__ */ R.fromClass(class {
|
|
1267
|
+
constructor(n) {
|
|
1268
|
+
this.paused = !1, this.decorations = mt(n.state);
|
|
1269
|
+
}
|
|
1270
|
+
update(n) {
|
|
1271
|
+
(n.docChanged || n.selectionSet || this.paused) && (n.view.composing ? (this.decorations = this.decorations.map(n.changes), this.paused = !0) : (this.decorations = mt(n.state), this.paused = !1));
|
|
1272
|
+
}
|
|
1273
|
+
}, {
|
|
1274
|
+
decorations: (n) => n.decorations
|
|
1275
|
+
}), Ve = [
|
|
1276
|
+
He,
|
|
1277
|
+
Ee
|
|
1278
|
+
];
|
|
1279
|
+
function Sn(n = {}) {
|
|
1280
|
+
return [zt.of(n), Ve];
|
|
1281
|
+
}
|
|
1282
|
+
const $e = /* @__PURE__ */ new y();
|
|
1283
|
+
function Z(n, t, e) {
|
|
1284
|
+
let r = n.prop(t < 0 ? y.openedBy : y.closedBy);
|
|
1285
|
+
if (r)
|
|
1286
|
+
return r;
|
|
1287
|
+
if (n.name.length == 1) {
|
|
1288
|
+
let s = e.indexOf(n.name);
|
|
1289
|
+
if (s > -1 && s % 2 == (t < 0 ? 1 : 0))
|
|
1290
|
+
return [e[s + t]];
|
|
1291
|
+
}
|
|
1292
|
+
return null;
|
|
1293
|
+
}
|
|
1294
|
+
function tt(n) {
|
|
1295
|
+
let t = n.type.prop($e);
|
|
1296
|
+
return t ? t(n.node) : n;
|
|
1297
|
+
}
|
|
1298
|
+
function F(n, t, e, r = {}) {
|
|
1299
|
+
let s = r.maxScanDistance || $t, i = r.brackets || jt, o = m(n), a = o.resolveInner(t, e);
|
|
1300
|
+
for (let l = a; l; l = l.parent) {
|
|
1301
|
+
let h = Z(l.type, e, i);
|
|
1302
|
+
if (h && l.from < l.to) {
|
|
1303
|
+
let f = tt(l);
|
|
1304
|
+
if (f && (e > 0 ? t >= f.from && t < f.to : t > f.from && t <= f.to))
|
|
1305
|
+
return je(n, t, e, l, f, h, i);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
return ze(n, t, e, o, a.type, s, i);
|
|
1309
|
+
}
|
|
1310
|
+
function je(n, t, e, r, s, i, o) {
|
|
1311
|
+
let a = r.parent, l = { from: s.from, to: s.to }, h = 0, f = a?.cursor();
|
|
1312
|
+
if (f && (e < 0 ? f.childBefore(r.from) : f.childAfter(r.to)))
|
|
1313
|
+
do
|
|
1314
|
+
if (e < 0 ? f.to <= r.from : f.from >= r.to) {
|
|
1315
|
+
if (h == 0 && i.indexOf(f.type.name) > -1 && f.from < f.to) {
|
|
1316
|
+
let c = tt(f);
|
|
1317
|
+
return { start: l, end: c ? { from: c.from, to: c.to } : void 0, matched: !0 };
|
|
1318
|
+
} else if (Z(f.type, e, o))
|
|
1319
|
+
h++;
|
|
1320
|
+
else if (Z(f.type, -e, o)) {
|
|
1321
|
+
if (h == 0) {
|
|
1322
|
+
let c = tt(f);
|
|
1323
|
+
return {
|
|
1324
|
+
start: l,
|
|
1325
|
+
end: c && c.from < c.to ? { from: c.from, to: c.to } : void 0,
|
|
1326
|
+
matched: !1
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
h--;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
while (e < 0 ? f.prevSibling() : f.nextSibling());
|
|
1333
|
+
return { start: l, matched: !1 };
|
|
1334
|
+
}
|
|
1335
|
+
function ze(n, t, e, r, s, i, o) {
|
|
1336
|
+
if (e < 0 ? !t : t == n.doc.length)
|
|
1337
|
+
return null;
|
|
1338
|
+
let a = e < 0 ? n.sliceDoc(t - 1, t) : n.sliceDoc(t, t + 1), l = o.indexOf(a);
|
|
1339
|
+
if (l < 0 || l % 2 == 0 != e > 0)
|
|
1340
|
+
return null;
|
|
1341
|
+
let h = { from: e < 0 ? t - 1 : t, to: e > 0 ? t + 1 : t }, f = n.doc.iterRange(t, e > 0 ? n.doc.length : 0), c = 0;
|
|
1342
|
+
for (let w = 0; !f.next().done && w <= i; ) {
|
|
1343
|
+
let k = f.value;
|
|
1344
|
+
e < 0 && (w += k.length);
|
|
1345
|
+
let P = t + w * e;
|
|
1346
|
+
for (let C = e > 0 ? 0 : k.length - 1, te = e > 0 ? k.length : -1; C != te; C += e) {
|
|
1347
|
+
let q = o.indexOf(k[C]);
|
|
1348
|
+
if (!(q < 0 || r.resolveInner(P + C, 1).type != s))
|
|
1349
|
+
if (q % 2 == 0 == e > 0)
|
|
1350
|
+
c++;
|
|
1351
|
+
else {
|
|
1352
|
+
if (c == 1)
|
|
1353
|
+
return { start: h, end: { from: P + C, to: P + C + 1 }, matched: q >> 1 == l >> 1 };
|
|
1354
|
+
c--;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
e > 0 && (w += k.length);
|
|
1358
|
+
}
|
|
1359
|
+
return f.done ? { start: h, matched: !1 } : null;
|
|
1360
|
+
}
|
|
1361
|
+
function kt(n, t, e, r = 0, s = 0) {
|
|
1362
|
+
t == null && (t = n.search(/[^\s\u00a0]/), t == -1 && (t = n.length));
|
|
1363
|
+
let i = s;
|
|
1364
|
+
for (let o = r; o < t; o++)
|
|
1365
|
+
n.charCodeAt(o) == 9 ? i += e - i % e : i++;
|
|
1366
|
+
return i;
|
|
1367
|
+
}
|
|
1368
|
+
class Gt {
|
|
1369
|
+
/**
|
|
1370
|
+
Create a stream.
|
|
1371
|
+
*/
|
|
1372
|
+
constructor(t, e, r, s) {
|
|
1373
|
+
this.string = t, this.tabSize = e, this.indentUnit = r, this.overrideIndent = s, this.pos = 0, this.start = 0, this.lastColumnPos = 0, this.lastColumnValue = 0;
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
True if we are at the end of the line.
|
|
1377
|
+
*/
|
|
1378
|
+
eol() {
|
|
1379
|
+
return this.pos >= this.string.length;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
True if we are at the start of the line.
|
|
1383
|
+
*/
|
|
1384
|
+
sol() {
|
|
1385
|
+
return this.pos == 0;
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
Get the next code unit after the current position, or undefined
|
|
1389
|
+
if we're at the end of the line.
|
|
1390
|
+
*/
|
|
1391
|
+
peek() {
|
|
1392
|
+
return this.string.charAt(this.pos) || void 0;
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
Read the next code unit and advance `this.pos`.
|
|
1396
|
+
*/
|
|
1397
|
+
next() {
|
|
1398
|
+
if (this.pos < this.string.length)
|
|
1399
|
+
return this.string.charAt(this.pos++);
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
Match the next character against the given string, regular
|
|
1403
|
+
expression, or predicate. Consume and return it if it matches.
|
|
1404
|
+
*/
|
|
1405
|
+
eat(t) {
|
|
1406
|
+
let e = this.string.charAt(this.pos), r;
|
|
1407
|
+
if (typeof t == "string" ? r = e == t : r = e && (t instanceof RegExp ? t.test(e) : t(e)), r)
|
|
1408
|
+
return ++this.pos, e;
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
Continue matching characters that match the given string,
|
|
1412
|
+
regular expression, or predicate function. Return true if any
|
|
1413
|
+
characters were consumed.
|
|
1414
|
+
*/
|
|
1415
|
+
eatWhile(t) {
|
|
1416
|
+
let e = this.pos;
|
|
1417
|
+
for (; this.eat(t); )
|
|
1418
|
+
;
|
|
1419
|
+
return this.pos > e;
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
Consume whitespace ahead of `this.pos`. Return true if any was
|
|
1423
|
+
found.
|
|
1424
|
+
*/
|
|
1425
|
+
eatSpace() {
|
|
1426
|
+
let t = this.pos;
|
|
1427
|
+
for (; /[\s\u00a0]/.test(this.string.charAt(this.pos)); )
|
|
1428
|
+
++this.pos;
|
|
1429
|
+
return this.pos > t;
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
Move to the end of the line.
|
|
1433
|
+
*/
|
|
1434
|
+
skipToEnd() {
|
|
1435
|
+
this.pos = this.string.length;
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
Move to directly before the given character, if found on the
|
|
1439
|
+
current line.
|
|
1440
|
+
*/
|
|
1441
|
+
skipTo(t) {
|
|
1442
|
+
let e = this.string.indexOf(t, this.pos);
|
|
1443
|
+
if (e > -1)
|
|
1444
|
+
return this.pos = e, !0;
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
Move back `n` characters.
|
|
1448
|
+
*/
|
|
1449
|
+
backUp(t) {
|
|
1450
|
+
this.pos -= t;
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
Get the column position at `this.pos`.
|
|
1454
|
+
*/
|
|
1455
|
+
column() {
|
|
1456
|
+
return this.lastColumnPos < this.start && (this.lastColumnValue = kt(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue), this.lastColumnPos = this.start), this.lastColumnValue;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
Get the indentation column of the current line.
|
|
1460
|
+
*/
|
|
1461
|
+
indentation() {
|
|
1462
|
+
var t;
|
|
1463
|
+
return (t = this.overrideIndent) !== null && t !== void 0 ? t : kt(this.string, null, this.tabSize);
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
Match the input against the given string or regular expression
|
|
1467
|
+
(which should start with a `^`). Return true or the regexp match
|
|
1468
|
+
if it matches.
|
|
1469
|
+
|
|
1470
|
+
Unless `consume` is set to `false`, this will move `this.pos`
|
|
1471
|
+
past the matched text.
|
|
1472
|
+
|
|
1473
|
+
When matching a string `caseInsensitive` can be set to true to
|
|
1474
|
+
make the match case-insensitive.
|
|
1475
|
+
*/
|
|
1476
|
+
match(t, e, r) {
|
|
1477
|
+
if (typeof t == "string") {
|
|
1478
|
+
let s = (o) => r ? o.toLowerCase() : o, i = this.string.substr(this.pos, t.length);
|
|
1479
|
+
return s(i) == s(t) ? (e !== !1 && (this.pos += t.length), !0) : null;
|
|
1480
|
+
} else {
|
|
1481
|
+
let s = this.string.slice(this.pos).match(t);
|
|
1482
|
+
return s && s.index > 0 ? null : (s && e !== !1 && (this.pos += s[0].length), s);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
Get the current token.
|
|
1487
|
+
*/
|
|
1488
|
+
current() {
|
|
1489
|
+
return this.string.slice(this.start, this.pos);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
function Ge(n) {
|
|
1493
|
+
return {
|
|
1494
|
+
name: n.name || "",
|
|
1495
|
+
token: n.token,
|
|
1496
|
+
blankLine: n.blankLine || (() => {
|
|
1497
|
+
}),
|
|
1498
|
+
startState: n.startState || (() => !0),
|
|
1499
|
+
copyState: n.copyState || qe,
|
|
1500
|
+
indent: n.indent || (() => null),
|
|
1501
|
+
languageData: n.languageData || {},
|
|
1502
|
+
tokenTable: n.tokenTable || ht,
|
|
1503
|
+
mergeTokens: n.mergeTokens !== !1
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
function qe(n) {
|
|
1507
|
+
if (typeof n != "object")
|
|
1508
|
+
return n;
|
|
1509
|
+
let t = {};
|
|
1510
|
+
for (let e in n) {
|
|
1511
|
+
let r = n[e];
|
|
1512
|
+
t[e] = r instanceof Array ? r.slice() : r;
|
|
1513
|
+
}
|
|
1514
|
+
return t;
|
|
1515
|
+
}
|
|
1516
|
+
const bt = /* @__PURE__ */ new WeakMap();
|
|
1517
|
+
class qt extends d {
|
|
1518
|
+
constructor(t) {
|
|
1519
|
+
let e = It(t.languageData), r = Ge(t), s, i = new class extends Tt {
|
|
1520
|
+
createParse(o, a, l) {
|
|
1521
|
+
return new _e(s, o, a, l);
|
|
1522
|
+
}
|
|
1523
|
+
}();
|
|
1524
|
+
super(e, i, [], t.name), this.topNode = Xe(e, this), s = this, this.streamParser = r, this.stateAfter = new y({ perNode: !0 }), this.tokenTable = t.tokenTable ? new Qt(r.tokenTable) : Qe;
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
Define a stream language.
|
|
1528
|
+
*/
|
|
1529
|
+
static define(t) {
|
|
1530
|
+
return new qt(t);
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
@internal
|
|
1534
|
+
*/
|
|
1535
|
+
getIndent(t) {
|
|
1536
|
+
let e, { overrideIndentation: r } = t.options;
|
|
1537
|
+
r && (e = bt.get(t.state), e != null && e < t.pos - 1e4 && (e = void 0));
|
|
1538
|
+
let s = at(this, t.node.tree, t.node.from, t.node.from, e ?? t.pos), i, o;
|
|
1539
|
+
if (s ? (o = s.state, i = s.pos + 1) : (o = this.streamParser.startState(t.unit), i = t.node.from), t.pos - i > 1e4)
|
|
1540
|
+
return null;
|
|
1541
|
+
for (; i < t.pos; ) {
|
|
1542
|
+
let l = t.state.doc.lineAt(i), h = Math.min(t.pos, l.to);
|
|
1543
|
+
if (l.length) {
|
|
1544
|
+
let f = r ? r(l.from) : -1, c = new Gt(l.text, t.state.tabSize, t.unit, f < 0 ? void 0 : f);
|
|
1545
|
+
for (; c.pos < h - l.from; )
|
|
1546
|
+
_t(this.streamParser.token, c, o);
|
|
1547
|
+
} else
|
|
1548
|
+
this.streamParser.blankLine(o, t.unit);
|
|
1549
|
+
if (h == t.pos)
|
|
1550
|
+
break;
|
|
1551
|
+
i = l.to + 1;
|
|
1552
|
+
}
|
|
1553
|
+
let a = t.lineAt(t.pos);
|
|
1554
|
+
return r && e == null && bt.set(t.state, a.from), this.streamParser.indent(o, /^\s*(.*)/.exec(a.text)[1], t);
|
|
1555
|
+
}
|
|
1556
|
+
get allowsNesting() {
|
|
1557
|
+
return !1;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
function at(n, t, e, r, s) {
|
|
1561
|
+
let i = e >= r && e + t.length <= s && t.prop(n.stateAfter);
|
|
1562
|
+
if (i)
|
|
1563
|
+
return { state: n.streamParser.copyState(i), pos: e + t.length };
|
|
1564
|
+
for (let o = t.children.length - 1; o >= 0; o--) {
|
|
1565
|
+
let a = t.children[o], l = e + t.positions[o], h = a instanceof g && l < s && at(n, a, l, r, s);
|
|
1566
|
+
if (h)
|
|
1567
|
+
return h;
|
|
1568
|
+
}
|
|
1569
|
+
return null;
|
|
1570
|
+
}
|
|
1571
|
+
function Jt(n, t, e, r, s) {
|
|
1572
|
+
if (s && e <= 0 && r >= t.length)
|
|
1573
|
+
return t;
|
|
1574
|
+
!s && e == 0 && t.type == n.topNode && (s = !0);
|
|
1575
|
+
for (let i = t.children.length - 1; i >= 0; i--) {
|
|
1576
|
+
let o = t.positions[i], a = t.children[i], l;
|
|
1577
|
+
if (o < r && a instanceof g) {
|
|
1578
|
+
if (!(l = Jt(n, a, e - o, r - o, s)))
|
|
1579
|
+
break;
|
|
1580
|
+
return s ? new g(t.type, t.children.slice(0, i).concat(l), t.positions.slice(0, i + 1), o + l.length) : l;
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
return null;
|
|
1584
|
+
}
|
|
1585
|
+
function Je(n, t, e, r, s) {
|
|
1586
|
+
for (let i of t) {
|
|
1587
|
+
let o = i.from + (i.openStart ? 25 : 0), a = i.to - (i.openEnd ? 25 : 0), l = o <= e && a > e && at(n, i.tree, 0 - i.offset, e, a), h;
|
|
1588
|
+
if (l && l.pos <= r && (h = Jt(n, i.tree, e + i.offset, l.pos + i.offset, !1)))
|
|
1589
|
+
return { state: l.state, tree: h };
|
|
1590
|
+
}
|
|
1591
|
+
return { state: n.streamParser.startState(s ? V(s) : 4), tree: g.empty };
|
|
1592
|
+
}
|
|
1593
|
+
class _e {
|
|
1594
|
+
constructor(t, e, r, s) {
|
|
1595
|
+
this.lang = t, this.input = e, this.fragments = r, this.ranges = s, this.stoppedAt = null, this.chunks = [], this.chunkPos = [], this.chunk = [], this.chunkReused = void 0, this.rangeIndex = 0, this.to = s[s.length - 1].to;
|
|
1596
|
+
let i = A.get(), o = s[0].from, { state: a, tree: l } = Je(t, r, o, this.to, i?.state);
|
|
1597
|
+
this.state = a, this.parsedPos = this.chunkStart = o + l.length;
|
|
1598
|
+
for (let h = 0; h < l.children.length; h++)
|
|
1599
|
+
this.chunks.push(l.children[h]), this.chunkPos.push(l.positions[h]);
|
|
1600
|
+
i && this.parsedPos < i.viewport.from - 1e5 && s.some((h) => h.from <= i.viewport.from && h.to >= i.viewport.from) && (this.state = this.lang.streamParser.startState(V(i.state)), i.skipUntilInView(this.parsedPos, i.viewport.from), this.parsedPos = i.viewport.from), this.moveRangeIndex();
|
|
1601
|
+
}
|
|
1602
|
+
advance() {
|
|
1603
|
+
let t = A.get(), e = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt), r = Math.min(
|
|
1604
|
+
e,
|
|
1605
|
+
this.chunkStart + 512
|
|
1606
|
+
/* C.ChunkSize */
|
|
1607
|
+
);
|
|
1608
|
+
for (t && (r = Math.min(r, t.viewport.to)); this.parsedPos < r; )
|
|
1609
|
+
this.parseLine(t);
|
|
1610
|
+
return this.chunkStart < this.parsedPos && this.finishChunk(), this.parsedPos >= e ? this.finish() : t && this.parsedPos >= t.viewport.to ? (t.skipUntilInView(this.parsedPos, e), this.finish()) : null;
|
|
1611
|
+
}
|
|
1612
|
+
stopAt(t) {
|
|
1613
|
+
this.stoppedAt = t;
|
|
1614
|
+
}
|
|
1615
|
+
lineAfter(t) {
|
|
1616
|
+
let e = this.input.chunk(t);
|
|
1617
|
+
if (this.input.lineChunks)
|
|
1618
|
+
e == `
|
|
1619
|
+
` && (e = "");
|
|
1620
|
+
else {
|
|
1621
|
+
let r = e.indexOf(`
|
|
1622
|
+
`);
|
|
1623
|
+
r > -1 && (e = e.slice(0, r));
|
|
1624
|
+
}
|
|
1625
|
+
return t + e.length <= this.to ? e : e.slice(0, this.to - t);
|
|
1626
|
+
}
|
|
1627
|
+
nextLine() {
|
|
1628
|
+
let t = this.parsedPos, e = this.lineAfter(t), r = t + e.length;
|
|
1629
|
+
for (let s = this.rangeIndex; ; ) {
|
|
1630
|
+
let i = this.ranges[s].to;
|
|
1631
|
+
if (i >= r || (e = e.slice(0, i - (r - e.length)), s++, s == this.ranges.length))
|
|
1632
|
+
break;
|
|
1633
|
+
let o = this.ranges[s].from, a = this.lineAfter(o);
|
|
1634
|
+
e += a, r = o + a.length;
|
|
1635
|
+
}
|
|
1636
|
+
return { line: e, end: r };
|
|
1637
|
+
}
|
|
1638
|
+
skipGapsTo(t, e, r) {
|
|
1639
|
+
for (; ; ) {
|
|
1640
|
+
let s = this.ranges[this.rangeIndex].to, i = t + e;
|
|
1641
|
+
if (r > 0 ? s > i : s >= i)
|
|
1642
|
+
break;
|
|
1643
|
+
let o = this.ranges[++this.rangeIndex].from;
|
|
1644
|
+
e += o - s;
|
|
1645
|
+
}
|
|
1646
|
+
return e;
|
|
1647
|
+
}
|
|
1648
|
+
moveRangeIndex() {
|
|
1649
|
+
for (; this.ranges[this.rangeIndex].to < this.parsedPos; )
|
|
1650
|
+
this.rangeIndex++;
|
|
1651
|
+
}
|
|
1652
|
+
emitToken(t, e, r, s) {
|
|
1653
|
+
let i = 4;
|
|
1654
|
+
if (this.ranges.length > 1) {
|
|
1655
|
+
s = this.skipGapsTo(e, s, 1), e += s;
|
|
1656
|
+
let a = this.chunk.length;
|
|
1657
|
+
s = this.skipGapsTo(r, s, -1), r += s, i += this.chunk.length - a;
|
|
1658
|
+
}
|
|
1659
|
+
let o = this.chunk.length - 4;
|
|
1660
|
+
return this.lang.streamParser.mergeTokens && i == 4 && o >= 0 && this.chunk[o] == t && this.chunk[o + 2] == e ? this.chunk[o + 2] = r : this.chunk.push(t, e, r, i), s;
|
|
1661
|
+
}
|
|
1662
|
+
parseLine(t) {
|
|
1663
|
+
let { line: e, end: r } = this.nextLine(), s = 0, { streamParser: i } = this.lang, o = new Gt(e, t ? t.state.tabSize : 4, t ? V(t.state) : 2);
|
|
1664
|
+
if (o.eol())
|
|
1665
|
+
i.blankLine(this.state, o.indentUnit);
|
|
1666
|
+
else
|
|
1667
|
+
for (; !o.eol(); ) {
|
|
1668
|
+
let a = _t(i.token, o, this.state);
|
|
1669
|
+
if (a && (s = this.emitToken(this.lang.tokenTable.resolve(a), this.parsedPos + o.start, this.parsedPos + o.pos, s)), o.start > 1e4)
|
|
1670
|
+
break;
|
|
1671
|
+
}
|
|
1672
|
+
this.parsedPos = r, this.moveRangeIndex(), this.parsedPos < this.to && this.parsedPos++;
|
|
1673
|
+
}
|
|
1674
|
+
finishChunk() {
|
|
1675
|
+
let t = g.build({
|
|
1676
|
+
buffer: this.chunk,
|
|
1677
|
+
start: this.chunkStart,
|
|
1678
|
+
length: this.parsedPos - this.chunkStart,
|
|
1679
|
+
nodeSet: Ke,
|
|
1680
|
+
topID: 0,
|
|
1681
|
+
maxBufferLength: 512,
|
|
1682
|
+
reused: this.chunkReused
|
|
1683
|
+
});
|
|
1684
|
+
t = new g(t.type, t.children, t.positions, t.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]), this.chunks.push(t), this.chunkPos.push(this.chunkStart - this.ranges[0].from), this.chunk = [], this.chunkReused = void 0, this.chunkStart = this.parsedPos;
|
|
1685
|
+
}
|
|
1686
|
+
finish() {
|
|
1687
|
+
return new g(this.lang.topNode, this.chunks, this.chunkPos, this.parsedPos - this.ranges[0].from).balance();
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
function _t(n, t, e) {
|
|
1691
|
+
t.start = t.pos;
|
|
1692
|
+
for (let r = 0; r < 10; r++) {
|
|
1693
|
+
let s = n(t, e);
|
|
1694
|
+
if (t.pos > t.start)
|
|
1695
|
+
return s;
|
|
1696
|
+
}
|
|
1697
|
+
throw new Error("Stream parser failed to advance stream.");
|
|
1698
|
+
}
|
|
1699
|
+
const ht = /* @__PURE__ */ Object.create(null), N = [j.none], Ke = /* @__PURE__ */ new ne(N), wt = [], yt = /* @__PURE__ */ Object.create(null), Kt = /* @__PURE__ */ Object.create(null);
|
|
1700
|
+
for (let [n, t] of [
|
|
1701
|
+
["variable", "variableName"],
|
|
1702
|
+
["variable-2", "variableName.special"],
|
|
1703
|
+
["string-2", "string.special"],
|
|
1704
|
+
["def", "variableName.definition"],
|
|
1705
|
+
["tag", "tagName"],
|
|
1706
|
+
["attribute", "attributeName"],
|
|
1707
|
+
["type", "typeName"],
|
|
1708
|
+
["builtin", "variableName.standard"],
|
|
1709
|
+
["qualifier", "modifier"],
|
|
1710
|
+
["error", "invalid"],
|
|
1711
|
+
["header", "heading"],
|
|
1712
|
+
["property", "propertyName"]
|
|
1713
|
+
])
|
|
1714
|
+
Kt[n] = /* @__PURE__ */ Xt(ht, t);
|
|
1715
|
+
class Qt {
|
|
1716
|
+
constructor(t) {
|
|
1717
|
+
this.extra = t, this.table = Object.assign(/* @__PURE__ */ Object.create(null), Kt);
|
|
1718
|
+
}
|
|
1719
|
+
resolve(t) {
|
|
1720
|
+
return t ? this.table[t] || (this.table[t] = Xt(this.extra, t)) : 0;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
const Qe = /* @__PURE__ */ new Qt(ht);
|
|
1724
|
+
function Q(n, t) {
|
|
1725
|
+
wt.indexOf(n) > -1 || (wt.push(n), console.warn(t));
|
|
1726
|
+
}
|
|
1727
|
+
function Xt(n, t) {
|
|
1728
|
+
let e = [];
|
|
1729
|
+
for (let a of t.split(" ")) {
|
|
1730
|
+
let l = [];
|
|
1731
|
+
for (let h of a.split(".")) {
|
|
1732
|
+
let f = n[h] || u[h];
|
|
1733
|
+
f ? typeof f == "function" ? l.length ? l = l.map(f) : Q(h, `Modifier ${h} used at start of tag`) : l.length ? Q(h, `Tag ${h} used as modifier`) : l = Array.isArray(f) ? f : [f] : Q(h, `Unknown highlighting tag ${h}`);
|
|
1734
|
+
}
|
|
1735
|
+
for (let h of l)
|
|
1736
|
+
e.push(h);
|
|
1737
|
+
}
|
|
1738
|
+
if (!e.length)
|
|
1739
|
+
return 0;
|
|
1740
|
+
let r = t.replace(/ /g, "_"), s = r + " " + e.map((a) => a.id), i = yt[s];
|
|
1741
|
+
if (i)
|
|
1742
|
+
return i.id;
|
|
1743
|
+
let o = yt[s] = j.define({
|
|
1744
|
+
id: N.length,
|
|
1745
|
+
name: r,
|
|
1746
|
+
props: [re({ [r]: e })]
|
|
1747
|
+
});
|
|
1748
|
+
return N.push(o), o.id;
|
|
1749
|
+
}
|
|
1750
|
+
function Xe(n, t) {
|
|
1751
|
+
let e = j.define({ id: N.length, name: "Document", props: [
|
|
1752
|
+
S.add(() => n),
|
|
1753
|
+
Rt.add(() => (r) => t.getIndent(r))
|
|
1754
|
+
], top: !0 });
|
|
1755
|
+
return N.push(e), e;
|
|
1756
|
+
}
|
|
1757
|
+
function Yt(n) {
|
|
1758
|
+
return n.length <= 4096 && /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(n);
|
|
1759
|
+
}
|
|
1760
|
+
function Zt(n) {
|
|
1761
|
+
for (let t = n.iter(); !t.next().done; )
|
|
1762
|
+
if (Yt(t.value))
|
|
1763
|
+
return !0;
|
|
1764
|
+
return !1;
|
|
1765
|
+
}
|
|
1766
|
+
function Ye(n) {
|
|
1767
|
+
let t = !1;
|
|
1768
|
+
return n.iterChanges((e, r, s, i, o) => {
|
|
1769
|
+
!t && Zt(o) && (t = !0);
|
|
1770
|
+
}), t;
|
|
1771
|
+
}
|
|
1772
|
+
const et = /* @__PURE__ */ v.define({ combine: (n) => n.some((t) => t) });
|
|
1773
|
+
function Pn(n = {}) {
|
|
1774
|
+
let t = [Ze];
|
|
1775
|
+
return n.alwaysIsolate && t.push(et.of(!0)), t;
|
|
1776
|
+
}
|
|
1777
|
+
const Ze = /* @__PURE__ */ R.fromClass(class {
|
|
1778
|
+
constructor(n) {
|
|
1779
|
+
this.always = n.state.facet(et) || n.textDirection != H.LTR || n.state.facet(b.perLineTextDirection), this.hasRTL = !this.always && Zt(n.state.doc), this.tree = m(n.state), this.decorations = this.always || this.hasRTL ? vt(n, this.tree, this.always) : p.none;
|
|
1780
|
+
}
|
|
1781
|
+
update(n) {
|
|
1782
|
+
let t = n.state.facet(et) || n.view.textDirection != H.LTR || n.state.facet(b.perLineTextDirection);
|
|
1783
|
+
if (!t && !this.hasRTL && Ye(n.changes) && (this.hasRTL = !0), !t && !this.hasRTL)
|
|
1784
|
+
return;
|
|
1785
|
+
let e = m(n.state);
|
|
1786
|
+
(t != this.always || e != this.tree || n.docChanged || n.viewportChanged) && (this.tree = e, this.always = t, this.decorations = vt(n.view, e, t));
|
|
1787
|
+
}
|
|
1788
|
+
}, {
|
|
1789
|
+
provide: (n) => {
|
|
1790
|
+
function t(e) {
|
|
1791
|
+
var r, s;
|
|
1792
|
+
return (s = (r = e.plugin(n)) === null || r === void 0 ? void 0 : r.decorations) !== null && s !== void 0 ? s : p.none;
|
|
1793
|
+
}
|
|
1794
|
+
return [
|
|
1795
|
+
b.outerDecorations.of(t),
|
|
1796
|
+
Pt.lowest(b.bidiIsolatedRanges.of(t))
|
|
1797
|
+
];
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
function vt(n, t, e) {
|
|
1801
|
+
let r = new nt(), s = n.visibleRanges;
|
|
1802
|
+
e || (s = tn(s, n.state.doc));
|
|
1803
|
+
for (let { from: i, to: o } of s)
|
|
1804
|
+
t.iterate({
|
|
1805
|
+
enter: (a) => {
|
|
1806
|
+
let l = a.type.prop(y.isolate);
|
|
1807
|
+
l && r.add(a.from, a.to, en[l]);
|
|
1808
|
+
},
|
|
1809
|
+
from: i,
|
|
1810
|
+
to: o
|
|
1811
|
+
});
|
|
1812
|
+
return r.finish();
|
|
1813
|
+
}
|
|
1814
|
+
function tn(n, t) {
|
|
1815
|
+
let e = t.iter(), r = 0, s = [], i = null;
|
|
1816
|
+
for (let { from: o, to: a } of n)
|
|
1817
|
+
if (!(i && i.to > o && (o = i.to, o >= a)))
|
|
1818
|
+
for (r + e.value.length < o && (e.next(o - (r + e.value.length)), r = o); ; ) {
|
|
1819
|
+
let l = r, h = r + e.value.length;
|
|
1820
|
+
if (!e.lineBreak && Yt(e.value) && (i && i.to > l - 10 ? i.to = Math.min(a, h) : s.push(i = { from: l, to: Math.min(a, h) })), h >= a)
|
|
1821
|
+
break;
|
|
1822
|
+
r = h, e.next();
|
|
1823
|
+
}
|
|
1824
|
+
return s;
|
|
1825
|
+
}
|
|
1826
|
+
const en = {
|
|
1827
|
+
rtl: /* @__PURE__ */ p.mark({ class: "cm-iso", inclusive: !0, attributes: { dir: "rtl" }, bidiIsolate: H.RTL }),
|
|
1828
|
+
ltr: /* @__PURE__ */ p.mark({ class: "cm-iso", inclusive: !0, attributes: { dir: "ltr" }, bidiIsolate: H.LTR }),
|
|
1829
|
+
auto: /* @__PURE__ */ p.mark({ class: "cm-iso", inclusive: !0, attributes: { dir: "auto" }, bidiIsolate: null })
|
|
1830
|
+
};
|
|
1831
|
+
export {
|
|
1832
|
+
ue as DocInput,
|
|
1833
|
+
G as HighlightStyle,
|
|
1834
|
+
rt as IndentContext,
|
|
1835
|
+
X as LRLanguage,
|
|
1836
|
+
d as Language,
|
|
1837
|
+
Ot as LanguageDescription,
|
|
1838
|
+
fn as LanguageSupport,
|
|
1839
|
+
A as ParseContext,
|
|
1840
|
+
qt as StreamLanguage,
|
|
1841
|
+
Gt as StringStream,
|
|
1842
|
+
st as TreeIndentContext,
|
|
1843
|
+
Pn as bidiIsolates,
|
|
1844
|
+
Sn as bracketMatching,
|
|
1845
|
+
$e as bracketMatchingHandle,
|
|
1846
|
+
Ut as codeFolding,
|
|
1847
|
+
pn as continuedIndent,
|
|
1848
|
+
xn as defaultHighlightStyle,
|
|
1849
|
+
It as defineLanguageFacet,
|
|
1850
|
+
cn as delimitedIndent,
|
|
1851
|
+
fe as ensureSyntaxTree,
|
|
1852
|
+
dn as flatIndent,
|
|
1853
|
+
Ae as foldAll,
|
|
1854
|
+
Pe as foldCode,
|
|
1855
|
+
E as foldEffect,
|
|
1856
|
+
yn as foldGutter,
|
|
1857
|
+
mn as foldInside,
|
|
1858
|
+
wn as foldKeymap,
|
|
1859
|
+
ve as foldNodeProp,
|
|
1860
|
+
ye as foldService,
|
|
1861
|
+
x as foldState,
|
|
1862
|
+
B as foldable,
|
|
1863
|
+
kn as foldedRanges,
|
|
1864
|
+
ln as forceParsing,
|
|
1865
|
+
V as getIndentUnit,
|
|
1866
|
+
Nt as getIndentation,
|
|
1867
|
+
Tn as highlightingFor,
|
|
1868
|
+
Rt as indentNodeProp,
|
|
1869
|
+
gn as indentOnInput,
|
|
1870
|
+
un as indentRange,
|
|
1871
|
+
ce as indentService,
|
|
1872
|
+
Lt as indentString,
|
|
1873
|
+
Bt as indentUnit,
|
|
1874
|
+
T as language,
|
|
1875
|
+
S as languageDataProp,
|
|
1876
|
+
F as matchBrackets,
|
|
1877
|
+
he as sublanguageProp,
|
|
1878
|
+
vn as syntaxHighlighting,
|
|
1879
|
+
an as syntaxParserRunning,
|
|
1880
|
+
m as syntaxTree,
|
|
1881
|
+
on as syntaxTreeAvailable,
|
|
1882
|
+
bn as toggleFold,
|
|
1883
|
+
Ie as unfoldAll,
|
|
1884
|
+
Ce as unfoldCode,
|
|
1885
|
+
D as unfoldEffect
|
|
1886
|
+
};
|