@glint/tsserver-plugin 0.2.1 → 1.0.1-unstable.845d5fa
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/README.md +4 -4
- package/lib/typescript-server-plugin.d.ts +34 -0
- package/lib/typescript-server-plugin.d.ts.map +1 -0
- package/lib/typescript-server-plugin.js +251 -0
- package/lib/typescript-server-plugin.js.map +1 -0
- package/package.json +27 -14
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -57
- package/lib/language-service.d.ts +0 -32
- package/lib/language-service.js +0 -363
- package/lib/logging.d.ts +0 -11
- package/lib/logging.js +0 -53
- package/lib/patch/language-service-host.d.ts +0 -7
- package/lib/patch/language-service-host.js +0 -60
- package/lib/patch/lib.d.ts +0 -10
- package/lib/patch/lib.js +0 -101
- package/lib/path-transformation.d.ts +0 -15
- package/lib/path-transformation.js +0 -30
- package/lib/util/auto-import.d.ts +0 -3
- package/lib/util/auto-import.js +0 -105
- package/lib/util/logging.d.ts +0 -11
- package/lib/util/logging.js +0 -53
- package/lib/util/path-transformation.d.ts +0 -15
- package/lib/util/path-transformation.js +0 -30
- package/lib/virtual-module-manager.d.ts +0 -15
- package/lib/virtual-module-manager.js +0 -68
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @glint/typescript-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The TypeScript server plugin that performs type-checking.
|
|
4
|
+
|
|
5
|
+
Old Glint used the LanguageServer to perform type-checking; Glint 2 uses a TypeScript server plugin to follow suit with Volar.
|
|
4
6
|
|
|
5
|
-
[language service plugin]: https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin
|
|
6
|
-
[glint]: https://github.com/typed-ember/glint
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const plugin: any;
|
|
2
|
+
export = plugin;
|
|
3
|
+
/**
|
|
4
|
+
* Return semantic tokens for semantic highlighting:
|
|
5
|
+
* https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide
|
|
6
|
+
function getEncodedSemanticClassifications<T>(
|
|
7
|
+
ts: typeof import('typescript'),
|
|
8
|
+
language: any, // Language<T>,
|
|
9
|
+
languageService: ts.LanguageService,
|
|
10
|
+
asScriptId: (fileName: string) => T,
|
|
11
|
+
getEncodedSemanticClassifications: ts.LanguageService['getEncodedSemanticClassifications'],
|
|
12
|
+
): ts.LanguageService['getEncodedSemanticClassifications'] {
|
|
13
|
+
return (filePath, span, format) => {
|
|
14
|
+
const fileName = filePath.replace(windowsPathReg, '/');
|
|
15
|
+
const result = getEncodedSemanticClassifications(fileName, span, format);
|
|
16
|
+
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
17
|
+
const root = sourceScript?.generated?.root;
|
|
18
|
+
if (root instanceof VirtualGtsCode) {
|
|
19
|
+
// This would remove all semantic highlighting from .gts files, including the TS parts
|
|
20
|
+
// outside of the `<template>` tags, which is probably undesirable.
|
|
21
|
+
// result.spans = [];
|
|
22
|
+
|
|
23
|
+
// We can push span to the end of the array to override previous entries.
|
|
24
|
+
// result.spans.push(
|
|
25
|
+
// 0,
|
|
26
|
+
// 100,
|
|
27
|
+
// 256, // class
|
|
28
|
+
// );
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
*/
|
|
34
|
+
//# sourceMappingURL=typescript-server-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-server-plugin.d.ts","sourceRoot":"","sources":["../src/typescript-server-plugin.ts"],"names":[],"mappings":"AA+BA,QAAA,MAAM,MAAM,KA4IX,CAAC;AAEF,SAAS,MAAM,CAAC;AA8HhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
const { createJiti } = require('jiti');
|
|
2
|
+
const jiti = createJiti(__filename);
|
|
3
|
+
const { createLanguageServicePlugin, } = require('@volar/typescript/lib/quickstart/createLanguageServicePlugin.js');
|
|
4
|
+
/**
|
|
5
|
+
* We use the jiti (https://github.com/unjs/jiti) runtime to make it possible to
|
|
6
|
+
* synchronously load the ESM glint libraries from the current CommonJS context.
|
|
7
|
+
* It is a requirement that TypeScript plugins are written in CommonJS, which poses issues
|
|
8
|
+
* with having Glint be authored in ESM due to the requirement that typically `await import`
|
|
9
|
+
* is required to load ESM modules from CJS. But with jiti we can synchronously load the ESM
|
|
10
|
+
* modules from CJS which lets us avoid a ton of hacks and complexity we (or Volar)
|
|
11
|
+
* would otherwise have to write to bridge the sync/async APIs.
|
|
12
|
+
*/
|
|
13
|
+
let emberTscPath = '@glint/ember-tsc';
|
|
14
|
+
try {
|
|
15
|
+
// @ts-expect-error esbuild define
|
|
16
|
+
emberTscPath = EMBER_TSC_PATH;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// Ignore; must not be running in esbuild context
|
|
20
|
+
}
|
|
21
|
+
const emberTsc = jiti(emberTscPath);
|
|
22
|
+
const { VirtualGtsCode, augmentDiagnostics } = emberTsc;
|
|
23
|
+
const plugin = createLanguageServicePlugin((ts, info) => {
|
|
24
|
+
const { findConfig, createEmberLanguagePlugin } = emberTsc;
|
|
25
|
+
const cwd = info.languageServiceHost.getCurrentDirectory();
|
|
26
|
+
const glintConfig = findConfig(cwd);
|
|
27
|
+
// Uncomment as a smoke test to see if the plugin is running
|
|
28
|
+
const enableLogging = false;
|
|
29
|
+
if (glintConfig) {
|
|
30
|
+
if (enableLogging) {
|
|
31
|
+
info.project.projectService.logger.info('Glint TS Plugin is running!');
|
|
32
|
+
}
|
|
33
|
+
const gtsLanguagePlugin = createEmberLanguagePlugin(glintConfig, {
|
|
34
|
+
clientId: 'tsserver-plugin',
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
languagePlugins: [gtsLanguagePlugin],
|
|
38
|
+
setup: (language) => {
|
|
39
|
+
// project2Service.set(info.project, [
|
|
40
|
+
// language,
|
|
41
|
+
// info.languageServiceHost,
|
|
42
|
+
// info.languageService,
|
|
43
|
+
// ]);
|
|
44
|
+
info.languageService = proxyLanguageServiceForGlint(ts, language, info.languageService, (fileName) => fileName);
|
|
45
|
+
const resolveModuleNameLiterals = info.languageServiceHost.resolveModuleNameLiterals?.bind(info.languageServiceHost);
|
|
46
|
+
if (resolveModuleNameLiterals) {
|
|
47
|
+
// TS isn't aware of our custom .gts/.gjs extensions by default which causes
|
|
48
|
+
// issues with resolving imports that omit extensions. We hackishly "teach"
|
|
49
|
+
// TS about these extensions by overriding `resolveModuleNameLiterals` to
|
|
50
|
+
// inject non-existent imports that cause TS to consider the extensions when
|
|
51
|
+
// resolving.
|
|
52
|
+
//
|
|
53
|
+
// Origin of this hack:
|
|
54
|
+
// https://github.com/typed-ember/glint/issues/806#issuecomment-2758616327
|
|
55
|
+
info.languageServiceHost.resolveModuleNameLiterals = (moduleLiterals, containingFile, redirectedReference, options, ...rest) => {
|
|
56
|
+
let fakeImportNodes = [];
|
|
57
|
+
if (moduleLiterals.length > 0) {
|
|
58
|
+
fakeImportNodes.push({
|
|
59
|
+
...moduleLiterals[0],
|
|
60
|
+
text: './__NONEXISTENT_GLINT_HACK__.gts',
|
|
61
|
+
});
|
|
62
|
+
fakeImportNodes.push({
|
|
63
|
+
...moduleLiterals[0],
|
|
64
|
+
text: './__NONEXISTENT_GLINT_HACK__.gjs',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const result = resolveModuleNameLiterals([...fakeImportNodes, ...moduleLiterals], containingFile, redirectedReference, options, ...rest);
|
|
68
|
+
return result.slice(fakeImportNodes.length);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Add Glint-specific protocol handlers for tsserver communication
|
|
72
|
+
addGlintCommands();
|
|
73
|
+
// #3963
|
|
74
|
+
// const timer = setInterval(() => {
|
|
75
|
+
// if (info.project['program']) {
|
|
76
|
+
// clearInterval(timer);
|
|
77
|
+
// info.project['program'].__glint__ = { language };
|
|
78
|
+
// }
|
|
79
|
+
// }, 50);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (enableLogging) {
|
|
85
|
+
info.project.projectService.logger.info('Glint TS Plugin is NOT running!');
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
languagePlugins: [],
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// https://github.com/JetBrains/intellij-plugins/blob/6435723ad88fa296b41144162ebe3b8513f4949b/Angular/src-js/angular-service/src/index.ts#L69
|
|
92
|
+
function addGlintCommands() {
|
|
93
|
+
const projectService = info.project.projectService;
|
|
94
|
+
projectService.logger.info('Glint: called handler processing ' + info.project.projectKind);
|
|
95
|
+
const session = info.session;
|
|
96
|
+
if (session == undefined) {
|
|
97
|
+
projectService.logger.info('Glint: there is no session in info.');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (session.addProtocolHandler == undefined) {
|
|
101
|
+
// addProtocolHandler was introduced in TS 4.4 or 4.5 in 2021, see https://github.com/microsoft/TypeScript/issues/43893
|
|
102
|
+
projectService.logger.info('Glint: there is no addProtocolHandler method.');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (session.handlers.has('_glint:projectInfo')) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// Map _glint: prefixed commands to their corresponding TypeScript server commands
|
|
109
|
+
session.addProtocolHandler('_glint:projectInfo', ({ arguments: args }) => {
|
|
110
|
+
return session.handlers.get('projectInfo')?.({ arguments: args });
|
|
111
|
+
});
|
|
112
|
+
session.addProtocolHandler('_glint:documentHighlights-full', ({ arguments: args }) => {
|
|
113
|
+
return session.handlers.get('documentHighlights-full')?.({ arguments: args });
|
|
114
|
+
});
|
|
115
|
+
session.addProtocolHandler('_glint:encodedSemanticClassifications-full', ({ arguments: args }) => {
|
|
116
|
+
return session.handlers.get('encodedSemanticClassifications-full')?.({
|
|
117
|
+
arguments: args,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
session.addProtocolHandler('_glint:quickinfo', ({ arguments: args }) => {
|
|
121
|
+
return session.handlers.get('quickinfo')?.({ arguments: args });
|
|
122
|
+
});
|
|
123
|
+
projectService.logger.info('Glint specific commands are successfully added.');
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
module.exports = plugin;
|
|
127
|
+
function proxyLanguageServiceForGlint(ts, language, // Language<T>,
|
|
128
|
+
languageService, asScriptId) {
|
|
129
|
+
const proxyCache = new Map();
|
|
130
|
+
const getProxyMethod = (target, p) => {
|
|
131
|
+
switch (p) {
|
|
132
|
+
case 'getCompletionsAtPosition':
|
|
133
|
+
return getCompletionsAtPosition(ts, language, languageService, asScriptId, target[p]);
|
|
134
|
+
// case 'getCompletionEntryDetails': return getCompletionEntryDetails(language, asScriptId, target[p]);
|
|
135
|
+
// case 'getCodeFixesAtPosition': return getCodeFixesAtPosition(target[p]);
|
|
136
|
+
// case 'getDefinitionAndBoundSpan': return getDefinitionAndBoundSpan(ts, language, languageService, glintOptions, asScriptId, target[p]);
|
|
137
|
+
// case 'getQuickInfoAtPosition': return getQuickInfoAtPosition(ts, target, target[p]);
|
|
138
|
+
// TS plugin only
|
|
139
|
+
// Left as an example in case we want to augment semantic classification in .gts files.
|
|
140
|
+
// e.g. Vue does this to semantically classify Component names as `class` tokens.
|
|
141
|
+
// case 'getEncodedSemanticClassifications':
|
|
142
|
+
// return getEncodedSemanticClassifications(ts, language, target, asScriptId, target[p]);
|
|
143
|
+
case 'getSemanticDiagnostics':
|
|
144
|
+
return getSemanticDiagnostics(ts, language, languageService, asScriptId, target[p]);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return new Proxy(languageService, {
|
|
148
|
+
get(target, p, receiver) {
|
|
149
|
+
if (getProxyMethod) {
|
|
150
|
+
if (!proxyCache.has(p)) {
|
|
151
|
+
proxyCache.set(p, getProxyMethod(target, p));
|
|
152
|
+
}
|
|
153
|
+
const proxyMethod = proxyCache.get(p);
|
|
154
|
+
if (proxyMethod) {
|
|
155
|
+
return proxyMethod;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return Reflect.get(target, p, receiver);
|
|
159
|
+
},
|
|
160
|
+
set(target, p, value, receiver) {
|
|
161
|
+
return Reflect.set(target, p, value, receiver);
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function getCompletionsAtPosition(ts, language, // Language<T>,
|
|
166
|
+
languageService, asScriptId, getCompletionsAtPosition) {
|
|
167
|
+
return (fileName, position, options, formattingSettings) => {
|
|
168
|
+
try {
|
|
169
|
+
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
170
|
+
const root = sourceScript?.generated?.root;
|
|
171
|
+
const transformedModule = root?.transformedModule;
|
|
172
|
+
const completions = getCompletionsAtPosition(fileName, position, options, formattingSettings);
|
|
173
|
+
const transformedRange = transformedModule?.getTransformedRange(transformedModule.originalFileName, position, position);
|
|
174
|
+
if (completions && transformedRange) {
|
|
175
|
+
// for attribute names on elements, we do not want the wrapping `"`.
|
|
176
|
+
if (transformedRange.mapping?.parent?.sourceNode.type === 'ElementNode') {
|
|
177
|
+
completions.entries = completions.entries.map((e) => ({
|
|
178
|
+
...e,
|
|
179
|
+
name: e.name.replace(/^"/, '').replace(/"$/, ''),
|
|
180
|
+
sortText: e.sortText.replace(/\\"/g, ''),
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
console.log(completions);
|
|
185
|
+
return completions;
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
console.log('error', e?.message);
|
|
189
|
+
console.log(e);
|
|
190
|
+
throw e;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function getSemanticDiagnostics(ts, language, // Language<T>,
|
|
195
|
+
languageService, asScriptId, getSemanticDiagnostics) {
|
|
196
|
+
return (fileName) => {
|
|
197
|
+
const tsDiagnostics = getSemanticDiagnostics(fileName);
|
|
198
|
+
const program = languageService.getProgram();
|
|
199
|
+
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
200
|
+
if (!sourceScript?.generated) {
|
|
201
|
+
return tsDiagnostics;
|
|
202
|
+
}
|
|
203
|
+
const root = sourceScript.generated.root;
|
|
204
|
+
if (!(root instanceof VirtualGtsCode)) {
|
|
205
|
+
return tsDiagnostics;
|
|
206
|
+
}
|
|
207
|
+
const transformedModule = root.transformedModule;
|
|
208
|
+
if (!transformedModule) {
|
|
209
|
+
return tsDiagnostics;
|
|
210
|
+
}
|
|
211
|
+
const sourceFile = program.getSourceFile(fileName);
|
|
212
|
+
if (!sourceFile) {
|
|
213
|
+
return tsDiagnostics;
|
|
214
|
+
}
|
|
215
|
+
const augmentedTsDiagnostics = augmentDiagnostics(transformedModule, tsDiagnostics);
|
|
216
|
+
return augmentedTsDiagnostics;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
const windowsPathReg = /\\/g;
|
|
220
|
+
/**
|
|
221
|
+
* Return semantic tokens for semantic highlighting:
|
|
222
|
+
* https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide
|
|
223
|
+
function getEncodedSemanticClassifications<T>(
|
|
224
|
+
ts: typeof import('typescript'),
|
|
225
|
+
language: any, // Language<T>,
|
|
226
|
+
languageService: ts.LanguageService,
|
|
227
|
+
asScriptId: (fileName: string) => T,
|
|
228
|
+
getEncodedSemanticClassifications: ts.LanguageService['getEncodedSemanticClassifications'],
|
|
229
|
+
): ts.LanguageService['getEncodedSemanticClassifications'] {
|
|
230
|
+
return (filePath, span, format) => {
|
|
231
|
+
const fileName = filePath.replace(windowsPathReg, '/');
|
|
232
|
+
const result = getEncodedSemanticClassifications(fileName, span, format);
|
|
233
|
+
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
234
|
+
const root = sourceScript?.generated?.root;
|
|
235
|
+
if (root instanceof VirtualGtsCode) {
|
|
236
|
+
// This would remove all semantic highlighting from .gts files, including the TS parts
|
|
237
|
+
// outside of the `<template>` tags, which is probably undesirable.
|
|
238
|
+
// result.spans = [];
|
|
239
|
+
|
|
240
|
+
// We can push span to the end of the array to override previous entries.
|
|
241
|
+
// result.spans.push(
|
|
242
|
+
// 0,
|
|
243
|
+
// 100,
|
|
244
|
+
// 256, // class
|
|
245
|
+
// );
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
*/
|
|
251
|
+
//# sourceMappingURL=typescript-server-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-server-plugin.js","sourceRoot":"","sources":["../src/typescript-server-plugin.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACvC,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;AAIpC,MAAM,EACJ,2BAA2B,GAC5B,GAAG,OAAO,CAAC,iEAAiE,CAAC,CAAC;AAE/E;;;;;;;;GAQG;AACH,IAAI,YAAY,GAAG,kBAAkB,CAAC;AACtC,IAAI,CAAC;IACH,kCAAkC;IAClC,YAAY,GAAG,cAAc,CAAC;AAChC,CAAC;AAAC,MAAM,CAAC;IACP,iDAAiD;AACnD,CAAC;AACD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;AAEpC,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CAAC;AAExD,MAAM,MAAM,GAAG,2BAA2B,CACxC,CAAC,EAA+B,EAAE,IAAgC,EAAE,EAAE;IACpE,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE,GAAG,QAAQ,CAAC;IAE3D,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,CAAC;IAC3D,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAEpC,4DAA4D;IAC5D,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AAiB,EAAE,aAAa,CAAC,CAAC;QAEpF,OAAO,sBAAsB,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glint/tsserver-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1-unstable.845d5fa",
|
|
4
|
+
"type": "commonjs",
|
|
4
5
|
"repository": "typed-ember/glint",
|
|
5
|
-
"description": "
|
|
6
|
+
"description": "TypeScript Server Plugin for Glint",
|
|
6
7
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
8
|
+
"main": "lib/typescript-server-plugin.js",
|
|
9
|
+
"authors": [
|
|
10
|
+
"Alex Matchneer (https://github.com/machty)"
|
|
11
|
+
],
|
|
10
12
|
"files": [
|
|
11
13
|
"README.md",
|
|
12
14
|
"lib"
|
|
13
15
|
],
|
|
14
16
|
"scripts": {
|
|
15
|
-
"
|
|
16
|
-
"test": "
|
|
17
|
+
"test": "echo 'no standalone tests within this project'",
|
|
18
|
+
"test:typecheck": "echo 'no standalone typecheck within this project'",
|
|
19
|
+
"test:tsc": "echo 'no standalone typecheck within this project'",
|
|
17
20
|
"build": "tsc --build",
|
|
18
|
-
"prepack": "
|
|
21
|
+
"prepack": "pnpm build"
|
|
19
22
|
},
|
|
20
23
|
"dependencies": {
|
|
21
|
-
"@glint/
|
|
22
|
-
"@
|
|
24
|
+
"@glint/ember-tsc": "1.0.1-unstable.845d5fa",
|
|
25
|
+
"@volar/language-core": "2.4.23",
|
|
26
|
+
"@volar/typescript": "2.4.23",
|
|
27
|
+
"jiti": "~2.4.2",
|
|
28
|
+
"typescript": ">=5.6.0"
|
|
23
29
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
"release-plan": {
|
|
31
|
+
"semverIncrementAs": {
|
|
32
|
+
"major": "prerelease",
|
|
33
|
+
"minor": "prerelease",
|
|
34
|
+
"patch": "prerelease"
|
|
35
|
+
},
|
|
36
|
+
"semverIncrementTag": "alpha",
|
|
37
|
+
"publishTag": "alpha"
|
|
28
38
|
},
|
|
29
39
|
"publishConfig": {
|
|
30
40
|
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^22.13.11"
|
|
31
44
|
}
|
|
32
45
|
}
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
const path_1 = __importDefault(require("path"));
|
|
6
|
-
const config_1 = require("@glint/config");
|
|
7
|
-
const virtual_module_manager_1 = __importDefault(require("./virtual-module-manager"));
|
|
8
|
-
const lib_1 = require("./patch/lib");
|
|
9
|
-
const language_service_host_1 = require("./patch/language-service-host");
|
|
10
|
-
const logging_1 = require("./util/logging");
|
|
11
|
-
const language_service_1 = __importDefault(require("./language-service"));
|
|
12
|
-
const init = ({ typescript: ts }) => {
|
|
13
|
-
const modules = new virtual_module_manager_1.default(ts);
|
|
14
|
-
lib_1.patchLib(ts, modules);
|
|
15
|
-
return {
|
|
16
|
-
create(info) {
|
|
17
|
-
let logger = logging_1.loggerFor(info);
|
|
18
|
-
let config = config_1.loadConfig(path_1.default.dirname(info.project.projectName));
|
|
19
|
-
logger.log('\nStarting @glint/tsserver-plugin at', new Date().toString());
|
|
20
|
-
language_service_host_1.patchLanguageServiceHost(config, info);
|
|
21
|
-
modules.addProject(config, info.project);
|
|
22
|
-
let glintService = new language_service_1.default(ts, modules, info);
|
|
23
|
-
let fullService = makeProxy(info.languageService, glintService);
|
|
24
|
-
if (info.config.logLanguageServiceMethodCalls) {
|
|
25
|
-
installMethodLogging(logger, fullService);
|
|
26
|
-
}
|
|
27
|
-
return fullService;
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
function makeProxy(base, glint) {
|
|
32
|
-
return new Proxy(base, {
|
|
33
|
-
get(_, key) {
|
|
34
|
-
if (key in glint) {
|
|
35
|
-
return glint[key];
|
|
36
|
-
}
|
|
37
|
-
return base[key];
|
|
38
|
-
},
|
|
39
|
-
set(_, key, value) {
|
|
40
|
-
glint[key] = value;
|
|
41
|
-
return true;
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function installMethodLogging(logger, service) {
|
|
46
|
-
for (let _key in service) {
|
|
47
|
-
let key = _key;
|
|
48
|
-
let f = service[key];
|
|
49
|
-
if (typeof f === 'function') {
|
|
50
|
-
service[key] = ((...params) => {
|
|
51
|
-
logger.log(key, params[0]);
|
|
52
|
-
return f.apply(service, params);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
module.exports = init;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import VirtualModuleManager from './virtual-module-manager';
|
|
3
|
-
export default class GlintLanguageService implements Partial<ts.LanguageService> {
|
|
4
|
-
private readonly ts;
|
|
5
|
-
private readonly modules;
|
|
6
|
-
private readonly ls;
|
|
7
|
-
private readonly logger;
|
|
8
|
-
constructor(ts: typeof import('typescript/lib/tsserverlibrary'), modules: VirtualModuleManager, info: ts.server.PluginCreateInfo);
|
|
9
|
-
private getTransformInfoForOriginalPath;
|
|
10
|
-
private getTransformInfoForTransformedPath;
|
|
11
|
-
private getTransformInfo;
|
|
12
|
-
getSyntacticDiagnostics(fileName: string): ts.DiagnosticWithLocation[];
|
|
13
|
-
getSemanticDiagnostics(fileName: string): ts.Diagnostic[];
|
|
14
|
-
getSuggestionDiagnostics(fileName: string): ts.DiagnosticWithLocation[];
|
|
15
|
-
getEncodedSyntacticClassifications(fileName: string, span: ts.TextSpan): ts.Classifications;
|
|
16
|
-
getEncodedSemanticClassifications(fileName: string, span: ts.TextSpan): ts.Classifications;
|
|
17
|
-
getCompletionsAtPosition(fileName: string, offset: number, options: ts.GetCompletionsAtPositionOptions | undefined): ts.WithMetadata<ts.CompletionInfo> | undefined;
|
|
18
|
-
getCompletionEntryDetails(fileName: string, offset: number, name: string, formatOptions: ts.FormatCodeOptions | ts.FormatCodeSettings | undefined, source: string | undefined, preferences: ts.UserPreferences | undefined): ts.CompletionEntryDetails | undefined;
|
|
19
|
-
getCompletionEntrySymbol(fileName: string, offset: number, name: string, source: string | undefined): ts.Symbol | undefined;
|
|
20
|
-
getQuickInfoAtPosition(fileName: string, offset: number): ts.QuickInfo | undefined;
|
|
21
|
-
getRenameInfo(fileName: string, offset: number, options?: ts.RenameInfoOptions | undefined): ts.RenameInfo;
|
|
22
|
-
findRenameLocations(fileName: string, offset: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean | undefined): readonly ts.RenameLocation[] | undefined;
|
|
23
|
-
getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: ts.FormatCodeSettings, preferences: ts.UserPreferences | undefined): readonly ts.FileTextChanges[];
|
|
24
|
-
getDefinitionAtPosition(fileName: string, offset: number): readonly ts.DefinitionInfo[] | undefined;
|
|
25
|
-
getDefinitionAndBoundSpan(fileName: string, offset: number): ts.DefinitionInfoAndBoundSpan | undefined;
|
|
26
|
-
getReferencesAtPosition(fileName: string, offset: number): ts.ReferenceEntry[] | undefined;
|
|
27
|
-
findReferences(fileName: string, offset: number): ts.ReferencedSymbol[] | undefined;
|
|
28
|
-
private rewriteDefinition;
|
|
29
|
-
private rewriteReferenceEntries;
|
|
30
|
-
private rewriteDocumentSpan;
|
|
31
|
-
private rewriteCodeAction;
|
|
32
|
-
}
|