@coze-editor/code-language-typescript 0.1.0-alpha.0fd19e

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/dist/index.js ADDED
@@ -0,0 +1,636 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ TypeScriptLanguageService: () => TypeScriptLanguageService,
33
+ typescript: () => typescript,
34
+ typescriptLanguage: () => import_lang_javascript.typescriptLanguage,
35
+ typescriptLanguageService: () => typescriptLanguageService
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_lang_javascript = require("@codemirror/lang-javascript");
39
+
40
+ // src/service.ts
41
+ var import_vscode_uri = require("vscode-uri");
42
+ var import_vscode_languageserver_types2 = require("vscode-languageserver-types");
43
+ var import_typescript2 = require("typescript");
44
+ var import_mitt = __toESM(require("mitt"));
45
+ var import_comlink = require("comlink");
46
+ var import_microfuzz = __toESM(require("@nozbe/microfuzz"));
47
+ var import_code_language_shared = require("@coze-editor/code-language-shared");
48
+
49
+ // src/utils.ts
50
+ function tagToString(tag) {
51
+ let tagLabel = `*@${tag.name}*`;
52
+ if (tag.name === "param" && tag.text) {
53
+ const [paramName, ...rest] = tag.text;
54
+ tagLabel += `\`${paramName.text}\``;
55
+ if (rest.length > 0) {
56
+ tagLabel += ` \u2014 ${rest.map((r) => r.text).join(" ")}`;
57
+ }
58
+ } else if (Array.isArray(tag.text)) {
59
+ tagLabel += ` \u2014 ${tag.text.map((r) => r.text).join(" ")}`;
60
+ } else if (tag.text) {
61
+ tagLabel += ` \u2014 ${tag.text}`;
62
+ }
63
+ return tagLabel;
64
+ }
65
+
66
+ // src/as.ts
67
+ var import_vscode_languageserver_types = require("vscode-languageserver-types");
68
+ var import_typescript = require("typescript");
69
+ function asCompletionItemKind(kind) {
70
+ switch (kind) {
71
+ case import_typescript.ScriptElementKind.primitiveType:
72
+ case import_typescript.ScriptElementKind.keyword:
73
+ return import_vscode_languageserver_types.CompletionItemKind.Keyword;
74
+ case import_typescript.ScriptElementKind.constElement:
75
+ case import_typescript.ScriptElementKind.letElement:
76
+ case import_typescript.ScriptElementKind.variableElement:
77
+ case import_typescript.ScriptElementKind.localVariableElement:
78
+ case import_typescript.ScriptElementKind.alias:
79
+ case import_typescript.ScriptElementKind.parameterElement:
80
+ return import_vscode_languageserver_types.CompletionItemKind.Variable;
81
+ case import_typescript.ScriptElementKind.memberVariableElement:
82
+ case import_typescript.ScriptElementKind.memberGetAccessorElement:
83
+ case import_typescript.ScriptElementKind.memberSetAccessorElement:
84
+ return import_vscode_languageserver_types.CompletionItemKind.Field;
85
+ case import_typescript.ScriptElementKind.functionElement:
86
+ case import_typescript.ScriptElementKind.localFunctionElement:
87
+ return import_vscode_languageserver_types.CompletionItemKind.Function;
88
+ case import_typescript.ScriptElementKind.memberFunctionElement:
89
+ case import_typescript.ScriptElementKind.constructSignatureElement:
90
+ case import_typescript.ScriptElementKind.callSignatureElement:
91
+ case import_typescript.ScriptElementKind.indexSignatureElement:
92
+ return import_vscode_languageserver_types.CompletionItemKind.Method;
93
+ case import_typescript.ScriptElementKind.enumElement:
94
+ return import_vscode_languageserver_types.CompletionItemKind.Enum;
95
+ case import_typescript.ScriptElementKind.enumMemberElement:
96
+ return import_vscode_languageserver_types.CompletionItemKind.EnumMember;
97
+ case import_typescript.ScriptElementKind.moduleElement:
98
+ case import_typescript.ScriptElementKind.externalModuleName:
99
+ return import_vscode_languageserver_types.CompletionItemKind.Module;
100
+ case import_typescript.ScriptElementKind.classElement:
101
+ case import_typescript.ScriptElementKind.typeElement:
102
+ return import_vscode_languageserver_types.CompletionItemKind.Class;
103
+ case import_typescript.ScriptElementKind.interfaceElement:
104
+ return import_vscode_languageserver_types.CompletionItemKind.Interface;
105
+ case import_typescript.ScriptElementKind.warning:
106
+ return import_vscode_languageserver_types.CompletionItemKind.Text;
107
+ case import_typescript.ScriptElementKind.scriptElement:
108
+ return import_vscode_languageserver_types.CompletionItemKind.File;
109
+ case import_typescript.ScriptElementKind.directory:
110
+ return import_vscode_languageserver_types.CompletionItemKind.Folder;
111
+ case import_typescript.ScriptElementKind.string:
112
+ return import_vscode_languageserver_types.CompletionItemKind.Constant;
113
+ }
114
+ return import_vscode_languageserver_types.CompletionItemKind.Property;
115
+ }
116
+
117
+ // src/service.ts
118
+ var identRe = /^[\w$]+$/;
119
+ function isDiagnostic(v) {
120
+ return Boolean(v);
121
+ }
122
+ function isChangeDesc(v) {
123
+ return Boolean(v);
124
+ }
125
+ var TypeScriptLanguageService = class {
126
+ worker = null;
127
+ starting = null;
128
+ _cachedFiles = /* @__PURE__ */ Object.create(null);
129
+ events = (0, import_mitt.default)();
130
+ async synchronize(paths) {
131
+ await this.starting;
132
+ if (!this.worker) {
133
+ throw new Error("TypeScript LanguageService is not initialized");
134
+ }
135
+ const files = {};
136
+ paths.forEach((path) => {
137
+ files[path] = this._cachedFiles[path] ?? "";
138
+ });
139
+ await this.worker.syncFiles(files);
140
+ return this.worker;
141
+ }
142
+ onTextDocumentDidChange = (ctx) => {
143
+ const { textDocument } = ctx;
144
+ const text = textDocument.getText();
145
+ const uri = import_vscode_uri.URI.parse(textDocument.uri);
146
+ const path = uri.fsPath;
147
+ this._cachedFiles[path] = text;
148
+ };
149
+ doHover = async (ctx) => {
150
+ const { textDocument } = ctx;
151
+ const uri = import_vscode_uri.URI.parse(textDocument.uri);
152
+ const path = uri.fsPath;
153
+ const worker = await this.synchronize([path]);
154
+ const info = await worker.getQuickInfoAtPosition(path, ctx.offset);
155
+ if (!info) {
156
+ return;
157
+ }
158
+ const tags = info.tags ? info.tags.map((tag) => tagToString(tag)).join(" \n\n") : "";
159
+ const contents = (0, import_typescript2.displayPartsToString)(info.displayParts);
160
+ const documentation = (0, import_typescript2.displayPartsToString)(info.documentation);
161
+ return {
162
+ kind: import_vscode_languageserver_types2.MarkupKind.Markdown,
163
+ value: `\`\`\`ts
164
+ ${contents}
165
+ \`\`\`
166
+ ${documentation}${tags ? `
167
+
168
+ ${tags}` : ""}`
169
+ };
170
+ };
171
+ async synchronizeByURI(uri, content) {
172
+ await this.onTextDocumentDidChange({
173
+ textDocument: {
174
+ uri,
175
+ getText() {
176
+ return content;
177
+ }
178
+ }
179
+ });
180
+ }
181
+ async validateByURI(uri) {
182
+ return this.doValidation({
183
+ textDocument: {
184
+ uri
185
+ }
186
+ });
187
+ }
188
+ doValidation = async (ctx) => {
189
+ const { textDocument } = ctx;
190
+ const uri = import_vscode_uri.URI.parse(textDocument.uri);
191
+ const path = uri.fsPath;
192
+ const worker = await this.synchronize([path]);
193
+ try {
194
+ const diagnostics = [
195
+ ...await worker.getSyntacticDiagnostics(path),
196
+ ...await worker.getSemanticDiagnostics(path),
197
+ ...await worker.getSuggestionDiagnostics(path)
198
+ ];
199
+ const categoryToSeverityMap = {
200
+ [import_typescript2.DiagnosticCategory.Error]: "error",
201
+ [import_typescript2.DiagnosticCategory.Warning]: "warning",
202
+ [import_typescript2.DiagnosticCategory.Message]: "info",
203
+ [import_typescript2.DiagnosticCategory.Suggestion]: "hint"
204
+ };
205
+ return diagnostics.map((d) => {
206
+ if (typeof d.start !== "number" || !categoryToSeverityMap[d.category]) {
207
+ return;
208
+ }
209
+ const tags = [];
210
+ if (d.reportsUnnecessary) {
211
+ tags.push(import_code_language_shared.MarkerTag.Unnecessary);
212
+ }
213
+ if (d.reportsDeprecated) {
214
+ tags.push(import_code_language_shared.MarkerTag.Deprecated);
215
+ }
216
+ return {
217
+ from: d.start,
218
+ to: d.start + (d.length ?? 0),
219
+ severity: categoryToSeverityMap[d.category],
220
+ message: typeof d.messageText === "string" ? d.messageText : d.messageText.messageText,
221
+ tags
222
+ };
223
+ }).filter((v) => isDiagnostic(v));
224
+ } catch (e) {
225
+ return [];
226
+ }
227
+ };
228
+ doComplete = async (ctx) => {
229
+ const uri = import_vscode_uri.URI.parse(ctx.textDocument.uri);
230
+ const path = uri.fsPath;
231
+ const content = ctx.textDocument.getText();
232
+ const worker = await this.synchronize([path]);
233
+ const result = await worker.getCompletionsAtPosition(path, ctx.offset);
234
+ if (!result) {
235
+ return null;
236
+ }
237
+ const items = result.entries.map((entry) => ({
238
+ label: entry.name,
239
+ kind: asCompletionItemKind(entry.kind)
240
+ }));
241
+ const fuzzySearch = (0, import_microfuzz.default)(items, {
242
+ key: "label"
243
+ });
244
+ let i = ctx.offset - 1;
245
+ let query = "";
246
+ while (i >= 0) {
247
+ const char = content.slice(i, i + 1);
248
+ if (char === "\n") {
249
+ break;
250
+ }
251
+ if (!identRe.test(char) && i + 1 <= ctx.offset) {
252
+ break;
253
+ }
254
+ i--;
255
+ }
256
+ query = content.slice(i + 1, ctx.offset);
257
+ const charBefore = content.slice(ctx.offset - 1, ctx.offset);
258
+ const triggerCharacters = [".", "'", '"'];
259
+ if (triggerCharacters.includes(charBefore)) {
260
+ return {
261
+ isIncomplete: true,
262
+ items
263
+ };
264
+ }
265
+ return query ? {
266
+ isIncomplete: true,
267
+ items: fuzzySearch(query).map((v) => ({
268
+ ...v.item,
269
+ textEdit: {
270
+ range: {
271
+ start: ctx.textDocument.positionAt(i + 1),
272
+ end: ctx.textDocument.positionAt(ctx.offset)
273
+ },
274
+ newText: v.item.label
275
+ }
276
+ }))
277
+ } : {
278
+ isIncomplete: true,
279
+ items: []
280
+ };
281
+ };
282
+ async resolveCompletionItem(ctx, item) {
283
+ const uri = import_vscode_uri.URI.parse(ctx.textDocument.uri);
284
+ const path = uri.fsPath;
285
+ const worker = await this.synchronize([path]);
286
+ const details = await worker.getCompletionEntryDetails(
287
+ path,
288
+ ctx.offset,
289
+ item.label,
290
+ void 0,
291
+ void 0,
292
+ void 0,
293
+ void 0
294
+ );
295
+ if (!details) {
296
+ return item;
297
+ }
298
+ const documentationString = createDocumentationString(details);
299
+ return {
300
+ label: details.name,
301
+ detail: (0, import_typescript2.displayPartsToString)(details == null ? void 0 : details.displayParts),
302
+ documentation: documentationString ? {
303
+ kind: import_vscode_languageserver_types2.MarkupKind.Markdown,
304
+ value: documentationString
305
+ } : void 0
306
+ };
307
+ }
308
+ async format(state, options = {}) {
309
+ const { textDocument, originalRangeFor } = state.field(import_code_language_shared.textDocumentField);
310
+ const uri = import_vscode_uri.URI.parse(textDocument.uri);
311
+ const path = uri.fsPath;
312
+ const worker = await this.synchronize([path]);
313
+ const edits = await worker.getFormattingEditsForDocument(path, {
314
+ indentSize: 2,
315
+ tabSize: 2,
316
+ convertTabsToSpaces: true,
317
+ newLineCharacter: "\n",
318
+ ...options
319
+ });
320
+ if (!edits) {
321
+ return {
322
+ changes: []
323
+ };
324
+ }
325
+ const changes = edits.map((edit) => {
326
+ const range = originalRangeFor({
327
+ from: edit.span.start,
328
+ to: edit.span.start + edit.span.length
329
+ });
330
+ if (range) {
331
+ return {
332
+ ...range,
333
+ insert: edit.newText
334
+ };
335
+ }
336
+ }).filter((v) => isChangeDesc(v));
337
+ return {
338
+ changes
339
+ };
340
+ }
341
+ async getTypeInformation(ctx) {
342
+ const { textDocument } = ctx;
343
+ const uri = import_vscode_uri.URI.parse(textDocument.uri);
344
+ const path = uri.fsPath;
345
+ const worker = await this.synchronize([path]);
346
+ const info = await worker.getTypeInfoAtPosition(path, ctx.offset);
347
+ return info;
348
+ }
349
+ async doSignatureHelp(ctx) {
350
+ const uri = import_vscode_uri.URI.parse(ctx.textDocument.uri);
351
+ const path = uri.fsPath;
352
+ const worker = await this.synchronize([path]);
353
+ const info = await worker.getSignatureHelpItems(path, ctx.offset, {});
354
+ if (!info) {
355
+ return null;
356
+ }
357
+ const ret = {
358
+ activeSignature: info.selectedItemIndex,
359
+ activeParameter: info.argumentIndex,
360
+ signatures: []
361
+ };
362
+ info.items.forEach((item) => {
363
+ const signature = {
364
+ label: "",
365
+ parameters: []
366
+ };
367
+ signature.documentation = {
368
+ kind: import_vscode_languageserver_types2.MarkupKind.Markdown,
369
+ value: (0, import_typescript2.displayPartsToString)(item.documentation)
370
+ };
371
+ signature.label += (0, import_typescript2.displayPartsToString)(item.prefixDisplayParts);
372
+ item.parameters.forEach((p, i, a) => {
373
+ const label = (0, import_typescript2.displayPartsToString)(p.displayParts);
374
+ const parameter = {
375
+ label,
376
+ documentation: {
377
+ kind: import_vscode_languageserver_types2.MarkupKind.Markdown,
378
+ value: (0, import_typescript2.displayPartsToString)(p.documentation)
379
+ }
380
+ };
381
+ signature.label += label;
382
+ signature.parameters.push(parameter);
383
+ if (i < a.length - 1) {
384
+ signature.label += (0, import_typescript2.displayPartsToString)(item.separatorDisplayParts);
385
+ }
386
+ });
387
+ signature.label += (0, import_typescript2.displayPartsToString)(item.suffixDisplayParts);
388
+ ret.signatures.push(signature);
389
+ });
390
+ return ret;
391
+ }
392
+ // async findDefinition(ctx) {
393
+ // const uri = URI.parse(ctx.textDocument.uri)
394
+ // const path = uri.fsPath
395
+ // const worker = await this.synchronize([path])
396
+ // const info = await worker.getDefinitionAtPosition(path, ctx.offset)
397
+ // if (!info) {
398
+ // return
399
+ // }
400
+ // return info.map(def => {
401
+ // return {
402
+ // from: def.textSpan.start,
403
+ // to: def.textSpan.start + def.textSpan.length,
404
+ // }
405
+ // })
406
+ // }
407
+ initialize(tsWorker, options) {
408
+ this.worker = (0, import_comlink.wrap)(tsWorker);
409
+ this.starting = this.worker.initialize({
410
+ compilerOptions: (options == null ? void 0 : options.compilerOptions) ?? {},
411
+ initialFiles: {
412
+ ...this.extraFiles,
413
+ ...(options == null ? void 0 : options.initialFiles) ?? {}
414
+ }
415
+ });
416
+ }
417
+ extraFiles = /* @__PURE__ */ Object.create(null);
418
+ async addExtraFiles(files) {
419
+ this.extraFiles = Object.assign({}, this.extraFiles, files);
420
+ await this.starting;
421
+ if (this.worker) {
422
+ await this.worker.syncFiles(files);
423
+ this.events.emit("refresh-diagnostics");
424
+ }
425
+ }
426
+ };
427
+ function createDocumentationString(details) {
428
+ let documentationString = (0, import_typescript2.displayPartsToString)(details.documentation);
429
+ if (details.tags) {
430
+ for (const tag of details.tags) {
431
+ documentationString += `
432
+
433
+ ${tagToString(tag)}`;
434
+ }
435
+ }
436
+ return documentationString;
437
+ }
438
+ var typescriptLanguageService = new TypeScriptLanguageService();
439
+
440
+ // src/extensions/index.ts
441
+ var import_code_language_shared2 = require("@coze-editor/code-language-shared");
442
+
443
+ // src/extensions/type-information.ts
444
+ var import_view = require("@codemirror/view");
445
+ var import_state = require("@codemirror/state");
446
+ var cmdKeyPressedState = import_state.StateField.define({
447
+ create: () => false,
448
+ update: (value, tr) => {
449
+ for (const effect of tr.effects) {
450
+ if (effect.is(setCmdKeyPressedEffect)) {
451
+ return effect.value;
452
+ }
453
+ }
454
+ return value;
455
+ }
456
+ });
457
+ var setCmdKeyPressedEffect = import_state.StateEffect.define();
458
+ var cmdKeyEventPlugin = import_view.ViewPlugin.fromClass(
459
+ class {
460
+ dispose;
461
+ constructor(view) {
462
+ const onKeyDown = (event) => {
463
+ if (event.metaKey && !view.state.field(cmdKeyPressedState)) {
464
+ view.dispatch({ effects: setCmdKeyPressedEffect.of(true) });
465
+ }
466
+ };
467
+ const onKeyUp = (event) => {
468
+ if (!event.metaKey && view.state.field(cmdKeyPressedState)) {
469
+ view.dispatch({ effects: setCmdKeyPressedEffect.of(false) });
470
+ }
471
+ };
472
+ const onBlur = () => {
473
+ if (view.state.field(cmdKeyPressedState)) {
474
+ view.dispatch({ effects: setCmdKeyPressedEffect.of(false) });
475
+ }
476
+ };
477
+ window.addEventListener("keydown", onKeyDown);
478
+ window.addEventListener("keyup", onKeyUp);
479
+ window.addEventListener("blur", onBlur);
480
+ this.dispose = () => {
481
+ window.removeEventListener("keydown", onKeyDown);
482
+ window.removeEventListener("keyup", onKeyUp);
483
+ window.removeEventListener("blur", onBlur);
484
+ };
485
+ }
486
+ destroy() {
487
+ this.dispose();
488
+ }
489
+ }
490
+ );
491
+ var getTypeInformationFacet = import_state.Facet.define({
492
+ combine(values) {
493
+ return values[values.length - 1];
494
+ }
495
+ });
496
+ var cmdHoverTooltipSource = async (view, pos, side) => {
497
+ const word = view.state.wordAt(pos);
498
+ if (!word) {
499
+ return null;
500
+ }
501
+ if (!view.state.facet(getTypeInformationFacet)) {
502
+ return null;
503
+ }
504
+ const doTypeInfoFn = view.state.facet(getTypeInformationFacet);
505
+ const info = await (doTypeInfoFn == null ? void 0 : doTypeInfoFn(view.state, word.from));
506
+ if (!info) {
507
+ return null;
508
+ }
509
+ return {
510
+ pos: word.from,
511
+ end: word.to,
512
+ above: true,
513
+ create() {
514
+ var _a;
515
+ const dom = document.createElement("div");
516
+ dom.className = "cm-type-tooltip";
517
+ const cmdPressed = view.state.field(cmdKeyPressedState, false);
518
+ dom.style.display = cmdPressed ? "block" : "none";
519
+ if ((_a = info == null ? void 0 : info.properties) == null ? void 0 : _a.length) {
520
+ const propsDiv = document.createElement("div");
521
+ propsDiv.className = "cm-type-tooltip-properties";
522
+ const propsHeader = document.createElement("div");
523
+ propsHeader.className = "cm-type-tooltip-props-header";
524
+ propsHeader.textContent = "Properties:";
525
+ propsDiv.appendChild(propsHeader);
526
+ const propsList = document.createElement("ul");
527
+ propsList.className = "cm-type-tooltip-props-list";
528
+ info.properties.forEach((prop) => {
529
+ if (prop && typeof prop.name === "string" && typeof prop.type === "string") {
530
+ const propItem = document.createElement("li");
531
+ propItem.className = "cm-type-tooltip-prop-item";
532
+ const propName = document.createElement("span");
533
+ propName.className = "cm-type-tooltip-prop-name";
534
+ propName.textContent = prop.name;
535
+ propItem.appendChild(propName);
536
+ const separator = document.createTextNode(": ");
537
+ propItem.appendChild(separator);
538
+ const propType = document.createElement("span");
539
+ propType.className = "cm-type-tooltip-prop-type";
540
+ propType.textContent = prop.type;
541
+ propItem.appendChild(propType);
542
+ propsList.appendChild(propItem);
543
+ }
544
+ });
545
+ propsDiv.appendChild(propsList);
546
+ dom.appendChild(propsDiv);
547
+ }
548
+ return {
549
+ dom,
550
+ update(update) {
551
+ for (const tr of update.transactions) {
552
+ for (const effect of tr.effects) {
553
+ if (effect.is(setCmdKeyPressedEffect)) {
554
+ const show = effect.value;
555
+ dom.style.display = show ? "block" : "none";
556
+ break;
557
+ }
558
+ }
559
+ }
560
+ }
561
+ };
562
+ }
563
+ };
564
+ };
565
+ var tooltipTheme = import_view.EditorView.theme({
566
+ ".cm-tooltip .cm-type-tooltip": {
567
+ padding: "0 10px 6px 10px",
568
+ maxWidth: "350px"
569
+ },
570
+ ".cm-type-tooltip-properties": {
571
+ paddingTop: "6px"
572
+ },
573
+ ".cm-type-tooltip-props-header": {
574
+ fontWeight: "bold",
575
+ marginBottom: "4px",
576
+ color: "#E06C75"
577
+ },
578
+ ".cm-type-tooltip-props-list": {
579
+ listStyle: "none",
580
+ margin: "0"
581
+ },
582
+ ".cm-type-tooltip-prop-item": {
583
+ marginBottom: "3px"
584
+ },
585
+ ".cm-type-tooltip-prop-name": {
586
+ color: "#E5C07B"
587
+ },
588
+ ".cm-type-tooltip-prop-type": {
589
+ color: "#ABB2BF"
590
+ }
591
+ });
592
+ function typeInformation(getTypeInformation) {
593
+ return [
594
+ getTypeInformationFacet.of(getTypeInformation),
595
+ tooltipTheme,
596
+ cmdKeyPressedState,
597
+ cmdKeyEventPlugin,
598
+ (0, import_view.hoverTooltip)(cmdHoverTooltipSource, {
599
+ hoverTime: 300
600
+ })
601
+ ];
602
+ }
603
+ var type_information_default = typeInformation;
604
+
605
+ // src/extensions/index.ts
606
+ var extensions = [
607
+ type_information_default(async (state, pos) => {
608
+ const { textDocument, generatedRangeFor } = state.field(import_code_language_shared2.textDocumentField);
609
+ const range = generatedRangeFor({ from: pos, to: pos });
610
+ const offset = range == null ? void 0 : range.from;
611
+ if (typeof offset !== "number") {
612
+ return null;
613
+ }
614
+ const result = await typescriptLanguageService.getTypeInformation({
615
+ textDocument,
616
+ offset
617
+ });
618
+ return result;
619
+ })
620
+ ];
621
+ var extensions_default = extensions;
622
+
623
+ // src/index.ts
624
+ var typescript = {
625
+ language: import_lang_javascript.typescriptLanguage,
626
+ languageService: typescriptLanguageService,
627
+ extensions: extensions_default
628
+ };
629
+ // Annotate the CommonJS export names for ESM import in node:
630
+ 0 && (module.exports = {
631
+ TypeScriptLanguageService,
632
+ typescript,
633
+ typescriptLanguage,
634
+ typescriptLanguageService
635
+ });
636
+ //# sourceMappingURL=index.js.map