typescript-svelte-plugin 0.3.39 → 0.3.40
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/src/index.js +2 -1
- package/dist/src/language-service/call-hierarchy.js +1 -2
- package/dist/src/language-service/code-action.d.ts +5 -0
- package/dist/src/language-service/code-action.js +133 -0
- package/dist/src/language-service/completions.js +1 -2
- package/dist/src/language-service/definition.js +1 -2
- package/dist/src/language-service/diagnostics.js +1 -2
- package/dist/src/language-service/file-references.js +1 -2
- package/dist/src/language-service/find-references.js +1 -2
- package/dist/src/language-service/host.js +1 -2
- package/dist/src/language-service/hover.js +1 -2
- package/dist/src/language-service/implementation.js +1 -2
- package/dist/src/language-service/index.js +4 -3
- package/dist/src/language-service/inlay-hints.js +1 -2
- package/dist/src/language-service/move-to-file.js +1 -2
- package/dist/src/language-service/navigate-to-items.js +1 -2
- package/dist/src/language-service/rename.js +1 -2
- package/dist/src/language-service/sveltekit.js +3 -3
- package/dist/src/language-service/update-imports.js +1 -2
- package/dist/src/module-loader.js +1 -2
- package/dist/src/svelte-sys.js +1 -2
- package/dist/src/utils.js +22 -23
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -98,7 +98,8 @@ function init(modules) {
|
|
|
98
98
|
// don't clear semantic cache here
|
|
99
99
|
// typescript now expected the program updates to be completely in their control
|
|
100
100
|
// doing so will result in a crash
|
|
101
|
-
|
|
101
|
+
// @ts-expect-error internal API since TS 5.5
|
|
102
|
+
info.project.markAsDirty?.();
|
|
102
103
|
// updateGraph checks for new root files
|
|
103
104
|
// if there's no tsconfig there isn't root files to check
|
|
104
105
|
if (projectSvelteFilesManager) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateCallHierarchy =
|
|
3
|
+
exports.decorateCallHierarchy = decorateCallHierarchy;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const ENSURE_COMPONENT_HELPER = '__sveltets_2_ensureComponent';
|
|
6
6
|
function decorateCallHierarchy(ls, snapshotManager, typescript) {
|
|
@@ -223,5 +223,4 @@ function decorateCallHierarchy(ls, snapshotManager, typescript) {
|
|
|
223
223
|
}) ?? null);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
|
-
exports.decorateCallHierarchy = decorateCallHierarchy;
|
|
227
226
|
//# sourceMappingURL=call-hierarchy.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decorateQuickFixAndRefactor = decorateQuickFixAndRefactor;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function decorateQuickFixAndRefactor(ls, ts, snapshotManager) {
|
|
6
|
+
const getEditsForRefactor = ls.getEditsForRefactor;
|
|
7
|
+
const getCodeFixesAtPosition = ls.getCodeFixesAtPosition;
|
|
8
|
+
ls.getEditsForRefactor = (...args) => {
|
|
9
|
+
const result = getEditsForRefactor(...args);
|
|
10
|
+
if (!result) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const edits = result.edits.map(mapFileTextChanges).filter(utils_1.isNotNullOrUndefined);
|
|
14
|
+
if (edits.length === 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
...result,
|
|
19
|
+
edits
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
ls.getCodeFixesAtPosition = (...args) => {
|
|
23
|
+
const result = getCodeFixesAtPosition(...args);
|
|
24
|
+
return result
|
|
25
|
+
.map((fix) => {
|
|
26
|
+
return {
|
|
27
|
+
...fix,
|
|
28
|
+
changes: fix.changes.map(mapFileTextChanges).filter(utils_1.isNotNullOrUndefined)
|
|
29
|
+
};
|
|
30
|
+
})
|
|
31
|
+
.filter((fix) => fix.changes.length > 0);
|
|
32
|
+
};
|
|
33
|
+
function mapFileTextChanges(change) {
|
|
34
|
+
const snapshot = snapshotManager.get(change.fileName);
|
|
35
|
+
if (!(0, utils_1.isSvelteFilePath)(change.fileName) || !snapshot) {
|
|
36
|
+
return change;
|
|
37
|
+
}
|
|
38
|
+
let baseIndent;
|
|
39
|
+
const getBaseIndent = () => {
|
|
40
|
+
if (baseIndent !== undefined) {
|
|
41
|
+
return baseIndent;
|
|
42
|
+
}
|
|
43
|
+
baseIndent = getIndentOfFirstStatement(ts, ls, change.fileName, snapshot);
|
|
44
|
+
return baseIndent;
|
|
45
|
+
};
|
|
46
|
+
const textChanges = change.textChanges
|
|
47
|
+
.map((textChange) => mapEdit(textChange, snapshot, getBaseIndent))
|
|
48
|
+
.filter(utils_1.isNotNullOrUndefined);
|
|
49
|
+
// If part of the text changes are invalid, filter out the whole change
|
|
50
|
+
if (textChanges.length === 0 || textChanges.length !== change.textChanges.length) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
...change,
|
|
55
|
+
textChanges
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function mapEdit(change, snapshot, getBaseIndent) {
|
|
60
|
+
const isNewImportStatement = change.newText.trimStart().startsWith('import');
|
|
61
|
+
if (isNewImportStatement) {
|
|
62
|
+
return mapNewImport(change, snapshot, getBaseIndent);
|
|
63
|
+
}
|
|
64
|
+
const span = snapshot.getOriginalTextSpan(change.span);
|
|
65
|
+
if (!span) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
span,
|
|
70
|
+
newText: change.newText
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function mapNewImport(change, snapshot, getBaseIndent) {
|
|
74
|
+
const previousLineEnds = getPreviousLineEnds(snapshot.getText(), change.span.start);
|
|
75
|
+
if (previousLineEnds === -1) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const mappable = snapshot.getOriginalTextSpan({
|
|
79
|
+
start: previousLineEnds,
|
|
80
|
+
length: 0
|
|
81
|
+
});
|
|
82
|
+
if (!mappable) {
|
|
83
|
+
// There might not be any import at all but this is rare enough so ignore for now
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const originalText = snapshot.getOriginalText();
|
|
87
|
+
const span = {
|
|
88
|
+
start: originalText.indexOf('\n', mappable.start) + 1,
|
|
89
|
+
length: change.span.length
|
|
90
|
+
};
|
|
91
|
+
const baseIndent = getBaseIndent();
|
|
92
|
+
let newText = baseIndent
|
|
93
|
+
? change.newText
|
|
94
|
+
.split('\n')
|
|
95
|
+
.map((line) => (line ? baseIndent + line : line))
|
|
96
|
+
.join('\n')
|
|
97
|
+
: change.newText;
|
|
98
|
+
return { span, newText };
|
|
99
|
+
}
|
|
100
|
+
function getPreviousLineEnds(text, start) {
|
|
101
|
+
const index = text.lastIndexOf('\n', start);
|
|
102
|
+
if (index === -1) {
|
|
103
|
+
return index;
|
|
104
|
+
}
|
|
105
|
+
if (text[index - 1] === '\r') {
|
|
106
|
+
return index - 1;
|
|
107
|
+
}
|
|
108
|
+
return index;
|
|
109
|
+
}
|
|
110
|
+
function getIndentOfFirstStatement(ts, ls, fileName, snapshot) {
|
|
111
|
+
const firstExportOrImport = ls
|
|
112
|
+
.getProgram()
|
|
113
|
+
?.getSourceFile(fileName)
|
|
114
|
+
?.statements.find((node) => ts.isExportDeclaration(node) || ts.isImportDeclaration(node));
|
|
115
|
+
const originalPosition = firstExportOrImport
|
|
116
|
+
? snapshot.getOriginalOffset(firstExportOrImport.getStart())
|
|
117
|
+
: -1;
|
|
118
|
+
if (originalPosition === -1) {
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
const source = snapshot.getOriginalText();
|
|
122
|
+
const start = source.lastIndexOf('\n', originalPosition) + 1;
|
|
123
|
+
let index = start;
|
|
124
|
+
while (index < originalPosition) {
|
|
125
|
+
const char = source[index];
|
|
126
|
+
if (char.trim()) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
index++;
|
|
130
|
+
}
|
|
131
|
+
return source.substring(start, index);
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=code-action.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateCompletions =
|
|
3
|
+
exports.decorateCompletions = decorateCompletions;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const sveltekit_1 = require("./sveltekit");
|
|
@@ -199,7 +199,6 @@ function decorateCompletions(ls, info, ts, logger) {
|
|
|
199
199
|
return getSignatureHelpItems(fileName, position, options);
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
exports.decorateCompletions = decorateCompletions;
|
|
203
202
|
function adjustPath(path) {
|
|
204
203
|
return path.replace(/(['"])(.+?)['"]/,
|
|
205
204
|
// .js logic for node16 module resolution
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateGetDefinition =
|
|
3
|
+
exports.decorateGetDefinition = decorateGetDefinition;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const sveltekit_1 = require("./sveltekit");
|
|
6
6
|
function decorateGetDefinition(ls, info, ts, snapshotManager, logger) {
|
|
@@ -38,7 +38,6 @@ function decorateGetDefinition(ls, info, ts, snapshotManager, logger) {
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
exports.decorateGetDefinition = decorateGetDefinition;
|
|
42
41
|
function getKitDefinitions(ts, info, fileName, position) {
|
|
43
42
|
const result = (0, sveltekit_1.getVirtualLS)(fileName, info, ts);
|
|
44
43
|
if (!result)
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.decorateDiagnostics =
|
|
6
|
+
exports.decorateDiagnostics = decorateDiagnostics;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const svelte2tsx_1 = require("svelte2tsx");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
@@ -13,7 +13,6 @@ function decorateDiagnostics(ls, info, typescript, logger) {
|
|
|
13
13
|
decorateSemanticDiagnostics(ls, info, typescript, logger);
|
|
14
14
|
decorateSuggestionDiagnostics(ls, info, typescript, logger);
|
|
15
15
|
}
|
|
16
|
-
exports.decorateDiagnostics = decorateDiagnostics;
|
|
17
16
|
function decorateSyntacticDiagnostics(ls, info, typescript, logger) {
|
|
18
17
|
const getSyntacticDiagnostics = ls.getSyntacticDiagnostics;
|
|
19
18
|
ls.getSyntacticDiagnostics = (fileName) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateFileReferences =
|
|
3
|
+
exports.decorateFileReferences = decorateFileReferences;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
function decorateFileReferences(ls, snapshotManager) {
|
|
6
6
|
const getFileReferences = ls.getFileReferences;
|
|
@@ -23,5 +23,4 @@ function decorateFileReferences(ls, snapshotManager) {
|
|
|
23
23
|
.filter(utils_1.isNotNullOrUndefined);
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
exports.decorateFileReferences = decorateFileReferences;
|
|
27
26
|
//# sourceMappingURL=file-references.js.map
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateFindReferences =
|
|
3
|
+
exports.decorateFindReferences = decorateFindReferences;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
function decorateFindReferences(ls, snapshotManager, logger) {
|
|
6
6
|
decorateGetReferencesAtPosition(ls, snapshotManager, logger);
|
|
7
7
|
_decorateFindReferences(ls, snapshotManager, logger);
|
|
8
8
|
}
|
|
9
|
-
exports.decorateFindReferences = decorateFindReferences;
|
|
10
9
|
function _decorateFindReferences(ls, snapshotManager, logger) {
|
|
11
10
|
const findReferences = ls.findReferences;
|
|
12
11
|
const getReferences = (fileName, position) => findReferences(fileName, position)?.reduce((acc, curr) => acc.concat(curr.references), []);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateLanguageServiceHost =
|
|
3
|
+
exports.decorateLanguageServiceHost = decorateLanguageServiceHost;
|
|
4
4
|
function decorateLanguageServiceHost(host) {
|
|
5
5
|
const originalReadDirectory = host.readDirectory?.bind(host);
|
|
6
6
|
host.readDirectory = originalReadDirectory
|
|
@@ -10,5 +10,4 @@ function decorateLanguageServiceHost(host) {
|
|
|
10
10
|
}
|
|
11
11
|
: undefined;
|
|
12
12
|
}
|
|
13
|
-
exports.decorateLanguageServiceHost = decorateLanguageServiceHost;
|
|
14
13
|
//# sourceMappingURL=host.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateHover =
|
|
3
|
+
exports.decorateHover = decorateHover;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const sveltekit_1 = require("./sveltekit");
|
|
6
6
|
function decorateHover(ls, info, ts, logger) {
|
|
@@ -28,5 +28,4 @@ function decorateHover(ls, info, ts, logger) {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
exports.decorateHover = decorateHover;
|
|
32
31
|
//# sourceMappingURL=hover.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateGetImplementation =
|
|
3
|
+
exports.decorateGetImplementation = decorateGetImplementation;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
function decorateGetImplementation(ls, snapshotManager, logger) {
|
|
6
6
|
const getImplementationAtPosition = ls.getImplementationAtPosition;
|
|
@@ -29,5 +29,4 @@ function decorateGetImplementation(ls, snapshotManager, logger) {
|
|
|
29
29
|
.filter(utils_1.isNotNullOrUndefined);
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
exports.decorateGetImplementation = decorateGetImplementation;
|
|
33
32
|
//# sourceMappingURL=implementation.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isPatched = isPatched;
|
|
4
|
+
exports.decorateLanguageService = decorateLanguageService;
|
|
4
5
|
const utils_1 = require("../utils");
|
|
5
6
|
const call_hierarchy_1 = require("./call-hierarchy");
|
|
6
7
|
const completions_1 = require("./completions");
|
|
@@ -16,11 +17,11 @@ const host_1 = require("./host");
|
|
|
16
17
|
const navigate_to_items_1 = require("./navigate-to-items");
|
|
17
18
|
const file_references_1 = require("./file-references");
|
|
18
19
|
const move_to_file_1 = require("./move-to-file");
|
|
20
|
+
const code_action_1 = require("./code-action");
|
|
19
21
|
const patchedProject = new Set();
|
|
20
22
|
function isPatched(project) {
|
|
21
23
|
return patchedProject.has(project.getProjectName());
|
|
22
24
|
}
|
|
23
|
-
exports.isPatched = isPatched;
|
|
24
25
|
function decorateLanguageService(ls, snapshotManager, logger, configManager, info, typescript, onDispose) {
|
|
25
26
|
patchedProject.add(info.project.getProjectName());
|
|
26
27
|
// Decorate using a proxy so we can dynamically enable/disable method
|
|
@@ -30,7 +31,6 @@ function decorateLanguageService(ls, snapshotManager, logger, configManager, inf
|
|
|
30
31
|
decorateLanguageServiceInner(proxy, snapshotManager, logger, info, typescript, onDispose);
|
|
31
32
|
return proxy;
|
|
32
33
|
}
|
|
33
|
-
exports.decorateLanguageService = decorateLanguageService;
|
|
34
34
|
function decorateLanguageServiceInner(ls, snapshotManager, logger, info, typescript, onDispose) {
|
|
35
35
|
patchLineColumnOffset(ls, snapshotManager);
|
|
36
36
|
(0, rename_1.decorateRename)(ls, snapshotManager, logger);
|
|
@@ -46,6 +46,7 @@ function decorateLanguageServiceInner(ls, snapshotManager, logger, info, typescr
|
|
|
46
46
|
(0, navigate_to_items_1.decorateNavigateToItems)(ls, snapshotManager);
|
|
47
47
|
(0, file_references_1.decorateFileReferences)(ls, snapshotManager);
|
|
48
48
|
(0, move_to_file_1.decorateMoveToRefactoringFileSuggestions)(ls);
|
|
49
|
+
(0, code_action_1.decorateQuickFixAndRefactor)(ls, typescript, snapshotManager);
|
|
49
50
|
decorateDispose(ls, info.project, onDispose);
|
|
50
51
|
return ls;
|
|
51
52
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateInlayHints =
|
|
3
|
+
exports.decorateInlayHints = decorateInlayHints;
|
|
4
4
|
const sveltekit_1 = require("./sveltekit");
|
|
5
5
|
function decorateInlayHints(ls, info, ts, logger) {
|
|
6
6
|
const provideInlayHints = ls.provideInlayHints;
|
|
@@ -22,5 +22,4 @@ function decorateInlayHints(ls, info, ts, logger) {
|
|
|
22
22
|
}));
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
exports.decorateInlayHints = decorateInlayHints;
|
|
26
25
|
//# sourceMappingURL=inlay-hints.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateMoveToRefactoringFileSuggestions =
|
|
3
|
+
exports.decorateMoveToRefactoringFileSuggestions = decorateMoveToRefactoringFileSuggestions;
|
|
4
4
|
function decorateMoveToRefactoringFileSuggestions(ls) {
|
|
5
5
|
const getMoveToRefactoringFileSuggestions = ls.getMoveToRefactoringFileSuggestions;
|
|
6
6
|
ls.getMoveToRefactoringFileSuggestions = (fileName, positionOrRange, preferences, triggerReason, kind) => {
|
|
@@ -20,5 +20,4 @@ function decorateMoveToRefactoringFileSuggestions(ls) {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
exports.decorateMoveToRefactoringFileSuggestions = decorateMoveToRefactoringFileSuggestions;
|
|
24
23
|
//# sourceMappingURL=move-to-file.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateNavigateToItems =
|
|
3
|
+
exports.decorateNavigateToItems = decorateNavigateToItems;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
function decorateNavigateToItems(ls, snapshotManager) {
|
|
6
6
|
const getNavigateToItems = ls.getNavigateToItems;
|
|
@@ -34,5 +34,4 @@ function decorateNavigateToItems(ls, snapshotManager) {
|
|
|
34
34
|
.filter(utils_1.isNotNullOrUndefined);
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
exports.decorateNavigateToItems = decorateNavigateToItems;
|
|
38
37
|
//# sourceMappingURL=navigate-to-items.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateRename =
|
|
3
|
+
exports.decorateRename = decorateRename;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
function decorateRename(ls, snapshotManager, logger) {
|
|
6
6
|
const findRenameLocations = ls.findRenameLocations;
|
|
@@ -56,5 +56,4 @@ function decorateRename(ls, snapshotManager, logger) {
|
|
|
56
56
|
return converted;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
exports.decorateRename = decorateRename;
|
|
60
59
|
//# sourceMappingURL=rename.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.kitExports = void 0;
|
|
4
|
+
exports.isKitRouteExportAllowedIn = isKitRouteExportAllowedIn;
|
|
5
|
+
exports.getVirtualLS = getVirtualLS;
|
|
4
6
|
const utils_1 = require("../utils");
|
|
5
7
|
const svelte2tsx_1 = require("svelte2tsx");
|
|
6
8
|
const cache = new WeakMap();
|
|
@@ -476,7 +478,6 @@ function isKitRouteExportAllowedIn(basename, kitExport) {
|
|
|
476
478
|
? allowedIn.includes('server')
|
|
477
479
|
: allowedIn.includes('universal')));
|
|
478
480
|
}
|
|
479
|
-
exports.isKitRouteExportAllowedIn = isKitRouteExportAllowedIn;
|
|
480
481
|
const kitFilesSettings = {
|
|
481
482
|
paramsPath: 'src/params',
|
|
482
483
|
clientHooksPath: 'src/hooks.client',
|
|
@@ -746,5 +747,4 @@ function getVirtualLS(fileName, info, ts, logger) {
|
|
|
746
747
|
};
|
|
747
748
|
}
|
|
748
749
|
}
|
|
749
|
-
exports.getVirtualLS = getVirtualLS;
|
|
750
750
|
//# sourceMappingURL=sveltekit.js.map
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.decorateUpdateImports =
|
|
6
|
+
exports.decorateUpdateImports = decorateUpdateImports;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
function decorateUpdateImports(ls, snapshotManager, logger) {
|
|
@@ -33,5 +33,4 @@ function decorateUpdateImports(ls, snapshotManager, logger) {
|
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
exports.decorateUpdateImports = decorateUpdateImports;
|
|
37
36
|
//# sourceMappingURL=update-imports.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.patchModuleLoader =
|
|
3
|
+
exports.patchModuleLoader = patchModuleLoader;
|
|
4
4
|
const svelte_sys_1 = require("./svelte-sys");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
6
|
/**
|
|
@@ -159,5 +159,4 @@ function patchModuleLoader(logger, snapshotManager, typescript, lsHost, project,
|
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
exports.patchModuleLoader = patchModuleLoader;
|
|
163
162
|
//# sourceMappingURL=module-loader.js.map
|
package/dist/src/svelte-sys.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSvelteSys =
|
|
3
|
+
exports.createSvelteSys = createSvelteSys;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
/**
|
|
6
6
|
* This should only be accessed by TS svelte module resolution.
|
|
@@ -33,5 +33,4 @@ function createSvelteSys(ts, logger) {
|
|
|
33
33
|
}
|
|
34
34
|
return svelteSys;
|
|
35
35
|
}
|
|
36
|
-
exports.createSvelteSys = createSvelteSys;
|
|
37
36
|
//# sourceMappingURL=svelte-sys.js.map
|
package/dist/src/utils.js
CHANGED
|
@@ -1,27 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isSvelteFilePath = isSvelteFilePath;
|
|
4
|
+
exports.isVirtualSvelteFilePath = isVirtualSvelteFilePath;
|
|
5
|
+
exports.toRealSvelteFilePath = toRealSvelteFilePath;
|
|
6
|
+
exports.ensureRealSvelteFilePath = ensureRealSvelteFilePath;
|
|
7
|
+
exports.isNotNullOrUndefined = isNotNullOrUndefined;
|
|
8
|
+
exports.isInGeneratedCode = isInGeneratedCode;
|
|
9
|
+
exports.isNoTextSpanInGeneratedCode = isNoTextSpanInGeneratedCode;
|
|
10
|
+
exports.replaceDeep = replaceDeep;
|
|
11
|
+
exports.getConfigPathForProject = getConfigPathForProject;
|
|
12
|
+
exports.isStoreVariableIn$storeDeclaration = isStoreVariableIn$storeDeclaration;
|
|
13
|
+
exports.get$storeOffsetOf$storeDeclaration = get$storeOffsetOf$storeDeclaration;
|
|
14
|
+
exports.findNodeAtSpan = findNodeAtSpan;
|
|
15
|
+
exports.findNodeAtPosition = findNodeAtPosition;
|
|
16
|
+
exports.isTopLevelExport = isTopLevelExport;
|
|
17
|
+
exports.isGeneratedSvelteComponentName = isGeneratedSvelteComponentName;
|
|
18
|
+
exports.offsetOfGeneratedComponentExport = offsetOfGeneratedComponentExport;
|
|
19
|
+
exports.gatherDescendants = gatherDescendants;
|
|
20
|
+
exports.findIdentifier = findIdentifier;
|
|
21
|
+
exports.getProjectDirectory = getProjectDirectory;
|
|
22
|
+
exports.hasNodeModule = hasNodeModule;
|
|
23
|
+
exports.isSvelteProject = isSvelteProject;
|
|
24
|
+
exports.importSvelteCompiler = importSvelteCompiler;
|
|
4
25
|
const path_1 = require("path");
|
|
5
26
|
function isSvelteFilePath(filePath) {
|
|
6
27
|
return filePath.endsWith('.svelte');
|
|
7
28
|
}
|
|
8
|
-
exports.isSvelteFilePath = isSvelteFilePath;
|
|
9
29
|
function isVirtualSvelteFilePath(filePath) {
|
|
10
30
|
return filePath.endsWith('.svelte.ts');
|
|
11
31
|
}
|
|
12
|
-
exports.isVirtualSvelteFilePath = isVirtualSvelteFilePath;
|
|
13
32
|
function toRealSvelteFilePath(filePath) {
|
|
14
33
|
return filePath.slice(0, -'.ts'.length);
|
|
15
34
|
}
|
|
16
|
-
exports.toRealSvelteFilePath = toRealSvelteFilePath;
|
|
17
35
|
function ensureRealSvelteFilePath(filePath) {
|
|
18
36
|
return isVirtualSvelteFilePath(filePath) ? toRealSvelteFilePath(filePath) : filePath;
|
|
19
37
|
}
|
|
20
|
-
exports.ensureRealSvelteFilePath = ensureRealSvelteFilePath;
|
|
21
38
|
function isNotNullOrUndefined(val) {
|
|
22
39
|
return val !== undefined && val !== null;
|
|
23
40
|
}
|
|
24
|
-
exports.isNotNullOrUndefined = isNotNullOrUndefined;
|
|
25
41
|
/**
|
|
26
42
|
* Checks if this a section that should be completely ignored
|
|
27
43
|
* because it's purely generated.
|
|
@@ -33,7 +49,6 @@ function isInGeneratedCode(text, start, end) {
|
|
|
33
49
|
const lastEnd = text.substring(lineStart, start).lastIndexOf('/*Ωignore_endΩ*/');
|
|
34
50
|
return lastStart > lastEnd && text.substring(end, lineEnd).includes('/*Ωignore_endΩ*/');
|
|
35
51
|
}
|
|
36
|
-
exports.isInGeneratedCode = isInGeneratedCode;
|
|
37
52
|
/**
|
|
38
53
|
* Checks that this isn't a text span that should be completely ignored
|
|
39
54
|
* because it's purely generated.
|
|
@@ -41,7 +56,6 @@ exports.isInGeneratedCode = isInGeneratedCode;
|
|
|
41
56
|
function isNoTextSpanInGeneratedCode(text, span) {
|
|
42
57
|
return !isInGeneratedCode(text, span.start, span.start + span.length);
|
|
43
58
|
}
|
|
44
|
-
exports.isNoTextSpanInGeneratedCode = isNoTextSpanInGeneratedCode;
|
|
45
59
|
/**
|
|
46
60
|
* Replace all occurrences of a string within an object with another string,
|
|
47
61
|
*/
|
|
@@ -63,21 +77,17 @@ function replaceDeep(obj, searchStr, replacementStr) {
|
|
|
63
77
|
return _obj;
|
|
64
78
|
}
|
|
65
79
|
}
|
|
66
|
-
exports.replaceDeep = replaceDeep;
|
|
67
80
|
function getConfigPathForProject(project) {
|
|
68
81
|
return (project.canonicalConfigFilePath ??
|
|
69
82
|
project.getCompilerOptions().configFilePath);
|
|
70
83
|
}
|
|
71
|
-
exports.getConfigPathForProject = getConfigPathForProject;
|
|
72
84
|
function isStoreVariableIn$storeDeclaration(text, varStart) {
|
|
73
85
|
return (text.lastIndexOf('__sveltets_2_store_get(', varStart) ===
|
|
74
86
|
varStart - '__sveltets_2_store_get('.length);
|
|
75
87
|
}
|
|
76
|
-
exports.isStoreVariableIn$storeDeclaration = isStoreVariableIn$storeDeclaration;
|
|
77
88
|
function get$storeOffsetOf$storeDeclaration(text, storePosition) {
|
|
78
89
|
return text.lastIndexOf(' =', storePosition) - 1;
|
|
79
90
|
}
|
|
80
|
-
exports.get$storeOffsetOf$storeDeclaration = get$storeOffsetOf$storeDeclaration;
|
|
81
91
|
/**
|
|
82
92
|
* Finds node exactly matching span {start, length}.
|
|
83
93
|
*/
|
|
@@ -107,7 +117,6 @@ function findNodeAtSpan(node, span, predicate) {
|
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
|
-
exports.findNodeAtSpan = findNodeAtSpan;
|
|
111
120
|
/**
|
|
112
121
|
* Finds node somewhere at position.
|
|
113
122
|
*/
|
|
@@ -133,7 +142,6 @@ function findNodeAtPosition(node, pos, predicate) {
|
|
|
133
142
|
}
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
|
-
exports.findNodeAtPosition = findNodeAtPosition;
|
|
137
145
|
/**
|
|
138
146
|
* True if is `export const/let/function`
|
|
139
147
|
*/
|
|
@@ -148,16 +156,13 @@ function isTopLevelExport(ts, node, source) {
|
|
|
148
156
|
ts.isFunctionDeclaration(node.parent) &&
|
|
149
157
|
source.statements.includes(node.parent)));
|
|
150
158
|
}
|
|
151
|
-
exports.isTopLevelExport = isTopLevelExport;
|
|
152
159
|
const COMPONENT_SUFFIX = '__SvelteComponent_';
|
|
153
160
|
function isGeneratedSvelteComponentName(className) {
|
|
154
161
|
return className.endsWith(COMPONENT_SUFFIX);
|
|
155
162
|
}
|
|
156
|
-
exports.isGeneratedSvelteComponentName = isGeneratedSvelteComponentName;
|
|
157
163
|
function offsetOfGeneratedComponentExport(snapshot) {
|
|
158
164
|
return snapshot.getText().lastIndexOf(COMPONENT_SUFFIX);
|
|
159
165
|
}
|
|
160
|
-
exports.offsetOfGeneratedComponentExport = offsetOfGeneratedComponentExport;
|
|
161
166
|
function gatherDescendants(node, predicate, dest = []) {
|
|
162
167
|
if (predicate(node)) {
|
|
163
168
|
dest.push(node);
|
|
@@ -169,7 +174,6 @@ function gatherDescendants(node, predicate, dest = []) {
|
|
|
169
174
|
}
|
|
170
175
|
return dest;
|
|
171
176
|
}
|
|
172
|
-
exports.gatherDescendants = gatherDescendants;
|
|
173
177
|
function findIdentifier(ts, node) {
|
|
174
178
|
if (ts.isIdentifier(node)) {
|
|
175
179
|
return node;
|
|
@@ -187,7 +191,6 @@ function findIdentifier(ts, node) {
|
|
|
187
191
|
node = node.parent;
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
|
-
exports.findIdentifier = findIdentifier;
|
|
191
194
|
function getProjectDirectory(project) {
|
|
192
195
|
const compilerOptions = project.getCompilerOptions();
|
|
193
196
|
if (typeof compilerOptions.configFilePath === 'string') {
|
|
@@ -196,7 +199,6 @@ function getProjectDirectory(project) {
|
|
|
196
199
|
const packageJsonPath = (0, path_1.join)(project.getCurrentDirectory(), 'package.json');
|
|
197
200
|
return project.fileExists(packageJsonPath) ? project.getCurrentDirectory() : undefined;
|
|
198
201
|
}
|
|
199
|
-
exports.getProjectDirectory = getProjectDirectory;
|
|
200
202
|
function hasNodeModule(startPath, module) {
|
|
201
203
|
try {
|
|
202
204
|
const hasModule = require.resolve(module, { paths: [startPath] });
|
|
@@ -208,7 +210,6 @@ function hasNodeModule(startPath, module) {
|
|
|
208
210
|
return e?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED';
|
|
209
211
|
}
|
|
210
212
|
}
|
|
211
|
-
exports.hasNodeModule = hasNodeModule;
|
|
212
213
|
function isSvelteProject(project) {
|
|
213
214
|
const projectDirectory = getProjectDirectory(project);
|
|
214
215
|
if (projectDirectory) {
|
|
@@ -222,7 +223,6 @@ function isSvelteProject(project) {
|
|
|
222
223
|
.filter((file) => file.endsWith('package.json') && !hasConfigInConjunction(file, project));
|
|
223
224
|
return packageJsons.some((packageJsonPath) => hasNodeModule((0, path_1.dirname)(packageJsonPath), 'svelte'));
|
|
224
225
|
}
|
|
225
|
-
exports.isSvelteProject = isSvelteProject;
|
|
226
226
|
function hasConfigInConjunction(packageJsonPath, project) {
|
|
227
227
|
const dir = (0, path_1.dirname)(packageJsonPath);
|
|
228
228
|
return (project.fileExists((0, path_1.join)(dir, 'tsconfig.json')) ||
|
|
@@ -244,5 +244,4 @@ function importSvelteCompiler(fromPath) {
|
|
|
244
244
|
// ignore
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
exports.importSvelteCompiler = importSvelteCompiler;
|
|
248
247
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-svelte-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.40",
|
|
4
4
|
"description": "A TypeScript Plugin providing Svelte intellisense",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "^16.0.0",
|
|
16
|
-
"typescript": "^5.
|
|
16
|
+
"typescript": "^5.5.2",
|
|
17
17
|
"svelte": "^3.57.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|