@react-router/dev 0.0.0-experimental-3278f3ca6 → 0.0.0-experimental-2d5e406e4
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/cli/commands.js +1 -1
- package/dist/cli/detectPackageManager.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/run.js +1 -1
- package/dist/cli/useJavascript.js +1 -1
- package/dist/colors.js +1 -1
- package/dist/config/format.js +1 -1
- package/dist/config/routes.js +2 -2
- package/dist/invariant.js +2 -4
- package/dist/routes.js +1 -1
- package/dist/typescript/ast.d.ts +8 -0
- package/dist/typescript/ast.js +98 -0
- package/dist/typescript/autotype/api.completions.d.ts +5 -0
- package/dist/typescript/autotype/api.completions.js +75 -0
- package/dist/typescript/autotype/api.definitions.d.ts +4 -0
- package/dist/typescript/autotype/api.definitions.js +55 -0
- package/dist/typescript/autotype/api.diagnostics.d.ts +5 -0
- package/dist/typescript/autotype/api.diagnostics.js +60 -0
- package/dist/typescript/autotype/api.hover.d.ts +3 -0
- package/dist/typescript/autotype/api.hover.js +33 -0
- package/dist/typescript/autotype/api.inlay-hints.d.ts +3 -0
- package/dist/typescript/autotype/api.inlay-hints.js +31 -0
- package/dist/typescript/autotype/index.d.ts +5 -0
- package/dist/typescript/autotype/language-service.d.ts +35 -0
- package/dist/typescript/autotype/language-service.js +290 -0
- package/dist/typescript/context.d.ts +15 -0
- package/dist/typescript/decorate.d.ts +2 -0
- package/dist/typescript/decorate.js +233 -0
- package/dist/typescript/plugin.d.ts +6 -0
- package/dist/typescript/plugin.js +67 -0
- package/dist/typescript/routes.d.ts +10 -0
- package/dist/typescript/routes.js +102 -0
- package/dist/typescript/typecheck.d.ts +1 -0
- package/dist/typescript/typegen.d.ts +5 -0
- package/dist/typescript/typegen.js +165 -0
- package/dist/vite/babel.d.ts +1 -1
- package/dist/vite/babel.js +1 -1
- package/dist/vite/build.js +3 -3
- package/dist/vite/cloudflare-dev-proxy.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite/combine-urls.js +1 -1
- package/dist/vite/config.d.ts +14 -8
- package/dist/vite/config.js +8 -14
- package/dist/vite/dev.js +1 -1
- package/dist/vite/import-vite-esm-sync.js +2 -2
- package/dist/vite/node-adapter.js +2 -2
- package/dist/vite/plugin.d.ts +1 -1
- package/dist/vite/plugin.js +64 -55
- package/dist/vite/profiler.js +1 -1
- package/dist/vite/remove-exports.js +1 -1
- package/dist/vite/resolve-file-url.js +1 -1
- package/dist/vite/styles.js +1 -1
- package/dist/vite/vite-node.d.ts +9 -0
- package/dist/vite/vite-node.js +57 -0
- package/dist/vite/vmod.js +1 -1
- package/dist/vite/with-props.js +1 -1
- package/dist/vite.js +1 -1
- package/package.json +11 -7
package/dist/cli/commands.js
CHANGED
package/dist/cli/index.js
CHANGED
package/dist/cli/run.js
CHANGED
package/dist/colors.js
CHANGED
package/dist/config/format.js
CHANGED
package/dist/config/routes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -49,7 +49,7 @@ function setAppDirectory(directory) {
|
|
|
49
49
|
* This is designed to support resolving file system routes.
|
|
50
50
|
*/
|
|
51
51
|
function getAppDirectory() {
|
|
52
|
-
invariant
|
|
52
|
+
invariant(appDirectory);
|
|
53
53
|
return appDirectory;
|
|
54
54
|
}
|
|
55
55
|
const routeConfigEntrySchema = v__namespace.pipe(v__namespace.custom(value => {
|
package/dist/invariant.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
13
|
function invariant(value, message) {
|
|
16
14
|
if (value === false || value === null || typeof value === "undefined") {
|
|
17
15
|
console.error("The following error is a bug in Remix; please open an issue! https://github.com/remix-run/remix/issues/new");
|
|
@@ -19,4 +17,4 @@ function invariant(value, message) {
|
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
exports
|
|
20
|
+
module.exports = invariant;
|
package/dist/routes.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type ts from "typescript/lib/tsserverlibrary";
|
|
2
|
+
import type { Context } from "./context";
|
|
3
|
+
export declare function generateUniqueIdentifier(): string;
|
|
4
|
+
export declare function findNodeAtPosition(node: ts.Node, pos: number): ts.Node | undefined;
|
|
5
|
+
export declare function getRouteExportName(ctx: Context, node: ts.Node): string | undefined;
|
|
6
|
+
export declare function getExportNames(ts: Context["ts"], sourceFile: ts.SourceFile): Set<string>;
|
|
7
|
+
export declare function exported(ts: Context["ts"], stmt: ts.VariableStatement | ts.FunctionDeclaration): ts.ModifierLike | undefined;
|
|
8
|
+
export declare function defaulted(ts: Context["ts"], stmt: ts.FunctionDeclaration): ts.ModifierLike | undefined;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
+
|
|
15
|
+
function findNodeAtPosition(node, pos) {
|
|
16
|
+
if (pos < node.getStart() || node.getEnd() < pos) return;
|
|
17
|
+
for (const child of node.getChildren()) {
|
|
18
|
+
if (pos < child.getStart()) break;
|
|
19
|
+
if (pos > child.getEnd()) continue;
|
|
20
|
+
const found = findNodeAtPosition(child, pos);
|
|
21
|
+
if (found) return found;
|
|
22
|
+
return child;
|
|
23
|
+
}
|
|
24
|
+
return node;
|
|
25
|
+
}
|
|
26
|
+
function getRouteExportName(ctx, node) {
|
|
27
|
+
if (node.kind === ctx.ts.SyntaxKind.DefaultKeyword) {
|
|
28
|
+
return "default";
|
|
29
|
+
}
|
|
30
|
+
if (node.kind === ctx.ts.SyntaxKind.FunctionKeyword) {
|
|
31
|
+
return getRouteExportName(ctx, node.parent);
|
|
32
|
+
}
|
|
33
|
+
if (ctx.ts.isIdentifier(node)) {
|
|
34
|
+
return getRouteExportName(ctx, node.parent);
|
|
35
|
+
}
|
|
36
|
+
if (ctx.ts.isExportAssignment(node)) {
|
|
37
|
+
if (node.isExportEquals) return;
|
|
38
|
+
if (!ctx.ts.isArrowFunction(node.expression)) return;
|
|
39
|
+
return "default";
|
|
40
|
+
}
|
|
41
|
+
if (ctx.ts.isFunctionDeclaration(node)) {
|
|
42
|
+
var _node$name;
|
|
43
|
+
if (!exported(ctx.ts, node)) return;
|
|
44
|
+
if (defaulted(ctx.ts, node)) return "default";
|
|
45
|
+
return (_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.text;
|
|
46
|
+
}
|
|
47
|
+
if (ctx.ts.isVariableDeclaration(node)) {
|
|
48
|
+
const varDeclList = node.parent;
|
|
49
|
+
if (!ctx.ts.isVariableDeclarationList(varDeclList)) return;
|
|
50
|
+
const varStmt = varDeclList.parent;
|
|
51
|
+
if (!ctx.ts.isVariableStatement(varStmt)) return;
|
|
52
|
+
if (!exported(ctx.ts, varStmt)) return;
|
|
53
|
+
if (!ctx.ts.isIdentifier(node.name)) return;
|
|
54
|
+
return node.name.text;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function getExportNames(ts, sourceFile) {
|
|
58
|
+
const exports = new Set();
|
|
59
|
+
sourceFile.statements.forEach(stmt => {
|
|
60
|
+
if (ts.isExportDeclaration(stmt)) {
|
|
61
|
+
if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
|
|
62
|
+
stmt.exportClause.elements.forEach(element => exports.add(element.name.text));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (ts.isVariableStatement(stmt) && exported(ts, stmt)) {
|
|
66
|
+
stmt.declarationList.declarations.forEach(decl => {
|
|
67
|
+
if (ts.isIdentifier(decl.name)) {
|
|
68
|
+
exports.add(decl.name.text);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (ts.isFunctionDeclaration(stmt) && exported(ts, stmt)) {
|
|
73
|
+
if (defaulted(ts, stmt)) {
|
|
74
|
+
exports.add("default");
|
|
75
|
+
} else if (stmt.name) {
|
|
76
|
+
exports.add(stmt.name.text);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (ts.isExportAssignment(stmt)) {
|
|
80
|
+
exports.add("default");
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return exports;
|
|
84
|
+
}
|
|
85
|
+
function exported(ts, stmt) {
|
|
86
|
+
var _stmt$modifiers;
|
|
87
|
+
return (_stmt$modifiers = stmt.modifiers) === null || _stmt$modifiers === void 0 ? void 0 : _stmt$modifiers.find(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
88
|
+
}
|
|
89
|
+
function defaulted(ts, stmt) {
|
|
90
|
+
var _stmt$modifiers2;
|
|
91
|
+
return (_stmt$modifiers2 = stmt.modifiers) === null || _stmt$modifiers2 === void 0 ? void 0 : _stmt$modifiers2.find(m => m.kind === ts.SyntaxKind.DefaultKeyword);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.defaulted = defaulted;
|
|
95
|
+
exports.exported = exported;
|
|
96
|
+
exports.findNodeAtPosition = findNodeAtPosition;
|
|
97
|
+
exports.getExportNames = getExportNames;
|
|
98
|
+
exports.getRouteExportName = getRouteExportName;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type ts from "typescript/lib/tsserverlibrary";
|
|
2
|
+
import { type Context } from "../context";
|
|
3
|
+
export declare const getCompletionsAtPosition: (ctx: Context) => ts.LanguageService["getCompletionsAtPosition"];
|
|
4
|
+
export declare const getCompletionEntryDetails: (ctx: Context) => ts.LanguageService["getCompletionEntryDetails"];
|
|
5
|
+
export declare const getSignatureHelpItems: (ctx: Context) => ts.LanguageService["getSignatureHelpItems"];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
+
|
|
15
|
+
var languageService = require('./language-service.js');
|
|
16
|
+
|
|
17
|
+
const getCompletionsAtPosition = ctx => (fileName, position, options, settings) => {
|
|
18
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
19
|
+
const route = autotype.getRoute(fileName);
|
|
20
|
+
if (!route) return;
|
|
21
|
+
const splicedIndex = route.autotyped.toSplicedIndex(position);
|
|
22
|
+
const completions = autotype.getCompletionsAtPosition(fileName, splicedIndex, options, settings);
|
|
23
|
+
if (!completions) return;
|
|
24
|
+
completions.entries = completions.entries.map(completion => {
|
|
25
|
+
if (!completion.replacementSpan) return completion;
|
|
26
|
+
return {
|
|
27
|
+
...completion,
|
|
28
|
+
replacementSpan: {
|
|
29
|
+
...completion.replacementSpan,
|
|
30
|
+
start: route.autotyped.toOriginalIndex(completion.replacementSpan.start).index
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
if (completions.optionalReplacementSpan) {
|
|
35
|
+
completions.optionalReplacementSpan = {
|
|
36
|
+
...completions.optionalReplacementSpan,
|
|
37
|
+
start: route.autotyped.toOriginalIndex(completions.optionalReplacementSpan.start).index
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return completions;
|
|
41
|
+
};
|
|
42
|
+
const getCompletionEntryDetails = ctx => (fileName, position, entryName, formatOptions, source, preferences, data) => {
|
|
43
|
+
var _details$codeActions;
|
|
44
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
45
|
+
const route = autotype.getRoute(fileName);
|
|
46
|
+
if (!route) return;
|
|
47
|
+
const details = autotype.getCompletionEntryDetails(fileName, route.autotyped.toSplicedIndex(position), entryName, formatOptions, source, preferences, data);
|
|
48
|
+
if (!details) return;
|
|
49
|
+
details.codeActions = (_details$codeActions = details.codeActions) === null || _details$codeActions === void 0 ? void 0 : _details$codeActions.map(codeAction => {
|
|
50
|
+
codeAction.changes = codeAction.changes.map(change => {
|
|
51
|
+
change.textChanges = change.textChanges.map(textChange => {
|
|
52
|
+
return {
|
|
53
|
+
...textChange,
|
|
54
|
+
span: {
|
|
55
|
+
...textChange.span,
|
|
56
|
+
start: route.autotyped.toOriginalIndex(textChange.span.start).index
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
return change;
|
|
61
|
+
});
|
|
62
|
+
return codeAction;
|
|
63
|
+
});
|
|
64
|
+
return details;
|
|
65
|
+
};
|
|
66
|
+
const getSignatureHelpItems = ctx => (fileName, position, options) => {
|
|
67
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
68
|
+
const route = autotype.getRoute(fileName);
|
|
69
|
+
if (!route) return;
|
|
70
|
+
return autotype.getSignatureHelpItems(fileName, route.autotyped.toSplicedIndex(position), options);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.getCompletionEntryDetails = getCompletionEntryDetails;
|
|
74
|
+
exports.getCompletionsAtPosition = getCompletionsAtPosition;
|
|
75
|
+
exports.getSignatureHelpItems = getSignatureHelpItems;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type ts from "typescript/lib/tsserverlibrary";
|
|
2
|
+
import { type Context } from "../context";
|
|
3
|
+
export declare const getDefinitionAndBoundSpan: (ctx: Context) => ts.LanguageService["getDefinitionAndBoundSpan"];
|
|
4
|
+
export declare const getTypeDefinitionAtPosition: (ctx: Context) => ts.LanguageService["getTypeDefinitionAtPosition"];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
+
|
|
15
|
+
var languageService = require('./language-service.js');
|
|
16
|
+
|
|
17
|
+
const getDefinitionAndBoundSpan = ctx => (fileName, position) => {
|
|
18
|
+
var _result$definitions;
|
|
19
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
20
|
+
const route = autotype.getRoute(fileName);
|
|
21
|
+
if (!route) return;
|
|
22
|
+
const splicedIndex = route.autotyped.toSplicedIndex(position);
|
|
23
|
+
const result = autotype.getDefinitionAndBoundSpan(fileName, splicedIndex);
|
|
24
|
+
if (!result) return;
|
|
25
|
+
return {
|
|
26
|
+
definitions: (_result$definitions = result.definitions) === null || _result$definitions === void 0 ? void 0 : _result$definitions.map(remapSpans(autotype)),
|
|
27
|
+
textSpan: {
|
|
28
|
+
...result.textSpan,
|
|
29
|
+
start: route.autotyped.toOriginalIndex(result.textSpan.start).index
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const getTypeDefinitionAtPosition = ctx => (fileName, position) => {
|
|
34
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
35
|
+
const route = autotype.getRoute(fileName);
|
|
36
|
+
if (!route) return;
|
|
37
|
+
const splicedIndex = route.autotyped.toSplicedIndex(position);
|
|
38
|
+
const definitions = autotype.getTypeDefinitionAtPosition(fileName, splicedIndex);
|
|
39
|
+
if (!definitions) return;
|
|
40
|
+
return definitions.map(remapSpans(autotype));
|
|
41
|
+
};
|
|
42
|
+
const remapSpans = autotype => definition => {
|
|
43
|
+
const definitionRoute = autotype.getRoute(definition.fileName);
|
|
44
|
+
if (!definitionRoute) return definition;
|
|
45
|
+
return {
|
|
46
|
+
...definition,
|
|
47
|
+
textSpan: {
|
|
48
|
+
...definition.textSpan,
|
|
49
|
+
start: definitionRoute.autotyped.toOriginalIndex(definition.textSpan.start).index
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
exports.getDefinitionAndBoundSpan = getDefinitionAndBoundSpan;
|
|
55
|
+
exports.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type ts from "typescript/lib/tsserverlibrary";
|
|
2
|
+
import { type Context } from "../context";
|
|
3
|
+
export declare const getSyntacticDiagnostics: (ctx: Context) => ts.LanguageService["getSyntacticDiagnostics"];
|
|
4
|
+
export declare const getSemanticDiagnostics: (ctx: Context) => ts.LanguageService["getSemanticDiagnostics"];
|
|
5
|
+
export declare const getSuggestionDiagnostics: (ctx: Context) => ts.LanguageService["getSuggestionDiagnostics"];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
+
|
|
15
|
+
var languageService = require('./language-service.js');
|
|
16
|
+
|
|
17
|
+
const getSyntacticDiagnostics = ctx => fileName => {
|
|
18
|
+
var _ctx$languageService$;
|
|
19
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
20
|
+
const route = autotype.getRoute(fileName);
|
|
21
|
+
if (!route) return [];
|
|
22
|
+
const sourceFile = (_ctx$languageService$ = ctx.languageService.getProgram()) === null || _ctx$languageService$ === void 0 ? void 0 : _ctx$languageService$.getSourceFile(fileName);
|
|
23
|
+
if (!sourceFile) return [];
|
|
24
|
+
return autotype.getSyntacticDiagnostics(fileName).map(remapSpans(sourceFile, route.autotyped));
|
|
25
|
+
};
|
|
26
|
+
const getSemanticDiagnostics = ctx => fileName => {
|
|
27
|
+
var _ctx$languageService$2;
|
|
28
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
29
|
+
const route = autotype.getRoute(fileName);
|
|
30
|
+
if (!route) return [];
|
|
31
|
+
const sourceFile = (_ctx$languageService$2 = ctx.languageService.getProgram()) === null || _ctx$languageService$2 === void 0 ? void 0 : _ctx$languageService$2.getSourceFile(fileName);
|
|
32
|
+
if (!sourceFile) return [];
|
|
33
|
+
return autotype.getSemanticDiagnostics(fileName).map(remapSpans(sourceFile, route.autotyped));
|
|
34
|
+
};
|
|
35
|
+
const getSuggestionDiagnostics = ctx => fileName => {
|
|
36
|
+
var _ctx$languageService$3;
|
|
37
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
38
|
+
const route = autotype.getRoute(fileName);
|
|
39
|
+
if (!route) return [];
|
|
40
|
+
const sourceFile = (_ctx$languageService$3 = ctx.languageService.getProgram()) === null || _ctx$languageService$3 === void 0 ? void 0 : _ctx$languageService$3.getSourceFile(fileName);
|
|
41
|
+
if (!sourceFile) return [];
|
|
42
|
+
return autotype.getSuggestionDiagnostics(fileName).map(remapSpans(sourceFile, route.autotyped));
|
|
43
|
+
};
|
|
44
|
+
const remapSpans = (sourceFile, route) => diagnostic => {
|
|
45
|
+
if (!diagnostic.start) return diagnostic;
|
|
46
|
+
const {
|
|
47
|
+
index,
|
|
48
|
+
remapDiagnostics
|
|
49
|
+
} = route.toOriginalIndex(diagnostic.start);
|
|
50
|
+
return {
|
|
51
|
+
...diagnostic,
|
|
52
|
+
start: (remapDiagnostics === null || remapDiagnostics === void 0 ? void 0 : remapDiagnostics.start) ?? index,
|
|
53
|
+
length: (remapDiagnostics === null || remapDiagnostics === void 0 ? void 0 : remapDiagnostics.length) ?? diagnostic.length,
|
|
54
|
+
file: sourceFile
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.getSemanticDiagnostics = getSemanticDiagnostics;
|
|
59
|
+
exports.getSuggestionDiagnostics = getSuggestionDiagnostics;
|
|
60
|
+
exports.getSyntacticDiagnostics = getSyntacticDiagnostics;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
+
|
|
15
|
+
var languageService = require('./language-service.js');
|
|
16
|
+
|
|
17
|
+
const getQuickInfoAtPosition = ctx => (fileName, position) => {
|
|
18
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
19
|
+
const route = autotype.getRoute(fileName);
|
|
20
|
+
if (!route) return;
|
|
21
|
+
const splicedIndex = route.autotyped.toSplicedIndex(position);
|
|
22
|
+
const quickinfo = autotype.getQuickInfoAtPosition(fileName, splicedIndex);
|
|
23
|
+
if (!quickinfo) return;
|
|
24
|
+
return {
|
|
25
|
+
...quickinfo,
|
|
26
|
+
textSpan: {
|
|
27
|
+
...quickinfo.textSpan,
|
|
28
|
+
start: route.autotyped.toOriginalIndex(quickinfo.textSpan.start).index
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.getQuickInfoAtPosition = getQuickInfoAtPosition;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-2d5e406e4
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
+
|
|
15
|
+
var languageService = require('./language-service.js');
|
|
16
|
+
|
|
17
|
+
const provideInlayHints = ctx => (fileName, span, preferences) => {
|
|
18
|
+
const autotype = languageService.getAutotypeLanguageService(ctx);
|
|
19
|
+
const route = autotype.getRoute(fileName);
|
|
20
|
+
if (!route) return [];
|
|
21
|
+
const start = route.autotyped.toSplicedIndex(span.start);
|
|
22
|
+
return autotype.provideInlayHints(fileName, {
|
|
23
|
+
start,
|
|
24
|
+
length: route.autotyped.toSplicedIndex(span.start + span.length) - start
|
|
25
|
+
}, preferences).map(hint => ({
|
|
26
|
+
...hint,
|
|
27
|
+
position: route.autotyped.toOriginalIndex(hint.position).index
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.provideInlayHints = provideInlayHints;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type ts from "typescript/lib/tsserverlibrary";
|
|
2
|
+
import type { Context } from "../context";
|
|
3
|
+
type RouteModule = {
|
|
4
|
+
snapshot: ts.IScriptSnapshot;
|
|
5
|
+
version: string;
|
|
6
|
+
autotyped: AutotypedRoute;
|
|
7
|
+
};
|
|
8
|
+
type AutotypeLanguageService = ts.LanguageService & {
|
|
9
|
+
getRoute: (fileName: string) => RouteModule | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare function getAutotypeLanguageService(ctx: Context): AutotypeLanguageService;
|
|
12
|
+
type Splice = {
|
|
13
|
+
index: number;
|
|
14
|
+
content: string;
|
|
15
|
+
remapDiagnostics: {
|
|
16
|
+
start: number;
|
|
17
|
+
length: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare class AutotypedRoute {
|
|
21
|
+
private _originalCode;
|
|
22
|
+
private _splices;
|
|
23
|
+
private _code;
|
|
24
|
+
constructor(code: string, splices: Splice[]);
|
|
25
|
+
code(): string;
|
|
26
|
+
toSplicedIndex(originalIndex: number): number;
|
|
27
|
+
toOriginalIndex(splicedIndex: number): {
|
|
28
|
+
index: number;
|
|
29
|
+
remapDiagnostics?: {
|
|
30
|
+
start: number;
|
|
31
|
+
length: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {};
|