next 15.2.0-canary.75 → 15.2.0-canary.76
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.
Potentially problematic release.
This version of next might be problematic. Click here for more details.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +2 -2
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/app-dir/form.d.ts +2 -43
- package/dist/client/app-dir/form.js +20 -144
- package/dist/client/app-dir/form.js.map +1 -1
- package/dist/client/components/react-dev-overlay/shared.d.ts +2 -0
- package/dist/client/components/react-dev-overlay/shared.js +10 -0
- package/dist/client/components/react-dev-overlay/shared.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/call-stack-frame/call-stack-frame.d.ts +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/call-stack-frame/call-stack-frame.js +11 -3
- package/dist/client/components/react-dev-overlay/ui/components/call-stack-frame/call-stack-frame.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.d.ts +3 -4
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.js +45 -9
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/dev-tools-info.d.ts +4 -4
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/dev-tools-info.js +5 -4
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/dev-tools-info.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/route-info.d.ts +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/route-info.js +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/route-info.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/turbopack-info.d.ts +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/turbopack-info.js +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/turbopack-info.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/user-preferences.d.ts +10 -0
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/user-preferences.js +254 -0
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/user-preferences.js.map +1 -0
- package/dist/client/components/react-dev-overlay/ui/components/shadow-portal.js +12 -0
- package/dist/client/components/react-dev-overlay/ui/components/shadow-portal.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/icons/dark-icon.d.ts +1 -0
- package/dist/client/components/react-dev-overlay/ui/icons/dark-icon.js +34 -0
- package/dist/client/components/react-dev-overlay/ui/icons/dark-icon.js.map +1 -0
- package/dist/client/components/react-dev-overlay/ui/icons/external.d.ts +1 -0
- package/dist/client/components/react-dev-overlay/ui/icons/external.js +31 -3
- package/dist/client/components/react-dev-overlay/ui/icons/external.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/icons/eye-icon.d.ts +1 -0
- package/dist/client/components/react-dev-overlay/ui/icons/eye-icon.js +33 -0
- package/dist/client/components/react-dev-overlay/ui/icons/eye-icon.js.map +1 -0
- package/dist/client/components/react-dev-overlay/ui/icons/gear-icon.d.ts +1 -0
- package/dist/client/components/react-dev-overlay/ui/icons/gear-icon.js +34 -0
- package/dist/client/components/react-dev-overlay/ui/icons/gear-icon.js.map +1 -0
- package/dist/client/components/react-dev-overlay/ui/icons/light-icon.d.ts +1 -0
- package/dist/client/components/react-dev-overlay/ui/icons/light-icon.js +48 -0
- package/dist/client/components/react-dev-overlay/ui/icons/light-icon.js.map +1 -0
- package/dist/client/components/react-dev-overlay/ui/styles/base.js +14 -2
- package/dist/client/components/react-dev-overlay/ui/styles/base.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/styles/colors.js +16 -4
- package/dist/client/components/react-dev-overlay/ui/styles/colors.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/styles/component-styles.js +3 -1
- package/dist/client/components/react-dev-overlay/ui/styles/component-styles.js.map +1 -1
- package/dist/client/form-shared.d.ts +50 -0
- package/dist/client/form-shared.js +155 -0
- package/dist/client/form-shared.js.map +1 -0
- package/dist/client/form.d.ts +6 -41
- package/dist/client/form.js +38 -196
- package/dist/client/form.js.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +3 -3
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/app-page.runtime.dev.js +3 -3
- package/dist/compiled/next-server/app-page.runtime.dev.js.map +1 -1
- package/dist/esm/build/index.js +2 -2
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/app-dir/form.js +17 -141
- package/dist/esm/client/app-dir/form.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/shared.js +2 -0
- package/dist/esm/client/components/react-dev-overlay/shared.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/call-stack-frame/call-stack-frame.js +12 -4
- package/dist/esm/client/components/react-dev-overlay/ui/components/call-stack-frame/call-stack-frame.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.js +44 -9
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/dev-tools-info.js +5 -4
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/dev-tools-info.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/route-info.js +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/route-info.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/turbopack-info.js +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/turbopack-info.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/user-preferences.js +225 -0
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-info/user-preferences.js.map +1 -0
- package/dist/esm/client/components/react-dev-overlay/ui/components/shadow-portal.js +12 -0
- package/dist/esm/client/components/react-dev-overlay/ui/components/shadow-portal.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/icons/dark-icon.js +18 -0
- package/dist/esm/client/components/react-dev-overlay/ui/icons/dark-icon.js.map +1 -0
- package/dist/esm/client/components/react-dev-overlay/ui/icons/external.js +16 -0
- package/dist/esm/client/components/react-dev-overlay/ui/icons/external.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/icons/eye-icon.js +17 -0
- package/dist/esm/client/components/react-dev-overlay/ui/icons/eye-icon.js.map +1 -0
- package/dist/esm/client/components/react-dev-overlay/ui/icons/gear-icon.js +18 -0
- package/dist/esm/client/components/react-dev-overlay/ui/icons/gear-icon.js.map +1 -0
- package/dist/esm/client/components/react-dev-overlay/ui/icons/light-icon.js +32 -0
- package/dist/esm/client/components/react-dev-overlay/ui/icons/light-icon.js.map +1 -0
- package/dist/esm/client/components/react-dev-overlay/ui/styles/base.js +14 -2
- package/dist/esm/client/components/react-dev-overlay/ui/styles/base.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/styles/colors.js +16 -4
- package/dist/esm/client/components/react-dev-overlay/ui/styles/colors.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/styles/component-styles.js +3 -1
- package/dist/esm/client/components/react-dev-overlay/ui/styles/component-styles.js.map +1 -1
- package/dist/esm/client/form-shared.js +103 -0
- package/dist/esm/client/form-shared.js.map +1 -0
- package/dist/esm/client/form.js +35 -193
- package/dist/esm/client/form.js.map +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/config.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/server/config.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +24 -24
package/dist/bin/next
CHANGED
@@ -79,7 +79,7 @@ const program = new NextRootCommand();
|
|
79
79
|
program.name('next').description('The Next.js CLI allows you to develop, build, start your application, and more.').configureHelp({
|
80
80
|
formatHelp: (cmd, helper)=>(0, _formatclihelpoutput.formatCliHelpOutput)(cmd, helper),
|
81
81
|
subcommandTerm: (cmd)=>`${cmd.name()} ${cmd.usage()}`
|
82
|
-
}).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.2.0-canary.
|
82
|
+
}).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.2.0-canary.76"}`, '-v, --version', 'Outputs the Next.js version.');
|
83
83
|
program.command('build').description('Creates an optimized production build of your application. The output displays information about each route.').argument('[directory]', `A directory on which to build the application. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).option('-d, --debug', 'Enables a more verbose build output.').option('--no-lint', 'Disables linting.').option('--no-mangling', 'Disables mangling.').option('--profile', 'Enables production profiling for React.').option('--experimental-app-only', 'Builds only App Router routes.').addOption(new _commander.Option('--experimental-turbo').hideHelp()).addOption(new _commander.Option('--experimental-build-mode [mode]', 'Uses an experimental build mode.').choices([
|
84
84
|
'compile',
|
85
85
|
'generate'
|
package/dist/build/index.js
CHANGED
@@ -364,7 +364,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
|
|
364
364
|
const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
|
365
365
|
buildMode: experimentalBuildMode,
|
366
366
|
isTurboBuild: String(turboNextBuild),
|
367
|
-
version: "15.2.0-canary.
|
367
|
+
version: "15.2.0-canary.76"
|
368
368
|
});
|
369
369
|
_buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
|
370
370
|
_buildcontext.NextBuildContext.dir = dir;
|
@@ -723,7 +723,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
|
|
723
723
|
// Files outside of the distDir can be "type": "module"
|
724
724
|
await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
725
725
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
726
|
-
await (0, _builddiagnostics.recordFrameworkVersion)("15.2.0-canary.
|
726
|
+
await (0, _builddiagnostics.recordFrameworkVersion)("15.2.0-canary.76");
|
727
727
|
await (0, _builddiagnostics.updateBuildDiagnostics)({
|
728
728
|
buildStage: 'start'
|
729
729
|
});
|
package/dist/build/swc/index.js
CHANGED
@@ -119,7 +119,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
119
119
|
}
|
120
120
|
return newObj;
|
121
121
|
}
|
122
|
-
const nextVersion = "15.2.0-canary.
|
122
|
+
const nextVersion = "15.2.0-canary.76";
|
123
123
|
const ArchName = (0, _os.arch)();
|
124
124
|
const PlatformName = (0, _os.platform)();
|
125
125
|
function infoLog(...args) {
|
@@ -1624,7 +1624,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
1624
1624
|
isClient && new _copyfileplugin.CopyFilePlugin({
|
1625
1625
|
// file path to build output of `@next/polyfill-nomodule`
|
1626
1626
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
1627
|
-
cacheKey: "15.2.0-canary.
|
1627
|
+
cacheKey: "15.2.0-canary.76",
|
1628
1628
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
1629
1629
|
minimize: false,
|
1630
1630
|
info: {
|
@@ -1801,7 +1801,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
1801
1801
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
1802
1802
|
// - Next.js version
|
1803
1803
|
// - next.config.js keys that affect compilation
|
1804
|
-
version: `${__dirname}|${"15.2.0-canary.
|
1804
|
+
version: `${__dirname}|${"15.2.0-canary.76"}|${configVars}`,
|
1805
1805
|
cacheDirectory: _path.default.join(distDir, 'cache', 'webpack'),
|
1806
1806
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
1807
1807
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
@@ -1,44 +1,3 @@
|
|
1
|
-
import { type
|
2
|
-
|
3
|
-
type HTMLFormProps = HTMLProps<HTMLFormElement>;
|
4
|
-
type DisallowedFormProps = (typeof DISALLOWED_FORM_PROPS)[number];
|
5
|
-
type InternalFormProps = {
|
6
|
-
/**
|
7
|
-
* `action` can be either a `string` or a function.
|
8
|
-
* - If `action` is a string, it will be interpreted as a path or URL to navigate to when the form is submitted.
|
9
|
-
* The path will be prefetched when the form becomes visible.
|
10
|
-
* - If `action` is a function, it will be called when the form is submitted. See the [React docs](https://react.dev/reference/react-dom/components/form#props) for more.
|
11
|
-
*/
|
12
|
-
action: NonNullable<HTMLFormProps['action']>;
|
13
|
-
/**
|
14
|
-
* Controls how the route specified by `action` is prefetched.
|
15
|
-
* Any `<Form />` that is in the viewport (initially or through scroll) will be prefetched.
|
16
|
-
* Prefetch can be disabled by passing `prefetch={false}`. Prefetching is only enabled in production.
|
17
|
-
*
|
18
|
-
* Options:
|
19
|
-
* - `null` (default): For statically generated pages, this will prefetch the full React Server Component data. For dynamic pages, this will prefetch up to the nearest route segment with a [`loading.js`](https://nextjs.org/docs/app/api-reference/file-conventions/loading) file. If there is no loading file, it will not fetch the full tree to avoid fetching too much data.
|
20
|
-
* - `false`: This will not prefetch any data.
|
21
|
-
*
|
22
|
-
* In pages dir, prefetching is not supported, and passing this prop will emit a warning.
|
23
|
-
*
|
24
|
-
* @defaultValue `null`
|
25
|
-
*/
|
26
|
-
prefetch?: false | null;
|
27
|
-
/**
|
28
|
-
* Whether submitting the form should replace the current `history` state instead of adding a new url into the stack.
|
29
|
-
* Only valid if `action` is a string.
|
30
|
-
*
|
31
|
-
* @defaultValue `false`
|
32
|
-
*/
|
33
|
-
replace?: boolean;
|
34
|
-
/**
|
35
|
-
* Override the default scroll behavior when navigating.
|
36
|
-
* Only valid if `action` is a string.
|
37
|
-
*
|
38
|
-
* @defaultValue `true`
|
39
|
-
*/
|
40
|
-
scroll?: boolean;
|
41
|
-
} & Omit<HTMLFormProps, 'action' | DisallowedFormProps>;
|
42
|
-
export type FormProps<RouteInferType = any> = InternalFormProps;
|
1
|
+
import { type FormProps } from '../form-shared';
|
2
|
+
export type { FormProps };
|
43
3
|
export default function Form({ replace, scroll, prefetch: prefetchProp, ref: externalRef, ...props }: FormProps): import("react/jsx-runtime").JSX.Element;
|
44
|
-
export {};
|
@@ -16,21 +16,16 @@ const _useintersection = require("../use-intersection");
|
|
16
16
|
const _usemergedref = require("../use-merged-ref");
|
17
17
|
const _approutercontextsharedruntime = require("../../shared/lib/app-router-context.shared-runtime");
|
18
18
|
const _routerreducertypes = require("../components/router-reducer/router-reducer-types");
|
19
|
-
const
|
20
|
-
const DISALLOWED_FORM_PROPS = [
|
21
|
-
'method',
|
22
|
-
'encType',
|
23
|
-
'target'
|
24
|
-
];
|
19
|
+
const _formshared = require("../form-shared");
|
25
20
|
function Form(param) {
|
26
21
|
let { replace, scroll, prefetch: prefetchProp, ref: externalRef, ...props } = param;
|
27
|
-
const router =
|
22
|
+
const router = (0, _react.useContext)(_approutercontextsharedruntime.AppRouterContext);
|
28
23
|
const actionProp = props.action;
|
29
24
|
const isNavigatingForm = typeof actionProp === 'string';
|
30
25
|
// Validate `action`
|
31
26
|
if (process.env.NODE_ENV === 'development') {
|
32
27
|
if (isNavigatingForm) {
|
33
|
-
|
28
|
+
(0, _formshared.checkFormActionUrl)(actionProp, 'action');
|
34
29
|
}
|
35
30
|
}
|
36
31
|
// Validate `prefetch`
|
@@ -38,12 +33,8 @@ function Form(param) {
|
|
38
33
|
if (!(prefetchProp === undefined || prefetchProp === false || prefetchProp === null)) {
|
39
34
|
console.error('The `prefetch` prop of <Form> must be `false` or `null`');
|
40
35
|
}
|
41
|
-
if (prefetchProp !== undefined) {
|
42
|
-
|
43
|
-
console.error('Passing `prefetch` to a <Form> has no effect in the pages directory.');
|
44
|
-
} else if (!isNavigatingForm) {
|
45
|
-
console.error('Passing `prefetch` to a <Form> whose `action` is a function has no effect.');
|
46
|
-
}
|
36
|
+
if (prefetchProp !== undefined && !isNavigatingForm) {
|
37
|
+
console.error('Passing `prefetch` to a <Form> whose `action` is a function has no effect.');
|
47
38
|
}
|
48
39
|
}
|
49
40
|
const prefetch = prefetchProp === false || prefetchProp === null ? prefetchProp : null;
|
@@ -54,7 +45,7 @@ function Form(param) {
|
|
54
45
|
}
|
55
46
|
}
|
56
47
|
// Clean up any unsupported form props (and warn if present)
|
57
|
-
for (const key of DISALLOWED_FORM_PROPS){
|
48
|
+
for (const key of _formshared.DISALLOWED_FORM_PROPS){
|
58
49
|
if (key in props) {
|
59
50
|
if (process.env.NODE_ENV === 'development') {
|
60
51
|
console.error("<Form> does not support changing `" + key + "`. " + (isNavigatingForm ? "If you'd like to use it to perform a mutation, consider making `action` a function instead.\n" + "Learn more: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations" : ''));
|
@@ -62,9 +53,8 @@ function Form(param) {
|
|
62
53
|
delete props[key];
|
63
54
|
}
|
64
55
|
}
|
65
|
-
const isPrefetchEnabled = //
|
66
|
-
|
67
|
-
isNavigatingForm && prefetch === null;
|
56
|
+
const isPrefetchEnabled = // if we don't have an action path, we can't prefetch anything.
|
57
|
+
!!router && isNavigatingForm && prefetch === null;
|
68
58
|
const [setIntersectionRef, isVisible] = (0, _useintersection.useIntersection)({
|
69
59
|
rootMargin: '200px',
|
70
60
|
disabled: !isPrefetchEnabled
|
@@ -119,6 +109,11 @@ function onFormSubmit(event, param) {
|
|
119
109
|
return;
|
120
110
|
}
|
121
111
|
}
|
112
|
+
if (!router) {
|
113
|
+
// Form was somehow used outside of the router (but not in pages, the implementation is forked!).
|
114
|
+
// We can't perform a soft navigation, so let the native submit handling do its thing.
|
115
|
+
return;
|
116
|
+
}
|
122
117
|
const formElement = event.currentTarget;
|
123
118
|
const submitter = event.nativeEvent.submitter;
|
124
119
|
let action = actionHref;
|
@@ -131,11 +126,11 @@ function onFormSubmit(event, param) {
|
|
131
126
|
return;
|
132
127
|
}
|
133
128
|
}
|
134
|
-
if (hasUnsupportedSubmitterAttributes(submitter)) {
|
129
|
+
if ((0, _formshared.hasUnsupportedSubmitterAttributes)(submitter)) {
|
135
130
|
return;
|
136
131
|
}
|
137
132
|
// client actions have `formAction="javascript:..."`. We obviously can't prefetch/navigate to that.
|
138
|
-
if (hasReactClientActionAttributes(submitter)) {
|
133
|
+
if ((0, _formshared.hasReactClientActionAttributes)(submitter)) {
|
139
134
|
return;
|
140
135
|
}
|
141
136
|
// If the submitter specified an alternate formAction,
|
@@ -145,144 +140,25 @@ function onFormSubmit(event, param) {
|
|
145
140
|
const submitterFormAction = submitter.getAttribute('formAction');
|
146
141
|
if (submitterFormAction !== null) {
|
147
142
|
if (process.env.NODE_ENV === 'development') {
|
148
|
-
|
143
|
+
(0, _formshared.checkFormActionUrl)(submitterFormAction, 'formAction');
|
149
144
|
}
|
150
145
|
action = submitterFormAction;
|
151
146
|
}
|
152
147
|
}
|
153
|
-
|
154
|
-
try {
|
155
|
-
// NOTE: It might be more correct to resolve URLs relative to `document.baseURI`,
|
156
|
-
// but we already do it relative to `location.href` elsewhere:
|
157
|
-
// (see e.g. https://github.com/vercel/next.js/blob/bb0e6722f87ceb2d43015f5b8a413d0072f2badf/packages/next/src/client/components/app-router.tsx#L146)
|
158
|
-
// so it's better to stay consistent.
|
159
|
-
const base = window.location.href;
|
160
|
-
targetUrl = new URL(action, base);
|
161
|
-
} catch (err) {
|
162
|
-
throw Object.defineProperty(new Error('Cannot parse form action "' + action + '" as a URL', {
|
163
|
-
cause: err
|
164
|
-
}), "__NEXT_ERROR_CODE", {
|
165
|
-
value: "E152",
|
166
|
-
enumerable: false,
|
167
|
-
configurable: true
|
168
|
-
});
|
169
|
-
}
|
170
|
-
if (targetUrl.searchParams.size) {
|
171
|
-
// url-encoded HTML forms *overwrite* any search params in the `action` url:
|
172
|
-
//
|
173
|
-
// "Let `query` be the result of running the application/x-www-form-urlencoded serializer [...]"
|
174
|
-
// "Set parsed action's query component to `query`."
|
175
|
-
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-mutate-action
|
176
|
-
//
|
177
|
-
// We need to match that.
|
178
|
-
// (note that all other parts of the URL, like `hash`, are preserved)
|
179
|
-
targetUrl.search = '';
|
180
|
-
}
|
181
|
-
const formData = new FormData(formElement);
|
182
|
-
for (let [name, value] of formData){
|
183
|
-
if (typeof value !== 'string') {
|
184
|
-
// For file inputs, the native browser behavior is to use the filename as the value instead:
|
185
|
-
//
|
186
|
-
// "If entry's value is a File object, then let value be entry's value's name. Otherwise, let value be entry's value."
|
187
|
-
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#converting-an-entry-list-to-a-list-of-name-value-pairs
|
188
|
-
//
|
189
|
-
if (process.env.NODE_ENV === 'development') {
|
190
|
-
console.warn("<Form> only supports file inputs if `action` is a function. File inputs cannot be used if `action` is a string, " + "because files cannot be encoded as search params.");
|
191
|
-
}
|
192
|
-
value = value.name;
|
193
|
-
}
|
194
|
-
targetUrl.searchParams.append(name, value);
|
195
|
-
}
|
148
|
+
const targetUrl = (0, _formshared.createFormSubmitDestinationUrl)(action, formElement);
|
196
149
|
// Finally, no more reasons for bailing out.
|
197
150
|
event.preventDefault();
|
198
151
|
const method = replace ? 'replace' : 'push';
|
199
152
|
const targetHref = targetUrl.href;
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
});
|
204
|
-
} else {
|
205
|
-
// TODO(form): Make this use a transition so that pending states work
|
206
|
-
//
|
207
|
-
// Unlike the app router, pages router doesn't use startTransition,
|
208
|
-
// and can't easily be wrapped in one because of implementation details
|
209
|
-
// (e.g. it doesn't use any react state)
|
210
|
-
// But it's important to have this wrapped in a transition because
|
211
|
-
// pending states from e.g. `useFormStatus` rely on that.
|
212
|
-
// So this needs some follow up work.
|
213
|
-
router[method](targetHref, undefined, {
|
214
|
-
scroll
|
215
|
-
});
|
216
|
-
}
|
217
|
-
}
|
218
|
-
function isAppRouter(router) {
|
219
|
-
return !('asPath' in router);
|
220
|
-
}
|
221
|
-
function useAppOrPagesRouter() {
|
222
|
-
const pagesRouter = (0, _react.useContext)(_routercontextsharedruntime.RouterContext);
|
223
|
-
const appRouter = (0, _react.useContext)(_approutercontextsharedruntime.AppRouterContext);
|
224
|
-
if (pagesRouter) {
|
225
|
-
return pagesRouter;
|
226
|
-
} else {
|
227
|
-
// We're in the app directory if there is no pages router.
|
228
|
-
return appRouter;
|
229
|
-
}
|
230
|
-
}
|
231
|
-
function checkActionUrl(action, source) {
|
232
|
-
const aPropName = source === 'action' ? "an `action`" : "a `formAction`";
|
233
|
-
let testUrl;
|
234
|
-
try {
|
235
|
-
testUrl = new URL(action, 'http://n');
|
236
|
-
} catch (err) {
|
237
|
-
console.error("<Form> received " + aPropName + ' that cannot be parsed as a URL: "' + action + '".');
|
238
|
-
return;
|
239
|
-
}
|
240
|
-
// url-encoded HTML forms ignore any queryparams in the `action` url. We need to match that.
|
241
|
-
if (testUrl.searchParams.size) {
|
242
|
-
console.warn("<Form> received " + aPropName + ' that contains search params: "' + action + '". This is not supported, and they will be ignored. ' + 'If you need to pass in additional search params, use an `<input type="hidden" />` instead.');
|
243
|
-
}
|
244
|
-
}
|
245
|
-
const isSupportedEncType = (value)=>value === 'application/x-www-form-urlencoded';
|
246
|
-
const isSupportedMethod = (value)=>value === 'get';
|
247
|
-
const isSupportedTarget = (value)=>value === '_self';
|
248
|
-
function hasUnsupportedSubmitterAttributes(submitter) {
|
249
|
-
// A submitter can override `encType` for the form.
|
250
|
-
const formEncType = submitter.getAttribute('formEncType');
|
251
|
-
if (formEncType !== null && !isSupportedEncType(formEncType)) {
|
252
|
-
if (process.env.NODE_ENV === 'development') {
|
253
|
-
console.error("<Form>'s `encType` was set to an unsupported value via `formEncType=\"" + formEncType + '"`. ' + "This will disable <Form>'s navigation functionality. If you need this, use a native <form> element instead.");
|
254
|
-
}
|
255
|
-
return true;
|
256
|
-
}
|
257
|
-
// A submitter can override `method` for the form.
|
258
|
-
const formMethod = submitter.getAttribute('formMethod');
|
259
|
-
if (formMethod !== null && !isSupportedMethod(formMethod)) {
|
260
|
-
if (process.env.NODE_ENV === 'development') {
|
261
|
-
console.error("<Form>'s `method` was set to an unsupported value via `formMethod=\"" + formMethod + '"`. ' + "This will disable <Form>'s navigation functionality. If you need this, use a native <form> element instead.");
|
262
|
-
}
|
263
|
-
return true;
|
264
|
-
}
|
265
|
-
// A submitter can override `target` for the form.
|
266
|
-
const formTarget = submitter.getAttribute('formTarget');
|
267
|
-
if (formTarget !== null && !isSupportedTarget(formTarget)) {
|
268
|
-
if (process.env.NODE_ENV === 'development') {
|
269
|
-
console.error("<Form>'s `target` was set to an unsupported value via `formTarget=\"" + formTarget + '"`. ' + "This will disable <Form>'s navigation functionality. If you need this, use a native <form> element instead.");
|
270
|
-
}
|
271
|
-
return true;
|
272
|
-
}
|
273
|
-
return false;
|
153
|
+
router[method](targetHref, {
|
154
|
+
scroll
|
155
|
+
});
|
274
156
|
}
|
275
157
|
function hasReactServerActionAttributes(submitter) {
|
276
158
|
// https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-client/src/ReactFlightReplyClient.js#L931-L934
|
277
159
|
const name = submitter.getAttribute('name');
|
278
160
|
return name && (name.startsWith('$ACTION_ID_') || name.startsWith('$ACTION_REF_'));
|
279
161
|
}
|
280
|
-
function hasReactClientActionAttributes(submitter) {
|
281
|
-
// CSR: https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-dom-bindings/src/client/ReactDOMComponent.js#L482-L487
|
282
|
-
// SSR: https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-dom-bindings/src/client/ReactDOMComponent.js#L2401
|
283
|
-
const action = submitter.getAttribute('formAction');
|
284
|
-
return action && /\s*javascript:/i.test(action);
|
285
|
-
}
|
286
162
|
|
287
163
|
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
288
164
|
Object.defineProperty(exports.default, '__esModule', { value: true });
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/client/app-dir/form.tsx"],"sourcesContent":["'use client'\n\nimport { useEffect, type HTMLProps, type FormEvent, useContext } from 'react'\nimport { addBasePath } from '../add-base-path'\nimport { useIntersection } from '../use-intersection'\nimport { useMergedRef } from '../use-merged-ref'\nimport {\n AppRouterContext,\n type AppRouterInstance,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport { PrefetchKind } from '../components/router-reducer/router-reducer-types'\nimport { RouterContext } from '../../shared/lib/router-context.shared-runtime'\nimport type { NextRouter } from '../router'\n\nconst DISALLOWED_FORM_PROPS = ['method', 'encType', 'target'] as const\n\ntype HTMLFormProps = HTMLProps<HTMLFormElement>\ntype DisallowedFormProps = (typeof DISALLOWED_FORM_PROPS)[number]\n\ntype InternalFormProps = {\n /**\n * `action` can be either a `string` or a function.\n * - If `action` is a string, it will be interpreted as a path or URL to navigate to when the form is submitted.\n * The path will be prefetched when the form becomes visible.\n * - If `action` is a function, it will be called when the form is submitted. See the [React docs](https://react.dev/reference/react-dom/components/form#props) for more.\n */\n action: NonNullable<HTMLFormProps['action']>\n /**\n * Controls how the route specified by `action` is prefetched.\n * Any `<Form />` that is in the viewport (initially or through scroll) will be prefetched.\n * Prefetch can be disabled by passing `prefetch={false}`. Prefetching is only enabled in production.\n *\n * Options:\n * - `null` (default): For statically generated pages, this will prefetch the full React Server Component data. For dynamic pages, this will prefetch up to the nearest route segment with a [`loading.js`](https://nextjs.org/docs/app/api-reference/file-conventions/loading) file. If there is no loading file, it will not fetch the full tree to avoid fetching too much data.\n * - `false`: This will not prefetch any data.\n *\n * In pages dir, prefetching is not supported, and passing this prop will emit a warning.\n *\n * @defaultValue `null`\n */\n prefetch?: false | null\n /**\n * Whether submitting the form should replace the current `history` state instead of adding a new url into the stack.\n * Only valid if `action` is a string.\n *\n * @defaultValue `false`\n */\n replace?: boolean\n /**\n * Override the default scroll behavior when navigating.\n * Only valid if `action` is a string.\n *\n * @defaultValue `true`\n */\n scroll?: boolean\n} & Omit<HTMLFormProps, 'action' | DisallowedFormProps>\n\n// `RouteInferType` is a stub here to avoid breaking `typedRoutes` when the type\n// isn't generated yet. It will be replaced when the webpack plugin runs.\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type FormProps<RouteInferType = any> = InternalFormProps\n\nexport default function Form({\n replace,\n scroll,\n prefetch: prefetchProp,\n ref: externalRef,\n ...props\n}: FormProps) {\n const router = useAppOrPagesRouter()\n\n const actionProp = props.action\n const isNavigatingForm = typeof actionProp === 'string'\n\n // Validate `action`\n if (process.env.NODE_ENV === 'development') {\n if (isNavigatingForm) {\n checkActionUrl(actionProp, 'action')\n }\n }\n\n // Validate `prefetch`\n if (process.env.NODE_ENV === 'development') {\n if (\n !(\n prefetchProp === undefined ||\n prefetchProp === false ||\n prefetchProp === null\n )\n ) {\n console.error('The `prefetch` prop of <Form> must be `false` or `null`')\n }\n\n if (prefetchProp !== undefined) {\n if (!isAppRouter(router)) {\n console.error(\n 'Passing `prefetch` to a <Form> has no effect in the pages directory.'\n )\n } else if (!isNavigatingForm) {\n console.error(\n 'Passing `prefetch` to a <Form> whose `action` is a function has no effect.'\n )\n }\n }\n }\n\n const prefetch =\n prefetchProp === false || prefetchProp === null ? prefetchProp : null\n\n // Validate `scroll` and `replace`\n if (process.env.NODE_ENV === 'development') {\n if (!isNavigatingForm && (replace !== undefined || scroll !== undefined)) {\n console.error(\n 'Passing `replace` or `scroll` to a <Form> whose `action` is a function has no effect.\\n' +\n 'See the relevant docs to learn how to control this behavior for navigations triggered from actions:\\n' +\n ' `redirect()` - https://nextjs.org/docs/app/api-reference/functions/redirect#parameters\\n' +\n ' `router.replace()` - https://nextjs.org/docs/app/api-reference/functions/use-router#userouter\\n'\n )\n }\n }\n\n // Clean up any unsupported form props (and warn if present)\n for (const key of DISALLOWED_FORM_PROPS) {\n if (key in props) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n `<Form> does not support changing \\`${key}\\`. ` +\n (isNavigatingForm\n ? `If you'd like to use it to perform a mutation, consider making \\`action\\` a function instead.\\n` +\n `Learn more: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations`\n : '')\n )\n }\n delete (props as Record<string, unknown>)[key]\n }\n }\n\n const isPrefetchEnabled =\n // there is no notion of instant loading states in pages dir, so prefetching is pointless\n isAppRouter(router) &&\n // if we don't have an action path, we can't preload anything anyway.\n isNavigatingForm &&\n prefetch === null\n\n const [setIntersectionRef, isVisible] = useIntersection({\n rootMargin: '200px',\n disabled: !isPrefetchEnabled,\n })\n\n const ownRef = useMergedRef<HTMLFormElement>(\n setIntersectionRef,\n externalRef ?? null\n )\n\n useEffect(() => {\n if (!isVisible || !isPrefetchEnabled) {\n return\n }\n\n try {\n const prefetchKind = PrefetchKind.AUTO\n router.prefetch(actionProp, { kind: prefetchKind })\n } catch (err) {\n console.error(err)\n }\n }, [isPrefetchEnabled, isVisible, actionProp, prefetch, router])\n\n if (!isNavigatingForm) {\n return <form {...props} ref={ownRef} />\n }\n\n const actionHref = addBasePath(actionProp)\n\n return (\n <form\n {...props}\n ref={ownRef}\n action={actionHref}\n onSubmit={(event) =>\n onFormSubmit(event, {\n router,\n actionHref,\n replace,\n scroll,\n onSubmit: props.onSubmit,\n })\n }\n />\n )\n}\n\nfunction onFormSubmit(\n event: FormEvent<HTMLFormElement>,\n {\n actionHref,\n onSubmit,\n replace,\n scroll,\n router,\n }: {\n actionHref: string\n onSubmit: FormProps['onSubmit']\n replace: FormProps['replace']\n scroll: FormProps['scroll']\n router: SomeRouter\n }\n) {\n if (typeof onSubmit === 'function') {\n onSubmit(event)\n\n // if the user called event.preventDefault(), do nothing.\n // (this matches what Link does for `onClick`)\n if (event.defaultPrevented) {\n return\n }\n }\n\n const formElement = event.currentTarget\n const submitter = (event.nativeEvent as SubmitEvent).submitter\n\n let action = actionHref\n\n if (submitter) {\n if (process.env.NODE_ENV === 'development') {\n // the way server actions are encoded (e.g. `formMethod=\"post\")\n // causes some unnecessary dev-mode warnings from `hasUnsupportedSubmitterAttributes`.\n // we'd bail out anyway, but we just do it silently.\n if (hasReactServerActionAttributes(submitter)) {\n return\n }\n }\n\n if (hasUnsupportedSubmitterAttributes(submitter)) {\n return\n }\n\n // client actions have `formAction=\"javascript:...\"`. We obviously can't prefetch/navigate to that.\n if (hasReactClientActionAttributes(submitter)) {\n return\n }\n\n // If the submitter specified an alternate formAction,\n // use that URL instead -- this is what a native form would do.\n // NOTE: `submitter.formAction` is unreliable, because it will give us `location.href` if it *wasn't* set\n // NOTE: this should not have `basePath` added, because we can't add it before hydration\n const submitterFormAction = submitter.getAttribute('formAction')\n if (submitterFormAction !== null) {\n if (process.env.NODE_ENV === 'development') {\n checkActionUrl(submitterFormAction, 'formAction')\n }\n action = submitterFormAction\n }\n }\n\n let targetUrl: URL\n try {\n // NOTE: It might be more correct to resolve URLs relative to `document.baseURI`,\n // but we already do it relative to `location.href` elsewhere:\n // (see e.g. https://github.com/vercel/next.js/blob/bb0e6722f87ceb2d43015f5b8a413d0072f2badf/packages/next/src/client/components/app-router.tsx#L146)\n // so it's better to stay consistent.\n const base = window.location.href\n targetUrl = new URL(action, base)\n } catch (err) {\n throw new Error(`Cannot parse form action \"${action}\" as a URL`, {\n cause: err,\n })\n }\n if (targetUrl.searchParams.size) {\n // url-encoded HTML forms *overwrite* any search params in the `action` url:\n //\n // \"Let `query` be the result of running the application/x-www-form-urlencoded serializer [...]\"\n // \"Set parsed action's query component to `query`.\"\n // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-mutate-action\n //\n // We need to match that.\n // (note that all other parts of the URL, like `hash`, are preserved)\n targetUrl.search = ''\n }\n\n const formData = new FormData(formElement)\n\n for (let [name, value] of formData) {\n if (typeof value !== 'string') {\n // For file inputs, the native browser behavior is to use the filename as the value instead:\n //\n // \"If entry's value is a File object, then let value be entry's value's name. Otherwise, let value be entry's value.\"\n // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#converting-an-entry-list-to-a-list-of-name-value-pairs\n //\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<Form> only supports file inputs if \\`action\\` is a function. File inputs cannot be used if \\`action\\` is a string, ` +\n `because files cannot be encoded as search params.`\n )\n }\n value = value.name\n }\n\n targetUrl.searchParams.append(name, value)\n }\n\n // Finally, no more reasons for bailing out.\n event.preventDefault()\n\n const method = replace ? 'replace' : 'push'\n const targetHref = targetUrl.href\n if (isAppRouter(router)) {\n router[method](targetHref, { scroll })\n } else {\n // TODO(form): Make this use a transition so that pending states work\n //\n // Unlike the app router, pages router doesn't use startTransition,\n // and can't easily be wrapped in one because of implementation details\n // (e.g. it doesn't use any react state)\n // But it's important to have this wrapped in a transition because\n // pending states from e.g. `useFormStatus` rely on that.\n // So this needs some follow up work.\n router[method](targetHref, undefined, { scroll })\n }\n}\n\ntype SomeRouter = AppRouterInstance | NextRouter\n\nfunction isAppRouter(router: SomeRouter): router is AppRouterInstance {\n return !('asPath' in router)\n}\n\nfunction useAppOrPagesRouter(): SomeRouter {\n const pagesRouter = useContext(RouterContext)\n const appRouter = useContext(AppRouterContext)\n if (pagesRouter) {\n return pagesRouter\n } else {\n // We're in the app directory if there is no pages router.\n return appRouter!\n }\n}\n\nfunction checkActionUrl(action: string, source: 'action' | 'formAction') {\n const aPropName = source === 'action' ? `an \\`action\\`` : `a \\`formAction\\``\n\n let testUrl: URL\n try {\n testUrl = new URL(action, 'http://n')\n } catch (err) {\n console.error(\n `<Form> received ${aPropName} that cannot be parsed as a URL: \"${action}\".`\n )\n return\n }\n\n // url-encoded HTML forms ignore any queryparams in the `action` url. We need to match that.\n if (testUrl.searchParams.size) {\n console.warn(\n `<Form> received ${aPropName} that contains search params: \"${action}\". This is not supported, and they will be ignored. ` +\n `If you need to pass in additional search params, use an \\`<input type=\"hidden\" />\\` instead.`\n )\n }\n}\n\nconst isSupportedEncType = (value: string) =>\n value === 'application/x-www-form-urlencoded'\nconst isSupportedMethod = (value: string) => value === 'get'\nconst isSupportedTarget = (value: string) => value === '_self'\n\nfunction hasUnsupportedSubmitterAttributes(submitter: HTMLElement): boolean {\n // A submitter can override `encType` for the form.\n const formEncType = submitter.getAttribute('formEncType')\n if (formEncType !== null && !isSupportedEncType(formEncType)) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n `<Form>'s \\`encType\\` was set to an unsupported value via \\`formEncType=\"${formEncType}\"\\`. ` +\n `This will disable <Form>'s navigation functionality. If you need this, use a native <form> element instead.`\n )\n }\n return true\n }\n\n // A submitter can override `method` for the form.\n const formMethod = submitter.getAttribute('formMethod')\n if (formMethod !== null && !isSupportedMethod(formMethod)) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n `<Form>'s \\`method\\` was set to an unsupported value via \\`formMethod=\"${formMethod}\"\\`. ` +\n `This will disable <Form>'s navigation functionality. If you need this, use a native <form> element instead.`\n )\n }\n return true\n }\n\n // A submitter can override `target` for the form.\n const formTarget = submitter.getAttribute('formTarget')\n if (formTarget !== null && !isSupportedTarget(formTarget)) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n `<Form>'s \\`target\\` was set to an unsupported value via \\`formTarget=\"${formTarget}\"\\`. ` +\n `This will disable <Form>'s navigation functionality. If you need this, use a native <form> element instead.`\n )\n }\n return true\n }\n\n return false\n}\n\nfunction hasReactServerActionAttributes(submitter: HTMLElement) {\n // https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-client/src/ReactFlightReplyClient.js#L931-L934\n const name = submitter.getAttribute('name')\n return (\n name && (name.startsWith('$ACTION_ID_') || name.startsWith('$ACTION_REF_'))\n )\n}\n\nfunction hasReactClientActionAttributes(submitter: HTMLElement) {\n // CSR: https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-dom-bindings/src/client/ReactDOMComponent.js#L482-L487\n // SSR: https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-dom-bindings/src/client/ReactDOMComponent.js#L2401\n const action = submitter.getAttribute('formAction')\n return action && /\\s*javascript:/i.test(action)\n}\n"],"names":["Form","DISALLOWED_FORM_PROPS","replace","scroll","prefetch","prefetchProp","ref","externalRef","props","router","useAppOrPagesRouter","actionProp","action","isNavigatingForm","process","env","NODE_ENV","checkActionUrl","undefined","console","error","isAppRouter","key","isPrefetchEnabled","setIntersectionRef","isVisible","useIntersection","rootMargin","disabled","ownRef","useMergedRef","useEffect","prefetchKind","PrefetchKind","AUTO","kind","err","form","actionHref","addBasePath","onSubmit","event","onFormSubmit","defaultPrevented","formElement","currentTarget","submitter","nativeEvent","hasReactServerActionAttributes","hasUnsupportedSubmitterAttributes","hasReactClientActionAttributes","submitterFormAction","getAttribute","targetUrl","base","window","location","href","URL","Error","cause","searchParams","size","search","formData","FormData","name","value","warn","append","preventDefault","method","targetHref","pagesRouter","useContext","RouterContext","appRouter","AppRouterContext","source","aPropName","testUrl","isSupportedEncType","isSupportedMethod","isSupportedTarget","formEncType","formMethod","formTarget","startsWith","test"],"mappings":"AAAA;;;;;+BA8DA;;;eAAwBA;;;;uBA5D8C;6BAC1C;iCACI;8BACH;+CAItB;oCACsB;4CACC;AAG9B,MAAMC,wBAAwB;IAAC;IAAU;IAAW;CAAS;AAgD9C,SAASD,KAAK,KAMjB;IANiB,IAAA,EAC3BE,OAAO,EACPC,MAAM,EACNC,UAAUC,YAAY,EACtBC,KAAKC,WAAW,EAChB,GAAGC,OACO,GANiB;IAO3B,MAAMC,SAASC;IAEf,MAAMC,aAAaH,MAAMI,MAAM;IAC/B,MAAMC,mBAAmB,OAAOF,eAAe;IAE/C,oBAAoB;IACpB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,IAAIH,kBAAkB;YACpBI,eAAeN,YAAY;QAC7B;IACF;IAEA,sBAAsB;IACtB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,IACE,CACEX,CAAAA,iBAAiBa,aACjBb,iBAAiB,SACjBA,iBAAiB,IAAG,GAEtB;YACAc,QAAQC,KAAK,CAAC;QAChB;QAEA,IAAIf,iBAAiBa,WAAW;YAC9B,IAAI,CAACG,YAAYZ,SAAS;gBACxBU,QAAQC,KAAK,CACX;YAEJ,OAAO,IAAI,CAACP,kBAAkB;gBAC5BM,QAAQC,KAAK,CACX;YAEJ;QACF;IACF;IAEA,MAAMhB,WACJC,iBAAiB,SAASA,iBAAiB,OAAOA,eAAe;IAEnE,kCAAkC;IAClC,IAAIS,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,IAAI,CAACH,oBAAqBX,CAAAA,YAAYgB,aAAaf,WAAWe,SAAQ,GAAI;YACxEC,QAAQC,KAAK,CACX,4FACE,0GACA,qGACA;QAE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C;IACpC,OACEc,QAASA,CAAAA,KAAKqB,UAAU,CAAC,kBAAkBrB,KAAKqB,UAAU,CAAC,eAAc;AAE7E;AAEA,SAASrC,+BAA+BJ,SAAsB;IAC5D,6JAA6J;IAC7J,yJAAyJ;IACzJ,MAAMlC,SAASkC,UAAUM,YAAY,CAAC;IACtC,OAAOxC,UAAU,kBAAkB4E,IAAI,CAAC5E;AAC1C"}
|
1
|
+
{"version":3,"sources":["../../../src/client/app-dir/form.tsx"],"sourcesContent":["'use client'\n\nimport { useEffect, type FormEvent, useContext } from 'react'\nimport { addBasePath } from '../add-base-path'\nimport { useIntersection } from '../use-intersection'\nimport { useMergedRef } from '../use-merged-ref'\nimport {\n AppRouterContext,\n type AppRouterInstance,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport { PrefetchKind } from '../components/router-reducer/router-reducer-types'\nimport {\n checkFormActionUrl,\n createFormSubmitDestinationUrl,\n DISALLOWED_FORM_PROPS,\n hasReactClientActionAttributes,\n hasUnsupportedSubmitterAttributes,\n type FormProps,\n} from '../form-shared'\n\nexport type { FormProps }\n\nexport default function Form({\n replace,\n scroll,\n prefetch: prefetchProp,\n ref: externalRef,\n ...props\n}: FormProps) {\n const router = useContext(AppRouterContext)\n\n const actionProp = props.action\n const isNavigatingForm = typeof actionProp === 'string'\n\n // Validate `action`\n if (process.env.NODE_ENV === 'development') {\n if (isNavigatingForm) {\n checkFormActionUrl(actionProp, 'action')\n }\n }\n\n // Validate `prefetch`\n if (process.env.NODE_ENV === 'development') {\n if (\n !(\n prefetchProp === undefined ||\n prefetchProp === false ||\n prefetchProp === null\n )\n ) {\n console.error('The `prefetch` prop of <Form> must be `false` or `null`')\n }\n\n if (prefetchProp !== undefined && !isNavigatingForm) {\n console.error(\n 'Passing `prefetch` to a <Form> whose `action` is a function has no effect.'\n )\n }\n }\n\n const prefetch =\n prefetchProp === false || prefetchProp === null ? prefetchProp : null\n\n // Validate `scroll` and `replace`\n if (process.env.NODE_ENV === 'development') {\n if (!isNavigatingForm && (replace !== undefined || scroll !== undefined)) {\n console.error(\n 'Passing `replace` or `scroll` to a <Form> whose `action` is a function has no effect.\\n' +\n 'See the relevant docs to learn how to control this behavior for navigations triggered from actions:\\n' +\n ' `redirect()` - https://nextjs.org/docs/app/api-reference/functions/redirect#parameters\\n' +\n ' `router.replace()` - https://nextjs.org/docs/app/api-reference/functions/use-router#userouter\\n'\n )\n }\n }\n\n // Clean up any unsupported form props (and warn if present)\n for (const key of DISALLOWED_FORM_PROPS) {\n if (key in props) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n `<Form> does not support changing \\`${key}\\`. ` +\n (isNavigatingForm\n ? `If you'd like to use it to perform a mutation, consider making \\`action\\` a function instead.\\n` +\n `Learn more: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations`\n : '')\n )\n }\n delete (props as Record<string, unknown>)[key]\n }\n }\n\n const isPrefetchEnabled =\n // if we don't have an action path, we can't prefetch anything.\n !!router && isNavigatingForm && prefetch === null\n\n const [setIntersectionRef, isVisible] = useIntersection({\n rootMargin: '200px',\n disabled: !isPrefetchEnabled,\n })\n\n const ownRef = useMergedRef<HTMLFormElement>(\n setIntersectionRef,\n externalRef ?? null\n )\n\n useEffect(() => {\n if (!isVisible || !isPrefetchEnabled) {\n return\n }\n\n try {\n const prefetchKind = PrefetchKind.AUTO\n router.prefetch(actionProp, { kind: prefetchKind })\n } catch (err) {\n console.error(err)\n }\n }, [isPrefetchEnabled, isVisible, actionProp, prefetch, router])\n\n if (!isNavigatingForm) {\n return <form {...props} ref={ownRef} />\n }\n\n const actionHref = addBasePath(actionProp)\n\n return (\n <form\n {...props}\n ref={ownRef}\n action={actionHref}\n onSubmit={(event) =>\n onFormSubmit(event, {\n router,\n actionHref,\n replace,\n scroll,\n onSubmit: props.onSubmit,\n })\n }\n />\n )\n}\n\nfunction onFormSubmit(\n event: FormEvent<HTMLFormElement>,\n {\n actionHref,\n onSubmit,\n replace,\n scroll,\n router,\n }: {\n actionHref: string\n onSubmit: FormProps['onSubmit']\n replace: FormProps['replace']\n scroll: FormProps['scroll']\n router: AppRouterInstance | null\n }\n) {\n if (typeof onSubmit === 'function') {\n onSubmit(event)\n\n // if the user called event.preventDefault(), do nothing.\n // (this matches what Link does for `onClick`)\n if (event.defaultPrevented) {\n return\n }\n }\n\n if (!router) {\n // Form was somehow used outside of the router (but not in pages, the implementation is forked!).\n // We can't perform a soft navigation, so let the native submit handling do its thing.\n return\n }\n\n const formElement = event.currentTarget\n const submitter = (event.nativeEvent as SubmitEvent).submitter\n\n let action = actionHref\n\n if (submitter) {\n if (process.env.NODE_ENV === 'development') {\n // the way server actions are encoded (e.g. `formMethod=\"post\")\n // causes some unnecessary dev-mode warnings from `hasUnsupportedSubmitterAttributes`.\n // we'd bail out anyway, but we just do it silently.\n if (hasReactServerActionAttributes(submitter)) {\n return\n }\n }\n\n if (hasUnsupportedSubmitterAttributes(submitter)) {\n return\n }\n\n // client actions have `formAction=\"javascript:...\"`. We obviously can't prefetch/navigate to that.\n if (hasReactClientActionAttributes(submitter)) {\n return\n }\n\n // If the submitter specified an alternate formAction,\n // use that URL instead -- this is what a native form would do.\n // NOTE: `submitter.formAction` is unreliable, because it will give us `location.href` if it *wasn't* set\n // NOTE: this should not have `basePath` added, because we can't add it before hydration\n const submitterFormAction = submitter.getAttribute('formAction')\n if (submitterFormAction !== null) {\n if (process.env.NODE_ENV === 'development') {\n checkFormActionUrl(submitterFormAction, 'formAction')\n }\n action = submitterFormAction\n }\n }\n\n const targetUrl = createFormSubmitDestinationUrl(action, formElement)\n\n // Finally, no more reasons for bailing out.\n event.preventDefault()\n\n const method = replace ? 'replace' : 'push'\n const targetHref = targetUrl.href\n router[method](targetHref, { scroll })\n}\n\nfunction hasReactServerActionAttributes(submitter: HTMLElement) {\n // https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-client/src/ReactFlightReplyClient.js#L931-L934\n const name = submitter.getAttribute('name')\n return (\n name && (name.startsWith('$ACTION_ID_') || name.startsWith('$ACTION_REF_'))\n )\n}\n"],"names":["Form","replace","scroll","prefetch","prefetchProp","ref","externalRef","props","router","useContext","AppRouterContext","actionProp","action","isNavigatingForm","process","env","NODE_ENV","checkFormActionUrl","undefined","console","error","key","DISALLOWED_FORM_PROPS","isPrefetchEnabled","setIntersectionRef","isVisible","useIntersection","rootMargin","disabled","ownRef","useMergedRef","useEffect","prefetchKind","PrefetchKind","AUTO","kind","err","form","actionHref","addBasePath","onSubmit","event","onFormSubmit","defaultPrevented","formElement","currentTarget","submitter","nativeEvent","hasReactServerActionAttributes","hasUnsupportedSubmitterAttributes","hasReactClientActionAttributes","submitterFormAction","getAttribute","targetUrl","createFormSubmitDestinationUrl","preventDefault","method","targetHref","href","name","startsWith"],"mappings":"AAAA;;;;;+BAsBA;;;eAAwBA;;;;uBApB8B;6BAC1B;iCACI;8BACH;+CAItB;oCACsB;4BAQtB;AAIQ,SAASA,KAAK,KAMjB;IANiB,IAAA,EAC3BC,OAAO,EACPC,MAAM,EACNC,UAAUC,YAAY,EACtBC,KAAKC,WAAW,EAChB,GAAGC,OACO,GANiB;IAO3B,MAAMC,SAASC,IAAAA,iBAAU,EAACC,+CAAgB;IAE1C,MAAMC,aAAaJ,MAAMK,MAAM;IAC/B,MAAMC,mBAAmB,OAAOF,eAAe;IAE/C,oBAAoB;IACpB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,IAAIH,kBAAkB;YACpBI,IAAAA,8BAAkB,EAACN,YAAY;QACjC;IACF;IAEA,sBAAsB;IACtB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,IACE,CACEZ,CAAAA,iBAAiBc,aACjBd,iBAAiB,SACjBA,iBAAiB,IAAG,GAEtB;YACAe,QAAQC,KAAK,CAAC;QAChB;QAEA,IAAIhB,iBAAiBc,aAAa,CAACL,kBAAkB;YACnDM,QAAQC,KAAK,CACX;QAEJ;IACF;IAEA,MA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YAAY;IACrC,MAAMwD,aAAaJ,UAAUK,IAAI;IACjClD,MAAM,CAACgD,OAAO,CAACC,YAAY;QAAEvD;IAAO;AACtC;AAEA,SAAS8C,+BAA+BF,SAAsB;IAC5D,gJAAgJ;IAChJ,MAAMa,OAAOb,UAAUM,YAAY,CAAC;IACpC,OACEO,QAASA,CAAAA,KAAKC,UAAU,CAAC,kBAAkBD,KAAKC,UAAU,CAAC,eAAc;AAE7E"}
|
@@ -37,6 +37,8 @@ export declare const ACTION_UNHANDLED_ERROR = "unhandled-error";
|
|
37
37
|
export declare const ACTION_UNHANDLED_REJECTION = "unhandled-rejection";
|
38
38
|
export declare const ACTION_DEBUG_INFO = "debug-info";
|
39
39
|
export declare const ACTION_DEV_INDICATOR = "dev-indicator";
|
40
|
+
export declare const STORAGE_KEY_THEME = "__nextjs-dev-tools-theme";
|
41
|
+
export declare const STORAGE_KEY_POSITION = "__nextjs-dev-tools-position";
|
40
42
|
interface StaticIndicatorAction {
|
41
43
|
type: typeof ACTION_STATIC_INDICATOR;
|
42
44
|
staticIndicator: boolean;
|
@@ -15,6 +15,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
ACTION_VERSION_INFO: null,
|
16
16
|
INITIAL_OVERLAY_STATE: null,
|
17
17
|
REACT_REFRESH_FULL_RELOAD_FROM_ERROR: null,
|
18
|
+
STORAGE_KEY_POSITION: null,
|
19
|
+
STORAGE_KEY_THEME: null,
|
18
20
|
useErrorOverlayReducer: null
|
19
21
|
});
|
20
22
|
function _export(target, all) {
|
@@ -60,6 +62,12 @@ _export(exports, {
|
|
60
62
|
REACT_REFRESH_FULL_RELOAD_FROM_ERROR: function() {
|
61
63
|
return REACT_REFRESH_FULL_RELOAD_FROM_ERROR;
|
62
64
|
},
|
65
|
+
STORAGE_KEY_POSITION: function() {
|
66
|
+
return STORAGE_KEY_POSITION;
|
67
|
+
},
|
68
|
+
STORAGE_KEY_THEME: function() {
|
69
|
+
return STORAGE_KEY_THEME;
|
70
|
+
},
|
63
71
|
useErrorOverlayReducer: function() {
|
64
72
|
return useErrorOverlayReducer;
|
65
73
|
}
|
@@ -76,6 +84,8 @@ const ACTION_UNHANDLED_ERROR = 'unhandled-error';
|
|
76
84
|
const ACTION_UNHANDLED_REJECTION = 'unhandled-rejection';
|
77
85
|
const ACTION_DEBUG_INFO = 'debug-info';
|
78
86
|
const ACTION_DEV_INDICATOR = 'dev-indicator';
|
87
|
+
const STORAGE_KEY_THEME = '__nextjs-dev-tools-theme';
|
88
|
+
const STORAGE_KEY_POSITION = '__nextjs-dev-tools-position';
|
79
89
|
function pushErrorFilterDuplicates(errors, err) {
|
80
90
|
return [
|
81
91
|
...errors.filter((e)=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/client/components/react-dev-overlay/shared.ts"],"sourcesContent":["import { useReducer } from 'react'\n\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport type { VersionInfo } from '../../../server/dev/parse-version-info'\nimport type { SupportedErrorEvent } from './ui/container/runtime-error/render-error'\nimport type { ComponentStackFrame } from './utils/parse-component-stack'\nimport type { DebugInfo } from './types'\nimport type { DevIndicatorServerState } from '../../../server/dev/dev-indicator-server-state'\n\ntype FastRefreshState =\n /** No refresh in progress. */\n | { type: 'idle' }\n /** The refresh process has been triggered, but the new code has not been executed yet. */\n | { type: 'pending'; errors: SupportedErrorEvent[] }\n\nexport interface OverlayState {\n nextId: number\n buildError: string | null\n errors: SupportedErrorEvent[]\n refreshState: FastRefreshState\n rootLayoutMissingTags: typeof window.__next_root_layout_missing_tags\n versionInfo: VersionInfo\n notFound: boolean\n staticIndicator: boolean\n disableDevIndicator: boolean\n debugInfo: DebugInfo\n routerType: 'pages' | 'app'\n}\n\nexport const ACTION_STATIC_INDICATOR = 'static-indicator'\nexport const ACTION_BUILD_OK = 'build-ok'\nexport const ACTION_BUILD_ERROR = 'build-error'\nexport const ACTION_BEFORE_REFRESH = 'before-fast-refresh'\nexport const ACTION_REFRESH = 'fast-refresh'\nexport const ACTION_VERSION_INFO = 'version-info'\nexport const ACTION_UNHANDLED_ERROR = 'unhandled-error'\nexport const ACTION_UNHANDLED_REJECTION = 'unhandled-rejection'\nexport const ACTION_DEBUG_INFO = 'debug-info'\nexport const ACTION_DEV_INDICATOR = 'dev-indicator'\n\ninterface StaticIndicatorAction {\n type: typeof ACTION_STATIC_INDICATOR\n staticIndicator: boolean\n}\n\ninterface BuildOkAction {\n type: typeof ACTION_BUILD_OK\n}\ninterface BuildErrorAction {\n type: typeof ACTION_BUILD_ERROR\n message: string\n}\ninterface BeforeFastRefreshAction {\n type: typeof ACTION_BEFORE_REFRESH\n}\ninterface FastRefreshAction {\n type: typeof ACTION_REFRESH\n}\n\nexport interface UnhandledErrorAction {\n type: typeof ACTION_UNHANDLED_ERROR\n reason: Error\n frames: StackFrame[]\n componentStackFrames?: ComponentStackFrame[]\n warning?: [string, string, string]\n}\nexport interface UnhandledRejectionAction {\n type: typeof ACTION_UNHANDLED_REJECTION\n reason: Error\n frames: StackFrame[]\n}\n\nexport interface DebugInfoAction {\n type: typeof ACTION_DEBUG_INFO\n debugInfo: any\n}\n\ninterface VersionInfoAction {\n type: typeof ACTION_VERSION_INFO\n versionInfo: VersionInfo\n}\n\ninterface DevIndicatorAction {\n type: typeof ACTION_DEV_INDICATOR\n devIndicator: DevIndicatorServerState\n}\n\nexport type BusEvent =\n | BuildOkAction\n | BuildErrorAction\n | BeforeFastRefreshAction\n | FastRefreshAction\n | UnhandledErrorAction\n | UnhandledRejectionAction\n | VersionInfoAction\n | StaticIndicatorAction\n | DebugInfoAction\n | DevIndicatorAction\n\nfunction pushErrorFilterDuplicates(\n errors: SupportedErrorEvent[],\n err: SupportedErrorEvent\n): SupportedErrorEvent[] {\n return [\n ...errors.filter((e) => {\n // Filter out duplicate errors\n return e.event.reason.stack !== err.event.reason.stack\n }),\n err,\n ]\n}\n\nconst shouldDisableDevIndicator =\n process.env.__NEXT_DEV_INDICATOR?.toString() === 'false'\n\nexport const INITIAL_OVERLAY_STATE: Omit<OverlayState, 'routerType'> = {\n nextId: 1,\n buildError: null,\n errors: [],\n notFound: false,\n staticIndicator: false,\n // To prevent flickering, set the initial state to disabled.\n disableDevIndicator: true,\n refreshState: { type: 'idle' },\n rootLayoutMissingTags: [],\n versionInfo: { installed: '0.0.0', staleness: 'unknown' },\n debugInfo: { devtoolsFrontendUrl: undefined },\n}\n\nfunction getInitialState(\n routerType: 'pages' | 'app'\n): OverlayState & { routerType: 'pages' | 'app' } {\n return {\n ...INITIAL_OVERLAY_STATE,\n routerType,\n }\n}\n\nexport function useErrorOverlayReducer(routerType: 'pages' | 'app') {\n return useReducer((_state: OverlayState, action: BusEvent): OverlayState => {\n switch (action.type) {\n case ACTION_DEBUG_INFO: {\n return { ..._state, debugInfo: action.debugInfo }\n }\n case ACTION_STATIC_INDICATOR: {\n return { ..._state, staticIndicator: action.staticIndicator }\n }\n case ACTION_BUILD_OK: {\n return { ..._state, buildError: null }\n }\n case ACTION_BUILD_ERROR: {\n return { ..._state, buildError: action.message }\n }\n case ACTION_BEFORE_REFRESH: {\n return { ..._state, refreshState: { type: 'pending', errors: [] } }\n }\n case ACTION_REFRESH: {\n return {\n ..._state,\n buildError: null,\n errors:\n // Errors can come in during updates. In this case, UNHANDLED_ERROR\n // and UNHANDLED_REJECTION events might be dispatched between the\n // BEFORE_REFRESH and the REFRESH event. We want to keep those errors\n // around until the next refresh. Otherwise we run into a race\n // condition where those errors would be cleared on refresh completion\n // before they can be displayed.\n _state.refreshState.type === 'pending'\n ? _state.refreshState.errors\n : [],\n refreshState: { type: 'idle' },\n }\n }\n case ACTION_UNHANDLED_ERROR:\n case ACTION_UNHANDLED_REJECTION: {\n switch (_state.refreshState.type) {\n case 'idle': {\n return {\n ..._state,\n nextId: _state.nextId + 1,\n errors: pushErrorFilterDuplicates(_state.errors, {\n id: _state.nextId,\n event: action,\n }),\n }\n }\n case 'pending': {\n return {\n ..._state,\n nextId: _state.nextId + 1,\n refreshState: {\n ..._state.refreshState,\n errors: pushErrorFilterDuplicates(_state.refreshState.errors, {\n id: _state.nextId,\n event: action,\n }),\n },\n }\n }\n default:\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: never = _state.refreshState\n return _state\n }\n }\n case ACTION_VERSION_INFO: {\n return { ..._state, versionInfo: action.versionInfo }\n }\n case ACTION_DEV_INDICATOR: {\n return {\n ..._state,\n disableDevIndicator:\n shouldDisableDevIndicator || !!action.devIndicator.disabledUntil,\n }\n }\n default: {\n return _state\n }\n }\n }, getInitialState(routerType))\n}\n\nexport const REACT_REFRESH_FULL_RELOAD_FROM_ERROR =\n '[Fast Refresh] performing full reload because your application had an unrecoverable error'\n"],"names":["ACTION_BEFORE_REFRESH","ACTION_BUILD_ERROR","ACTION_BUILD_OK","ACTION_DEBUG_INFO","ACTION_DEV_INDICATOR","ACTION_REFRESH","ACTION_STATIC_INDICATOR","ACTION_UNHANDLED_ERROR","ACTION_UNHANDLED_REJECTION","ACTION_VERSION_INFO","INITIAL_OVERLAY_STATE","REACT_REFRESH_FULL_RELOAD_FROM_ERROR","useErrorOverlayReducer","process","pushErrorFilterDuplicates","errors","err","filter","e","event","reason","stack","shouldDisableDevIndicator","env","__NEXT_DEV_INDICATOR","toString","nextId","buildError","notFound","staticIndicator","disableDevIndicator","refreshState","type","rootLayoutMissingTags","versionInfo","installed","staleness","debugInfo","devtoolsFrontendUrl","undefined","getInitialState","routerType","useReducer","_state","action","message","id","_","devIndicator","disabledUntil"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;IAgCaA,qBAAqB;eAArBA;;IADAC,kBAAkB;eAAlBA;;IADAC,eAAe;eAAfA;;IAOAC,iBAAiB;eAAjBA;;IACAC,oBAAoB;eAApBA;;IALAC,cAAc;eAAdA;;IAJAC,uBAAuB;eAAvBA;;IAMAC,sBAAsB;eAAtBA;;IACAC,0BAA0B;eAA1BA;;IAFAC,mBAAmB;eAAnBA;;IAiFAC,qBAAqB;eAArBA;;IA2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AA6D;4BAC7D,MAAMG,IAAWJ,OAAOZ,YAAY;4BACpC,OAAOY;oBACX;gBACF;YACA,KAAKlC;gBAAqB;oBACxB,OAAO;wBAAE,GAAGkC,MAAM;wBAAET,aAAaU,OAAOV,WAAW;oBAAC;gBACtD;YACA,KAAK9B;gBAAsB;oBACzB,OAAO;wBACL,GAAGuC,MAAM;wBACTb,qBACER,6BAA6B,CAAC,CAACsB,OAAOI,YAAY,CAACC,aAAa;oBACpE;gBACF;YACA;gBAAS;oBACP,OAAON;gBACT;QACF;IACF,GAAGH,gBAAgBC;AACrB;AAEO,MAAM9B,uCACX"}
|
1
|
+
{"version":3,"sources":["../../../../src/client/components/react-dev-overlay/shared.ts"],"sourcesContent":["import { useReducer } from 'react'\n\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport type { VersionInfo } from '../../../server/dev/parse-version-info'\nimport type { SupportedErrorEvent } from './ui/container/runtime-error/render-error'\nimport type { ComponentStackFrame } from './utils/parse-component-stack'\nimport type { DebugInfo } from './types'\nimport type { DevIndicatorServerState } from '../../../server/dev/dev-indicator-server-state'\n\ntype FastRefreshState =\n /** No refresh in progress. */\n | { type: 'idle' }\n /** The refresh process has been triggered, but the new code has not been executed yet. */\n | { type: 'pending'; errors: SupportedErrorEvent[] }\n\nexport interface OverlayState {\n nextId: number\n buildError: string | null\n errors: SupportedErrorEvent[]\n refreshState: FastRefreshState\n rootLayoutMissingTags: typeof window.__next_root_layout_missing_tags\n versionInfo: VersionInfo\n notFound: boolean\n staticIndicator: boolean\n disableDevIndicator: boolean\n debugInfo: DebugInfo\n routerType: 'pages' | 'app'\n}\n\nexport const ACTION_STATIC_INDICATOR = 'static-indicator'\nexport const ACTION_BUILD_OK = 'build-ok'\nexport const ACTION_BUILD_ERROR = 'build-error'\nexport const ACTION_BEFORE_REFRESH = 'before-fast-refresh'\nexport const ACTION_REFRESH = 'fast-refresh'\nexport const ACTION_VERSION_INFO = 'version-info'\nexport const ACTION_UNHANDLED_ERROR = 'unhandled-error'\nexport const ACTION_UNHANDLED_REJECTION = 'unhandled-rejection'\nexport const ACTION_DEBUG_INFO = 'debug-info'\nexport const ACTION_DEV_INDICATOR = 'dev-indicator'\n\nexport const STORAGE_KEY_THEME = '__nextjs-dev-tools-theme'\nexport const STORAGE_KEY_POSITION = '__nextjs-dev-tools-position'\n\ninterface StaticIndicatorAction {\n type: typeof ACTION_STATIC_INDICATOR\n staticIndicator: boolean\n}\n\ninterface BuildOkAction {\n type: typeof ACTION_BUILD_OK\n}\ninterface BuildErrorAction {\n type: typeof ACTION_BUILD_ERROR\n message: string\n}\ninterface BeforeFastRefreshAction {\n type: typeof ACTION_BEFORE_REFRESH\n}\ninterface FastRefreshAction {\n type: typeof ACTION_REFRESH\n}\n\nexport interface UnhandledErrorAction {\n type: typeof ACTION_UNHANDLED_ERROR\n reason: Error\n frames: StackFrame[]\n componentStackFrames?: ComponentStackFrame[]\n warning?: [string, string, string]\n}\nexport interface UnhandledRejectionAction {\n type: typeof ACTION_UNHANDLED_REJECTION\n reason: Error\n frames: StackFrame[]\n}\n\nexport interface DebugInfoAction {\n type: typeof ACTION_DEBUG_INFO\n debugInfo: any\n}\n\ninterface VersionInfoAction {\n type: typeof ACTION_VERSION_INFO\n versionInfo: VersionInfo\n}\n\ninterface DevIndicatorAction {\n type: typeof ACTION_DEV_INDICATOR\n devIndicator: DevIndicatorServerState\n}\n\nexport type BusEvent =\n | BuildOkAction\n | BuildErrorAction\n | BeforeFastRefreshAction\n | FastRefreshAction\n | UnhandledErrorAction\n | UnhandledRejectionAction\n | VersionInfoAction\n | StaticIndicatorAction\n | DebugInfoAction\n | DevIndicatorAction\n\nfunction pushErrorFilterDuplicates(\n errors: SupportedErrorEvent[],\n err: SupportedErrorEvent\n): SupportedErrorEvent[] {\n return [\n ...errors.filter((e) => {\n // Filter out duplicate errors\n return e.event.reason.stack !== err.event.reason.stack\n }),\n err,\n ]\n}\n\nconst shouldDisableDevIndicator =\n process.env.__NEXT_DEV_INDICATOR?.toString() === 'false'\n\nexport const INITIAL_OVERLAY_STATE: Omit<OverlayState, 'routerType'> = {\n nextId: 1,\n buildError: null,\n errors: [],\n notFound: false,\n staticIndicator: false,\n // To prevent flickering, set the initial state to disabled.\n disableDevIndicator: true,\n refreshState: { type: 'idle' },\n rootLayoutMissingTags: [],\n versionInfo: { installed: '0.0.0', staleness: 'unknown' },\n debugInfo: { devtoolsFrontendUrl: undefined },\n}\n\nfunction getInitialState(\n routerType: 'pages' | 'app'\n): OverlayState & { routerType: 'pages' | 'app' } {\n return {\n ...INITIAL_OVERLAY_STATE,\n routerType,\n }\n}\n\nexport function useErrorOverlayReducer(routerType: 'pages' | 'app') {\n return useReducer((_state: OverlayState, action: BusEvent): OverlayState => {\n switch (action.type) {\n case ACTION_DEBUG_INFO: {\n return { ..._state, debugInfo: action.debugInfo }\n }\n case ACTION_STATIC_INDICATOR: {\n return { ..._state, staticIndicator: action.staticIndicator }\n }\n case ACTION_BUILD_OK: {\n return { ..._state, buildError: null }\n }\n case ACTION_BUILD_ERROR: {\n return { ..._state, buildError: action.message }\n }\n case ACTION_BEFORE_REFRESH: {\n return { ..._state, refreshState: { type: 'pending', errors: [] } }\n }\n case ACTION_REFRESH: {\n return {\n ..._state,\n buildError: null,\n errors:\n // Errors can come in during updates. In this case, UNHANDLED_ERROR\n // and UNHANDLED_REJECTION events might be dispatched between the\n // BEFORE_REFRESH and the REFRESH event. We want to keep those errors\n // around until the next refresh. Otherwise we run into a race\n // condition where those errors would be cleared on refresh completion\n // before they can be displayed.\n _state.refreshState.type === 'pending'\n ? _state.refreshState.errors\n : [],\n refreshState: { type: 'idle' },\n }\n }\n case ACTION_UNHANDLED_ERROR:\n case ACTION_UNHANDLED_REJECTION: {\n switch (_state.refreshState.type) {\n case 'idle': {\n return {\n ..._state,\n nextId: _state.nextId + 1,\n errors: pushErrorFilterDuplicates(_state.errors, {\n id: _state.nextId,\n event: action,\n }),\n }\n }\n case 'pending': {\n return {\n ..._state,\n nextId: _state.nextId + 1,\n refreshState: {\n ..._state.refreshState,\n errors: pushErrorFilterDuplicates(_state.refreshState.errors, {\n id: _state.nextId,\n event: action,\n }),\n },\n }\n }\n default:\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: never = _state.refreshState\n return _state\n }\n }\n case ACTION_VERSION_INFO: {\n return { ..._state, versionInfo: action.versionInfo }\n }\n case ACTION_DEV_INDICATOR: {\n return {\n ..._state,\n disableDevIndicator:\n shouldDisableDevIndicator || !!action.devIndicator.disabledUntil,\n }\n }\n default: {\n return _state\n }\n }\n }, getInitialState(routerType))\n}\n\nexport const REACT_REFRESH_FULL_RELOAD_FROM_ERROR =\n '[Fast Refresh] performing full reload because your application had an unrecoverable error'\n"],"names":["ACTION_BEFORE_REFRESH","ACTION_BUILD_ERROR","ACTION_BUILD_OK","ACTION_DEBUG_INFO","ACTION_DEV_INDICATOR","ACTION_REFRESH","ACTION_STATIC_INDICATOR","ACTION_UNHANDLED_ERROR","ACTION_UNHANDLED_REJECTION","ACTION_VERSION_INFO","INITIAL_OVERLAY_STATE","REACT_REFRESH_FULL_RELOAD_FROM_ERROR","STORAGE_KEY_POSITION","STORAGE_KEY_THEME","useErrorOverlayReducer","process","pushErrorFilterDuplicates","errors","err","filter","e","event","reason","stack","shouldDisableDevIndicator","env","__NEXT_DEV_INDICATOR","toString","nextId","buildError","notFound","staticIndicator","disableDevIndicator","refreshState","type","rootLayoutMissingTags","versionInfo","installed","staleness","debugInfo","devtoolsFrontendUrl","undefined","getInitialState","routerType","useReducer","_state","action","message","id","_","devIndicator","disabledUntil"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgCaA,qBAAqB;eAArBA;;IADAC,kBAAkB;eAAlBA;;IADAC,eAAe;eAAfA;;IAOAC,iBAAiB;eAAjBA;;IACAC,oBAAoB;eAApBA;;IALAC,cAAc;eAAdA;;IAJAC,uBAAuB;eAAvBA;;IAMAC,sBAAsB;eAAtBA;;IACAC,0BAA0B;eAA1BA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,YAAY;wCACtBhB,QAAQD,0BAA0B6B,OAAOZ,YAAY,CAAChB,MAAM,EAAE;4CAC5D+B,IAAIH,OAAOjB,MAAM;4CACjBP,OAAOyB;wCACT;oCACF;gCACF;4BACF;wBACA;4BACE,6DAA6D;4BAC7D,MAAMG,IAAWJ,OAAOZ,YAAY;4BACpC,OAAOY;oBACX;gBACF;YACA,KAAKpC;gBAAqB;oBACxB,OAAO;wBAAE,GAAGoC,MAAM;wBAAET,aAAaU,OAAOV,WAAW;oBAAC;gBACtD;YACA,KAAKhC;gBAAsB;oBACzB,OAAO;wBACL,GAAGyC,MAAM;wBACTb,qBACER,6BAA6B,CAAC,CAACsB,OAAOI,YAAY,CAACC,aAAa;oBACpE;gBACF;YACA;gBAAS;oBACP,OAAON;gBACT;QACF;IACF,GAAGH,gBAAgBC;AACrB;AAEO,MAAMhC,uCACX"}
|
@@ -3,4 +3,4 @@ export declare const CallStackFrame: React.FC<{
|
|
3
3
|
frame: OriginalStackFrame;
|
4
4
|
index: number;
|
5
5
|
}>;
|
6
|
-
export declare const CALL_STACK_FRAME_STYLES = "\n [data-nextjs-call-stack-frame-ignored] {\n padding: 6px 8px;\n margin-bottom: 4px;\n\n border-radius: var(--rounded-lg);\n }\n\n [data-nextjs-call-stack-frame-ignored]:last-child {\n margin-bottom: 0;\n }\n\n [data-nextjs-call-stack-frame] {\n user-select: text;\n display: block;\n box-sizing: border-box;\n\n user-select: text;\n -webkit-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n\n padding: 6px 8px;\n\n border-radius: var(--rounded-lg);\n }\n\n .call-stack-frame-method-name {\n display: flex;\n align-items: center;\n gap: 4px;\n\n margin-bottom: 4px;\n font-family: var(--font-stack-monospace);\n\n color: var(--color-gray-1000);\n font-size: var(--size-14);\n font-weight: 500;\n line-height: var(--size-20);\n\n svg {\n width: var(--size-16px);\n height: var(--size-16px);\n }\n }\n\n .open-in-editor-button {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: var(--rounded-full);\n padding: 4px;\n color: var(--color-font);\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: var(--focus-ring);\n outline-offset: -2px;\n }\n\n &:hover {\n background: var(--color-gray-100);\n }\n }\n\n .call-stack-frame-file-source {\n color: var(--color-gray-900);\n font-size: var(--size-14);\n line-height: var(--size-20);\n }\n";
|
6
|
+
export declare const CALL_STACK_FRAME_STYLES = "\n [data-nextjs-call-stack-frame-ignored] {\n padding: 6px 8px;\n margin-bottom: 4px;\n\n border-radius: var(--rounded-lg);\n }\n\n [data-nextjs-call-stack-frame-ignored]:last-child {\n margin-bottom: 0;\n }\n\n [data-nextjs-call-stack-frame] {\n user-select: text;\n display: block;\n box-sizing: border-box;\n\n user-select: text;\n -webkit-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n\n padding: 6px 8px;\n\n border-radius: var(--rounded-lg);\n }\n\n .call-stack-frame-method-name {\n display: flex;\n align-items: center;\n gap: 4px;\n\n margin-bottom: 4px;\n font-family: var(--font-stack-monospace);\n\n color: var(--color-gray-1000);\n font-size: var(--size-14);\n font-weight: 500;\n line-height: var(--size-20);\n\n svg {\n width: var(--size-16px);\n height: var(--size-16px);\n }\n }\n\n .open-in-editor-button, .source-mapping-error-button {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: var(--rounded-full);\n padding: 4px;\n color: var(--color-font);\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: var(--focus-ring);\n outline-offset: -2px;\n }\n\n &:hover {\n background: var(--color-gray-100);\n }\n }\n\n .call-stack-frame-file-source {\n color: var(--color-gray-900);\n font-size: var(--size-14);\n line-height: var(--size-20);\n }\n";
|
package/dist/client/components/react-dev-overlay/ui/components/call-stack-frame/call-stack-frame.js
CHANGED
@@ -29,7 +29,6 @@ const CallStackFrame = function CallStackFrame(param) {
|
|
29
29
|
let { frame, index } = param;
|
30
30
|
var _frame_originalStackFrame;
|
31
31
|
// TODO: ability to expand resolved frames
|
32
|
-
// TODO: render error or external indicator
|
33
32
|
const f = (_frame_originalStackFrame = frame.originalStackFrame) != null ? _frame_originalStackFrame : frame.sourceStackFrame;
|
34
33
|
const hasSource = Boolean(frame.originalCodeFrame);
|
35
34
|
const open = (0, _useopenineditor.useOpenInEditor)(hasSource ? {
|
@@ -67,7 +66,16 @@ const CallStackFrame = function CallStackFrame(param) {
|
|
67
66
|
width: 16,
|
68
67
|
height: 16
|
69
68
|
})
|
70
|
-
})
|
69
|
+
}),
|
70
|
+
frame.error ? /*#__PURE__*/ (0, _jsxruntime.jsx)("button", {
|
71
|
+
className: "source-mapping-error-button",
|
72
|
+
onClick: ()=>console.error(frame.reason),
|
73
|
+
title: "Sourcemapping failed. Click to log cause of error.",
|
74
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_external.SourceMappingErrorIcon, {
|
75
|
+
width: 16,
|
76
|
+
height: 16
|
77
|
+
})
|
78
|
+
}) : null
|
71
79
|
]
|
72
80
|
}),
|
73
81
|
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
@@ -78,7 +86,7 @@ const CallStackFrame = function CallStackFrame(param) {
|
|
78
86
|
]
|
79
87
|
});
|
80
88
|
};
|
81
|
-
const CALL_STACK_FRAME_STYLES = "\n [data-nextjs-call-stack-frame-ignored] {\n padding: 6px 8px;\n margin-bottom: 4px;\n\n border-radius: var(--rounded-lg);\n }\n\n [data-nextjs-call-stack-frame-ignored]:last-child {\n margin-bottom: 0;\n }\n\n [data-nextjs-call-stack-frame] {\n user-select: text;\n display: block;\n box-sizing: border-box;\n\n user-select: text;\n -webkit-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n\n padding: 6px 8px;\n\n border-radius: var(--rounded-lg);\n }\n\n .call-stack-frame-method-name {\n display: flex;\n align-items: center;\n gap: 4px;\n\n margin-bottom: 4px;\n font-family: var(--font-stack-monospace);\n\n color: var(--color-gray-1000);\n font-size: var(--size-14);\n font-weight: 500;\n line-height: var(--size-20);\n\n svg {\n width: var(--size-16px);\n height: var(--size-16px);\n }\n }\n\n .open-in-editor-button {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: var(--rounded-full);\n padding: 4px;\n color: var(--color-font);\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: var(--focus-ring);\n outline-offset: -2px;\n }\n\n &:hover {\n background: var(--color-gray-100);\n }\n }\n\n .call-stack-frame-file-source {\n color: var(--color-gray-900);\n font-size: var(--size-14);\n line-height: var(--size-20);\n }\n";
|
89
|
+
const CALL_STACK_FRAME_STYLES = "\n [data-nextjs-call-stack-frame-ignored] {\n padding: 6px 8px;\n margin-bottom: 4px;\n\n border-radius: var(--rounded-lg);\n }\n\n [data-nextjs-call-stack-frame-ignored]:last-child {\n margin-bottom: 0;\n }\n\n [data-nextjs-call-stack-frame] {\n user-select: text;\n display: block;\n box-sizing: border-box;\n\n user-select: text;\n -webkit-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n\n padding: 6px 8px;\n\n border-radius: var(--rounded-lg);\n }\n\n .call-stack-frame-method-name {\n display: flex;\n align-items: center;\n gap: 4px;\n\n margin-bottom: 4px;\n font-family: var(--font-stack-monospace);\n\n color: var(--color-gray-1000);\n font-size: var(--size-14);\n font-weight: 500;\n line-height: var(--size-20);\n\n svg {\n width: var(--size-16px);\n height: var(--size-16px);\n }\n }\n\n .open-in-editor-button, .source-mapping-error-button {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: var(--rounded-full);\n padding: 4px;\n color: var(--color-font);\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: var(--focus-ring);\n outline-offset: -2px;\n }\n\n &:hover {\n background: var(--color-gray-100);\n }\n }\n\n .call-stack-frame-file-source {\n color: var(--color-gray-900);\n font-size: var(--size-14);\n line-height: var(--size-20);\n }\n";
|
82
90
|
|
83
91
|
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
84
92
|
Object.defineProperty(exports.default, '__esModule', { value: true });
|