@react-router/dev 7.0.0-pre.2 → 7.0.0-pre.4

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 (67) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cli/index.d.ts +2 -1
  3. package/dist/cli/index.js +1198 -8
  4. package/dist/{config/routes.d.ts → routes-C14jcF98.d.ts} +15 -21
  5. package/dist/routes.d.ts +2 -2
  6. package/dist/routes.js +181 -11
  7. package/dist/typescript/plugin.d.ts +5 -2
  8. package/dist/typescript/plugin.js +479 -31
  9. package/dist/vite/cloudflare.d.ts +23 -1
  10. package/dist/vite/cloudflare.js +171 -5
  11. package/dist/vite.d.ts +169 -2
  12. package/dist/vite.js +2394 -5
  13. package/package.json +28 -7
  14. package/dist/cli/commands.d.ts +0 -13
  15. package/dist/cli/commands.js +0 -179
  16. package/dist/cli/detectPackageManager.d.ts +0 -10
  17. package/dist/cli/detectPackageManager.js +0 -39
  18. package/dist/cli/run.d.ts +0 -5
  19. package/dist/cli/run.js +0 -188
  20. package/dist/cli/useJavascript.d.ts +0 -4
  21. package/dist/cli/useJavascript.js +0 -66
  22. package/dist/colors.d.ts +0 -17
  23. package/dist/colors.js +0 -49
  24. package/dist/config/format.d.ts +0 -5
  25. package/dist/config/format.js +0 -68
  26. package/dist/config/routes.js +0 -253
  27. package/dist/config/serverModes.d.ts +0 -9
  28. package/dist/invariant.d.ts +0 -2
  29. package/dist/invariant.js +0 -20
  30. package/dist/manifest.d.ts +0 -28
  31. package/dist/typescript/typegen.d.ts +0 -10
  32. package/dist/typescript/typegen.js +0 -190
  33. package/dist/vite/babel.d.ts +0 -20
  34. package/dist/vite/babel.js +0 -49
  35. package/dist/vite/build.d.ts +0 -15
  36. package/dist/vite/build.js +0 -249
  37. package/dist/vite/cloudflare-dev-proxy.d.ts +0 -21
  38. package/dist/vite/cloudflare-dev-proxy.js +0 -89
  39. package/dist/vite/combine-urls-test.d.ts +0 -1
  40. package/dist/vite/combine-urls.d.ts +0 -1
  41. package/dist/vite/combine-urls.js +0 -20
  42. package/dist/vite/config.d.ts +0 -234
  43. package/dist/vite/config.js +0 -282
  44. package/dist/vite/dev.d.ts +0 -15
  45. package/dist/vite/dev.js +0 -81
  46. package/dist/vite/import-vite-esm-sync.d.ts +0 -4
  47. package/dist/vite/import-vite-esm-sync.js +0 -28
  48. package/dist/vite/node-adapter.d.ts +0 -6
  49. package/dist/vite/node-adapter.js +0 -90
  50. package/dist/vite/plugin.d.ts +0 -75
  51. package/dist/vite/plugin.js +0 -1301
  52. package/dist/vite/profiler.d.ts +0 -5
  53. package/dist/vite/profiler.js +0 -55
  54. package/dist/vite/remove-exports-test.d.ts +0 -1
  55. package/dist/vite/remove-exports.d.ts +0 -2
  56. package/dist/vite/remove-exports.js +0 -148
  57. package/dist/vite/resolve-file-url.d.ts +0 -3
  58. package/dist/vite/resolve-file-url.js +0 -53
  59. package/dist/vite/styles.d.ts +0 -14
  60. package/dist/vite/styles.js +0 -199
  61. package/dist/vite/vite-node.d.ts +0 -9
  62. package/dist/vite/vite-node.js +0 -57
  63. package/dist/vite/vmod.d.ts +0 -3
  64. package/dist/vite/vmod.js +0 -21
  65. package/dist/vite/with-props.d.ts +0 -4
  66. package/dist/vite/with-props.js +0 -151
  67. /package/dist/{vite/static → static}/refresh-utils.cjs +0 -0
