@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.
Files changed (53) hide show
  1. package/dist/cli/commands.js +1 -1
  2. package/dist/cli/detectPackageManager.js +1 -1
  3. package/dist/cli/index.js +1 -1
  4. package/dist/cli/run.js +1 -1
  5. package/dist/cli/useJavascript.js +1 -1
  6. package/dist/colors.js +1 -1
  7. package/dist/config/format.js +1 -1
  8. package/dist/config/routes.js +1 -1
  9. package/dist/invariant.js +1 -1
  10. package/dist/routes.js +1 -1
  11. package/dist/typescript/plugin.js +2 -13
  12. package/dist/typescript/typegen.d.ts +8 -4
  13. package/dist/typescript/typegen.js +23 -23
  14. package/dist/vite/babel.js +1 -1
  15. package/dist/vite/build.js +1 -1
  16. package/dist/vite/cloudflare-dev-proxy.js +1 -1
  17. package/dist/vite/cloudflare.js +1 -1
  18. package/dist/vite/combine-urls.js +1 -1
  19. package/dist/vite/config.js +1 -1
  20. package/dist/vite/dev.js +1 -1
  21. package/dist/vite/import-vite-esm-sync.js +1 -1
  22. package/dist/vite/node-adapter.js +1 -1
  23. package/dist/vite/plugin.js +1 -1
  24. package/dist/vite/profiler.js +1 -1
  25. package/dist/vite/remove-exports.js +1 -1
  26. package/dist/vite/resolve-file-url.js +1 -1
  27. package/dist/vite/styles.js +1 -1
  28. package/dist/vite/vite-node.js +1 -1
  29. package/dist/vite/vmod.js +1 -1
  30. package/dist/vite/with-props.js +1 -1
  31. package/dist/vite.js +1 -1
  32. package/package.json +6 -7
  33. package/dist/typescript/ast.d.ts +0 -8
  34. package/dist/typescript/ast.js +0 -98
  35. package/dist/typescript/autotype/api.completions.d.ts +0 -5
  36. package/dist/typescript/autotype/api.completions.js +0 -75
  37. package/dist/typescript/autotype/api.definitions.d.ts +0 -4
  38. package/dist/typescript/autotype/api.definitions.js +0 -55
  39. package/dist/typescript/autotype/api.diagnostics.d.ts +0 -5
  40. package/dist/typescript/autotype/api.diagnostics.js +0 -60
  41. package/dist/typescript/autotype/api.hover.d.ts +0 -3
  42. package/dist/typescript/autotype/api.hover.js +0 -33
  43. package/dist/typescript/autotype/api.inlay-hints.d.ts +0 -3
  44. package/dist/typescript/autotype/api.inlay-hints.js +0 -31
  45. package/dist/typescript/autotype/index.d.ts +0 -5
  46. package/dist/typescript/autotype/language-service.d.ts +0 -35
  47. package/dist/typescript/autotype/language-service.js +0 -290
  48. package/dist/typescript/context.d.ts +0 -15
  49. package/dist/typescript/decorate.d.ts +0 -2
  50. package/dist/typescript/decorate.js +0 -233
  51. package/dist/typescript/routes.d.ts +0 -10
  52. package/dist/typescript/routes.js +0 -102
  53. package/dist/typescript/typecheck.d.ts +0 -1
