@astrojs/language-server 2.4.0 → 2.5.0
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/parseJS.js +18 -1
- package/dist/languageServerPlugin.js +1 -1
- package/package.json +2 -2
package/dist/core/parseJS.js
CHANGED
|
@@ -101,7 +101,7 @@ function findIsolatedScripts(fileName, snapshot, roots) {
|
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Get all the inline scripts in the HTML document
|
|
104
|
-
* Inline scripts are scripts that are not hoisted by Astro and as such, are isolated from the rest of the code.
|
|
104
|
+
* Inline scripts are scripts that are not hoisted by Astro and as such, are not isolated from the rest of the code.
|
|
105
105
|
* All the inline scripts are concatenated into a single `.mjs` file and passed to the TypeScript language server.
|
|
106
106
|
*/
|
|
107
107
|
function findInlineScripts(htmlDocument, snapshot) {
|
|
@@ -112,6 +112,7 @@ function findInlineScripts(htmlDocument, snapshot) {
|
|
|
112
112
|
if (node.tag === 'script' &&
|
|
113
113
|
node.startTagEnd !== undefined &&
|
|
114
114
|
node.endTagStart !== undefined &&
|
|
115
|
+
!isJSON(node.attributes?.type) &&
|
|
115
116
|
!isIsolatedScriptTag(node)) {
|
|
116
117
|
const scriptText = snapshot.getText(node.startTagEnd, node.endTagStart);
|
|
117
118
|
inlineScripts.push({
|
|
@@ -125,6 +126,22 @@ function findInlineScripts(htmlDocument, snapshot) {
|
|
|
125
126
|
}
|
|
126
127
|
return inlineScripts;
|
|
127
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Include both MIME JSON types and `importmap` and `speculationrules` script types
|
|
131
|
+
* See MIME Types -> https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
|
132
|
+
* See Script Types -> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type
|
|
133
|
+
*/
|
|
134
|
+
const JSON_TYPES = ['application/json', 'application/ld+json', 'importmap', 'speculationrules'];
|
|
135
|
+
/**
|
|
136
|
+
* Check if the script has a type, and if it's included in JSON_TYPES above.
|
|
137
|
+
* @param type Found in the `type` attribute of the script tag
|
|
138
|
+
*/
|
|
139
|
+
function isJSON(type) {
|
|
140
|
+
if (!type)
|
|
141
|
+
return false;
|
|
142
|
+
// HTML attributes are quoted, slice " and ' at the start and end of the string
|
|
143
|
+
return JSON_TYPES.includes(type.slice(1, -1));
|
|
144
|
+
}
|
|
128
145
|
function findEventAttributes(ast) {
|
|
129
146
|
const eventAttrs = [];
|
|
130
147
|
// `@astrojs/compiler`'s `walk` method is async, so we can't use it here. Arf
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"astro-ls": "./bin/nodeServer.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@astrojs/compiler": "
|
|
23
|
+
"@astrojs/compiler": "^2.2.1",
|
|
24
24
|
"@jridgewell/sourcemap-codec": "^1.4.15",
|
|
25
25
|
"@volar/kit": "~1.10.3",
|
|
26
26
|
"@volar/language-core": "~1.10.3",
|