sun-form-v3 1.0.77 → 1.0.78

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,886 +0,0 @@
1
- import { t as O, m as I } from "./index-BMOft-Zj.js";
2
- /*!-----------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Version: 0.49.0(383fdf3fc0e1e1a024068b8d0fd4f3dcbae74d04)
5
- * Released under the MIT license
6
- * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
7
- *-----------------------------------------------------------------------------*/
8
- var N = Object.defineProperty, M = Object.getOwnPropertyDescriptor, R = Object.getOwnPropertyNames, K = Object.prototype.hasOwnProperty, E = (e, t, r, o) => {
9
- if (t && typeof t == "object" || typeof t == "function")
10
- for (let i of R(t))
11
- !K.call(e, i) && i !== r && N(e, i, { get: () => t[i], enumerable: !(o = M(t, i)) || o.enumerable });
12
- return e;
13
- }, H = (e, t, r) => (E(e, t, "default"), r), a = {};
14
- H(a, I);
15
- var V = class {
16
- constructor(e, t) {
17
- this._modeId = e, this._defaults = t, this._worker = null, this._client = null, this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker()), this._updateExtraLibsToken = 0, this._extraLibsChangeListener = this._defaults.onDidExtraLibsChange(
18
- () => this._updateExtraLibs()
19
- );
20
- }
21
- dispose() {
22
- this._configChangeListener.dispose(), this._extraLibsChangeListener.dispose(), this._stopWorker();
23
- }
24
- _stopWorker() {
25
- this._worker && (this._worker.dispose(), this._worker = null), this._client = null;
26
- }
27
- async _updateExtraLibs() {
28
- if (!this._worker)
29
- return;
30
- const e = ++this._updateExtraLibsToken, t = await this._worker.getProxy();
31
- this._updateExtraLibsToken === e && t.updateExtraLibs(this._defaults.getExtraLibs());
32
- }
33
- _getClient() {
34
- return this._client || (this._client = (async () => (this._worker = a.editor.createWebWorker({
35
- // module that exports the create() method and returns a `TypeScriptWorker` instance
36
- moduleId: "vs/language/typescript/tsWorker",
37
- label: this._modeId,
38
- keepIdleModels: !0,
39
- // passed in to the create() method
40
- createData: {
41
- compilerOptions: this._defaults.getCompilerOptions(),
42
- extraLibs: this._defaults.getExtraLibs(),
43
- customWorkerPath: this._defaults.workerOptions.customWorkerPath,
44
- inlayHintsOptions: this._defaults.inlayHintsOptions
45
- }
46
- }), this._defaults.getEagerModelSync() ? await this._worker.withSyncedResources(
47
- a.editor.getModels().filter((e) => e.getLanguageId() === this._modeId).map((e) => e.uri)
48
- ) : await this._worker.getProxy()))()), this._client;
49
- }
50
- async getLanguageServiceWorker(...e) {
51
- const t = await this._getClient();
52
- return this._worker && await this._worker.withSyncedResources(e), t;
53
- }
54
- }, n = {};
55
- n["lib.d.ts"] = !0;
56
- n["lib.decorators.d.ts"] = !0;
57
- n["lib.decorators.legacy.d.ts"] = !0;
58
- n["lib.dom.d.ts"] = !0;
59
- n["lib.dom.iterable.d.ts"] = !0;
60
- n["lib.es2015.collection.d.ts"] = !0;
61
- n["lib.es2015.core.d.ts"] = !0;
62
- n["lib.es2015.d.ts"] = !0;
63
- n["lib.es2015.generator.d.ts"] = !0;
64
- n["lib.es2015.iterable.d.ts"] = !0;
65
- n["lib.es2015.promise.d.ts"] = !0;
66
- n["lib.es2015.proxy.d.ts"] = !0;
67
- n["lib.es2015.reflect.d.ts"] = !0;
68
- n["lib.es2015.symbol.d.ts"] = !0;
69
- n["lib.es2015.symbol.wellknown.d.ts"] = !0;
70
- n["lib.es2016.array.include.d.ts"] = !0;
71
- n["lib.es2016.d.ts"] = !0;
72
- n["lib.es2016.full.d.ts"] = !0;
73
- n["lib.es2017.d.ts"] = !0;
74
- n["lib.es2017.full.d.ts"] = !0;
75
- n["lib.es2017.intl.d.ts"] = !0;
76
- n["lib.es2017.object.d.ts"] = !0;
77
- n["lib.es2017.sharedmemory.d.ts"] = !0;
78
- n["lib.es2017.string.d.ts"] = !0;
79
- n["lib.es2017.typedarrays.d.ts"] = !0;
80
- n["lib.es2018.asyncgenerator.d.ts"] = !0;
81
- n["lib.es2018.asynciterable.d.ts"] = !0;
82
- n["lib.es2018.d.ts"] = !0;
83
- n["lib.es2018.full.d.ts"] = !0;
84
- n["lib.es2018.intl.d.ts"] = !0;
85
- n["lib.es2018.promise.d.ts"] = !0;
86
- n["lib.es2018.regexp.d.ts"] = !0;
87
- n["lib.es2019.array.d.ts"] = !0;
88
- n["lib.es2019.d.ts"] = !0;
89
- n["lib.es2019.full.d.ts"] = !0;
90
- n["lib.es2019.intl.d.ts"] = !0;
91
- n["lib.es2019.object.d.ts"] = !0;
92
- n["lib.es2019.string.d.ts"] = !0;
93
- n["lib.es2019.symbol.d.ts"] = !0;
94
- n["lib.es2020.bigint.d.ts"] = !0;
95
- n["lib.es2020.d.ts"] = !0;
96
- n["lib.es2020.date.d.ts"] = !0;
97
- n["lib.es2020.full.d.ts"] = !0;
98
- n["lib.es2020.intl.d.ts"] = !0;
99
- n["lib.es2020.number.d.ts"] = !0;
100
- n["lib.es2020.promise.d.ts"] = !0;
101
- n["lib.es2020.sharedmemory.d.ts"] = !0;
102
- n["lib.es2020.string.d.ts"] = !0;
103
- n["lib.es2020.symbol.wellknown.d.ts"] = !0;
104
- n["lib.es2021.d.ts"] = !0;
105
- n["lib.es2021.full.d.ts"] = !0;
106
- n["lib.es2021.intl.d.ts"] = !0;
107
- n["lib.es2021.promise.d.ts"] = !0;
108
- n["lib.es2021.string.d.ts"] = !0;
109
- n["lib.es2021.weakref.d.ts"] = !0;
110
- n["lib.es2022.array.d.ts"] = !0;
111
- n["lib.es2022.d.ts"] = !0;
112
- n["lib.es2022.error.d.ts"] = !0;
113
- n["lib.es2022.full.d.ts"] = !0;
114
- n["lib.es2022.intl.d.ts"] = !0;
115
- n["lib.es2022.object.d.ts"] = !0;
116
- n["lib.es2022.regexp.d.ts"] = !0;
117
- n["lib.es2022.sharedmemory.d.ts"] = !0;
118
- n["lib.es2022.string.d.ts"] = !0;
119
- n["lib.es2023.array.d.ts"] = !0;
120
- n["lib.es2023.d.ts"] = !0;
121
- n["lib.es2023.full.d.ts"] = !0;
122
- n["lib.es5.d.ts"] = !0;
123
- n["lib.es6.d.ts"] = !0;
124
- n["lib.esnext.d.ts"] = !0;
125
- n["lib.esnext.full.d.ts"] = !0;
126
- n["lib.esnext.intl.d.ts"] = !0;
127
- n["lib.scripthost.d.ts"] = !0;
128
- n["lib.webworker.d.ts"] = !0;
129
- n["lib.webworker.importscripts.d.ts"] = !0;
130
- n["lib.webworker.iterable.d.ts"] = !0;
131
- function D(e, t, r = 0) {
132
- if (typeof e == "string")
133
- return e;
134
- if (e === void 0)
135
- return "";
136
- let o = "";
137
- if (r) {
138
- o += t;
139
- for (let i = 0; i < r; i++)
140
- o += " ";
141
- }
142
- if (o += e.messageText, r++, e.next)
143
- for (const i of e.next)
144
- o += D(i, t, r);
145
- return o;
146
- }
147
- function w(e) {
148
- return e ? e.map((t) => t.text).join("") : "";
149
- }
150
- var _ = class {
151
- constructor(e) {
152
- this._worker = e;
153
- }
154
- // protected _positionToOffset(model: editor.ITextModel, position: monaco.IPosition): number {
155
- // return model.getOffsetAt(position);
156
- // }
157
- // protected _offsetToPosition(model: editor.ITextModel, offset: number): monaco.IPosition {
158
- // return model.getPositionAt(offset);
159
- // }
160
- _textSpanToRange(e, t) {
161
- let r = e.getPositionAt(t.start), o = e.getPositionAt(t.start + t.length), { lineNumber: i, column: l } = r, { lineNumber: u, column: s } = o;
162
- return { startLineNumber: i, startColumn: l, endLineNumber: u, endColumn: s };
163
- }
164
- }, W = class {
165
- constructor(e) {
166
- this._worker = e, this._libFiles = {}, this._hasFetchedLibFiles = !1, this._fetchLibFilesPromise = null;
167
- }
168
- isLibFile(e) {
169
- return e && e.path.indexOf("/lib.") === 0 ? !!n[e.path.slice(1)] : !1;
170
- }
171
- getOrCreateModel(e) {
172
- const t = a.Uri.parse(e), r = a.editor.getModel(t);
173
- if (r)
174
- return r;
175
- if (this.isLibFile(t) && this._hasFetchedLibFiles)
176
- return a.editor.createModel(this._libFiles[t.path.slice(1)], "typescript", t);
177
- const o = O.getExtraLibs()[e];
178
- return o ? a.editor.createModel(o.content, "typescript", t) : null;
179
- }
180
- _containsLibFile(e) {
181
- for (let t of e)
182
- if (this.isLibFile(t))
183
- return !0;
184
- return !1;
185
- }
186
- async fetchLibFilesIfNecessary(e) {
187
- this._containsLibFile(e) && await this._fetchLibFiles();
188
- }
189
- _fetchLibFiles() {
190
- return this._fetchLibFilesPromise || (this._fetchLibFilesPromise = this._worker().then((e) => e.getLibFiles()).then((e) => {
191
- this._hasFetchedLibFiles = !0, this._libFiles = e;
192
- })), this._fetchLibFilesPromise;
193
- }
194
- }, j = class extends _ {
195
- constructor(e, t, r, o) {
196
- super(o), this._libFiles = e, this._defaults = t, this._selector = r, this._disposables = [], this._listener = /* @__PURE__ */ Object.create(null);
197
- const i = (s) => {
198
- if (s.getLanguageId() !== r)
199
- return;
200
- const c = () => {
201
- const { onlyVisible: h } = this._defaults.getDiagnosticsOptions();
202
- h ? s.isAttachedToEditor() && this._doValidate(s) : this._doValidate(s);
203
- };
204
- let g;
205
- const d = s.onDidChangeContent(() => {
206
- clearTimeout(g), g = window.setTimeout(c, 500);
207
- }), b = s.onDidChangeAttached(() => {
208
- const { onlyVisible: h } = this._defaults.getDiagnosticsOptions();
209
- h && (s.isAttachedToEditor() ? c() : a.editor.setModelMarkers(s, this._selector, []));
210
- });
211
- this._listener[s.uri.toString()] = {
212
- dispose() {
213
- d.dispose(), b.dispose(), clearTimeout(g);
214
- }
215
- }, c();
216
- }, l = (s) => {
217
- a.editor.setModelMarkers(s, this._selector, []);
218
- const c = s.uri.toString();
219
- this._listener[c] && (this._listener[c].dispose(), delete this._listener[c]);
220
- };
221
- this._disposables.push(
222
- a.editor.onDidCreateModel((s) => i(s))
223
- ), this._disposables.push(a.editor.onWillDisposeModel(l)), this._disposables.push(
224
- a.editor.onDidChangeModelLanguage((s) => {
225
- l(s.model), i(s.model);
226
- })
227
- ), this._disposables.push({
228
- dispose() {
229
- for (const s of a.editor.getModels())
230
- l(s);
231
- }
232
- });
233
- const u = () => {
234
- for (const s of a.editor.getModels())
235
- l(s), i(s);
236
- };
237
- this._disposables.push(this._defaults.onDidChange(u)), this._disposables.push(this._defaults.onDidExtraLibsChange(u)), a.editor.getModels().forEach((s) => i(s));
238
- }
239
- dispose() {
240
- this._disposables.forEach((e) => e && e.dispose()), this._disposables = [];
241
- }
242
- async _doValidate(e) {
243
- const t = await this._worker(e.uri);
244
- if (e.isDisposed())
245
- return;
246
- const r = [], { noSyntaxValidation: o, noSemanticValidation: i, noSuggestionDiagnostics: l } = this._defaults.getDiagnosticsOptions();
247
- o || r.push(t.getSyntacticDiagnostics(e.uri.toString())), i || r.push(t.getSemanticDiagnostics(e.uri.toString())), l || r.push(t.getSuggestionDiagnostics(e.uri.toString()));
248
- const u = await Promise.all(r);
249
- if (!u || e.isDisposed())
250
- return;
251
- const s = u.reduce((g, d) => d.concat(g), []).filter(
252
- (g) => (this._defaults.getDiagnosticsOptions().diagnosticCodesToIgnore || []).indexOf(g.code) === -1
253
- ), c = s.map((g) => g.relatedInformation || []).reduce((g, d) => d.concat(g), []).map(
254
- (g) => g.file ? a.Uri.parse(g.file.fileName) : null
255
- );
256
- await this._libFiles.fetchLibFilesIfNecessary(c), !e.isDisposed() && a.editor.setModelMarkers(
257
- e,
258
- this._selector,
259
- s.map((g) => this._convertDiagnostics(e, g))
260
- );
261
- }
262
- _convertDiagnostics(e, t) {
263
- const r = t.start || 0, o = t.length || 1, { lineNumber: i, column: l } = e.getPositionAt(r), { lineNumber: u, column: s } = e.getPositionAt(
264
- r + o
265
- ), c = [];
266
- return t.reportsUnnecessary && c.push(a.MarkerTag.Unnecessary), t.reportsDeprecated && c.push(a.MarkerTag.Deprecated), {
267
- severity: this._tsDiagnosticCategoryToMarkerSeverity(t.category),
268
- startLineNumber: i,
269
- startColumn: l,
270
- endLineNumber: u,
271
- endColumn: s,
272
- message: D(t.messageText, `
273
- `),
274
- code: t.code.toString(),
275
- tags: c,
276
- relatedInformation: this._convertRelatedInformation(e, t.relatedInformation)
277
- };
278
- }
279
- _convertRelatedInformation(e, t) {
280
- if (!t)
281
- return [];
282
- const r = [];
283
- return t.forEach((o) => {
284
- let i = e;
285
- if (o.file && (i = this._libFiles.getOrCreateModel(o.file.fileName)), !i)
286
- return;
287
- const l = o.start || 0, u = o.length || 1, { lineNumber: s, column: c } = i.getPositionAt(l), { lineNumber: g, column: d } = i.getPositionAt(
288
- l + u
289
- );
290
- r.push({
291
- resource: i.uri,
292
- startLineNumber: s,
293
- startColumn: c,
294
- endLineNumber: g,
295
- endColumn: d,
296
- message: D(o.messageText, `
297
- `)
298
- });
299
- }), r;
300
- }
301
- _tsDiagnosticCategoryToMarkerSeverity(e) {
302
- switch (e) {
303
- case 1:
304
- return a.MarkerSeverity.Error;
305
- case 3:
306
- return a.MarkerSeverity.Info;
307
- case 0:
308
- return a.MarkerSeverity.Warning;
309
- case 2:
310
- return a.MarkerSeverity.Hint;
311
- }
312
- return a.MarkerSeverity.Info;
313
- }
314
- }, B = class C extends _ {
315
- get triggerCharacters() {
316
- return ["."];
317
- }
318
- async provideCompletionItems(t, r, o, i) {
319
- const l = t.getWordUntilPosition(r), u = new a.Range(
320
- r.lineNumber,
321
- l.startColumn,
322
- r.lineNumber,
323
- l.endColumn
324
- ), s = t.uri, c = t.getOffsetAt(r), g = await this._worker(s);
325
- if (t.isDisposed())
326
- return;
327
- const d = await g.getCompletionsAtPosition(s.toString(), c);
328
- return !d || t.isDisposed() ? void 0 : {
329
- suggestions: d.entries.map((h) => {
330
- let y = u;
331
- if (h.replacementSpan) {
332
- const S = t.getPositionAt(h.replacementSpan.start), x = t.getPositionAt(h.replacementSpan.start + h.replacementSpan.length);
333
- y = new a.Range(S.lineNumber, S.column, x.lineNumber, x.column);
334
- }
335
- const v = [];
336
- return h.kindModifiers !== void 0 && h.kindModifiers.indexOf("deprecated") !== -1 && v.push(a.languages.CompletionItemTag.Deprecated), {
337
- uri: s,
338
- position: r,
339
- offset: c,
340
- range: y,
341
- label: h.name,
342
- insertText: h.name,
343
- sortText: h.sortText,
344
- kind: C.convertKind(h.kind),
345
- tags: v
346
- };
347
- })
348
- };
349
- }
350
- async resolveCompletionItem(t, r) {
351
- const o = t, i = o.uri, l = o.position, u = o.offset, c = await (await this._worker(i)).getCompletionEntryDetails(
352
- i.toString(),
353
- u,
354
- o.label
355
- );
356
- return c ? {
357
- uri: i,
358
- position: l,
359
- label: c.name,
360
- kind: C.convertKind(c.kind),
361
- detail: w(c.displayParts),
362
- documentation: {
363
- value: C.createDocumentationString(c)
364
- }
365
- } : o;
366
- }
367
- static convertKind(t) {
368
- switch (t) {
369
- case f.primitiveType:
370
- case f.keyword:
371
- return a.languages.CompletionItemKind.Keyword;
372
- case f.variable:
373
- case f.localVariable:
374
- return a.languages.CompletionItemKind.Variable;
375
- case f.memberVariable:
376
- case f.memberGetAccessor:
377
- case f.memberSetAccessor:
378
- return a.languages.CompletionItemKind.Field;
379
- case f.function:
380
- case f.memberFunction:
381
- case f.constructSignature:
382
- case f.callSignature:
383
- case f.indexSignature:
384
- return a.languages.CompletionItemKind.Function;
385
- case f.enum:
386
- return a.languages.CompletionItemKind.Enum;
387
- case f.module:
388
- return a.languages.CompletionItemKind.Module;
389
- case f.class:
390
- return a.languages.CompletionItemKind.Class;
391
- case f.interface:
392
- return a.languages.CompletionItemKind.Interface;
393
- case f.warning:
394
- return a.languages.CompletionItemKind.File;
395
- }
396
- return a.languages.CompletionItemKind.Property;
397
- }
398
- static createDocumentationString(t) {
399
- let r = w(t.documentation);
400
- if (t.tags)
401
- for (const o of t.tags)
402
- r += `
403
-
404
- ${T(o)}`;
405
- return r;
406
- }
407
- };
408
- function T(e) {
409
- let t = `*@${e.name}*`;
410
- if (e.name === "param" && e.text) {
411
- const [r, ...o] = e.text;
412
- t += `\`${r.text}\``, o.length > 0 && (t += ` — ${o.map((i) => i.text).join(" ")}`);
413
- } else
414
- Array.isArray(e.text) ? t += ` — ${e.text.map((r) => r.text).join(" ")}` : e.text && (t += ` — ${e.text}`);
415
- return t;
416
- }
417
- var U = class P extends _ {
418
- constructor() {
419
- super(...arguments), this.signatureHelpTriggerCharacters = ["(", ","];
420
- }
421
- static _toSignatureHelpTriggerReason(t) {
422
- switch (t.triggerKind) {
423
- case a.languages.SignatureHelpTriggerKind.TriggerCharacter:
424
- return t.triggerCharacter ? t.isRetrigger ? { kind: "retrigger", triggerCharacter: t.triggerCharacter } : { kind: "characterTyped", triggerCharacter: t.triggerCharacter } : { kind: "invoked" };
425
- case a.languages.SignatureHelpTriggerKind.ContentChange:
426
- return t.isRetrigger ? { kind: "retrigger" } : { kind: "invoked" };
427
- case a.languages.SignatureHelpTriggerKind.Invoke:
428
- default:
429
- return { kind: "invoked" };
430
- }
431
- }
432
- async provideSignatureHelp(t, r, o, i) {
433
- const l = t.uri, u = t.getOffsetAt(r), s = await this._worker(l);
434
- if (t.isDisposed())
435
- return;
436
- const c = await s.getSignatureHelpItems(l.toString(), u, {
437
- triggerReason: P._toSignatureHelpTriggerReason(i)
438
- });
439
- if (!c || t.isDisposed())
440
- return;
441
- const g = {
442
- activeSignature: c.selectedItemIndex,
443
- activeParameter: c.argumentIndex,
444
- signatures: []
445
- };
446
- return c.items.forEach((d) => {
447
- const b = {
448
- label: "",
449
- parameters: []
450
- };
451
- b.documentation = {
452
- value: w(d.documentation)
453
- }, b.label += w(d.prefixDisplayParts), d.parameters.forEach((h, y, v) => {
454
- const S = w(h.displayParts), x = {
455
- label: S,
456
- documentation: {
457
- value: w(h.documentation)
458
- }
459
- };
460
- b.label += S, b.parameters.push(x), y < v.length - 1 && (b.label += w(d.separatorDisplayParts));
461
- }), b.label += w(d.suffixDisplayParts), g.signatures.push(b);
462
- }), {
463
- value: g,
464
- dispose() {
465
- }
466
- };
467
- }
468
- }, $ = class extends _ {
469
- async provideHover(e, t, r) {
470
- const o = e.uri, i = e.getOffsetAt(t), l = await this._worker(o);
471
- if (e.isDisposed())
472
- return;
473
- const u = await l.getQuickInfoAtPosition(o.toString(), i);
474
- if (!u || e.isDisposed())
475
- return;
476
- const s = w(u.documentation), c = u.tags ? u.tags.map((d) => T(d)).join(`
477
-
478
- `) : "", g = w(u.displayParts);
479
- return {
480
- range: this._textSpanToRange(e, u.textSpan),
481
- contents: [
482
- {
483
- value: "```typescript\n" + g + "\n```\n"
484
- },
485
- {
486
- value: s + (c ? `
487
-
488
- ` + c : "")
489
- }
490
- ]
491
- };
492
- }
493
- }, z = class extends _ {
494
- async provideDocumentHighlights(e, t, r) {
495
- const o = e.uri, i = e.getOffsetAt(t), l = await this._worker(o);
496
- if (e.isDisposed())
497
- return;
498
- const u = await l.getDocumentHighlights(o.toString(), i, [
499
- o.toString()
500
- ]);
501
- if (!(!u || e.isDisposed()))
502
- return u.flatMap((s) => s.highlightSpans.map((c) => ({
503
- range: this._textSpanToRange(e, c.textSpan),
504
- kind: c.kind === "writtenReference" ? a.languages.DocumentHighlightKind.Write : a.languages.DocumentHighlightKind.Text
505
- })));
506
- }
507
- }, G = class extends _ {
508
- constructor(e, t) {
509
- super(t), this._libFiles = e;
510
- }
511
- async provideDefinition(e, t, r) {
512
- const o = e.uri, i = e.getOffsetAt(t), l = await this._worker(o);
513
- if (e.isDisposed())
514
- return;
515
- const u = await l.getDefinitionAtPosition(o.toString(), i);
516
- if (!u || e.isDisposed() || (await this._libFiles.fetchLibFilesIfNecessary(
517
- u.map((c) => a.Uri.parse(c.fileName))
518
- ), e.isDisposed()))
519
- return;
520
- const s = [];
521
- for (let c of u) {
522
- const g = this._libFiles.getOrCreateModel(c.fileName);
523
- g && s.push({
524
- uri: g.uri,
525
- range: this._textSpanToRange(g, c.textSpan)
526
- });
527
- }
528
- return s;
529
- }
530
- }, J = class extends _ {
531
- constructor(e, t) {
532
- super(t), this._libFiles = e;
533
- }
534
- async provideReferences(e, t, r, o) {
535
- const i = e.uri, l = e.getOffsetAt(t), u = await this._worker(i);
536
- if (e.isDisposed())
537
- return;
538
- const s = await u.getReferencesAtPosition(i.toString(), l);
539
- if (!s || e.isDisposed() || (await this._libFiles.fetchLibFilesIfNecessary(
540
- s.map((g) => a.Uri.parse(g.fileName))
541
- ), e.isDisposed()))
542
- return;
543
- const c = [];
544
- for (let g of s) {
545
- const d = this._libFiles.getOrCreateModel(g.fileName);
546
- d && c.push({
547
- uri: d.uri,
548
- range: this._textSpanToRange(d, g.textSpan)
549
- });
550
- }
551
- return c;
552
- }
553
- }, Q = class extends _ {
554
- async provideDocumentSymbols(e, t) {
555
- const r = e.uri, o = await this._worker(r);
556
- if (e.isDisposed())
557
- return;
558
- const i = await o.getNavigationTree(r.toString());
559
- if (!i || e.isDisposed())
560
- return;
561
- const l = (s, c) => {
562
- var d;
563
- return {
564
- name: s.text,
565
- detail: "",
566
- kind: m[s.kind] || a.languages.SymbolKind.Variable,
567
- range: this._textSpanToRange(e, s.spans[0]),
568
- selectionRange: this._textSpanToRange(e, s.spans[0]),
569
- tags: [],
570
- children: (d = s.childItems) == null ? void 0 : d.map((b) => l(b, s.text)),
571
- containerName: c
572
- };
573
- };
574
- return i.childItems ? i.childItems.map((s) => l(s)) : [];
575
- }
576
- }, p, f = (p = class {
577
- }, p.unknown = "", p.keyword = "keyword", p.script = "script", p.module = "module", p.class = "class", p.interface = "interface", p.type = "type", p.enum = "enum", p.variable = "var", p.localVariable = "local var", p.function = "function", p.localFunction = "local function", p.memberFunction = "method", p.memberGetAccessor = "getter", p.memberSetAccessor = "setter", p.memberVariable = "property", p.constructorImplementation = "constructor", p.callSignature = "call", p.indexSignature = "index", p.constructSignature = "construct", p.parameter = "parameter", p.typeParameter = "type parameter", p.primitiveType = "primitive type", p.label = "label", p.alias = "alias", p.const = "const", p.let = "let", p.warning = "warning", p), m = /* @__PURE__ */ Object.create(null);
578
- m[f.module] = a.languages.SymbolKind.Module;
579
- m[f.class] = a.languages.SymbolKind.Class;
580
- m[f.enum] = a.languages.SymbolKind.Enum;
581
- m[f.interface] = a.languages.SymbolKind.Interface;
582
- m[f.memberFunction] = a.languages.SymbolKind.Method;
583
- m[f.memberVariable] = a.languages.SymbolKind.Property;
584
- m[f.memberGetAccessor] = a.languages.SymbolKind.Property;
585
- m[f.memberSetAccessor] = a.languages.SymbolKind.Property;
586
- m[f.variable] = a.languages.SymbolKind.Variable;
587
- m[f.const] = a.languages.SymbolKind.Variable;
588
- m[f.localVariable] = a.languages.SymbolKind.Variable;
589
- m[f.variable] = a.languages.SymbolKind.Variable;
590
- m[f.function] = a.languages.SymbolKind.Function;
591
- m[f.localFunction] = a.languages.SymbolKind.Function;
592
- var k = class extends _ {
593
- static _convertOptions(e) {
594
- return {
595
- ConvertTabsToSpaces: e.insertSpaces,
596
- TabSize: e.tabSize,
597
- IndentSize: e.tabSize,
598
- IndentStyle: 2,
599
- NewLineCharacter: `
600
- `,
601
- InsertSpaceAfterCommaDelimiter: !0,
602
- InsertSpaceAfterSemicolonInForStatements: !0,
603
- InsertSpaceBeforeAndAfterBinaryOperators: !0,
604
- InsertSpaceAfterKeywordsInControlFlowStatements: !0,
605
- InsertSpaceAfterFunctionKeywordForAnonymousFunctions: !0,
606
- InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: !1,
607
- InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: !1,
608
- InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: !1,
609
- PlaceOpenBraceOnNewLineForControlBlocks: !1,
610
- PlaceOpenBraceOnNewLineForFunctions: !1
611
- };
612
- }
613
- _convertTextChanges(e, t) {
614
- return {
615
- text: t.newText,
616
- range: this._textSpanToRange(e, t.span)
617
- };
618
- }
619
- }, q = class extends k {
620
- constructor() {
621
- super(...arguments), this.canFormatMultipleRanges = !1;
622
- }
623
- async provideDocumentRangeFormattingEdits(e, t, r, o) {
624
- const i = e.uri, l = e.getOffsetAt({
625
- lineNumber: t.startLineNumber,
626
- column: t.startColumn
627
- }), u = e.getOffsetAt({
628
- lineNumber: t.endLineNumber,
629
- column: t.endColumn
630
- }), s = await this._worker(i);
631
- if (e.isDisposed())
632
- return;
633
- const c = await s.getFormattingEditsForRange(
634
- i.toString(),
635
- l,
636
- u,
637
- k._convertOptions(r)
638
- );
639
- if (!(!c || e.isDisposed()))
640
- return c.map((g) => this._convertTextChanges(e, g));
641
- }
642
- }, X = class extends k {
643
- get autoFormatTriggerCharacters() {
644
- return [";", "}", `
645
- `];
646
- }
647
- async provideOnTypeFormattingEdits(e, t, r, o, i) {
648
- const l = e.uri, u = e.getOffsetAt(t), s = await this._worker(l);
649
- if (e.isDisposed())
650
- return;
651
- const c = await s.getFormattingEditsAfterKeystroke(
652
- l.toString(),
653
- u,
654
- r,
655
- k._convertOptions(o)
656
- );
657
- if (!(!c || e.isDisposed()))
658
- return c.map((g) => this._convertTextChanges(e, g));
659
- }
660
- }, Y = class extends k {
661
- async provideCodeActions(e, t, r, o) {
662
- const i = e.uri, l = e.getOffsetAt({
663
- lineNumber: t.startLineNumber,
664
- column: t.startColumn
665
- }), u = e.getOffsetAt({
666
- lineNumber: t.endLineNumber,
667
- column: t.endColumn
668
- }), s = k._convertOptions(e.getOptions()), c = r.markers.filter((h) => h.code).map((h) => h.code).map(Number), g = await this._worker(i);
669
- if (e.isDisposed())
670
- return;
671
- const d = await g.getCodeFixesAtPosition(
672
- i.toString(),
673
- l,
674
- u,
675
- c,
676
- s
677
- );
678
- return !d || e.isDisposed() ? { actions: [], dispose: () => {
679
- } } : {
680
- actions: d.filter((h) => h.changes.filter((y) => y.isNewFile).length === 0).map((h) => this._tsCodeFixActionToMonacoCodeAction(e, r, h)),
681
- dispose: () => {
682
- }
683
- };
684
- }
685
- _tsCodeFixActionToMonacoCodeAction(e, t, r) {
686
- const o = [];
687
- for (const l of r.changes)
688
- for (const u of l.textChanges)
689
- o.push({
690
- resource: e.uri,
691
- versionId: void 0,
692
- textEdit: {
693
- range: this._textSpanToRange(e, u.span),
694
- text: u.newText
695
- }
696
- });
697
- return {
698
- title: r.description,
699
- edit: { edits: o },
700
- diagnostics: t.markers,
701
- kind: "quickfix"
702
- };
703
- }
704
- }, Z = class extends _ {
705
- constructor(e, t) {
706
- super(t), this._libFiles = e;
707
- }
708
- async provideRenameEdits(e, t, r, o) {
709
- const i = e.uri, l = i.toString(), u = e.getOffsetAt(t), s = await this._worker(i);
710
- if (e.isDisposed())
711
- return;
712
- const c = await s.getRenameInfo(l, u, {
713
- allowRenameOfImportPath: !1
714
- });
715
- if (c.canRename === !1)
716
- return {
717
- edits: [],
718
- rejectReason: c.localizedErrorMessage
719
- };
720
- if (c.fileToRename !== void 0)
721
- throw new Error("Renaming files is not supported.");
722
- const g = await s.findRenameLocations(
723
- l,
724
- u,
725
- /*strings*/
726
- !1,
727
- /*comments*/
728
- !1,
729
- /*prefixAndSuffix*/
730
- !1
731
- );
732
- if (!g || e.isDisposed())
733
- return;
734
- const d = [];
735
- for (const b of g) {
736
- const h = this._libFiles.getOrCreateModel(b.fileName);
737
- if (h)
738
- d.push({
739
- resource: h.uri,
740
- versionId: void 0,
741
- textEdit: {
742
- range: this._textSpanToRange(h, b.textSpan),
743
- text: r
744
- }
745
- });
746
- else
747
- throw new Error(`Unknown file ${b.fileName}.`);
748
- }
749
- return { edits: d };
750
- }
751
- }, ee = class extends _ {
752
- async provideInlayHints(e, t, r) {
753
- const o = e.uri, i = o.toString(), l = e.getOffsetAt({
754
- lineNumber: t.startLineNumber,
755
- column: t.startColumn
756
- }), u = e.getOffsetAt({
757
- lineNumber: t.endLineNumber,
758
- column: t.endColumn
759
- }), s = await this._worker(o);
760
- return e.isDisposed() ? null : { hints: (await s.provideInlayHints(i, l, u)).map((d) => ({
761
- ...d,
762
- label: d.text,
763
- position: e.getPositionAt(d.position),
764
- kind: this._convertHintKind(d.kind)
765
- })), dispose: () => {
766
- } };
767
- }
768
- _convertHintKind(e) {
769
- switch (e) {
770
- case "Parameter":
771
- return a.languages.InlayHintKind.Parameter;
772
- case "Type":
773
- return a.languages.InlayHintKind.Type;
774
- default:
775
- return a.languages.InlayHintKind.Type;
776
- }
777
- }
778
- }, A, F;
779
- function re(e) {
780
- F = L(e, "typescript");
781
- }
782
- function ie(e) {
783
- A = L(e, "javascript");
784
- }
785
- function ne() {
786
- return new Promise((e, t) => {
787
- if (!A)
788
- return t("JavaScript not registered!");
789
- e(A);
790
- });
791
- }
792
- function ae() {
793
- return new Promise((e, t) => {
794
- if (!F)
795
- return t("TypeScript not registered!");
796
- e(F);
797
- });
798
- }
799
- function L(e, t) {
800
- const r = [], o = new V(t, e), i = (...s) => o.getLanguageServiceWorker(...s), l = new W(i);
801
- function u() {
802
- const { modeConfiguration: s } = e;
803
- te(r), s.completionItems && r.push(
804
- a.languages.registerCompletionItemProvider(
805
- t,
806
- new B(i)
807
- )
808
- ), s.signatureHelp && r.push(
809
- a.languages.registerSignatureHelpProvider(
810
- t,
811
- new U(i)
812
- )
813
- ), s.hovers && r.push(
814
- a.languages.registerHoverProvider(t, new $(i))
815
- ), s.documentHighlights && r.push(
816
- a.languages.registerDocumentHighlightProvider(
817
- t,
818
- new z(i)
819
- )
820
- ), s.definitions && r.push(
821
- a.languages.registerDefinitionProvider(
822
- t,
823
- new G(l, i)
824
- )
825
- ), s.references && r.push(
826
- a.languages.registerReferenceProvider(
827
- t,
828
- new J(l, i)
829
- )
830
- ), s.documentSymbols && r.push(
831
- a.languages.registerDocumentSymbolProvider(
832
- t,
833
- new Q(i)
834
- )
835
- ), s.rename && r.push(
836
- a.languages.registerRenameProvider(
837
- t,
838
- new Z(l, i)
839
- )
840
- ), s.documentRangeFormattingEdits && r.push(
841
- a.languages.registerDocumentRangeFormattingEditProvider(
842
- t,
843
- new q(i)
844
- )
845
- ), s.onTypeFormattingEdits && r.push(
846
- a.languages.registerOnTypeFormattingEditProvider(
847
- t,
848
- new X(i)
849
- )
850
- ), s.codeActions && r.push(
851
- a.languages.registerCodeActionProvider(t, new Y(i))
852
- ), s.inlayHints && r.push(
853
- a.languages.registerInlayHintsProvider(t, new ee(i))
854
- ), s.diagnostics && r.push(new j(l, e, t, i));
855
- }
856
- return u(), i;
857
- }
858
- function te(e) {
859
- for (; e.length; )
860
- e.pop().dispose();
861
- }
862
- export {
863
- _ as Adapter,
864
- Y as CodeActionAdaptor,
865
- G as DefinitionAdapter,
866
- j as DiagnosticsAdapter,
867
- z as DocumentHighlightAdapter,
868
- q as FormatAdapter,
869
- k as FormatHelper,
870
- X as FormatOnTypeAdapter,
871
- ee as InlayHintsAdapter,
872
- f as Kind,
873
- W as LibFiles,
874
- Q as OutlineAdapter,
875
- $ as QuickInfoAdapter,
876
- J as ReferenceAdapter,
877
- Z as RenameAdapter,
878
- U as SignatureHelpAdapter,
879
- B as SuggestAdapter,
880
- V as WorkerManager,
881
- D as flattenDiagnosticMessageText,
882
- ne as getJavaScriptWorker,
883
- ae as getTypeScriptWorker,
884
- ie as setupJavaScript,
885
- re as setupTypeScript
886
- };