@@ -1,151 +0,0 @@
1
- /**
2
- * @react-router/dev v7.0.0-pre.2
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 dedent = require('dedent');
16
- var babel = require('./babel.js');
17
- var vmod = require('./vmod.js');
18
- var t = require('@babel/types');
19
-
20
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
-
22
- function _interopNamespace(e) {
23
- if (e && e.__esModule) return e;
24
- var n = Object.create(null);
25
- if (e) {
26
- Object.keys(e).forEach(function (k) {
27
- if (k !== 'default') {
28
- var d = Object.getOwnPropertyDescriptor(e, k);
29
- Object.defineProperty(n, k, d.get ? d : {
30
- enumerable: true,
31
- get: function () { return e[k]; }
32
- });
33
- }
34
- });
35
- }
36
- n["default"] = e;
37
- return Object.freeze(n);
38
- }
39
-
40
- var dedent__default = /*#__PURE__*/_interopDefaultLegacy(dedent);
41
- var t__namespace = /*#__PURE__*/_interopNamespace(t);
42
-
43
- const vmodId = vmod.id("with-props");
44
- const NAMED_COMPONENT_EXPORTS = ["HydrateFallback", "ErrorBoundary"];
45
- const plugin = {
46
- name: "react-router-with-props",
47
- enforce: "pre",
48
- resolveId(id) {
49
- if (id === vmodId) return vmod.resolve(vmodId);
50
- },
51
- async load(id) {
52
- if (id !== vmod.resolve(vmodId)) return;
53
- return dedent__default["default"]`
54
- import { createElement as h } from "react";
55
- import { useActionData, useLoaderData, useParams } from "react-router";
56
-
57
- export function withComponentProps(Component) {
58
- return function Wrapped() {
59
- const props = {
60
- params: useParams(),
61
- loaderData: useLoaderData(),
62
- actionData: useActionData(),
63
- };
64
- return h(Component, props);
65
- };
66
- }
67
-
68
- export function withHydrateFallbackProps(HydrateFallback) {
69
- return function Wrapped() {
70
- const props = {
71
- params: useParams(),
72
- };
73
- return h(HydrateFallback, props);
74
- };
75
- }
76
-
77
- export function withErrorBoundaryProps(ErrorBoundary) {
78
- return function Wrapped() {
79
- const props = {
80
- params: useParams(),
81
- loaderData: useLoaderData(),
82
- actionData: useActionData(),
83
- };
84
- return h(ErrorBoundary, props);
85
- };
86
- }
87
- `;
88
- }
89
- };
90
- const transform = ast => {
91
- const hocs = [];
92
- function getHocUid(path, hocName) {
93
- const uid = path.scope.generateUidIdentifier(hocName);
94
- hocs.push([hocName, uid]);
95
- return uid;
96
- }
97
- babel.traverse(ast, {
98
- ExportDeclaration(path) {
99
- if (path.isExportDefaultDeclaration()) {
100
- const declaration = path.get("declaration");
101
- // prettier-ignore
102
- const expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : undefined;
103
- if (expr) {
104
- const uid = getHocUid(path, "withComponentProps");
105
- declaration.replaceWith(t__namespace.callExpression(uid, [expr]));
106
- }
107
- return;
108
- }
109
- if (path.isExportNamedDeclaration()) {
110
- const decl = path.get("declaration");
111
- if (decl.isVariableDeclaration()) {
112
- decl.get("declarations").forEach(varDeclarator => {
113
- const id = varDeclarator.get("id");
114
- const init = varDeclarator.get("init");
115
- const expr = init.node;
116
- if (!expr) return;
117
- if (!id.isIdentifier()) return;
118
- const {
119
- name
120
- } = id.node;
121
- if (!NAMED_COMPONENT_EXPORTS.includes(name)) return;
122
- const uid = getHocUid(path, `with${name}Props`);
123
- init.replaceWith(t__namespace.callExpression(uid, [expr]));
124
- });
125
- return;
126
- }
127
- if (decl.isFunctionDeclaration()) {
128
- const {
129
- id
130
- } = decl.node;
131
- if (!id) return;
132
- const {
133
- name
134
- } = id;
135
- if (!NAMED_COMPONENT_EXPORTS.includes(name)) return;
136
- const uid = getHocUid(path, `with${name}Props`);
137
- decl.replaceWith(t__namespace.variableDeclaration("const", [t__namespace.variableDeclarator(t__namespace.identifier(name), t__namespace.callExpression(uid, [toFunctionExpression(decl.node)]))]));
138
- }
139
- }
140
- }
141
- });
142
- if (hocs.length > 0) {
143
- ast.program.body.unshift(t__namespace.importDeclaration(hocs.map(([name, identifier]) => t__namespace.importSpecifier(identifier, t__namespace.identifier(name))), t__namespace.stringLiteral(vmodId)));
144
- }
145
- };
146
- function toFunctionExpression(decl) {
147
- return t__namespace.functionExpression(decl.id, decl.params, decl.body, decl.generator, decl.async);
148
- }
149
-
150
- exports.plugin = plugin;
151
- exports.transform = transform;
File without changes