@coze-editor/lang-javascript 0.1.0-alpha.6b15c1
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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/esm/index.js +553 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +573 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 coze-dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
// src/javascript.ts
|
|
2
|
+
import { parser } from "@lezer/javascript";
|
|
3
|
+
import { EditorView } from "@codemirror/view";
|
|
4
|
+
import { EditorSelection } from "@codemirror/state";
|
|
5
|
+
import {
|
|
6
|
+
LRLanguage,
|
|
7
|
+
LanguageSupport,
|
|
8
|
+
sublanguageProp,
|
|
9
|
+
defineLanguageFacet,
|
|
10
|
+
delimitedIndent,
|
|
11
|
+
flatIndent,
|
|
12
|
+
continuedIndent,
|
|
13
|
+
indentNodeProp,
|
|
14
|
+
foldNodeProp,
|
|
15
|
+
foldInside,
|
|
16
|
+
syntaxTree as syntaxTree2
|
|
17
|
+
} from "@codemirror/language";
|
|
18
|
+
import { completeFromList, ifNotIn } from "@codemirror/autocomplete";
|
|
19
|
+
|
|
20
|
+
// src/snippets.ts
|
|
21
|
+
import {
|
|
22
|
+
snippetCompletion as snip
|
|
23
|
+
} from "@codemirror/autocomplete";
|
|
24
|
+
var snippets = [
|
|
25
|
+
snip("function ${name}(${params}) {\n ${}\n}", {
|
|
26
|
+
label: "function",
|
|
27
|
+
detail: "definition",
|
|
28
|
+
type: "keyword"
|
|
29
|
+
}),
|
|
30
|
+
snip("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}", {
|
|
31
|
+
label: "for",
|
|
32
|
+
detail: "loop",
|
|
33
|
+
type: "keyword"
|
|
34
|
+
}),
|
|
35
|
+
snip("for (let ${name} of ${collection}) {\n ${}\n}", {
|
|
36
|
+
label: "for",
|
|
37
|
+
detail: "of loop",
|
|
38
|
+
type: "keyword"
|
|
39
|
+
}),
|
|
40
|
+
snip("do {\n ${}\n} while (${})", {
|
|
41
|
+
label: "do",
|
|
42
|
+
detail: "loop",
|
|
43
|
+
type: "keyword"
|
|
44
|
+
}),
|
|
45
|
+
snip("while (${}) {\n ${}\n}", {
|
|
46
|
+
label: "while",
|
|
47
|
+
detail: "loop",
|
|
48
|
+
type: "keyword"
|
|
49
|
+
}),
|
|
50
|
+
snip("try {\n ${}\n} catch (${error}) {\n ${}\n}", {
|
|
51
|
+
label: "try",
|
|
52
|
+
detail: "/ catch block",
|
|
53
|
+
type: "keyword"
|
|
54
|
+
}),
|
|
55
|
+
snip("if (${}) {\n ${}\n}", {
|
|
56
|
+
label: "if",
|
|
57
|
+
detail: "block",
|
|
58
|
+
type: "keyword"
|
|
59
|
+
}),
|
|
60
|
+
snip("if (${}) {\n ${}\n} else {\n ${}\n}", {
|
|
61
|
+
label: "if",
|
|
62
|
+
detail: "/ else block",
|
|
63
|
+
type: "keyword"
|
|
64
|
+
}),
|
|
65
|
+
snip("class ${name} {\n constructor(${params}) {\n ${}\n }\n}", {
|
|
66
|
+
label: "class",
|
|
67
|
+
detail: "definition",
|
|
68
|
+
type: "keyword"
|
|
69
|
+
}),
|
|
70
|
+
snip('import {${names}} from "${module}"\n${}', {
|
|
71
|
+
label: "import",
|
|
72
|
+
detail: "named",
|
|
73
|
+
type: "keyword"
|
|
74
|
+
}),
|
|
75
|
+
snip('import ${name} from "${module}"\n${}', {
|
|
76
|
+
label: "import",
|
|
77
|
+
detail: "default",
|
|
78
|
+
type: "keyword"
|
|
79
|
+
})
|
|
80
|
+
];
|
|
81
|
+
var typescriptSnippets = snippets.concat([
|
|
82
|
+
snip("interface ${name} {\n ${}\n}", {
|
|
83
|
+
label: "interface",
|
|
84
|
+
detail: "definition",
|
|
85
|
+
type: "keyword"
|
|
86
|
+
}),
|
|
87
|
+
snip("type ${name} = ${type}", {
|
|
88
|
+
label: "type",
|
|
89
|
+
detail: "definition",
|
|
90
|
+
type: "keyword"
|
|
91
|
+
}),
|
|
92
|
+
snip("enum ${name} {\n ${}\n}", {
|
|
93
|
+
label: "enum",
|
|
94
|
+
detail: "definition",
|
|
95
|
+
type: "keyword"
|
|
96
|
+
})
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
// src/complete.ts
|
|
100
|
+
import {
|
|
101
|
+
NodeWeakMap,
|
|
102
|
+
IterMode
|
|
103
|
+
} from "@lezer/common";
|
|
104
|
+
import { syntaxTree } from "@codemirror/language";
|
|
105
|
+
var cache = new NodeWeakMap();
|
|
106
|
+
var ScopeNodes = /* @__PURE__ */ new Set([
|
|
107
|
+
"Script",
|
|
108
|
+
"Block",
|
|
109
|
+
"FunctionExpression",
|
|
110
|
+
"FunctionDeclaration",
|
|
111
|
+
"ArrowFunction",
|
|
112
|
+
"MethodDeclaration",
|
|
113
|
+
"ForStatement"
|
|
114
|
+
]);
|
|
115
|
+
function defID(type) {
|
|
116
|
+
return (node, def) => {
|
|
117
|
+
const id = node.node.getChild("VariableDefinition");
|
|
118
|
+
if (id) {
|
|
119
|
+
def(id, type);
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
var functionContext = ["FunctionDeclaration"];
|
|
125
|
+
var gatherCompletions = {
|
|
126
|
+
FunctionDeclaration: defID("function"),
|
|
127
|
+
ClassDeclaration: defID("class"),
|
|
128
|
+
ClassExpression: () => true,
|
|
129
|
+
EnumDeclaration: defID("constant"),
|
|
130
|
+
TypeAliasDeclaration: defID("type"),
|
|
131
|
+
NamespaceDeclaration: defID("namespace"),
|
|
132
|
+
VariableDefinition(node, def) {
|
|
133
|
+
if (!node.matchContext(functionContext)) {
|
|
134
|
+
def(node, "variable");
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
TypeDefinition(node, def) {
|
|
138
|
+
def(node, "type");
|
|
139
|
+
},
|
|
140
|
+
__proto__: null
|
|
141
|
+
};
|
|
142
|
+
function getScope(doc, node) {
|
|
143
|
+
const cached = cache.get(node);
|
|
144
|
+
if (cached) {
|
|
145
|
+
return cached;
|
|
146
|
+
}
|
|
147
|
+
const completions = [];
|
|
148
|
+
let top = true;
|
|
149
|
+
function def(node2, type) {
|
|
150
|
+
const name = doc.sliceString(node2.from, node2.to);
|
|
151
|
+
completions.push({ label: name, type });
|
|
152
|
+
}
|
|
153
|
+
node.cursor(IterMode.IncludeAnonymous).iterate((node2) => {
|
|
154
|
+
if (top) {
|
|
155
|
+
top = false;
|
|
156
|
+
} else if (node2.name) {
|
|
157
|
+
const gather = gatherCompletions[node2.name];
|
|
158
|
+
if (gather && gather(node2, def) || ScopeNodes.has(node2.name)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
} else if (node2.to - node2.from > 8192) {
|
|
162
|
+
for (const c of getScope(doc, node2.node)) {
|
|
163
|
+
completions.push(c);
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
cache.set(node, completions);
|
|
169
|
+
return completions;
|
|
170
|
+
}
|
|
171
|
+
var Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
|
|
172
|
+
var dontComplete = [
|
|
173
|
+
"TemplateString",
|
|
174
|
+
"String",
|
|
175
|
+
"RegExp",
|
|
176
|
+
"LineComment",
|
|
177
|
+
"BlockComment",
|
|
178
|
+
"VariableDefinition",
|
|
179
|
+
"TypeDefinition",
|
|
180
|
+
"Label",
|
|
181
|
+
"PropertyDefinition",
|
|
182
|
+
"PropertyName",
|
|
183
|
+
"PrivatePropertyDefinition",
|
|
184
|
+
"PrivatePropertyName",
|
|
185
|
+
"JSXText",
|
|
186
|
+
"JSXAttributeValue",
|
|
187
|
+
"JSXOpenTag",
|
|
188
|
+
"JSXCloseTag",
|
|
189
|
+
"JSXSelfClosingTag",
|
|
190
|
+
".",
|
|
191
|
+
"?."
|
|
192
|
+
];
|
|
193
|
+
function localCompletionSource(context) {
|
|
194
|
+
const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
|
|
195
|
+
if (dontComplete.indexOf(inner.name) > -1) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
const isWord = inner.name == "VariableName" || inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
|
|
199
|
+
if (!isWord && !context.explicit) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
let options = [];
|
|
203
|
+
for (let pos = inner; pos; pos = pos.parent) {
|
|
204
|
+
if (ScopeNodes.has(pos.name)) {
|
|
205
|
+
options = options.concat(getScope(context.state.doc, pos));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
options,
|
|
210
|
+
from: isWord ? inner.from : context.pos,
|
|
211
|
+
validFor: Identifier
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function pathFor(read, member, name) {
|
|
215
|
+
var _a;
|
|
216
|
+
const path = [];
|
|
217
|
+
for (; ; ) {
|
|
218
|
+
const obj = member.firstChild;
|
|
219
|
+
let prop;
|
|
220
|
+
if ((obj == null ? void 0 : obj.name) == "VariableName") {
|
|
221
|
+
path.push(read(obj));
|
|
222
|
+
return { path: path.reverse(), name };
|
|
223
|
+
} else if ((obj == null ? void 0 : obj.name) == "MemberExpression" && ((_a = prop = obj.lastChild) == null ? void 0 : _a.name) == "PropertyName") {
|
|
224
|
+
path.push(read(prop));
|
|
225
|
+
member = obj;
|
|
226
|
+
} else {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function completionPath(context) {
|
|
232
|
+
const read = (node) => context.state.doc.sliceString(node.from, node.to);
|
|
233
|
+
const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
|
|
234
|
+
if (inner.name == "PropertyName") {
|
|
235
|
+
return pathFor(read, inner.parent, read(inner));
|
|
236
|
+
} else if ((inner.name == "." || inner.name == "?.") && inner.parent.name == "MemberExpression") {
|
|
237
|
+
return pathFor(read, inner.parent, "");
|
|
238
|
+
} else if (dontComplete.indexOf(inner.name) > -1) {
|
|
239
|
+
return null;
|
|
240
|
+
} else if (inner.name == "VariableName" || inner.to - inner.from < 20 && Identifier.test(read(inner))) {
|
|
241
|
+
return { path: [], name: read(inner) };
|
|
242
|
+
} else if (inner.name == "MemberExpression") {
|
|
243
|
+
return pathFor(read, inner, "");
|
|
244
|
+
} else {
|
|
245
|
+
return context.explicit ? { path: [], name: "" } : null;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function enumeratePropertyCompletions(obj, top) {
|
|
249
|
+
const options = [], seen = /* @__PURE__ */ new Set();
|
|
250
|
+
for (let depth = 0; ; depth++) {
|
|
251
|
+
for (const name of (Object.getOwnPropertyNames || Object.keys)(obj)) {
|
|
252
|
+
if (!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(name) || seen.has(name)) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
seen.add(name);
|
|
256
|
+
let value;
|
|
257
|
+
try {
|
|
258
|
+
value = obj[name];
|
|
259
|
+
} catch (_) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
options.push({
|
|
263
|
+
label: name,
|
|
264
|
+
type: typeof value === "function" ? /^[A-Z]/.test(name) ? "class" : top ? "function" : "method" : top ? "variable" : "property",
|
|
265
|
+
boost: -depth
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const next = Object.getPrototypeOf(obj);
|
|
269
|
+
if (!next) {
|
|
270
|
+
return options;
|
|
271
|
+
}
|
|
272
|
+
obj = next;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function scopeCompletionSource(scope) {
|
|
276
|
+
const cache2 = /* @__PURE__ */ new Map();
|
|
277
|
+
return (context) => {
|
|
278
|
+
const path = completionPath(context);
|
|
279
|
+
if (!path) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
let target = scope;
|
|
283
|
+
for (const step of path.path) {
|
|
284
|
+
target = target[step];
|
|
285
|
+
if (!target) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
let options = cache2.get(target);
|
|
290
|
+
if (!options) {
|
|
291
|
+
cache2.set(
|
|
292
|
+
target,
|
|
293
|
+
options = enumeratePropertyCompletions(target, !path.path.length)
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
from: context.pos - path.name.length,
|
|
298
|
+
options,
|
|
299
|
+
validFor: Identifier
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/javascript.ts
|
|
305
|
+
var javascriptLanguage = LRLanguage.define({
|
|
306
|
+
name: "javascript",
|
|
307
|
+
parser: parser.configure({
|
|
308
|
+
props: [
|
|
309
|
+
indentNodeProp.add({
|
|
310
|
+
IfStatement: continuedIndent({ except: /^\s*({|else\b)/ }),
|
|
311
|
+
TryStatement: continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
|
|
312
|
+
LabeledStatement: flatIndent,
|
|
313
|
+
SwitchBody: (context) => {
|
|
314
|
+
const after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
|
|
315
|
+
return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
|
|
316
|
+
},
|
|
317
|
+
Block: delimitedIndent({ closing: "}" }),
|
|
318
|
+
ArrowFunction: (cx) => cx.baseIndent + cx.unit,
|
|
319
|
+
"TemplateString BlockComment": () => null,
|
|
320
|
+
"Statement Property": continuedIndent({ except: /^\s*{/ }),
|
|
321
|
+
JSXElement(context) {
|
|
322
|
+
const closed = /^\s*<\//.test(context.textAfter);
|
|
323
|
+
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
|
324
|
+
},
|
|
325
|
+
JSXEscape(context) {
|
|
326
|
+
const closed = /\s*\}/.test(context.textAfter);
|
|
327
|
+
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
|
328
|
+
},
|
|
329
|
+
"JSXOpenTag JSXSelfClosingTag"(context) {
|
|
330
|
+
return context.column(context.node.from) + context.unit;
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
foldNodeProp.add({
|
|
334
|
+
"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": foldInside,
|
|
335
|
+
BlockComment(tree) {
|
|
336
|
+
return { from: tree.from + 2, to: tree.to - 2 };
|
|
337
|
+
},
|
|
338
|
+
JSXElement(node) {
|
|
339
|
+
var _a;
|
|
340
|
+
const first = node.firstChild;
|
|
341
|
+
const start = (first == null ? void 0 : first.firstChild) ? first.firstChild.nextSibling : null;
|
|
342
|
+
let end = null;
|
|
343
|
+
if (!first) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
if (first.name === "JSXSelfClosingTag") {
|
|
347
|
+
end = first.lastChild;
|
|
348
|
+
}
|
|
349
|
+
if (["JSXOpenTag", "JSXFragmentTag"].includes(first.name)) {
|
|
350
|
+
end = ((_a = node.lastChild) == null ? void 0 : _a.name) === "JSXCloseTag" ? node.lastChild : null;
|
|
351
|
+
}
|
|
352
|
+
if (!start || !end) {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
return start && start.to < end.from ? { from: start.to, to: end.type.isError ? node.to : end.from } : null;
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
]
|
|
359
|
+
}),
|
|
360
|
+
languageData: {
|
|
361
|
+
closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
|
|
362
|
+
commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
|
|
363
|
+
indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
|
|
364
|
+
wordChars: "$"
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
var jsxSublanguage = {
|
|
368
|
+
test: (node) => /^JSX/.test(node.name),
|
|
369
|
+
facet: defineLanguageFacet({
|
|
370
|
+
commentTokens: { block: { open: "{/*", close: "*/}" } }
|
|
371
|
+
})
|
|
372
|
+
};
|
|
373
|
+
var typescriptLanguage = javascriptLanguage.configure(
|
|
374
|
+
{ dialect: "ts" },
|
|
375
|
+
"typescript"
|
|
376
|
+
);
|
|
377
|
+
var jsxLanguage = javascriptLanguage.configure({
|
|
378
|
+
dialect: "jsx",
|
|
379
|
+
props: [sublanguageProp.add((n) => n.isTop ? [jsxSublanguage] : void 0)]
|
|
380
|
+
});
|
|
381
|
+
var tsxLanguage = javascriptLanguage.configure(
|
|
382
|
+
{
|
|
383
|
+
dialect: "jsx ts",
|
|
384
|
+
props: [sublanguageProp.add((n) => n.isTop ? [jsxSublanguage] : void 0)]
|
|
385
|
+
},
|
|
386
|
+
"typescript"
|
|
387
|
+
);
|
|
388
|
+
var kwCompletion = (name) => ({ label: name, type: "keyword" });
|
|
389
|
+
var keywords = "break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion);
|
|
390
|
+
var typescriptKeywords = keywords.concat(
|
|
391
|
+
["declare", "implements", "private", "protected", "public"].map(kwCompletion)
|
|
392
|
+
);
|
|
393
|
+
function javascript(config = {}) {
|
|
394
|
+
const lang = config.jsx ? config.typescript ? tsxLanguage : jsxLanguage : config.typescript ? typescriptLanguage : javascriptLanguage;
|
|
395
|
+
const completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords);
|
|
396
|
+
return new LanguageSupport(lang, [
|
|
397
|
+
javascriptLanguage.data.of({
|
|
398
|
+
autocomplete: ifNotIn(dontComplete, completeFromList(completions))
|
|
399
|
+
}),
|
|
400
|
+
javascriptLanguage.data.of({
|
|
401
|
+
autocomplete: localCompletionSource
|
|
402
|
+
}),
|
|
403
|
+
config.jsx ? autoCloseTags : []
|
|
404
|
+
]);
|
|
405
|
+
}
|
|
406
|
+
function findOpenTag(node) {
|
|
407
|
+
for (; ; ) {
|
|
408
|
+
if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag") {
|
|
409
|
+
return node;
|
|
410
|
+
}
|
|
411
|
+
if (node.name == "JSXEscape" || !node.parent) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
node = node.parent;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function elementName(doc, tree, max = doc.length) {
|
|
418
|
+
for (let ch = tree == null ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
|
|
419
|
+
if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" || ch.name == "JSXMemberExpression") {
|
|
420
|
+
return doc.sliceString(ch.from, Math.min(ch.to, max));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return "";
|
|
424
|
+
}
|
|
425
|
+
var android = typeof navigator === "object" && /Android\b/.test(navigator.userAgent);
|
|
426
|
+
var autoCloseTags = EditorView.inputHandler.of(
|
|
427
|
+
(view, from, to, text, defaultInsert) => {
|
|
428
|
+
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly || from != to || text != ">" && text != "/" || !javascriptLanguage.isActiveAt(view.state, from, -1)) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
const base = defaultInsert(), { state } = base;
|
|
432
|
+
const closeTags = state.changeByRange((range) => {
|
|
433
|
+
var _a;
|
|
434
|
+
const { head } = range;
|
|
435
|
+
let around = syntaxTree2(state).resolveInner(head - 1, -1);
|
|
436
|
+
let name;
|
|
437
|
+
if (around.name == "JSXStartTag") {
|
|
438
|
+
around = around.parent;
|
|
439
|
+
}
|
|
440
|
+
if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) {
|
|
441
|
+
} else if (text == ">" && around.name == "JSXFragmentTag") {
|
|
442
|
+
return { range, changes: { from: head, insert: "</>" } };
|
|
443
|
+
} else if (text == "/" && around.name == "JSXStartCloseTag") {
|
|
444
|
+
const empty = around.parent, base2 = empty.parent;
|
|
445
|
+
if (base2 && empty.from == head - 2 && ((name = elementName(state.doc, base2.firstChild, head)) || ((_a = base2.firstChild) == null ? void 0 : _a.name) == "JSXFragmentTag")) {
|
|
446
|
+
const insert = `${name}>`;
|
|
447
|
+
return {
|
|
448
|
+
range: EditorSelection.cursor(head + insert.length, -1),
|
|
449
|
+
changes: { from: head, insert }
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
} else if (text == ">") {
|
|
453
|
+
const openTag = findOpenTag(around);
|
|
454
|
+
if (openTag && openTag.name == "JSXOpenTag" && !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) && (name = elementName(state.doc, openTag, head))) {
|
|
455
|
+
return { range, changes: { from: head, insert: `</${name}>` } };
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return { range };
|
|
459
|
+
});
|
|
460
|
+
if (closeTags.changes.empty) {
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
view.dispatch([
|
|
464
|
+
base,
|
|
465
|
+
state.update(closeTags, {
|
|
466
|
+
userEvent: "input.complete",
|
|
467
|
+
scrollIntoView: true
|
|
468
|
+
})
|
|
469
|
+
]);
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
// src/eslint.ts
|
|
475
|
+
function esLint(eslint, config) {
|
|
476
|
+
if (!config) {
|
|
477
|
+
config = {
|
|
478
|
+
parserOptions: { ecmaVersion: 2019, sourceType: "module" },
|
|
479
|
+
env: {
|
|
480
|
+
browser: true,
|
|
481
|
+
node: true,
|
|
482
|
+
es6: true,
|
|
483
|
+
es2015: true,
|
|
484
|
+
es2017: true,
|
|
485
|
+
es2020: true
|
|
486
|
+
},
|
|
487
|
+
rules: {}
|
|
488
|
+
};
|
|
489
|
+
eslint.getRules().forEach((desc, name) => {
|
|
490
|
+
var _a;
|
|
491
|
+
if ((_a = desc.meta.docs) == null ? void 0 : _a.recommended) {
|
|
492
|
+
config.rules[name] = 2;
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
return (view) => {
|
|
497
|
+
const { state } = view, found = [];
|
|
498
|
+
for (const { from, to } of javascriptLanguage.findRegions(state)) {
|
|
499
|
+
const fromLine = state.doc.lineAt(from), offset = {
|
|
500
|
+
line: fromLine.number - 1,
|
|
501
|
+
col: from - fromLine.from,
|
|
502
|
+
pos: from
|
|
503
|
+
};
|
|
504
|
+
for (const d of eslint.verify(state.sliceDoc(from, to), config)) {
|
|
505
|
+
found.push(translateDiagnostic(d, state.doc, offset));
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return found;
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function mapPos(line, col, doc, offset) {
|
|
512
|
+
return doc.line(line + offset.line).from + col + (line == 1 ? offset.col - 1 : -1);
|
|
513
|
+
}
|
|
514
|
+
function translateDiagnostic(input, doc, offset) {
|
|
515
|
+
const start = mapPos(input.line, input.column, doc, offset);
|
|
516
|
+
const result = {
|
|
517
|
+
from: start,
|
|
518
|
+
to: input.endLine != null && input.endColumn != 1 ? mapPos(input.endLine, input.endColumn, doc, offset) : start,
|
|
519
|
+
message: input.message,
|
|
520
|
+
source: input.ruleId ? `eslint:${input.ruleId}` : "eslint",
|
|
521
|
+
severity: input.severity == 1 ? "warning" : "error"
|
|
522
|
+
};
|
|
523
|
+
if (input.fix) {
|
|
524
|
+
const { range, text } = input.fix, from = range[0] + offset.pos - start, to = range[1] + offset.pos - start;
|
|
525
|
+
result.actions = [
|
|
526
|
+
{
|
|
527
|
+
name: "fix",
|
|
528
|
+
apply(view, start2) {
|
|
529
|
+
view.dispatch({
|
|
530
|
+
changes: { from: start2 + from, to: start2 + to, insert: text },
|
|
531
|
+
scrollIntoView: true
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
];
|
|
536
|
+
}
|
|
537
|
+
return result;
|
|
538
|
+
}
|
|
539
|
+
export {
|
|
540
|
+
autoCloseTags,
|
|
541
|
+
completionPath,
|
|
542
|
+
esLint,
|
|
543
|
+
javascript,
|
|
544
|
+
javascriptLanguage,
|
|
545
|
+
jsxLanguage,
|
|
546
|
+
localCompletionSource,
|
|
547
|
+
scopeCompletionSource,
|
|
548
|
+
snippets,
|
|
549
|
+
tsxLanguage,
|
|
550
|
+
typescriptLanguage,
|
|
551
|
+
typescriptSnippets
|
|
552
|
+
};
|
|
553
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/javascript.ts","../../src/snippets.ts","../../src/complete.ts","../../src/eslint.ts"],"sourcesContent":["/* eslint-disable complexity */\nimport { parser } from '@lezer/javascript';\nimport { type SyntaxNode } from '@lezer/common';\nimport { EditorView } from '@codemirror/view';\nimport { EditorSelection, type Text } from '@codemirror/state';\nimport {\n LRLanguage,\n LanguageSupport,\n type Sublanguage,\n sublanguageProp,\n defineLanguageFacet,\n delimitedIndent,\n flatIndent,\n continuedIndent,\n indentNodeProp,\n foldNodeProp,\n foldInside,\n syntaxTree,\n} from '@codemirror/language';\nimport { completeFromList, ifNotIn } from '@codemirror/autocomplete';\n\nimport { snippets, typescriptSnippets } from './snippets';\nimport { localCompletionSource, dontComplete } from './complete';\n\n/// A language provider based on the [Lezer JavaScript\n/// parser](https://github.com/lezer-parser/javascript), extended with\n/// highlighting and indentation information.\nexport const javascriptLanguage = LRLanguage.define({\n name: 'javascript',\n parser: parser.configure({\n props: [\n indentNodeProp.add({\n IfStatement: continuedIndent({ except: /^\\s*({|else\\b)/ }),\n TryStatement: continuedIndent({ except: /^\\s*({|catch\\b|finally\\b)/ }),\n LabeledStatement: flatIndent,\n SwitchBody: context => {\n const after = context.textAfter,\n closed = /^\\s*\\}/.test(after),\n isCase = /^\\s*(case|default)\\b/.test(after);\n return (\n context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit\n );\n },\n Block: delimitedIndent({ closing: '}' }),\n ArrowFunction: cx => cx.baseIndent + cx.unit,\n 'TemplateString BlockComment': () => null,\n 'Statement Property': continuedIndent({ except: /^\\s*{/ }),\n JSXElement(context) {\n const closed = /^\\s*<\\//.test(context.textAfter);\n return (\n context.lineIndent(context.node.from) + (closed ? 0 : context.unit)\n );\n },\n JSXEscape(context) {\n const closed = /\\s*\\}/.test(context.textAfter);\n return (\n context.lineIndent(context.node.from) + (closed ? 0 : context.unit)\n );\n },\n 'JSXOpenTag JSXSelfClosingTag'(context) {\n return context.column(context.node.from) + context.unit;\n },\n }),\n foldNodeProp.add({\n 'Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType':\n foldInside,\n BlockComment(tree) {\n return { from: tree.from + 2, to: tree.to - 2 };\n },\n JSXElement(node) {\n const first = node.firstChild;\n const start = first?.firstChild ? first.firstChild.nextSibling : null;\n\n let end = null;\n\n if (!first) {\n return null;\n }\n\n if (first.name === 'JSXSelfClosingTag') {\n end = first.lastChild;\n }\n\n if (['JSXOpenTag', 'JSXFragmentTag'].includes(first.name)) {\n end =\n node.lastChild?.name === 'JSXCloseTag' ? node.lastChild : null;\n }\n\n if (!start || !end) {\n return null;\n }\n\n return start && start.to < end.from\n ? { from: start.to, to: end.type.isError ? node.to : end.from }\n : null;\n },\n }),\n ],\n }),\n languageData: {\n closeBrackets: { brackets: ['(', '[', '{', \"'\", '\"', '`'] },\n commentTokens: { line: '//', block: { open: '/*', close: '*/' } },\n indentOnInput: /^\\s*(?:case |default:|\\{|\\}|<\\/)$/,\n wordChars: '$',\n },\n});\n\nconst jsxSublanguage: Sublanguage = {\n test: node => /^JSX/.test(node.name),\n facet: defineLanguageFacet({\n commentTokens: { block: { open: '{/*', close: '*/}' } },\n }),\n};\n\n/// A language provider for TypeScript.\nexport const typescriptLanguage = javascriptLanguage.configure(\n { dialect: 'ts' },\n 'typescript',\n);\n\n/// Language provider for JSX.\nexport const jsxLanguage = javascriptLanguage.configure({\n dialect: 'jsx',\n props: [sublanguageProp.add(n => (n.isTop ? [jsxSublanguage] : undefined))],\n});\n\n/// Language provider for JSX + TypeScript.\nexport const tsxLanguage = javascriptLanguage.configure(\n {\n dialect: 'jsx ts',\n props: [sublanguageProp.add(n => (n.isTop ? [jsxSublanguage] : undefined))],\n },\n 'typescript',\n);\n\nconst kwCompletion = (name: string) => ({ label: name, type: 'keyword' });\n\nconst keywords =\n 'break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield'\n .split(' ')\n .map(kwCompletion);\nconst typescriptKeywords = keywords.concat(\n ['declare', 'implements', 'private', 'protected', 'public'].map(kwCompletion),\n);\n\n/// JavaScript support. Includes [snippet](#lang-javascript.snippets)\n/// and local variable completion.\nexport function javascript(\n config: { jsx?: boolean; typescript?: boolean } = {},\n) {\n const lang = config.jsx\n ? config.typescript\n ? tsxLanguage\n : jsxLanguage\n : config.typescript\n ? typescriptLanguage\n : javascriptLanguage;\n const completions = config.typescript\n ? typescriptSnippets.concat(typescriptKeywords)\n : snippets.concat(keywords);\n return new LanguageSupport(lang, [\n javascriptLanguage.data.of({\n autocomplete: ifNotIn(dontComplete, completeFromList(completions)),\n }),\n javascriptLanguage.data.of({\n autocomplete: localCompletionSource,\n }),\n config.jsx ? autoCloseTags : [],\n ]);\n}\n\nfunction findOpenTag(node: SyntaxNode) {\n for (;;) {\n if (\n node.name == 'JSXOpenTag' ||\n node.name == 'JSXSelfClosingTag' ||\n node.name == 'JSXFragmentTag'\n ) {\n return node;\n }\n if (node.name == 'JSXEscape' || !node.parent) {\n return null;\n }\n node = node.parent;\n }\n}\n\nfunction elementName(\n doc: Text,\n tree: SyntaxNode | null | undefined,\n max = doc.length,\n) {\n for (let ch = tree?.firstChild; ch; ch = ch.nextSibling) {\n if (\n ch.name == 'JSXIdentifier' ||\n ch.name == 'JSXBuiltin' ||\n ch.name == 'JSXNamespacedName' ||\n ch.name == 'JSXMemberExpression'\n ) {\n return doc.sliceString(ch.from, Math.min(ch.to, max));\n }\n }\n return '';\n}\n\nconst android =\n typeof navigator === 'object' && /Android\\b/.test(navigator.userAgent);\n\n/// Extension that will automatically insert JSX close tags when a `>` or\n/// `/` is typed.\nexport const autoCloseTags = EditorView.inputHandler.of(\n (view, from, to, text, defaultInsert) => {\n if (\n (android ? view.composing : view.compositionStarted) ||\n view.state.readOnly ||\n from != to ||\n (text != '>' && text != '/') ||\n !javascriptLanguage.isActiveAt(view.state, from, -1)\n ) {\n return false;\n }\n const base = defaultInsert(),\n { state } = base;\n const closeTags = state.changeByRange(range => {\n const { head } = range;\n let around = syntaxTree(state).resolveInner(head - 1, -1);\n let name;\n if (around.name == 'JSXStartTag') {\n around = around.parent!;\n }\n if (\n state.doc.sliceString(head - 1, head) != text ||\n (around.name == 'JSXAttributeValue' && around.to > head)\n ) {\n // Ignore input inside attribute or cases where the text wasn't actually inserted\n } else if (text == '>' && around.name == 'JSXFragmentTag') {\n return { range, changes: { from: head, insert: '</>' } };\n } else if (text == '/' && around.name == 'JSXStartCloseTag') {\n const empty = around.parent!,\n base = empty.parent;\n if (\n base &&\n empty.from == head - 2 &&\n ((name = elementName(state.doc, base.firstChild, head)) ||\n base.firstChild?.name == 'JSXFragmentTag')\n ) {\n const insert = `${name}>`;\n return {\n range: EditorSelection.cursor(head + insert.length, -1),\n changes: { from: head, insert },\n };\n }\n } else if (text == '>') {\n const openTag = findOpenTag(around);\n if (\n openTag &&\n openTag.name == 'JSXOpenTag' &&\n !/^\\/?>|^<\\//.test(state.doc.sliceString(head, head + 2)) &&\n (name = elementName(state.doc, openTag, head))\n ) {\n return { range, changes: { from: head, insert: `</${name}>` } };\n }\n }\n return { range };\n });\n if (closeTags.changes.empty) {\n return false;\n }\n view.dispatch([\n base,\n state.update(closeTags, {\n userEvent: 'input.complete',\n scrollIntoView: true,\n }),\n ]);\n return true;\n },\n);\n","import {\n type Completion,\n snippetCompletion as snip,\n} from '@codemirror/autocomplete';\n\n/// A collection of JavaScript-related\n/// [snippets](#autocomplete.snippet).\nexport const snippets: readonly Completion[] = [\n snip('function ${name}(${params}) {\\n\\t${}\\n}', {\n label: 'function',\n detail: 'definition',\n type: 'keyword',\n }),\n snip('for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\\n\\t${}\\n}', {\n label: 'for',\n detail: 'loop',\n type: 'keyword',\n }),\n snip('for (let ${name} of ${collection}) {\\n\\t${}\\n}', {\n label: 'for',\n detail: 'of loop',\n type: 'keyword',\n }),\n snip('do {\\n\\t${}\\n} while (${})', {\n label: 'do',\n detail: 'loop',\n type: 'keyword',\n }),\n snip('while (${}) {\\n\\t${}\\n}', {\n label: 'while',\n detail: 'loop',\n type: 'keyword',\n }),\n snip('try {\\n\\t${}\\n} catch (${error}) {\\n\\t${}\\n}', {\n label: 'try',\n detail: '/ catch block',\n type: 'keyword',\n }),\n snip('if (${}) {\\n\\t${}\\n}', {\n label: 'if',\n detail: 'block',\n type: 'keyword',\n }),\n snip('if (${}) {\\n\\t${}\\n} else {\\n\\t${}\\n}', {\n label: 'if',\n detail: '/ else block',\n type: 'keyword',\n }),\n snip('class ${name} {\\n\\tconstructor(${params}) {\\n\\t\\t${}\\n\\t}\\n}', {\n label: 'class',\n detail: 'definition',\n type: 'keyword',\n }),\n snip('import {${names}} from \"${module}\"\\n${}', {\n label: 'import',\n detail: 'named',\n type: 'keyword',\n }),\n snip('import ${name} from \"${module}\"\\n${}', {\n label: 'import',\n detail: 'default',\n type: 'keyword',\n }),\n];\n\n/// A collection of snippet completions for TypeScript. Includes the\n/// JavaScript [snippets](#lang-javascript.snippets).\nexport const typescriptSnippets = snippets.concat([\n snip('interface ${name} {\\n\\t${}\\n}', {\n label: 'interface',\n detail: 'definition',\n type: 'keyword',\n }),\n snip('type ${name} = ${type}', {\n label: 'type',\n detail: 'definition',\n type: 'keyword',\n }),\n snip('enum ${name} {\\n\\t${}\\n}', {\n label: 'enum',\n detail: 'definition',\n type: 'keyword',\n }),\n]);\n","import {\n NodeWeakMap,\n type SyntaxNodeRef,\n type SyntaxNode,\n IterMode,\n} from '@lezer/common';\nimport { type Text } from '@codemirror/state';\nimport { syntaxTree } from '@codemirror/language';\nimport {\n type Completion,\n type CompletionContext,\n type CompletionResult,\n type CompletionSource,\n} from '@codemirror/autocomplete';\n\nconst cache = new NodeWeakMap<readonly Completion[]>();\n\nconst ScopeNodes = new Set([\n 'Script',\n 'Block',\n 'FunctionExpression',\n 'FunctionDeclaration',\n 'ArrowFunction',\n 'MethodDeclaration',\n 'ForStatement',\n]);\n\nfunction defID(type: string) {\n return (\n node: SyntaxNodeRef,\n def: (node: SyntaxNodeRef, type: string) => void,\n ) => {\n const id = node.node.getChild('VariableDefinition');\n if (id) {\n def(id, type);\n }\n return true;\n };\n}\n\nconst functionContext = ['FunctionDeclaration'];\n\nconst gatherCompletions: {\n [node: string]: (\n node: SyntaxNodeRef,\n def: (node: SyntaxNodeRef, type: string) => void,\n ) => void | boolean;\n} = {\n FunctionDeclaration: defID('function'),\n ClassDeclaration: defID('class'),\n ClassExpression: () => true,\n EnumDeclaration: defID('constant'),\n TypeAliasDeclaration: defID('type'),\n NamespaceDeclaration: defID('namespace'),\n VariableDefinition(node, def) {\n if (!node.matchContext(functionContext)) {\n def(node, 'variable');\n }\n },\n TypeDefinition(node, def) {\n def(node, 'type');\n },\n __proto__: null as any,\n};\n\nfunction getScope(doc: Text, node: SyntaxNode) {\n const cached = cache.get(node);\n if (cached) {\n return cached;\n }\n\n const completions: Completion[] = [];\n let top = true;\n function def(node: SyntaxNodeRef, type: string) {\n const name = doc.sliceString(node.from, node.to);\n completions.push({ label: name, type });\n }\n node.cursor(IterMode.IncludeAnonymous).iterate(node => {\n if (top) {\n top = false;\n } else if (node.name) {\n const gather = gatherCompletions[node.name];\n if ((gather && gather(node, def)) || ScopeNodes.has(node.name)) {\n return false;\n }\n } else if (node.to - node.from > 8192) {\n // Allow caching for bigger internal nodes\n for (const c of getScope(doc, node.node)) {\n completions.push(c);\n }\n return false;\n }\n });\n cache.set(node, completions);\n return completions;\n}\n\nconst Identifier = /^[\\w$\\xa1-\\uffff][\\w$\\d\\xa1-\\uffff]*$/;\n\nexport const dontComplete = [\n 'TemplateString',\n 'String',\n 'RegExp',\n 'LineComment',\n 'BlockComment',\n 'VariableDefinition',\n 'TypeDefinition',\n 'Label',\n 'PropertyDefinition',\n 'PropertyName',\n 'PrivatePropertyDefinition',\n 'PrivatePropertyName',\n 'JSXText',\n 'JSXAttributeValue',\n 'JSXOpenTag',\n 'JSXCloseTag',\n 'JSXSelfClosingTag',\n '.',\n '?.',\n];\n\n/// Completion source that looks up locally defined names in\n/// JavaScript code.\nexport function localCompletionSource(\n context: CompletionContext,\n): CompletionResult | null {\n const inner = syntaxTree(context.state).resolveInner(context.pos, -1);\n if (dontComplete.indexOf(inner.name) > -1) {\n return null;\n }\n const isWord =\n inner.name == 'VariableName' ||\n (inner.to - inner.from < 20 &&\n Identifier.test(context.state.sliceDoc(inner.from, inner.to)));\n if (!isWord && !context.explicit) {\n return null;\n }\n let options: Completion[] = [];\n for (let pos: SyntaxNode | null = inner; pos; pos = pos.parent) {\n if (ScopeNodes.has(pos.name)) {\n options = options.concat(getScope(context.state.doc, pos));\n }\n }\n return {\n options,\n from: isWord ? inner.from : context.pos,\n validFor: Identifier,\n };\n}\n\nfunction pathFor(\n read: (node: SyntaxNode) => string,\n member: SyntaxNode,\n name: string,\n) {\n const path: string[] = [];\n for (;;) {\n const obj = member.firstChild;\n let prop;\n if (obj?.name == 'VariableName') {\n path.push(read(obj));\n return { path: path.reverse(), name };\n } else if (\n obj?.name == 'MemberExpression' &&\n (prop = obj.lastChild)?.name == 'PropertyName'\n ) {\n path.push(read(prop!));\n member = obj;\n } else {\n return null;\n }\n }\n}\n\n/// Helper function for defining JavaScript completion sources. It\n/// returns the completable name and object path for a completion\n/// context, or null if no name/property completion should happen at\n/// that position. For example, when completing after `a.b.c` it will\n/// return `{path: [\"a\", \"b\"], name: \"c\"}`. When completing after `x`\n/// it will return `{path: [], name: \"x\"}`. When not in a property or\n/// name, it will return null if `context.explicit` is false, and\n/// `{path: [], name: \"\"}` otherwise.\nexport function completionPath(\n context: CompletionContext,\n): { path: readonly string[]; name: string } | null {\n const read = (node: SyntaxNode) =>\n context.state.doc.sliceString(node.from, node.to);\n const inner = syntaxTree(context.state).resolveInner(context.pos, -1);\n if (inner.name == 'PropertyName') {\n return pathFor(read, inner.parent!, read(inner));\n } else if (\n (inner.name == '.' || inner.name == '?.') &&\n inner.parent!.name == 'MemberExpression'\n ) {\n return pathFor(read, inner.parent!, '');\n } else if (dontComplete.indexOf(inner.name) > -1) {\n return null;\n } else if (\n inner.name == 'VariableName' ||\n (inner.to - inner.from < 20 && Identifier.test(read(inner)))\n ) {\n return { path: [], name: read(inner) };\n } else if (inner.name == 'MemberExpression') {\n return pathFor(read, inner, '');\n } else {\n return context.explicit ? { path: [], name: '' } : null;\n }\n}\n\nfunction enumeratePropertyCompletions(\n obj: any,\n top: boolean,\n): readonly Completion[] {\n const options: Completion[] = [],\n seen: Set<string> = new Set();\n for (let depth = 0; ; depth++) {\n for (const name of (Object.getOwnPropertyNames || Object.keys)(obj)) {\n if (\n !/^[a-zA-Z_$\\xaa-\\uffdc][\\w$\\xaa-\\uffdc]*$/.test(name) ||\n seen.has(name)\n ) {\n continue;\n }\n seen.add(name);\n let value;\n try {\n value = obj[name];\n } catch (_) {\n continue;\n }\n options.push({\n label: name,\n type:\n typeof value === 'function'\n ? /^[A-Z]/.test(name)\n ? 'class'\n : top\n ? 'function'\n : 'method'\n : top\n ? 'variable'\n : 'property',\n boost: -depth,\n });\n }\n const next = Object.getPrototypeOf(obj);\n if (!next) {\n return options;\n }\n obj = next;\n }\n}\n\n/// Defines a [completion source](#autocomplete.CompletionSource) that\n/// completes from the given scope object (for example `globalThis`).\n/// Will enter properties of the object when completing properties on\n/// a directly-named path.\nexport function scopeCompletionSource(scope: any): CompletionSource {\n const cache: Map<any, readonly Completion[]> = new Map();\n return (context: CompletionContext) => {\n const path = completionPath(context);\n if (!path) {\n return null;\n }\n let target = scope;\n for (const step of path.path) {\n target = target[step];\n if (!target) {\n return null;\n }\n }\n let options = cache.get(target);\n if (!options) {\n cache.set(\n target,\n (options = enumeratePropertyCompletions(target, !path.path.length)),\n );\n }\n return {\n from: context.pos - path.name.length,\n options,\n validFor: Identifier,\n };\n };\n}\n","import { type EditorView } from '@codemirror/view';\nimport { type Text } from '@codemirror/state';\nimport { type Diagnostic } from '@codemirror/lint';\n\nimport { javascriptLanguage } from './javascript';\n\n/// Connects an [ESLint](https://eslint.org/) linter to CodeMirror's\n/// [lint](#lint) integration. `eslint` should be an instance of the\n/// [`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)\n/// class, and `config` an optional ESLint configuration. The return\n/// value of this function can be passed to [`linter`](#lint.linter)\n/// to create a JavaScript linting extension.\n///\n/// Note that ESLint targets node, and is tricky to run in the\n/// browser. The\n/// [eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify)\n/// package may help with that (see\n/// [example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)).\nexport function esLint(eslint: any, config?: any) {\n if (!config) {\n config = {\n parserOptions: { ecmaVersion: 2019, sourceType: 'module' },\n env: {\n browser: true,\n node: true,\n es6: true,\n es2015: true,\n es2017: true,\n es2020: true,\n },\n rules: {},\n };\n eslint.getRules().forEach((desc: any, name: string) => {\n if (desc.meta.docs?.recommended) {\n config.rules[name] = 2;\n }\n });\n }\n\n return (view: EditorView) => {\n const { state } = view,\n found: Diagnostic[] = [];\n for (const { from, to } of javascriptLanguage.findRegions(state)) {\n const fromLine = state.doc.lineAt(from),\n offset = {\n line: fromLine.number - 1,\n col: from - fromLine.from,\n pos: from,\n };\n for (const d of eslint.verify(state.sliceDoc(from, to), config)) {\n found.push(translateDiagnostic(d, state.doc, offset));\n }\n }\n return found;\n };\n}\n\nfunction mapPos(\n line: number,\n col: number,\n doc: Text,\n offset: { line: number; col: number; pos: number },\n) {\n return (\n doc.line(line + offset.line).from + col + (line == 1 ? offset.col - 1 : -1)\n );\n}\n\nfunction translateDiagnostic(\n input: any,\n doc: Text,\n offset: { line: number; col: number; pos: number },\n): Diagnostic {\n const start = mapPos(input.line, input.column, doc, offset);\n const result: Diagnostic = {\n from: start,\n to:\n input.endLine != null && input.endColumn != 1\n ? mapPos(input.endLine, input.endColumn, doc, offset)\n : start,\n message: input.message,\n source: input.ruleId ? `eslint:${input.ruleId}` : 'eslint',\n severity: input.severity == 1 ? 'warning' : 'error',\n };\n if (input.fix) {\n const { range, text } = input.fix,\n from = range[0] + offset.pos - start,\n to = range[1] + offset.pos - start;\n result.actions = [\n {\n name: 'fix',\n apply(view: EditorView, start: number) {\n view.dispatch({\n changes: { from: start + from, to: start + to, insert: text },\n scrollIntoView: true,\n });\n },\n },\n ];\n }\n return result;\n}\n"],"mappings":";AACA,SAAS,cAAc;AAEvB,SAAS,kBAAkB;AAC3B,SAAS,uBAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAAA;AAAA,OACK;AACP,SAAS,kBAAkB,eAAe;;;ACnB1C;AAAA,EAEE,qBAAqB;AAAA,OAChB;AAIA,IAAM,WAAkC;AAAA,EAC7C,KAAK,0CAA2C;AAAA,IAC9C,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACR,CAAC;AAAA,EACD,KAAK,sEAAuE;AAAA,IAC1E,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACR,CAAC;AAAA,EACD,KAAK,iDAAkD;AAAA,IACrD,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACR,CAAC;AAAA,EACD,KAAK,6BAA8B;AAAA,IACjC,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACR,CAAC;AAAA,EACD,KAAK,0BAA2B;AAAA,IAC9B,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACR,CAAC;AAAA,EACD,KAAK,8CAAgD;AAAA,IACnD,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACR,CAAC;AAAA,EACD,KAAK,uBAAwB;AAAA,IAC3B,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACR,CAAC;AAAA,EACD,KAAK,uCAAyC;AAAA,IAC5C,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACR,C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