typescript-svelte-plugin 0.3.30 → 0.3.32
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.
|
@@ -420,6 +420,7 @@ exports.kitExports = {
|
|
|
420
420
|
DELETE: createApiExport('DELETE'),
|
|
421
421
|
OPTIONS: createApiExport('OPTIONS'),
|
|
422
422
|
HEAD: createApiExport('HEAD'),
|
|
423
|
+
fallback: createApiExport('fallback'),
|
|
423
424
|
// param matching
|
|
424
425
|
match: {
|
|
425
426
|
allowedIn: [],
|
|
@@ -471,6 +472,7 @@ exports.kitExports = {
|
|
|
471
472
|
]
|
|
472
473
|
}
|
|
473
474
|
};
|
|
475
|
+
const FORCE_UPDATE_VERSION = 'FORCE_UPDATE_VERSION';
|
|
474
476
|
function isKitRouteExportAllowedIn(basename, kitExport) {
|
|
475
477
|
if (!basename.startsWith('+')) {
|
|
476
478
|
return false;
|
|
@@ -597,9 +599,10 @@ function getProxiedLanguageService(info, ts, logger) {
|
|
|
597
599
|
return [...names];
|
|
598
600
|
}
|
|
599
601
|
getKitScriptSnapshotIfUpToDate(fileName) {
|
|
602
|
+
const scriptVersion = this.getScriptVersion(fileName);
|
|
600
603
|
if (!this.files[fileName] ||
|
|
601
|
-
|
|
602
|
-
|
|
604
|
+
(scriptVersion !== originalLanguageServiceHost.getScriptVersion(fileName) &&
|
|
605
|
+
scriptVersion !== FORCE_UPDATE_VERSION)) {
|
|
603
606
|
return undefined;
|
|
604
607
|
}
|
|
605
608
|
return this.files[fileName];
|
|
@@ -616,8 +619,14 @@ function getProxiedLanguageService(info, ts, logger) {
|
|
|
616
619
|
const { text, addedCode } = result;
|
|
617
620
|
const snap = ts.ScriptSnapshot.fromString(text);
|
|
618
621
|
snap.getChangeRange = (_) => undefined;
|
|
622
|
+
// If this is a new file, typescript might have cached the unpatched version
|
|
623
|
+
// It won't update even if we return the patched version in getScriptSnapshot, so we force an update
|
|
624
|
+
// This should only happen to files that are opened by the client after the first compilation of the proxy language service
|
|
625
|
+
// and won't happen if there are any updates to the file afterwards
|
|
619
626
|
this.files[fileName] = {
|
|
620
|
-
version:
|
|
627
|
+
version: this.files[fileName] === undefined
|
|
628
|
+
? FORCE_UPDATE_VERSION
|
|
629
|
+
: originalLanguageServiceHost.getScriptVersion(fileName),
|
|
621
630
|
file: snap,
|
|
622
631
|
addedCode
|
|
623
632
|
};
|
|
@@ -32,6 +32,7 @@ export declare class ProjectSvelteFilesManager {
|
|
|
32
32
|
private readProjectSvelteFilesFromFs;
|
|
33
33
|
private onConfigChanged;
|
|
34
34
|
private removeFileFromProject;
|
|
35
|
-
private
|
|
35
|
+
private disposeWatchers;
|
|
36
|
+
private clearProjectFile;
|
|
36
37
|
dispose(): void;
|
|
37
38
|
}
|
|
@@ -27,7 +27,8 @@ class ProjectSvelteFilesManager {
|
|
|
27
27
|
if (!parsedCommandLine) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
this.
|
|
30
|
+
this.disposeWatchers();
|
|
31
|
+
this.clearProjectFile();
|
|
31
32
|
this.parsedCommandLine = parsedCommandLine;
|
|
32
33
|
this.setupWatchers();
|
|
33
34
|
this.updateProjectSvelteFiles();
|
|
@@ -109,7 +110,8 @@ class ProjectSvelteFilesManager {
|
|
|
109
110
|
.map(this.typescript.server.toNormalizedPath);
|
|
110
111
|
}
|
|
111
112
|
onConfigChanged(config) {
|
|
112
|
-
this.
|
|
113
|
+
this.disposeWatchers();
|
|
114
|
+
this.clearProjectFile();
|
|
113
115
|
if (config.enable) {
|
|
114
116
|
this.setupWatchers();
|
|
115
117
|
this.updateProjectSvelteFiles();
|
|
@@ -121,14 +123,20 @@ class ProjectSvelteFilesManager {
|
|
|
121
123
|
this.project.removeFile(info, exists, true);
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
|
-
|
|
126
|
+
disposeWatchers() {
|
|
125
127
|
this.directoryWatchers.forEach((watcher) => watcher.close());
|
|
126
128
|
this.directoryWatchers.clear();
|
|
129
|
+
}
|
|
130
|
+
clearProjectFile() {
|
|
127
131
|
this.projectFileToOriginalCasing.forEach((file) => this.removeFileFromProject(file));
|
|
128
132
|
this.projectFileToOriginalCasing.clear();
|
|
129
133
|
}
|
|
130
134
|
dispose() {
|
|
131
|
-
this.
|
|
135
|
+
this.disposeWatchers();
|
|
136
|
+
// Don't remove files from the project here
|
|
137
|
+
// because TypeScript already does that when the project is closed
|
|
138
|
+
// - and because the project is closed, `project.removeFile` will result in an error
|
|
139
|
+
this.projectFileToOriginalCasing.clear();
|
|
132
140
|
ProjectSvelteFilesManager.instances.delete(this.project.getProjectName());
|
|
133
141
|
}
|
|
134
142
|
}
|
package/dist/src/svelte-sys.js
CHANGED
|
@@ -14,6 +14,12 @@ function createSvelteSys(ts, logger) {
|
|
|
14
14
|
readDirectory(path, extensions, exclude, include, depth) {
|
|
15
15
|
const extensionsWithSvelte = (extensions ?? []).concat('.svelte');
|
|
16
16
|
return ts.sys.readDirectory(path, extensionsWithSvelte, exclude, include, depth);
|
|
17
|
+
},
|
|
18
|
+
readFile(path, encoding) {
|
|
19
|
+
// imba typescript plugin patch this with Object.defineProperty
|
|
20
|
+
// and copying the property descriptor from a class that extends the original ts.sys
|
|
21
|
+
// so we explicitly define it here
|
|
22
|
+
return ts.sys.readFile(path, encoding);
|
|
17
23
|
}
|
|
18
24
|
};
|
|
19
25
|
if (ts.sys.realpath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-svelte-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"description": "A TypeScript Plugin providing Svelte intellisense",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
"author": "The Svelte Community",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@tsconfig/node16": "^1.0.0",
|
|
16
15
|
"@types/node": "^16.0.0",
|
|
17
|
-
"typescript": "
|
|
16
|
+
"typescript": "^5.2.2"
|
|
18
17
|
},
|
|
19
18
|
"dependencies": {
|
|
20
19
|
"@jridgewell/sourcemap-codec": "^1.4.14",
|