@astrojs/ts-plugin 1.0.9 → 1.1.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/README.md +25 -1
- package/dist/astro2tsx.d.ts +15 -2
- package/dist/astro2tsx.js +142 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.js +24 -0
- package/dist/language.d.ts +17 -0
- package/dist/language.js +47 -0
- package/package.json +10 -3
- package/.turbo/turbo-build.log +0 -4
- package/CHANGELOG.md +0 -113
- package/dist/astro-snapshots.d.ts +0 -44
- package/dist/astro-sys.d.ts +0 -6
- package/dist/language-service/completions.d.ts +0 -3
- package/dist/language-service/definition.d.ts +0 -3
- package/dist/language-service/diagnostics.d.ts +0 -7
- package/dist/language-service/file-references.d.ts +0 -3
- package/dist/language-service/find-references.d.ts +0 -4
- package/dist/language-service/implementation.d.ts +0 -3
- package/dist/language-service/index.d.ts +0 -5
- package/dist/language-service/line-column-offset.d.ts +0 -3
- package/dist/language-service/rename.d.ts +0 -4
- package/dist/logger.d.ts +0 -8
- package/dist/module-loader.d.ts +0 -13
- package/dist/project-astro-files.d.ts +0 -28
- package/dist/utils.d.ts +0 -16
- package/src/astro-snapshots.ts +0 -285
- package/src/astro-sys.ts +0 -35
- package/src/astro2tsx.ts +0 -26
- package/src/index.ts +0 -84
- package/src/language-service/completions.ts +0 -73
- package/src/language-service/definition.ts +0 -42
- package/src/language-service/diagnostics.ts +0 -73
- package/src/language-service/file-references.ts +0 -34
- package/src/language-service/find-references.ts +0 -90
- package/src/language-service/implementation.ts +0 -34
- package/src/language-service/index.ts +0 -56
- package/src/language-service/line-column-offset.ts +0 -24
- package/src/language-service/rename.ts +0 -46
- package/src/logger.ts +0 -41
- package/src/module-loader.ts +0 -219
- package/src/project-astro-files.ts +0 -138
- package/src/utils.ts +0 -77
- package/test/fixtures/MyAstroComponent.astro +0 -5
- package/test/fixtures/script.ts +0 -9
- package/test/fixtures/tsconfig.json +0 -3
- package/test/runTest.js +0 -43
- package/test/suite/extension.test.js +0 -78
- package/test/suite/index.js +0 -38
- package/test/tsconfig.json +0 -14
- package/test/utils.js +0 -69
- package/tsconfig.json +0 -13
package/README.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
1
|
# @astrojs/ts-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Using the Astro VS Code extension? This plugin is automatically installed and configured for you.
|
|
4
|
+
|
|
5
|
+
TypeScript plugin adding support for `.astro` imports in `.ts` files. This plugin also adds support for renaming symbols and finding references across `.ts` and `.astro` files.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev @astrojs/ts-plugin
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Add the plugin to your `tsconfig.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"compilerOptions": {
|
|
20
|
+
"plugins": [
|
|
21
|
+
{
|
|
22
|
+
"name": "@astrojs/ts-plugin"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
package/dist/astro2tsx.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function astro2tsx(
|
|
1
|
+
import { VirtualFile } from '@volar/language-core';
|
|
2
|
+
export declare function astro2tsx(input: string, fileName: string, ts: typeof import('typescript/lib/tsserverlibrary.js')): {
|
|
3
|
+
virtualFile: VirtualFile;
|
|
4
|
+
diagnostics: import("@astrojs/compiler").DiagnosticMessage[] | {
|
|
5
|
+
code: 1000;
|
|
6
|
+
location: {
|
|
7
|
+
file: string;
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
length: number;
|
|
11
|
+
};
|
|
12
|
+
severity: 1;
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.astro2tsx = void 0;
|
|
7
|
+
const sync_1 = require("@astrojs/compiler/sync");
|
|
8
|
+
const sourcemap_codec_1 = require("@jridgewell/sourcemap-codec");
|
|
9
|
+
const language_core_1 = require("@volar/language-core");
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
12
|
+
function safeConvertToTSX(content, options) {
|
|
13
|
+
try {
|
|
14
|
+
const tsx = (0, sync_1.convertToTSX)(content, { filename: options.filename });
|
|
15
|
+
return tsx;
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.error(`There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.`);
|
|
19
|
+
return {
|
|
20
|
+
code: '',
|
|
21
|
+
map: {
|
|
22
|
+
file: options.filename ?? '',
|
|
23
|
+
sources: [],
|
|
24
|
+
sourcesContent: [],
|
|
25
|
+
names: [],
|
|
26
|
+
mappings: '',
|
|
27
|
+
version: 0,
|
|
28
|
+
},
|
|
29
|
+
diagnostics: [
|
|
30
|
+
{
|
|
31
|
+
code: 1000,
|
|
32
|
+
location: { file: options.filename, line: 1, column: 1, length: content.length },
|
|
33
|
+
severity: 1,
|
|
34
|
+
text: `The Astro compiler encountered an unknown error while parsing this file. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/language-tools/issues`,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function astro2tsx(input, fileName, ts) {
|
|
41
|
+
const tsx = safeConvertToTSX(input, { filename: fileName });
|
|
42
|
+
return {
|
|
43
|
+
virtualFile: getVirtualFileTSX(input, tsx, fileName, ts),
|
|
44
|
+
diagnostics: tsx.diagnostics,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.astro2tsx = astro2tsx;
|
|
48
|
+
function getVirtualFileTSX(input, tsx, fileName, ts) {
|
|
49
|
+
tsx.code = patchTSX(tsx.code, fileName);
|
|
50
|
+
const v3Mappings = (0, sourcemap_codec_1.decode)(tsx.map.mappings);
|
|
51
|
+
const sourcedDoc = vscode_languageserver_textdocument_1.TextDocument.create(fileName, 'astro', 0, input);
|
|
52
|
+
const genDoc = vscode_languageserver_textdocument_1.TextDocument.create(fileName + '.tsx', 'typescriptreact', 0, tsx.code);
|
|
53
|
+
const mappings = [];
|
|
54
|
+
let current;
|
|
55
|
+
for (let genLine = 0; genLine < v3Mappings.length; genLine++) {
|
|
56
|
+
for (const segment of v3Mappings[genLine]) {
|
|
57
|
+
const genCharacter = segment[0];
|
|
58
|
+
const genOffset = genDoc.offsetAt({ line: genLine, character: genCharacter });
|
|
59
|
+
if (current) {
|
|
60
|
+
let length = genOffset - current.genOffset;
|
|
61
|
+
const sourceText = input.substring(current.sourceOffset, current.sourceOffset + length);
|
|
62
|
+
const genText = tsx.code.substring(current.genOffset, current.genOffset + length);
|
|
63
|
+
if (sourceText !== genText) {
|
|
64
|
+
length = 0;
|
|
65
|
+
for (let i = 0; i < genOffset - current.genOffset; i++) {
|
|
66
|
+
if (sourceText[i] === genText[i]) {
|
|
67
|
+
length = i + 1;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (length > 0) {
|
|
75
|
+
const lastMapping = mappings.length ? mappings[mappings.length - 1] : undefined;
|
|
76
|
+
if (lastMapping &&
|
|
77
|
+
lastMapping.generatedRange[1] === current.genOffset &&
|
|
78
|
+
lastMapping.sourceRange[1] === current.sourceOffset) {
|
|
79
|
+
lastMapping.generatedRange[1] = current.genOffset + length;
|
|
80
|
+
lastMapping.sourceRange[1] = current.sourceOffset + length;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
mappings.push({
|
|
84
|
+
sourceRange: [current.sourceOffset, current.sourceOffset + length],
|
|
85
|
+
generatedRange: [current.genOffset, current.genOffset + length],
|
|
86
|
+
data: language_core_1.FileRangeCapabilities.full,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
current = undefined;
|
|
91
|
+
}
|
|
92
|
+
if (segment[2] !== undefined && segment[3] !== undefined) {
|
|
93
|
+
const sourceOffset = sourcedDoc.offsetAt({ line: segment[2], character: segment[3] });
|
|
94
|
+
current = {
|
|
95
|
+
genOffset,
|
|
96
|
+
sourceOffset,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const ast = ts.createSourceFile('/a.tsx', tsx.code, ts.ScriptTarget.ESNext);
|
|
102
|
+
if (ast.statements[0]) {
|
|
103
|
+
mappings.push({
|
|
104
|
+
sourceRange: [0, input.length],
|
|
105
|
+
generatedRange: [ast.statements[0].getStart(ast), tsx.code.length],
|
|
106
|
+
data: {},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
fileName: fileName + '.tsx',
|
|
111
|
+
kind: language_core_1.FileKind.TypeScriptHostFile,
|
|
112
|
+
capabilities: {
|
|
113
|
+
codeAction: true,
|
|
114
|
+
documentFormatting: false,
|
|
115
|
+
diagnostic: true,
|
|
116
|
+
documentSymbol: true,
|
|
117
|
+
inlayHint: true,
|
|
118
|
+
foldingRange: true,
|
|
119
|
+
},
|
|
120
|
+
codegenStacks: [],
|
|
121
|
+
snapshot: {
|
|
122
|
+
getText: (start, end) => tsx.code.substring(start, end),
|
|
123
|
+
getLength: () => tsx.code.length,
|
|
124
|
+
getChangeRange: () => undefined,
|
|
125
|
+
},
|
|
126
|
+
mappings: mappings,
|
|
127
|
+
embeddedFiles: [],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function patchTSX(code, fileName) {
|
|
131
|
+
const basename = node_path_1.default.basename(fileName, node_path_1.default.extname(fileName));
|
|
132
|
+
const isDynamic = basename.startsWith('[') && basename.endsWith(']');
|
|
133
|
+
return code.replace(/\b(\S*)__AstroComponent_/gm, (fullMatch, m1) => {
|
|
134
|
+
// If we don't have a match here, it usually means the file has a weird name that couldn't be expressed with valid identifier characters
|
|
135
|
+
if (!m1) {
|
|
136
|
+
if (basename === '404')
|
|
137
|
+
return 'FourOhFour';
|
|
138
|
+
return fullMatch;
|
|
139
|
+
}
|
|
140
|
+
return isDynamic ? `_${m1}_` : m1[0].toUpperCase() + m1.slice(1);
|
|
141
|
+
});
|
|
142
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
declare
|
|
3
|
-
typescript: typeof import('typescript/lib/tsserverlibrary');
|
|
4
|
-
}): {
|
|
5
|
-
create: (info: ts.server.PluginCreateInfo) => ts.LanguageService;
|
|
6
|
-
getExternalFiles: (project: ts.server.ConfiguredProject) => string[];
|
|
7
|
-
};
|
|
2
|
+
declare const init: ts.server.PluginModuleFactory;
|
|
8
3
|
export = init;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const language_core_1 = require("@volar/language-core");
|
|
3
|
+
const typescript_1 = require("@volar/typescript");
|
|
4
|
+
const language_js_1 = require("./language.js");
|
|
5
|
+
const externalFiles = new WeakMap();
|
|
6
|
+
const init = (modules) => {
|
|
7
|
+
const { typescript: ts } = modules;
|
|
8
|
+
const pluginModule = {
|
|
9
|
+
create(info) {
|
|
10
|
+
const virtualFiles = (0, language_core_1.createVirtualFiles)([(0, language_js_1.getLanguageModule)(ts)]);
|
|
11
|
+
(0, typescript_1.decorateLanguageService)(virtualFiles, info.languageService, true);
|
|
12
|
+
(0, typescript_1.decorateLanguageServiceHost)(virtualFiles, info.languageServiceHost, ts, ['.astro']);
|
|
13
|
+
return info.languageService;
|
|
14
|
+
},
|
|
15
|
+
getExternalFiles(project) {
|
|
16
|
+
if (!externalFiles.has(project)) {
|
|
17
|
+
externalFiles.set(project, (0, typescript_1.getExternalFiles)(ts, project, ['.astro']));
|
|
18
|
+
}
|
|
19
|
+
return externalFiles.get(project);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return pluginModule;
|
|
23
|
+
};
|
|
24
|
+
module.exports = init;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FileCapabilities, FileKind, type Language, type VirtualFile } from '@volar/language-core';
|
|
2
|
+
import type ts from 'typescript/lib/tsserverlibrary.js';
|
|
3
|
+
export declare function getLanguageModule(ts: typeof import('typescript/lib/tsserverlibrary.js')): Language<AstroFile>;
|
|
4
|
+
export declare class AstroFile implements VirtualFile {
|
|
5
|
+
sourceFileName: string;
|
|
6
|
+
snapshot: ts.IScriptSnapshot;
|
|
7
|
+
private readonly ts;
|
|
8
|
+
kind: FileKind;
|
|
9
|
+
capabilities: FileCapabilities;
|
|
10
|
+
fileName: string;
|
|
11
|
+
mappings: VirtualFile['mappings'];
|
|
12
|
+
embeddedFiles: VirtualFile['embeddedFiles'];
|
|
13
|
+
codegenStacks: never[];
|
|
14
|
+
constructor(sourceFileName: string, snapshot: ts.IScriptSnapshot, ts: typeof import('typescript/lib/tsserverlibrary.js'));
|
|
15
|
+
update(newSnapshot: ts.IScriptSnapshot): void;
|
|
16
|
+
onSnapshotUpdated(): void;
|
|
17
|
+
}
|
package/dist/language.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AstroFile = exports.getLanguageModule = void 0;
|
|
4
|
+
const language_core_1 = require("@volar/language-core");
|
|
5
|
+
const astro2tsx_js_1 = require("./astro2tsx.js");
|
|
6
|
+
function getLanguageModule(ts) {
|
|
7
|
+
return {
|
|
8
|
+
createVirtualFile(fileName, snapshot) {
|
|
9
|
+
if (fileName.endsWith('.astro')) {
|
|
10
|
+
return new AstroFile(fileName, snapshot, ts);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
updateVirtualFile(astroFile, snapshot) {
|
|
14
|
+
astroFile.update(snapshot);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.getLanguageModule = getLanguageModule;
|
|
19
|
+
class AstroFile {
|
|
20
|
+
constructor(sourceFileName, snapshot, ts) {
|
|
21
|
+
this.sourceFileName = sourceFileName;
|
|
22
|
+
this.snapshot = snapshot;
|
|
23
|
+
this.ts = ts;
|
|
24
|
+
this.kind = language_core_1.FileKind.TextFile;
|
|
25
|
+
this.capabilities = language_core_1.FileCapabilities.full;
|
|
26
|
+
this.codegenStacks = [];
|
|
27
|
+
this.fileName = sourceFileName;
|
|
28
|
+
this.onSnapshotUpdated();
|
|
29
|
+
}
|
|
30
|
+
update(newSnapshot) {
|
|
31
|
+
this.snapshot = newSnapshot;
|
|
32
|
+
this.onSnapshotUpdated();
|
|
33
|
+
}
|
|
34
|
+
onSnapshotUpdated() {
|
|
35
|
+
this.mappings = [
|
|
36
|
+
{
|
|
37
|
+
sourceRange: [0, this.snapshot.getLength()],
|
|
38
|
+
generatedRange: [0, this.snapshot.getLength()],
|
|
39
|
+
data: language_core_1.FileRangeCapabilities.full,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
this.embeddedFiles = [];
|
|
43
|
+
const tsx = (0, astro2tsx_js_1.astro2tsx)(this.snapshot.getText(0, this.snapshot.getLength()), this.fileName, this.ts);
|
|
44
|
+
this.embeddedFiles.push(tsx.virtualFile);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.AstroFile = AstroFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/ts-plugin",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A TypeScript Plugin providing Astro intellisense",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -15,11 +15,18 @@
|
|
|
15
15
|
"javascript",
|
|
16
16
|
"plugin"
|
|
17
17
|
],
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/**/*.js",
|
|
20
|
+
"dist/**/*.d.ts"
|
|
21
|
+
],
|
|
18
22
|
"author": "withastro",
|
|
19
23
|
"license": "MIT",
|
|
20
24
|
"dependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
25
|
+
"@volar/language-core": "~1.9.0",
|
|
26
|
+
"@volar/typescript": "~1.9.0",
|
|
27
|
+
"@astrojs/compiler": "1.5.7",
|
|
28
|
+
"@jridgewell/sourcemap-codec": "^1.4.15",
|
|
29
|
+
"vscode-languageserver-textdocument": "^1.0.8"
|
|
23
30
|
},
|
|
24
31
|
"devDependencies": {
|
|
25
32
|
"@types/chai": "^4.3.5",
|
package/.turbo/turbo-build.log
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# @astrojs/ts-plugin
|
|
2
|
-
|
|
3
|
-
## 1.0.9
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- b6a98e0: Better handle when the Astro compiler fails to parse a file
|
|
8
|
-
|
|
9
|
-
## 1.0.8
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- 170a193: Update dependencies
|
|
14
|
-
|
|
15
|
-
## 1.0.7
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- c6cf1d7: Update Prettier plugin version
|
|
20
|
-
|
|
21
|
-
## 1.0.6
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- 3fcbc1a: Fix TypeScript plugin crashing at start in certain circumstances
|
|
26
|
-
|
|
27
|
-
## 1.0.5
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- ae15420: Fix importing `.astro` files in `.ts` files not working with TypeScript 5.0+
|
|
32
|
-
|
|
33
|
-
## 1.0.4
|
|
34
|
-
|
|
35
|
-
### Patch Changes
|
|
36
|
-
|
|
37
|
-
- eaefe96: Fix packaging error
|
|
38
|
-
|
|
39
|
-
## 1.0.3
|
|
40
|
-
|
|
41
|
-
### Patch Changes
|
|
42
|
-
|
|
43
|
-
- 685513b: Improve stability related to converting files to TSX
|
|
44
|
-
|
|
45
|
-
## 1.0.0
|
|
46
|
-
|
|
47
|
-
### Major Changes
|
|
48
|
-
|
|
49
|
-
- 39a7669: 1.0! This release includes no new changes by itself, but symbolize the official release of what was previously the pre-release version of the extension. For changelogs, please refer to the changelog from `0.29.0` to now.
|
|
50
|
-
|
|
51
|
-
## 0.4.5
|
|
52
|
-
|
|
53
|
-
### Patch Changes
|
|
54
|
-
|
|
55
|
-
- 8ff8bdf: Update compiler version to fix Windows mapping issue
|
|
56
|
-
|
|
57
|
-
## 0.4.4
|
|
58
|
-
|
|
59
|
-
### Patch Changes
|
|
60
|
-
|
|
61
|
-
- c04adf3: Upgrade compiler version to 1.1.1
|
|
62
|
-
|
|
63
|
-
## 0.4.3
|
|
64
|
-
|
|
65
|
-
### Patch Changes
|
|
66
|
-
|
|
67
|
-
- 6b81412: Added an explanation on how to generate types for content collections to the error message for the `astro:content` import
|
|
68
|
-
|
|
69
|
-
## 0.4.2
|
|
70
|
-
|
|
71
|
-
### Patch Changes
|
|
72
|
-
|
|
73
|
-
- 94a9b61: Add proper support for renaming symbols inside Astro (.astro) files
|
|
74
|
-
|
|
75
|
-
## 0.4.1
|
|
76
|
-
|
|
77
|
-
### Patch Changes
|
|
78
|
-
|
|
79
|
-
- 985515d: Update `@astrojs/compiler`, fixing a few bugs
|
|
80
|
-
|
|
81
|
-
## 0.4.0
|
|
82
|
-
|
|
83
|
-
### Minor Changes
|
|
84
|
-
|
|
85
|
-
- c8cdef9: Improved support for `.astro` imports inside JavaScript/TypeScript files:
|
|
86
|
-
- Added support for finding file references inside Astro files
|
|
87
|
-
- Added support for path completions for .astro, .md and .mdx files
|
|
88
|
-
- Fixed cases where our TypeScript plugin would fail to load under certain circumstance
|
|
89
|
-
- Fixed certain cases where Go to definition / implementation would fail
|
|
90
|
-
|
|
91
|
-
## 0.3.0
|
|
92
|
-
|
|
93
|
-
### Minor Changes
|
|
94
|
-
|
|
95
|
-
- b66ae70: Update the VS Code extension to use a bundled version of the language server for better performance and compatibility with running the extension in the web
|
|
96
|
-
|
|
97
|
-
## 0.2.1
|
|
98
|
-
|
|
99
|
-
### Patch Changes
|
|
100
|
-
|
|
101
|
-
- d056cd5: Fixes production bugs in extension
|
|
102
|
-
|
|
103
|
-
## 0.2.0
|
|
104
|
-
|
|
105
|
-
### Minor Changes
|
|
106
|
-
|
|
107
|
-
- 6b6b47a: Remove internal astro.d.ts files, instead prefer the one provided by Astro itself
|
|
108
|
-
|
|
109
|
-
## 0.1.1
|
|
110
|
-
|
|
111
|
-
### Patch Changes
|
|
112
|
-
|
|
113
|
-
- f1f3091: Fix commenting, namespaced elements, and Fragment typings
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { TraceMap } from '@jridgewell/trace-mapping';
|
|
2
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
-
import type { Logger } from './logger.js';
|
|
4
|
-
export declare class AstroSnapshot {
|
|
5
|
-
private typescript;
|
|
6
|
-
private fileName;
|
|
7
|
-
private astroCode;
|
|
8
|
-
private traceMap;
|
|
9
|
-
private logger;
|
|
10
|
-
private scriptInfo?;
|
|
11
|
-
private lineOffsets?;
|
|
12
|
-
private convertInternalCodePositions;
|
|
13
|
-
constructor(typescript: typeof ts, fileName: string, astroCode: string, traceMap: TraceMap, logger: Logger);
|
|
14
|
-
update(astroCode: string, traceMap: TraceMap): void;
|
|
15
|
-
getOriginalTextSpan(textSpan: ts.TextSpan): ts.TextSpan | null;
|
|
16
|
-
getOriginalOffset(generatedOffset: number): number;
|
|
17
|
-
setAndPatchScriptInfo(scriptInfo: ts.server.ScriptInfo): void;
|
|
18
|
-
/**
|
|
19
|
-
* Get the line and character based on the offset
|
|
20
|
-
* @param offset The index of the position
|
|
21
|
-
*/
|
|
22
|
-
positionAt(offset: number): ts.LineAndCharacter;
|
|
23
|
-
/**
|
|
24
|
-
* Get the index of the line and character position
|
|
25
|
-
* @param position Line and character position
|
|
26
|
-
*/
|
|
27
|
-
offsetAt(position: ts.LineAndCharacter): number;
|
|
28
|
-
private getLineOffsets;
|
|
29
|
-
private clamp;
|
|
30
|
-
private log;
|
|
31
|
-
private debug;
|
|
32
|
-
private toggleMappingMode;
|
|
33
|
-
private getText;
|
|
34
|
-
}
|
|
35
|
-
export declare class AstroSnapshotManager {
|
|
36
|
-
private typescript;
|
|
37
|
-
private projectService;
|
|
38
|
-
private logger;
|
|
39
|
-
private snapshots;
|
|
40
|
-
constructor(typescript: typeof ts, projectService: ts.server.ProjectService, logger: Logger);
|
|
41
|
-
get(fileName: string): AstroSnapshot | undefined;
|
|
42
|
-
create(fileName: string): AstroSnapshot | undefined;
|
|
43
|
-
private patchProjectServiceReadFile;
|
|
44
|
-
}
|
package/dist/astro-sys.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type { Logger } from './logger.js';
|
|
3
|
-
/**
|
|
4
|
-
* This should only be accessed by TS astro module resolution.
|
|
5
|
-
*/
|
|
6
|
-
export declare function createAstroSys(logger: Logger, typescript: typeof import('typescript/lib/tsserverlibrary')): ts.System;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type { AstroSnapshotManager } from '../astro-snapshots.js';
|
|
3
|
-
import type { Logger } from '../logger';
|
|
4
|
-
export declare function decorateFindReferences(ls: ts.LanguageService, snapshotManager: AstroSnapshotManager, logger: Logger): void;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type { AstroSnapshotManager } from '../astro-snapshots.js';
|
|
3
|
-
import type { Logger } from '../logger';
|
|
4
|
-
export declare function isPatched(ls: ts.LanguageService): boolean;
|
|
5
|
-
export declare function decorateLanguageService(ls: ts.LanguageService, snapshotManager: AstroSnapshotManager, ts: typeof import('typescript/lib/tsserverlibrary'), logger: Logger): ts.LanguageService;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type { AstroSnapshotManager } from '../astro-snapshots.js';
|
|
3
|
-
import type { Logger } from '../logger.js';
|
|
4
|
-
export declare function decorateRename(ls: ts.LanguageService, snapshotManager: AstroSnapshotManager, logger: Logger): void;
|
package/dist/logger.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
export declare class Logger {
|
|
3
|
-
private tsLogService;
|
|
4
|
-
private logDebug;
|
|
5
|
-
constructor(tsLogService: ts.server.Logger, suppressNonAstroLogs?: boolean, logDebug?: boolean);
|
|
6
|
-
log(...args: any[]): void;
|
|
7
|
-
debug(...args: any[]): void;
|
|
8
|
-
}
|
package/dist/module-loader.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type { AstroSnapshotManager } from './astro-snapshots.js';
|
|
3
|
-
import type { Logger } from './logger.js';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a module loader than can also resolve `.astro` files.
|
|
6
|
-
*
|
|
7
|
-
* The typescript language service tries to look up other files that are referenced in the currently open astro file.
|
|
8
|
-
* For `.ts`/`.js` files this works, for `.astro` files it does not by default.
|
|
9
|
-
* Reason: The typescript language service does not know about the `.astro` file ending,
|
|
10
|
-
* so it assumes it's a normal typescript file and searches for files like `../Component.astro.ts`, which is wrong.
|
|
11
|
-
* In order to fix this, we need to wrap typescript's module resolution and reroute all `.astro.ts` file lookups to .astro.
|
|
12
|
-
*/
|
|
13
|
-
export declare function patchModuleLoader(logger: Logger, snapshotManager: AstroSnapshotManager, typescript: typeof ts, lsHost: ts.LanguageServiceHost, project: ts.server.Project): void;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type { AstroSnapshotManager } from './astro-snapshots';
|
|
3
|
-
export declare class ProjectAstroFilesManager {
|
|
4
|
-
private readonly typescript;
|
|
5
|
-
private readonly project;
|
|
6
|
-
private readonly serverHost;
|
|
7
|
-
private readonly snapshotManager;
|
|
8
|
-
private parsedCommandLine;
|
|
9
|
-
private files;
|
|
10
|
-
private directoryWatchers;
|
|
11
|
-
private static instances;
|
|
12
|
-
static getInstance(projectName: string): ProjectAstroFilesManager | undefined;
|
|
13
|
-
constructor(typescript: typeof ts, project: ts.server.Project, serverHost: ts.server.ServerHost, snapshotManager: AstroSnapshotManager, parsedCommandLine: ts.ParsedCommandLine);
|
|
14
|
-
updateProjectConfig(serviceHost: ts.LanguageServiceHost): void;
|
|
15
|
-
getFiles(): string[];
|
|
16
|
-
/**
|
|
17
|
-
* Create directory watcher for include and exclude
|
|
18
|
-
* The watcher in tsserver doesn't support astro file
|
|
19
|
-
* It won't add new created astro file to root
|
|
20
|
-
*/
|
|
21
|
-
private setupWatchers;
|
|
22
|
-
private watcherCallback;
|
|
23
|
-
private updateProjectAstroFiles;
|
|
24
|
-
private addFileToProject;
|
|
25
|
-
private removeFileFromProject;
|
|
26
|
-
private disposeWatchersAndFiles;
|
|
27
|
-
dispose(): void;
|
|
28
|
-
}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
export declare function isAstroFilePath(filePath: string): boolean;
|
|
3
|
-
export declare function isVirtualAstroFilePath(filePath: string): boolean;
|
|
4
|
-
export declare function toRealAstroFilePath(filePath: string): string;
|
|
5
|
-
export declare function ensureRealAstroFilePath(filePath: string): string;
|
|
6
|
-
export declare function isNotNullOrUndefined<T>(val: T | undefined | null): val is T;
|
|
7
|
-
/**
|
|
8
|
-
* Replace all occurrences of a string within an object with another string,
|
|
9
|
-
*/
|
|
10
|
-
export declare function replaceDeep<T extends Record<string, any>>(obj: T, searchStr: string | RegExp, replacementStr: string): T;
|
|
11
|
-
export declare function getConfigPathForProject(project: ts.server.Project): ts.server.NormalizedPath;
|
|
12
|
-
export declare function readProjectAstroFilesFromFs(ts: typeof import('typescript/lib/tsserverlibrary'), project: ts.server.Project, parsedCommandLine: ts.ParsedCommandLine): ts.server.NormalizedPath[];
|
|
13
|
-
export interface TsFilesSpec {
|
|
14
|
-
include?: readonly string[];
|
|
15
|
-
exclude?: readonly string[];
|
|
16
|
-
}
|