@astrojs/language-server 2.16.2 → 2.16.4
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/check.js +5 -6
- package/dist/core/parseHTML.js +1 -1
- package/dist/languageServerPlugin.js +1 -1
- package/dist/plugins/astro.d.ts +1 -1
- package/dist/plugins/astro.js +1 -51
- package/dist/plugins/html-data.js +3 -3
- package/dist/plugins/typescript/utils.js +1 -1
- package/dist/plugins/typescript-addons/snippets.js +3 -3
- package/dist/plugins/yaml.js +2 -2
- package/package.json +23 -24
- package/types/env.d.ts +1 -1
- package/dist/core/compilerUtils.d.ts +0 -11
- package/dist/core/compilerUtils.js +0 -12
package/dist/check.js
CHANGED
|
@@ -32,9 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.AstroCheck = exports.DiagnosticSeverity = exports.Diagnostic = void 0;
|
|
40
37
|
const node_fs_1 = require("node:fs");
|
|
@@ -45,7 +42,7 @@ const kit = __importStar(require("@volar/kit"));
|
|
|
45
42
|
const language_server_1 = require("@volar/language-server");
|
|
46
43
|
Object.defineProperty(exports, "Diagnostic", { enumerable: true, get: function () { return language_server_1.Diagnostic; } });
|
|
47
44
|
Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return language_server_1.DiagnosticSeverity; } });
|
|
48
|
-
const
|
|
45
|
+
const tinyglobby_1 = require("tinyglobby");
|
|
49
46
|
const vscode_uri_1 = require("vscode-uri");
|
|
50
47
|
const index_js_1 = require("./core/index.js");
|
|
51
48
|
const svelte_js_1 = require("./core/svelte.js");
|
|
@@ -128,7 +125,7 @@ class AstroCheck {
|
|
|
128
125
|
(0, svelte_js_1.getSvelteLanguagePlugin)(),
|
|
129
126
|
(0, vue_js_1.getVueLanguagePlugin)(),
|
|
130
127
|
];
|
|
131
|
-
const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)(
|
|
128
|
+
const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)()];
|
|
132
129
|
if (tsconfigPath) {
|
|
133
130
|
const includeProjectReference = false; // #920
|
|
134
131
|
this.linter = kit.createTypeScriptChecker(languagePlugins, services, tsconfigPath, includeProjectReference, ({ project }) => {
|
|
@@ -139,10 +136,12 @@ class AstroCheck {
|
|
|
139
136
|
}
|
|
140
137
|
else {
|
|
141
138
|
this.linter = kit.createTypeScriptInferredChecker(languagePlugins, services, () => {
|
|
142
|
-
return
|
|
139
|
+
return (0, tinyglobby_1.globSync)('**/*.astro', {
|
|
143
140
|
cwd: this.workspacePath,
|
|
144
141
|
ignore: ['node_modules'],
|
|
145
142
|
absolute: true,
|
|
143
|
+
// Required to avoid tinyglobby running eternally
|
|
144
|
+
expandDirectories: false,
|
|
146
145
|
});
|
|
147
146
|
}, undefined, ({ project }) => {
|
|
148
147
|
const { languageServiceHost } = project.typescript;
|
package/dist/core/parseHTML.js
CHANGED
|
@@ -83,7 +83,7 @@ function preprocessHTML(text, frontmatterEnd) {
|
|
|
83
83
|
}
|
|
84
84
|
return content;
|
|
85
85
|
function shouldBlankStartOrEndTagLike(offset) {
|
|
86
|
-
// not null rather than falsy
|
|
86
|
+
// not null rather than falsy; otherwise, it won't work on first tag(0)
|
|
87
87
|
return (currentStartTagStart !== null && (0, utils_1.isInsideExpression)(content, currentStartTagStart, offset));
|
|
88
88
|
}
|
|
89
89
|
function blankStartOrEndTagLike(offset, state) {
|
|
@@ -38,7 +38,7 @@ function getLanguageServicePlugins(connection, ts, collectionConfig, initializeP
|
|
|
38
38
|
}),
|
|
39
39
|
(0, volar_service_typescript_twoslash_queries_1.create)(ts),
|
|
40
40
|
(0, index_js_2.create)(),
|
|
41
|
-
(0, astro_js_1.create)(
|
|
41
|
+
(0, astro_js_1.create)(),
|
|
42
42
|
getPrettierService(),
|
|
43
43
|
(0, yaml_js_1.create)(collectionConfig),
|
|
44
44
|
];
|
package/dist/plugins/astro.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LanguageServicePlugin } from '@volar/language-server';
|
|
2
|
-
export declare const create: (
|
|
2
|
+
export declare const create: () => LanguageServicePlugin;
|
package/dist/plugins/astro.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.create = void 0;
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
4
|
const language_server_1 = require("@volar/language-server");
|
|
9
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
10
5
|
const vscode_uri_1 = require("vscode-uri");
|
|
11
6
|
const index_js_1 = require("../core/index.js");
|
|
12
|
-
const
|
|
13
|
-
const create = (ts) => {
|
|
7
|
+
const create = () => {
|
|
14
8
|
return {
|
|
15
9
|
capabilities: {
|
|
16
10
|
completionProvider: {
|
|
@@ -20,7 +14,6 @@ const create = (ts) => {
|
|
|
20
14
|
interFileDependencies: false,
|
|
21
15
|
workspaceDiagnostics: false,
|
|
22
16
|
},
|
|
23
|
-
codeLensProvider: {},
|
|
24
17
|
},
|
|
25
18
|
create(context) {
|
|
26
19
|
return {
|
|
@@ -64,54 +57,11 @@ const create = (ts) => {
|
|
|
64
57
|
};
|
|
65
58
|
}
|
|
66
59
|
},
|
|
67
|
-
provideCodeLenses(document, token) {
|
|
68
|
-
if (token.isCancellationRequested)
|
|
69
|
-
return;
|
|
70
|
-
if (!(0, utils_js_1.isJSDocument)(document.languageId))
|
|
71
|
-
return;
|
|
72
|
-
if (!context.project.typescript)
|
|
73
|
-
return;
|
|
74
|
-
const { uriConverter } = context.project.typescript;
|
|
75
|
-
const languageService = context.inject('typescript/languageService');
|
|
76
|
-
if (!languageService)
|
|
77
|
-
return;
|
|
78
|
-
const tsProgram = languageService.getProgram();
|
|
79
|
-
if (!tsProgram)
|
|
80
|
-
return;
|
|
81
|
-
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
|
82
|
-
if (!decoded)
|
|
83
|
-
return;
|
|
84
|
-
const globcodeLens = [];
|
|
85
|
-
const sourceFile = tsProgram.getSourceFile(decoded[0].fsPath);
|
|
86
|
-
function walk() {
|
|
87
|
-
return ts.forEachChild(sourceFile, function cb(node) {
|
|
88
|
-
if (ts.isCallExpression(node) && node.expression.getText() === 'Astro.glob') {
|
|
89
|
-
const globArgument = node.arguments.at(0);
|
|
90
|
-
if (globArgument && decoded) {
|
|
91
|
-
globcodeLens.push(getGlobResultAsCodeLens(globArgument.getText().slice(1, -1), (0, node_path_1.dirname)(uriConverter.asFileName(decoded[0])), document.positionAt(node.arguments.pos)));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return ts.forEachChild(node, cb);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
walk();
|
|
98
|
-
return globcodeLens;
|
|
99
|
-
},
|
|
100
60
|
};
|
|
101
61
|
},
|
|
102
62
|
};
|
|
103
63
|
};
|
|
104
64
|
exports.create = create;
|
|
105
|
-
function getGlobResultAsCodeLens(globText, dir, position) {
|
|
106
|
-
const globResult = fast_glob_1.default.sync(globText, {
|
|
107
|
-
cwd: dir,
|
|
108
|
-
onlyFiles: true,
|
|
109
|
-
});
|
|
110
|
-
return {
|
|
111
|
-
range: language_server_1.Range.create(position, position),
|
|
112
|
-
command: { title: `Matches ${globResult.length} files`, command: '' },
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
65
|
function getFrontmatterCompletion(file, document, position) {
|
|
116
66
|
const base = {
|
|
117
67
|
kind: language_server_1.CompletionItemKind.Snippet,
|
|
@@ -28,7 +28,7 @@ exports.astroElements = (0, vscode_html_languageservice_1.newHTMLDataProvider)('
|
|
|
28
28
|
references: [
|
|
29
29
|
{
|
|
30
30
|
name: 'Astro reference',
|
|
31
|
-
url: 'https://docs.astro.build/en/
|
|
31
|
+
url: 'https://docs.astro.build/en/basics/astro-components/#slots',
|
|
32
32
|
},
|
|
33
33
|
],
|
|
34
34
|
attributes: [
|
|
@@ -38,7 +38,7 @@ exports.astroElements = (0, vscode_html_languageservice_1.newHTMLDataProvider)('
|
|
|
38
38
|
references: [
|
|
39
39
|
{
|
|
40
40
|
name: 'Astro reference',
|
|
41
|
-
url: 'https://docs.astro.build/en/
|
|
41
|
+
url: 'https://docs.astro.build/en/basics/astro-components/#named-slots',
|
|
42
42
|
},
|
|
43
43
|
],
|
|
44
44
|
},
|
|
@@ -92,7 +92,7 @@ exports.astroElements = (0, vscode_html_languageservice_1.newHTMLDataProvider)('
|
|
|
92
92
|
references: [
|
|
93
93
|
{
|
|
94
94
|
name: 'Astro reference',
|
|
95
|
-
url: 'https://docs.astro.build/en/guides/view-transitions/#
|
|
95
|
+
url: 'https://docs.astro.build/en/guides/view-transitions/#data-astro-rerun',
|
|
96
96
|
},
|
|
97
97
|
],
|
|
98
98
|
},
|
|
@@ -10,7 +10,7 @@ function mapEdit(edit, code, languageId) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
// If the edit is at the start of the file, add a newline before it
|
|
13
|
+
// If the edit is at the start of the file, add a newline before it; otherwise, we'll get `<script>text`
|
|
14
14
|
if (edit.range.start.line === 0 && edit.range.start.character === 0) {
|
|
15
15
|
edit.newText = '\n' + edit.newText;
|
|
16
16
|
}
|
|
@@ -35,7 +35,7 @@ function getSnippetCompletions(frontmatter) {
|
|
|
35
35
|
value: [
|
|
36
36
|
'Create a new getStaticPaths function.',
|
|
37
37
|
'\n',
|
|
38
|
-
'[Astro reference](https://docs.astro.build/en/reference/
|
|
38
|
+
'[Astro reference](https://docs.astro.build/en/reference/routing-reference/#getstaticpaths)',
|
|
39
39
|
].join('\n'),
|
|
40
40
|
},
|
|
41
41
|
insertText: 'export const getStaticPaths = (() => {\n\t$1\n\treturn [];\n}) satisfies GetStaticPaths;',
|
|
@@ -52,9 +52,9 @@ function getSnippetCompletions(frontmatter) {
|
|
|
52
52
|
documentation: {
|
|
53
53
|
kind: 'markdown',
|
|
54
54
|
value: [
|
|
55
|
-
'Add prerender export. When [using server-side rendering](https://docs.astro.build/en/guides/
|
|
55
|
+
'Add prerender export. When [using server-side rendering](https://docs.astro.build/en/guides/on-demand-rendering/#enabling-on-demand-rendering), this value will be used to determine whether or not to prerender the page.',
|
|
56
56
|
'\n',
|
|
57
|
-
'[Astro reference](https://docs.astro.build/en/
|
|
57
|
+
'[Astro reference](https://docs.astro.build/en/reference/routing-reference/#prerender)',
|
|
58
58
|
].join('\n'),
|
|
59
59
|
},
|
|
60
60
|
insertText: 'export const prerender = ${1|true,false|}',
|
package/dist/plugins/yaml.js
CHANGED
|
@@ -47,7 +47,7 @@ const create = (collectionConfig) => {
|
|
|
47
47
|
const changedConfig = events.changes.some((change) => change.uri.endsWith('collections.json'));
|
|
48
48
|
if (changedConfig) {
|
|
49
49
|
collectionConfig.reload(
|
|
50
|
-
// For some reason, context.env.workspaceFolders is
|
|
50
|
+
// For some reason, context.env.workspaceFolders is neither an array of WorkspaceFolders nor the older format, strange
|
|
51
51
|
context.env.workspaceFolders.map((folder) => ({ uri: folder.toString() })));
|
|
52
52
|
languageService.configure(getSettings(collectionConfig));
|
|
53
53
|
}
|
|
@@ -83,7 +83,7 @@ const create = (collectionConfig) => {
|
|
|
83
83
|
diagnostic.source = 'astro';
|
|
84
84
|
// In Astro, schema errors are always fatal
|
|
85
85
|
diagnostic.severity = language_server_1.DiagnosticSeverity.Error;
|
|
86
|
-
// Map missing properties to the entire
|
|
86
|
+
// Map missing properties to the entire frontmatter
|
|
87
87
|
if (diagnostic.message.startsWith('Missing property')) {
|
|
88
88
|
diagnostic.range = language_server_1.Range.create({ line: 0, character: 0 }, document.positionAt(document.getText().length));
|
|
89
89
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.4",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/withastro/astro.git",
|
|
8
|
+
"url": "git+https://github.com/withastro/astro.git",
|
|
9
9
|
"directory": "packages/language-tools/language-server"
|
|
10
10
|
},
|
|
11
11
|
"type": "commonjs",
|
|
@@ -20,33 +20,33 @@
|
|
|
20
20
|
"astro-ls": "./bin/nodeServer.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@astrojs/compiler": "^2.
|
|
24
|
-
"@astrojs/yaml2ts": "^0.2.
|
|
25
|
-
"@jridgewell/sourcemap-codec": "^1.
|
|
26
|
-
"@volar/kit": "~2.4.
|
|
27
|
-
"@volar/language-core": "~2.4.
|
|
28
|
-
"@volar/language-server": "~2.4.
|
|
29
|
-
"@volar/language-service": "~2.4.
|
|
30
|
-
"fast-glob": "^3.2.12",
|
|
23
|
+
"@astrojs/compiler": "^2.13.1",
|
|
24
|
+
"@astrojs/yaml2ts": "^0.2.3",
|
|
25
|
+
"@jridgewell/sourcemap-codec": "^1.5.5",
|
|
26
|
+
"@volar/kit": "~2.4.28",
|
|
27
|
+
"@volar/language-core": "~2.4.28",
|
|
28
|
+
"@volar/language-server": "~2.4.28",
|
|
29
|
+
"@volar/language-service": "~2.4.28",
|
|
31
30
|
"muggle-string": "^0.4.1",
|
|
32
|
-
"
|
|
33
|
-
"volar-service-
|
|
34
|
-
"volar-service-
|
|
35
|
-
"volar-service-
|
|
36
|
-
"volar-service-
|
|
37
|
-
"volar-service-typescript
|
|
38
|
-
"volar-service-
|
|
39
|
-
"
|
|
31
|
+
"tinyglobby": "^0.2.15",
|
|
32
|
+
"volar-service-css": "0.0.68",
|
|
33
|
+
"volar-service-emmet": "0.0.68",
|
|
34
|
+
"volar-service-html": "0.0.68",
|
|
35
|
+
"volar-service-prettier": "0.0.68",
|
|
36
|
+
"volar-service-typescript": "0.0.68",
|
|
37
|
+
"volar-service-typescript-twoslash-queries": "0.0.68",
|
|
38
|
+
"volar-service-yaml": "0.0.68",
|
|
39
|
+
"vscode-html-languageservice": "^5.6.1",
|
|
40
40
|
"vscode-uri": "^3.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^20.9.0",
|
|
44
|
-
"@volar/test-utils": "~2.4.
|
|
45
|
-
"@volar/typescript": "~2.4.
|
|
46
|
-
"tsx": "^4.
|
|
44
|
+
"@volar/test-utils": "~2.4.28",
|
|
45
|
+
"@volar/typescript": "~2.4.28",
|
|
46
|
+
"tsx": "^4.21.0",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
49
|
-
"vscode-languageserver-textdocument": "^1.0.
|
|
49
|
+
"vscode-languageserver-textdocument": "^1.0.12",
|
|
50
50
|
"astro-scripts": "0.0.14"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
@@ -64,8 +64,7 @@
|
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsc",
|
|
66
66
|
"dev": "tsc --watch",
|
|
67
|
-
"
|
|
68
|
-
"test": "pnpm sync-fixture && astro-scripts test \"**/*.test.ts\" --teardown-test ./test/misc/teardown.ts --tsx true",
|
|
67
|
+
"test": "astro-scripts test \"**/*.test.ts\" --teardown-test ./test/misc/teardown.ts --tsx true --setup ./test/setup.js",
|
|
69
68
|
"test:match": "pnpm run test --match"
|
|
70
69
|
}
|
|
71
70
|
}
|
package/types/env.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Astro global available in all contexts in .astro files
|
|
3
3
|
*
|
|
4
|
-
* [Astro documentation](https://docs.astro.build/reference/api-reference
|
|
4
|
+
* [Astro documentation](https://docs.astro.build/en/reference/api-reference/)
|
|
5
5
|
*/
|
|
6
6
|
declare const Astro: any;
|
|
7
7
|
declare const Fragment: any;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AttributeNode, Point } from '@astrojs/compiler';
|
|
2
|
-
import { Position as LSPPosition } from '@volar/language-server';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Point from the Astro compiler to an LSP Position
|
|
5
|
-
*/
|
|
6
|
-
export declare function PointToPosition(point: Point): LSPPosition;
|
|
7
|
-
type WithRequired<T, K extends keyof T> = T & {
|
|
8
|
-
[P in K]-?: T[P];
|
|
9
|
-
};
|
|
10
|
-
export type AttributeNodeWithPosition = WithRequired<AttributeNode, 'position'>;
|
|
11
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PointToPosition = PointToPosition;
|
|
4
|
-
const language_server_1 = require("@volar/language-server");
|
|
5
|
-
/**
|
|
6
|
-
* Transform a Point from the Astro compiler to an LSP Position
|
|
7
|
-
*/
|
|
8
|
-
function PointToPosition(point) {
|
|
9
|
-
// Columns and lines are 0-based in LSP, but the compiler's Point are 1 based.
|
|
10
|
-
return language_server_1.Position.create(point.line - 1, point.column - 1);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=compilerUtils.js.map
|