@react-router/dev 0.0.0-experimental-2d5e406e4 → 0.0.0-experimental-7de693505
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 +1 -1
- package/dist/invariant.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/typescript/plugin.js +2 -13
- package/dist/typescript/typegen.d.ts +8 -4
- package/dist/typescript/typegen.js +23 -23
- package/dist/vite/babel.js +1 -1
- package/dist/vite/build.js +1 -1
- 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.js +1 -1
- package/dist/vite/dev.js +1 -1
- package/dist/vite/import-vite-esm-sync.js +1 -1
- package/dist/vite/node-adapter.js +1 -1
- package/dist/vite/plugin.js +1 -1
- 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.js +1 -1
- package/dist/vite/vmod.js +1 -1
- package/dist/vite/with-props.js +1 -1
- package/dist/vite.js +1 -1
- package/package.json +6 -7
- package/dist/typescript/ast.d.ts +0 -8
- package/dist/typescript/ast.js +0 -98
- package/dist/typescript/autotype/api.completions.d.ts +0 -5
- package/dist/typescript/autotype/api.completions.js +0 -75
- package/dist/typescript/autotype/api.definitions.d.ts +0 -4
- package/dist/typescript/autotype/api.definitions.js +0 -55
- package/dist/typescript/autotype/api.diagnostics.d.ts +0 -5
- package/dist/typescript/autotype/api.diagnostics.js +0 -60
- package/dist/typescript/autotype/api.hover.d.ts +0 -3
- package/dist/typescript/autotype/api.hover.js +0 -33
- package/dist/typescript/autotype/api.inlay-hints.d.ts +0 -3
- package/dist/typescript/autotype/api.inlay-hints.js +0 -31
- package/dist/typescript/autotype/index.d.ts +0 -5
- package/dist/typescript/autotype/language-service.d.ts +0 -35
- package/dist/typescript/autotype/language-service.js +0 -290
- package/dist/typescript/context.d.ts +0 -15
- package/dist/typescript/decorate.d.ts +0 -2
- package/dist/typescript/decorate.js +0 -233
- package/dist/typescript/routes.d.ts +0 -10
- package/dist/typescript/routes.js +0 -102
- package/dist/typescript/typecheck.d.ts +0 -1
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
package/dist/invariant.js
CHANGED
package/dist/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-7de693505
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
var Path = require('pathe');
|
|
14
14
|
var typegen = require('./typegen.js');
|
|
15
|
-
var decorate = require('./decorate.js');
|
|
16
15
|
|
|
17
16
|
function _interopNamespace(e) {
|
|
18
17
|
if (e && e.__esModule) return e;
|
|
@@ -42,21 +41,11 @@ function init(modules) {
|
|
|
42
41
|
} = info.project.projectService;
|
|
43
42
|
logger.info("[react-router] setup");
|
|
44
43
|
const rootDirectory = Path__namespace.normalize(info.project.getCurrentDirectory());
|
|
45
|
-
const
|
|
44
|
+
const ctx = {
|
|
46
45
|
rootDirectory,
|
|
47
46
|
appDirectory: Path__namespace.join(rootDirectory, "app")
|
|
48
47
|
};
|
|
49
|
-
const ctx = {
|
|
50
|
-
config,
|
|
51
|
-
routes: {},
|
|
52
|
-
// will be updated by `Typegen.watch`
|
|
53
|
-
languageService: info.languageService,
|
|
54
|
-
languageServiceHost: info.languageServiceHost,
|
|
55
|
-
ts: modules.typescript,
|
|
56
|
-
logger
|
|
57
|
-
};
|
|
58
48
|
typegen.watch(ctx);
|
|
59
|
-
decorate.decorateLanguageService(ctx);
|
|
60
49
|
return info.languageService;
|
|
61
50
|
}
|
|
62
51
|
return {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { type RouteManifestEntry } from "../config/routes";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type RouteManifest, type RouteManifestEntry } from "../config/routes";
|
|
2
|
+
type Context = {
|
|
3
|
+
rootDirectory: string;
|
|
4
|
+
appDirectory: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function getPath(ctx: Context, route: RouteManifestEntry): string;
|
|
4
7
|
export declare function watch(ctx: Context): Promise<void>;
|
|
5
|
-
export declare function typegenAll(ctx: Context): Promise<void>;
|
|
8
|
+
export declare function typegenAll(ctx: Context, routes: RouteManifest): Promise<void>;
|
|
9
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-7de693505
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -47,75 +47,75 @@ var Path__namespace = /*#__PURE__*/_interopNamespace(Path);
|
|
|
47
47
|
var Pathe__namespace = /*#__PURE__*/_interopNamespace(Pathe);
|
|
48
48
|
|
|
49
49
|
function getDirectory(ctx) {
|
|
50
|
-
return Path__namespace.join(ctx.
|
|
50
|
+
return Path__namespace.join(ctx.rootDirectory, ".react-router/types");
|
|
51
51
|
}
|
|
52
52
|
function getPath(ctx, route) {
|
|
53
53
|
return Path__namespace.join(getDirectory(ctx), "app", Path__namespace.dirname(route.file), "+types." + Path__namespace.basename(route.file));
|
|
54
54
|
}
|
|
55
55
|
async function watch(ctx) {
|
|
56
|
-
const appDirectory = Path__namespace.normalize(ctx.
|
|
56
|
+
const appDirectory = Path__namespace.normalize(ctx.appDirectory);
|
|
57
57
|
const routesTsPath = Path__namespace.join(appDirectory, "routes.ts");
|
|
58
58
|
const routesViteNodeContext = await viteNode.createContext();
|
|
59
|
-
async function
|
|
59
|
+
async function getRoutes() {
|
|
60
60
|
routesViteNodeContext.devServer.moduleGraph.invalidateAll();
|
|
61
61
|
routesViteNodeContext.runner.moduleCache.clear();
|
|
62
62
|
const result = await routesViteNodeContext.runner.executeFile(routesTsPath);
|
|
63
|
-
|
|
63
|
+
return routes.configRoutesToRouteManifest(result.routes);
|
|
64
64
|
}
|
|
65
|
-
await
|
|
66
|
-
await typegenAll(ctx);
|
|
65
|
+
const initialRoutes = await getRoutes();
|
|
66
|
+
await typegenAll(ctx, initialRoutes);
|
|
67
67
|
const watcher = Chokidar__default["default"].watch(appDirectory, {
|
|
68
68
|
ignoreInitial: true
|
|
69
69
|
});
|
|
70
70
|
watcher.on("all", async (event, path) => {
|
|
71
71
|
path = Path__namespace.normalize(path);
|
|
72
|
-
await
|
|
72
|
+
const routes = await getRoutes();
|
|
73
73
|
const routeConfigChanged = Boolean(routesViteNodeContext.devServer.moduleGraph.getModuleById(path));
|
|
74
74
|
if (routeConfigChanged) {
|
|
75
|
-
await typegenAll(ctx);
|
|
75
|
+
await typegenAll(ctx, routes);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
const isRoute = Object.values(
|
|
78
|
+
const isRoute = Object.values(routes).find(route => path === Path__namespace.join(ctx.appDirectory, route.file));
|
|
79
79
|
if (isRoute && (event === "add" || event === "unlink")) {
|
|
80
|
-
await typegenAll(ctx);
|
|
80
|
+
await typegenAll(ctx, routes);
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
async function typegenAll(ctx) {
|
|
85
|
+
async function typegenAll(ctx, routes) {
|
|
86
86
|
fs__default["default"].rmSync(getDirectory(ctx), {
|
|
87
87
|
recursive: true,
|
|
88
88
|
force: true
|
|
89
89
|
});
|
|
90
|
-
Object.values(
|
|
90
|
+
Object.values(routes).forEach(route => {
|
|
91
91
|
const typesPath = getPath(ctx, route);
|
|
92
|
-
const content = getModule(
|
|
92
|
+
const content = getModule(routes, route);
|
|
93
93
|
fs__default["default"].mkdirSync(Path__namespace.dirname(typesPath), {
|
|
94
94
|
recursive: true
|
|
95
95
|
});
|
|
96
96
|
fs__default["default"].writeFileSync(typesPath, content);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
function getModule(
|
|
99
|
+
function getModule(routes, route) {
|
|
100
100
|
return dedent__default["default"]`
|
|
101
101
|
// typegen: ${route.file}
|
|
102
102
|
import * as T from "react-router/types"
|
|
103
103
|
|
|
104
|
-
export type Params = {${formattedParamsProperties(
|
|
104
|
+
export type Params = {${formattedParamsProperties(routes, route)}}
|
|
105
105
|
|
|
106
106
|
type Route = typeof import("./${Pathe__namespace.filename(route.file)}")
|
|
107
107
|
|
|
108
108
|
export type LoaderData = T.LoaderData<Route>
|
|
109
109
|
export type ActionData = T.ActionData<Route>
|
|
110
110
|
|
|
111
|
-
export type
|
|
112
|
-
export type
|
|
113
|
-
export type
|
|
114
|
-
export type
|
|
111
|
+
export type LoaderArgs = T.ServerLoaderArgs<Params>
|
|
112
|
+
export type ClientLoaderArgs = T.ClientLoaderArgs<Params, Route>
|
|
113
|
+
export type ActionArgs = T.ServerActionArgs<Params>
|
|
114
|
+
export type ClientActionArgs = T.ClientActionArgs<Params, Route>
|
|
115
115
|
|
|
116
|
-
export type
|
|
117
|
-
export type
|
|
118
|
-
export type
|
|
116
|
+
export type HydrateFallbackProps = T.HydrateFallbackProps<Params>
|
|
117
|
+
export type DefaultProps = T.DefaultProps<Params, LoaderData, ActionData>
|
|
118
|
+
export type ErrorBoundaryProps = T.ErrorBoundaryProps<Params, LoaderData, ActionData>
|
|
119
119
|
`;
|
|
120
120
|
}
|
|
121
121
|
function formattedParamsProperties(routes, route) {
|
package/dist/vite/babel.js
CHANGED
package/dist/vite/build.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
package/dist/vite/config.js
CHANGED
package/dist/vite/dev.js
CHANGED
package/dist/vite/plugin.js
CHANGED
package/dist/vite/profiler.js
CHANGED
package/dist/vite/styles.js
CHANGED
package/dist/vite/vite-node.js
CHANGED
package/dist/vite/vmod.js
CHANGED
package/dist/vite/with-props.js
CHANGED
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-7de693505",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"set-cookie-parser": "^2.6.0",
|
|
62
62
|
"valibot": "^0.41.0",
|
|
63
63
|
"vite-node": "^1.6.0",
|
|
64
|
-
"@react-router/node": "0.0.0-experimental-
|
|
64
|
+
"@react-router/node": "0.0.0-experimental-7de693505"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/babel__core": "^7.20.5",
|
|
@@ -85,18 +85,17 @@
|
|
|
85
85
|
"fast-glob": "3.2.11",
|
|
86
86
|
"strip-ansi": "^6.0.1",
|
|
87
87
|
"tiny-invariant": "^1.2.0",
|
|
88
|
-
"typescript": "^5.6.2",
|
|
89
88
|
"vite": "^5.1.0",
|
|
90
89
|
"wrangler": "^3.28.2",
|
|
91
|
-
"react-router": "
|
|
92
|
-
"
|
|
90
|
+
"@react-router/serve": "0.0.0-experimental-7de693505",
|
|
91
|
+
"react-router": "^0.0.0-experimental-7de693505"
|
|
93
92
|
},
|
|
94
93
|
"peerDependencies": {
|
|
95
94
|
"typescript": "^5.1.0",
|
|
96
95
|
"vite": "^5.1.0",
|
|
97
96
|
"wrangler": "^3.28.2",
|
|
98
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
99
|
-
"react-router": "^0.0.0-experimental-
|
|
97
|
+
"@react-router/serve": "^0.0.0-experimental-7de693505",
|
|
98
|
+
"react-router": "^0.0.0-experimental-7de693505"
|
|
100
99
|
},
|
|
101
100
|
"peerDependenciesMeta": {
|
|
102
101
|
"@react-router/serve": {
|
package/dist/typescript/ast.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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;
|
package/dist/typescript/ast.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
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;
|
|
@@ -1,5 +0,0 @@
|
|
|
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"];
|
|
@@ -1,75 +0,0 @@
|
|
|
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;
|
|
@@ -1,4 +0,0 @@
|
|
|
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"];
|