@astrojs/language-server 2.0.17 → 2.1.2
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/core/astro2tsx.js +0 -6
- package/dist/core/parseAstro.d.ts +0 -1
- package/dist/core/parseAstro.js +15 -4
- package/dist/core/parseJS.d.ts +1 -1
- package/dist/core/parseJS.js +10 -9
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -25
- package/dist/languageServerPlugin.js +10 -6
- package/dist/plugins/html-data.js +20 -0
- package/package.json +16 -17
package/dist/core/astro2tsx.js
CHANGED
|
@@ -111,12 +111,6 @@ function getVirtualFileTSX(input, tsx, fileName, ts, htmlDocument) {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
// Ensure that `0:0` is mapped to `0:0` to make sure we properly handle "unmapped" lines
|
|
115
|
-
mappings.push({
|
|
116
|
-
sourceRange: [0, 0],
|
|
117
|
-
generatedRange: [0, 0],
|
|
118
|
-
data: {},
|
|
119
|
-
});
|
|
120
114
|
const ast = ts.createSourceFile('/a.tsx', tsx.code, ts.ScriptTarget.ESNext);
|
|
121
115
|
if (ast.statements[0]) {
|
|
122
116
|
mappings.push({
|
package/dist/core/parseAstro.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getAstroMetadata = void 0;
|
|
4
4
|
const sync_1 = require("@astrojs/compiler/sync");
|
|
5
5
|
function getAstroMetadata(input, position = true) {
|
|
6
6
|
const parseResult = (0, sync_1.parse)(input, { position: position });
|
|
7
7
|
return {
|
|
8
8
|
...parseResult,
|
|
9
|
-
frontmatter: getFrontmatterStatus(parseResult.ast),
|
|
9
|
+
frontmatter: getFrontmatterStatus(parseResult.ast, input),
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
exports.getAstroMetadata = getAstroMetadata;
|
|
13
|
-
function getFrontmatterStatus(ast) {
|
|
13
|
+
function getFrontmatterStatus(ast, text) {
|
|
14
14
|
if (!ast.children || (ast.children && ast.children.length === 0)) {
|
|
15
15
|
return {
|
|
16
16
|
status: 'doesnt-exist',
|
|
@@ -21,6 +21,18 @@ function getFrontmatterStatus(ast) {
|
|
|
21
21
|
const frontmatter = ast.children[0];
|
|
22
22
|
if (frontmatter.position) {
|
|
23
23
|
if (frontmatter.position.end) {
|
|
24
|
+
// HACK: The compiler as of 1.5.5 always return an ending position, even if there's only a frontmatter opening
|
|
25
|
+
// This hack checks if the frontmatter's ending is the end of the file, and if so, checks if there's a `---`.
|
|
26
|
+
// If there's not, it means the compiler returned the EOF with an opened frontmatter
|
|
27
|
+
if (frontmatter.position.end.offset === text.length && !text.endsWith('---')) {
|
|
28
|
+
return {
|
|
29
|
+
status: 'open',
|
|
30
|
+
position: {
|
|
31
|
+
start: frontmatter.position.start,
|
|
32
|
+
end: undefined,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
24
36
|
return {
|
|
25
37
|
status: 'closed',
|
|
26
38
|
position: {
|
|
@@ -43,5 +55,4 @@ function getFrontmatterStatus(ast) {
|
|
|
43
55
|
position: undefined,
|
|
44
56
|
};
|
|
45
57
|
}
|
|
46
|
-
exports.getFrontmatterStatus = getFrontmatterStatus;
|
|
47
58
|
//# sourceMappingURL=parseAstro.js.map
|
package/dist/core/parseJS.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { VirtualFile } from '@volar/language-core';
|
|
|
3
3
|
import type ts from 'typescript/lib/tsserverlibrary';
|
|
4
4
|
import type { HTMLDocument, Node } from 'vscode-html-languageservice';
|
|
5
5
|
export declare function extractScriptTags(fileName: string, snapshot: ts.IScriptSnapshot, htmlDocument: HTMLDocument, ast: ParseResult['ast']): VirtualFile[];
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function isIsolatedScriptTag(scriptTag: Node): boolean;
|
|
7
7
|
export declare const htmlEventAttributes: string[];
|
package/dist/core/parseJS.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.htmlEventAttributes = exports.
|
|
26
|
+
exports.htmlEventAttributes = exports.isIsolatedScriptTag = exports.extractScriptTags = void 0;
|
|
27
27
|
const utils_1 = require("@astrojs/compiler/utils");
|
|
28
28
|
const language_core_1 = require("@volar/language-core");
|
|
29
29
|
const SourceMap = __importStar(require("@volar/source-map"));
|
|
@@ -34,7 +34,7 @@ function extractScriptTags(fileName, snapshot, htmlDocument, ast) {
|
|
|
34
34
|
if (root.tag === 'script' &&
|
|
35
35
|
root.startTagEnd !== undefined &&
|
|
36
36
|
root.endTagStart !== undefined &&
|
|
37
|
-
|
|
37
|
+
isIsolatedScriptTag(root)) {
|
|
38
38
|
const scriptText = snapshot.getText(root.startTagEnd, root.endTagStart);
|
|
39
39
|
embeddedJSFiles.push({
|
|
40
40
|
fileName: fileName + `.${index}.mts`,
|
|
@@ -103,7 +103,7 @@ function findInlineScripts(htmlDocument, snapshot) {
|
|
|
103
103
|
if (root.tag === 'script' &&
|
|
104
104
|
root.startTagEnd !== undefined &&
|
|
105
105
|
root.endTagStart !== undefined &&
|
|
106
|
-
|
|
106
|
+
!isIsolatedScriptTag(root)) {
|
|
107
107
|
const scriptText = snapshot.getText(root.startTagEnd, root.endTagStart);
|
|
108
108
|
inlineScripts.push({
|
|
109
109
|
startOffset: root.startTagEnd,
|
|
@@ -137,15 +137,16 @@ function findEventAttributes(ast) {
|
|
|
137
137
|
walkDown(ast);
|
|
138
138
|
return eventAttrs;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
// Using any kind of attributes on the script tag will disable hoisting
|
|
140
|
+
function isIsolatedScriptTag(scriptTag) {
|
|
141
|
+
// Using any kind of attributes on the script tag will disable hoisting
|
|
142
142
|
if (!scriptTag.attributes ||
|
|
143
|
-
(scriptTag.attributes && Object.entries(scriptTag.attributes).length === 0)
|
|
144
|
-
|
|
143
|
+
(scriptTag.attributes && Object.entries(scriptTag.attributes).length === 0) ||
|
|
144
|
+
scriptTag.attributes['type']?.includes('module')) {
|
|
145
|
+
return true;
|
|
145
146
|
}
|
|
146
|
-
return
|
|
147
|
+
return false;
|
|
147
148
|
}
|
|
148
|
-
exports.
|
|
149
|
+
exports.isIsolatedScriptTag = isIsolatedScriptTag;
|
|
149
150
|
exports.htmlEventAttributes = [
|
|
150
151
|
'onabort',
|
|
151
152
|
'onafterprint',
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.DiagnosticSeverity = exports.AstroCheck =
|
|
27
|
-
exports.protocol = __importStar(require("@volar/language-server/protocol"));
|
|
3
|
+
exports.DiagnosticSeverity = exports.AstroCheck = void 0;
|
|
28
4
|
var check_js_1 = require("./check.js");
|
|
29
5
|
Object.defineProperty(exports, "AstroCheck", { enumerable: true, get: function () { return check_js_1.AstroCheck; } });
|
|
30
6
|
Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return check_js_1.DiagnosticSeverity; } });
|
|
@@ -64,24 +64,28 @@ const plugin = (initOptions, modules) => ({
|
|
|
64
64
|
const prettierPluginPath = (0, importPackage_js_1.getPrettierPluginPath)(rootDir);
|
|
65
65
|
if (prettier && prettierPluginPath) {
|
|
66
66
|
config.services.prettier ??= (0, volar_service_prettier_1.default)({
|
|
67
|
+
prettier: prettier,
|
|
67
68
|
languages: ['astro'],
|
|
69
|
+
ignoreIdeOptions: true,
|
|
68
70
|
resolveConfigOptions: {
|
|
69
71
|
// Prettier's cache is a bit cumbersome, because you need to reload the config yourself on change
|
|
70
72
|
// TODO: Upstream a fix for this
|
|
71
73
|
useCache: false,
|
|
72
74
|
},
|
|
73
|
-
additionalOptions: (resolvedConfig) => {
|
|
74
|
-
function getAstroPrettierPlugin() {
|
|
75
|
+
additionalOptions: async (resolvedConfig) => {
|
|
76
|
+
async function getAstroPrettierPlugin() {
|
|
75
77
|
if (!prettier || !prettierPluginPath) {
|
|
76
78
|
return [];
|
|
77
79
|
}
|
|
78
|
-
const hasPluginLoadedAlready = prettier
|
|
79
|
-
.getSupportInfo()
|
|
80
|
-
.languages.some((l) => l.name === 'astro');
|
|
80
|
+
const hasPluginLoadedAlready = (await prettier.getSupportInfo()).languages.some((l) => l.name === 'astro');
|
|
81
81
|
return hasPluginLoadedAlready ? [] : [prettierPluginPath];
|
|
82
82
|
}
|
|
83
|
+
const plugins = [
|
|
84
|
+
...(await getAstroPrettierPlugin()),
|
|
85
|
+
...(resolvedConfig.plugins ?? []),
|
|
86
|
+
];
|
|
83
87
|
return {
|
|
84
|
-
plugins:
|
|
88
|
+
plugins: plugins,
|
|
85
89
|
parser: 'astro',
|
|
86
90
|
...resolvedConfig,
|
|
87
91
|
};
|
|
@@ -171,6 +171,26 @@ exports.astroAttributes = (0, vscode_html_languageservice_1.newHTMLDataProvider)
|
|
|
171
171
|
},
|
|
172
172
|
],
|
|
173
173
|
},
|
|
174
|
+
{
|
|
175
|
+
name: 'transition:animate',
|
|
176
|
+
description: 'Specifies an animation to use with this element on page transition.',
|
|
177
|
+
references: [
|
|
178
|
+
{
|
|
179
|
+
name: 'Astro reference',
|
|
180
|
+
url: 'https://docs.astro.build/en/guides/view-transitions/#transition-directives',
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'transition:name',
|
|
186
|
+
description: 'Specifies a `view-transition-name` for this element. The name should be unique on the page.',
|
|
187
|
+
references: [
|
|
188
|
+
{
|
|
189
|
+
name: 'Astro reference',
|
|
190
|
+
url: 'https://docs.astro.build/en/guides/view-transitions/#transition-directives',
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
},
|
|
174
194
|
slotAttr,
|
|
175
195
|
],
|
|
176
196
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
"astro-ls": "./bin/nodeServer.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@astrojs/compiler": "
|
|
23
|
+
"@astrojs/compiler": "1.5.7",
|
|
24
24
|
"@jridgewell/sourcemap-codec": "^1.4.15",
|
|
25
|
-
"@volar/kit": "1.
|
|
26
|
-
"@volar/language-core": "1.
|
|
27
|
-
"@volar/language-server": "1.
|
|
28
|
-
"@volar/language-service": "1.
|
|
29
|
-
"@volar/source-map": "1.
|
|
30
|
-
"@volar/typescript": "1.
|
|
25
|
+
"@volar/kit": "~1.9.0",
|
|
26
|
+
"@volar/language-core": "~1.9.0",
|
|
27
|
+
"@volar/language-server": "~1.9.0",
|
|
28
|
+
"@volar/language-service": "~1.9.0",
|
|
29
|
+
"@volar/source-map": "~1.9.0",
|
|
30
|
+
"@volar/typescript": "~1.9.0",
|
|
31
31
|
"fast-glob": "^3.2.12",
|
|
32
32
|
"muggle-string": "^0.3.1",
|
|
33
|
-
"volar-service-css": "0.0.
|
|
34
|
-
"volar-service-emmet": "0.0.
|
|
35
|
-
"volar-service-html": "0.0.
|
|
36
|
-
"volar-service-prettier": "0.0.
|
|
37
|
-
"volar-service-typescript": "0.0.
|
|
38
|
-
"volar-service-typescript-twoslash-queries": "0.0.
|
|
33
|
+
"volar-service-css": "0.0.10",
|
|
34
|
+
"volar-service-emmet": "0.0.10",
|
|
35
|
+
"volar-service-html": "0.0.10",
|
|
36
|
+
"volar-service-prettier": "0.0.10",
|
|
37
|
+
"volar-service-typescript": "0.0.10",
|
|
38
|
+
"volar-service-typescript-twoslash-queries": "0.0.10",
|
|
39
39
|
"vscode-html-languageservice": "^5.0.6",
|
|
40
40
|
"vscode-uri": "^3.0.7"
|
|
41
41
|
},
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"@types/chai": "^4.3.5",
|
|
46
46
|
"@types/mocha": "^10.0.1",
|
|
47
47
|
"@types/node": "^16.18.26",
|
|
48
|
-
"@types/prettier": "^2.7.3",
|
|
49
48
|
"astro": "^2.6.2",
|
|
50
49
|
"chai": "^4.3.7",
|
|
51
50
|
"mocha": "^10.2.0",
|
|
@@ -55,8 +54,8 @@
|
|
|
55
54
|
"vscode-languageserver-textdocument": "^1.0.8"
|
|
56
55
|
},
|
|
57
56
|
"peerDependencies": {
|
|
58
|
-
"prettier": "^
|
|
59
|
-
"prettier-plugin-astro": "^0.
|
|
57
|
+
"prettier": "^3.0.0",
|
|
58
|
+
"prettier-plugin-astro": "^0.11.0"
|
|
60
59
|
},
|
|
61
60
|
"peerDependenciesMeta": {
|
|
62
61
|
"prettier": {
|