@@ -1,233 +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 api_completions = require('./autotype/api.completions.js');
16
- var api_definitions = require('./autotype/api.definitions.js');
17
- var api_diagnostics = require('./autotype/api.diagnostics.js');
18
- var api_hover = require('./autotype/api.hover.js');
19
- var api_inlayHints = require('./autotype/api.inlay-hints.js');
20
- var ast = require('./ast.js');
21
- var routes = require('./routes.js');
22
-
23
- function decorateLanguageService(ctx) {
24
- const ls = ctx.languageService;
25
- // completions
26
- // --------------------------------------------------------------------------
27
- const {
28
- getCompletionsAtPosition
29
- } = ls;
30
- ls.getCompletionsAtPosition = (fileName, position, ...rest) => {
31
- var _ctx$languageService$;
32
- if (!routes.get(ctx, fileName)) {
33
- return getCompletionsAtPosition(fileName, position, ...rest);
34
- }
35
- const completions = api_completions.getCompletionsAtPosition(ctx)(fileName, position, ...rest);
36
- const sourceFile = (_ctx$languageService$ = ctx.languageService.getProgram()) === null || _ctx$languageService$ === void 0 ? void 0 : _ctx$languageService$.getSourceFile(fileName);
37
- if (!sourceFile) return completions;
38
- const node = ast.findNodeAtPosition(sourceFile, position);
39
- if (!node) return completions;
40
- const isTopLevel = ctx.ts.isSourceFile(node.parent) || ctx.ts.isStatement(node.parent) && ctx.ts.isSourceFile(node.parent.parent);
41
- if (!isTopLevel) return completions;
42
- const {
43
- line
44
- } = sourceFile.getLineAndCharacterOfPosition(position);
45
- const lineStart = sourceFile.getPositionOfLineAndCharacter(line, 0);
46
- const normalizedLine = sourceFile.text.slice(lineStart, position).trim().replace(/\s+g/, " ");
47
- const exports = ast.getExportNames(ctx.ts, sourceFile);
48
- const routeExportCompletions = Object.keys(routes.exports).map(key => {
49
- if (exports.has(key)) return null;
50
- const insertText = key === "default" ? `export default function Component() {}` : `export function ${key}() {}`;
51
- if (!fzf(normalizedLine, insertText)) return null;
52
- const completion = {
53
- name: key,
54
- insertText,
55
- kind: ctx.ts.ScriptElementKind.functionElement,
56
- kindModifiers: ctx.ts.ScriptElementKindModifier.exportedModifier,
57
- sortText: "0",
58
- labelDetails: {
59
- description: "React Router Export"
60
- },
61
- data: {
62
- exportName: key,
63
- // TS needs this
64
- __reactRouter: key
65
- }
66
- };
67
- return {
68
- ...completion,
69
- replacementSpan: {
70
- start: lineStart,
71
- length: position - lineStart
72
- }
73
- };
74
- }).filter(x => x !== null);
75
- if (!completions) {
76
- return routeExportCompletions.length > 0 ? {
77
- isGlobalCompletion: false,
78
- isMemberCompletion: false,
79
- isNewIdentifierLocation: false,
80
- isIncomplete: true,
81
- entries: routeExportCompletions
82
- } : undefined;
83
- }
84
- return routeExportCompletions.length > 0 ? {
85
- ...completions,
86
- entries: [...routeExportCompletions, ...completions.entries]
87
- } : completions;
88
- };
89
- const {
90
- getCompletionEntryDetails
91
- } = ls;
92
- ls.getCompletionEntryDetails = (...args) => {
93
- const data = args[6];
94
- if (data.__reactRouter) {
95
- var _Route$exports$key;
96
- const key = data.__reactRouter;
97
- return {
98
- name: key,
99
- kind: ctx.ts.ScriptElementKind.functionElement,
100
- kindModifiers: ctx.ts.ScriptElementKindModifier.exportedModifier,
101
- documentation: ((_Route$exports$key = routes.exports[key]) === null || _Route$exports$key === void 0 ? void 0 : _Route$exports$key.documentation) ?? [],
102
- displayParts: []
103
- };
104
- }
105
- return routes.get(ctx, args[0]) ? api_completions.getCompletionEntryDetails(ctx)(...args) : getCompletionEntryDetails(...args);
106
- };
107
- const {
108
- getSignatureHelpItems
109
- } = ls;
110
- ls.getSignatureHelpItems = (...args) => routes.get(ctx, args[0]) ? api_completions.getSignatureHelpItems(ctx)(...args) : getSignatureHelpItems(...args);
111
- // definitions
112
- // --------------------------------------------------------------------------
113
- const {
114
- getDefinitionAndBoundSpan
115
- } = ls;
116
- ls.getDefinitionAndBoundSpan = (...args) => routes.get(ctx, args[0]) ? api_definitions.getDefinitionAndBoundSpan(ctx)(...args) : getDefinitionAndBoundSpan(...args);
117
- const {
118
- getTypeDefinitionAtPosition
119
- } = ls;
120
- ls.getTypeDefinitionAtPosition = (...args) => routes.get(ctx, args[0]) ? api_definitions.getTypeDefinitionAtPosition(ctx)(...args) : getTypeDefinitionAtPosition(...args);
121
- // diagnostics
122
- // --------------------------------------------------------------------------
123
- const {
124
- getSyntacticDiagnostics
125
- } = ls;
126
- ls.getSyntacticDiagnostics = (...args) => routes.get(ctx, args[0]) ? api_diagnostics.getSyntacticDiagnostics(ctx)(...args) : getSyntacticDiagnostics(...args);
127
- const {
128
- getSemanticDiagnostics
129
- } = ls;
130
- ls.getSemanticDiagnostics = fileName => {
131
- var _ls$getProgram;
132
- if (!routes.get(ctx, fileName)) return getSemanticDiagnostics(fileName);
133
- const diagnostics = api_diagnostics.getSemanticDiagnostics(ctx)(fileName);
134
- const sourceFile = (_ls$getProgram = ls.getProgram()) === null || _ls$getProgram === void 0 ? void 0 : _ls$getProgram.getSourceFile(fileName);
135
- if (!sourceFile) return diagnostics;
136
- const exportStarDiagnostics = sourceFile.statements
137
- // eslint-disable-next-line array-callback-return
138
- .map(stmt => {
139
- if (!ctx.ts.isExportDeclaration(stmt)) return undefined;
140
- if (stmt.exportClause === undefined ||
141
- // export * as stuff from "..."
142
- ctx.ts.isNamespaceExportDeclaration(stmt) // export * as stuff from "..."
143
- ) {
144
- const diagnostic = {
145
- file: sourceFile,
146
- category: ctx.ts.DiagnosticCategory.Warning,
147
- start: stmt.getStart(),
148
- length: stmt.getWidth(),
149
- messageText: "React Router cannot typecheck route exports from `*` exports",
150
- code: 100
151
- };
152
- return diagnostic;
153
- }
154
- }).filter(x => x !== undefined);
155
- const hmrNamedFunctionsDiagnostics = sourceFile.statements
156
- // eslint-disable-next-line array-callback-return
157
- .map(stmt => {
158
- if (ctx.ts.isFunctionDeclaration(stmt)) {
159
- // export default function ...
160
- if (!ast.exported(ctx.ts, stmt)) return undefined;
161
- if (!ast.defaulted(ctx.ts, stmt)) return undefined;
162
- if (!stmt.name) {
163
- return {
164
- file: sourceFile,
165
- category: ctx.ts.DiagnosticCategory.Warning,
166
- start: stmt.getStart(),
167
- length: stmt.getWidth(),
168
- messageText: "For HMR to work, React Router default export must be named\n\nhttps://remix.run/docs/en/main/discussion/hot-module-replacement#named-function-components",
169
- code: 101
170
- };
171
- }
172
- }
173
- if (ctx.ts.isExportAssignment(stmt)) {
174
- if (stmt.isExportEquals) return undefined;
175
- // export default expr
176
- return {
177
- file: sourceFile,
178
- category: ctx.ts.DiagnosticCategory.Warning,
179
- start: stmt.getStart(),
180
- length: stmt.getWidth(),
181
- messageText: "For HMR to work, React Router default export must be named\n\nhttps://remix.run/docs/en/main/discussion/hot-module-replacement#named-function-components",
182
- code: 101
183
- };
184
- }
185
- }).filter(x => x !== undefined);
186
- return [...hmrNamedFunctionsDiagnostics, ...exportStarDiagnostics, ...diagnostics];
187
- };
188
- const {
189
- getSuggestionDiagnostics
190
- } = ls;
191
- ls.getSuggestionDiagnostics = (...args) => routes.get(ctx, args[0]) ? api_diagnostics.getSuggestionDiagnostics(ctx)(...args) : getSuggestionDiagnostics(...args);
192
- // diagnostics
193
- // --------------------------------------------------------------------------
194
- const {
195
- getQuickInfoAtPosition
196
- } = ls;
197
- ls.getQuickInfoAtPosition = (fileName, position) => {
198
- var _ctx$languageService$2, _Route$exports$export;
199
- const route = routes.get(ctx, fileName);
200
- if (!route) return getQuickInfoAtPosition(fileName, position);
201
- const quickinfo = routes.get(ctx, fileName) ? api_hover.getQuickInfoAtPosition(ctx)(fileName, position) : getQuickInfoAtPosition(fileName, position);
202
- if (!quickinfo) return;
203
- const sourceFile = (_ctx$languageService$2 = ctx.languageService.getProgram()) === null || _ctx$languageService$2 === void 0 ? void 0 : _ctx$languageService$2.getSourceFile(fileName);
204
- const node = sourceFile && ast.findNodeAtPosition(sourceFile, position);
205
- const exportName = node && ast.getRouteExportName(ctx, node);
206
- const routeExportDocs = exportName ? (_Route$exports$export = routes.exports[exportName]) === null || _Route$exports$export === void 0 ? void 0 : _Route$exports$export.documentation : undefined;
207
- const documentation = [...(quickinfo.documentation ?? []), ...(routeExportDocs ?? [])];
208
- return {
209
- ...quickinfo,
210
- documentation: documentation.length > 0 ? documentation : undefined
211
- };
212
- };
213
- // inlay hints
214
- // --------------------------------------------------------------------------
215
- const {
216
- provideInlayHints
217
- } = ls;
218
- ls.provideInlayHints = (...args) => routes.get(ctx, args[0]) ? api_inlayHints.provideInlayHints(ctx)(...args) : provideInlayHints(...args);
219
- }
220
- function fzf(pattern, target) {
221
- let patternIndex = 0;
222
- let targetIndex = 0;
223
- while (patternIndex < pattern.length && targetIndex < target.length) {
224
- var _pattern$patternIndex, _target$targetIndex;
225
- if (((_pattern$patternIndex = pattern[patternIndex]) === null || _pattern$patternIndex === void 0 ? void 0 : _pattern$patternIndex.toLowerCase()) === ((_target$targetIndex = target[targetIndex]) === null || _target$targetIndex === void 0 ? void 0 : _target$targetIndex.toLowerCase())) {
226
- patternIndex += 1;
227
- }
228
- targetIndex += 1;
229
- }
230
- return patternIndex === pattern.length;
231
- }
232
-
233
- exports.decorateLanguageService = decorateLanguageService;
@@ -1,10 +0,0 @@
1
- import type ts from "typescript/lib/tsserverlibrary";
2
- import type { Context } from "./context";
3
- import type { RouteManifestEntry } from "../config/routes";
4
- export declare function get(ctx: Context, fileName: string): RouteManifestEntry | undefined;
5
- type RouteExportInfo = {
6
- annotateReturnType: boolean;
7
- documentation: ts.SymbolDisplayPart[];
8
- };
9
- export declare const exports: Record<string, RouteExportInfo>;
10
- export {};
@@ -1,102 +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 Path = require('pathe');
16
- var Pathe = require('pathe/utils');
17
-
18
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
-
20
- var Path__default = /*#__PURE__*/_interopDefaultLegacy(Path);
21
- var Pathe__default = /*#__PURE__*/_interopDefaultLegacy(Pathe);
22
-
23
- function noext(path) {
24
- return Path__default["default"].join(Path__default["default"].dirname(path), Pathe__default["default"].filename(path));
25
- }
26
- function get(ctx, fileName) {
27
- var _ctx$logger;
28
- const routeId = noext(Path__default["default"].relative(ctx.config.appDirectory, fileName));
29
- (_ctx$logger = ctx.logger) === null || _ctx$logger === void 0 ? void 0 : _ctx$logger.info(`Route.get filename:${fileName} routeId:${routeId} routes:${JSON.stringify(ctx.routes)}`);
30
- return ctx.routes[routeId];
31
- }
32
- const exports$1 = {
33
- links: {
34
- annotateReturnType: true,
35
- documentation: createDocumentation({
36
- name: "links",
37
- link: `https://remix.run/docs/en/main/route/links`
38
- })
39
- },
40
- loader: {
41
- annotateReturnType: false,
42
- documentation: createDocumentation({
43
- name: "serverLoader",
44
- link: `https://remix.run/docs/en/main/route/loader`
45
- })
46
- },
47
- clientLoader: {
48
- annotateReturnType: false,
49
- documentation: createDocumentation({
50
- name: "clientLoader",
51
- link: `https://remix.run/docs/en/main/route/client-loader`
52
- })
53
- },
54
- // TODO clientLoader.hydrate?
55
- HydrateFallback: {
56
- annotateReturnType: true,
57
- documentation: createDocumentation({
58
- name: "HydrateFallback",
59
- link: `https://remix.run/docs/en/main/route/hydrate-fallback`
60
- })
61
- },
62
- action: {
63
- annotateReturnType: false,
64
- documentation: createDocumentation({
65
- name: "serverAction",
66
- link: `https://remix.run/docs/en/main/route/action`
67
- })
68
- },
69
- clientAction: {
70
- annotateReturnType: false,
71
- documentation: createDocumentation({
72
- name: "clientAction",
73
- link: `https://remix.run/docs/en/main/route/client-action`
74
- })
75
- },
76
- default: {
77
- annotateReturnType: true,
78
- documentation: createDocumentation({
79
- name: "default",
80
- link: `https://remix.run/docs/en/main/route/component`
81
- })
82
- },
83
- ErrorBoundary: {
84
- annotateReturnType: true,
85
- documentation: createDocumentation({
86
- name: "ErrorBoundary",
87
- link: `https://remix.run/docs/en/main/route/error-boundary`
88
- })
89
- }
90
- // TODO handle
91
- // TODO meta
92
- // TODO shouldRevalidate
93
- };
94
- function createDocumentation(args) {
95
- return [{
96
- kind: "text",
97
- text: `React Router \`${args.name}\` export\n\nDocs: ${args.link}`
98
- }];
99
- }
100
-
101
- exports.exports = exports$1;
102
- exports.get = get;
@@ -1 +0,0 @@
1
- export declare function typecheck(rootDirectory: string): void;