next 15.4.0-canary.19 → 15.4.0-canary.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.d.ts +2 -2
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.js +30 -21
- 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/draggable.d.ts +29 -0
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/draggable.js +271 -0
- package/dist/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/draggable.js.map +1 -0
- package/dist/client/components/react-dev-overlay/ui/components/fader/index.d.ts +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/fader/index.js +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/fader/index.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/toast/styles.d.ts +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/toast/styles.js +1 -1
- package/dist/client/components/react-dev-overlay/ui/components/toast/styles.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/styles/base.js +1 -1
- package/dist/client/components/react-dev-overlay/ui/styles/base.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-turbo-experimental.runtime.dev.js +3 -3
- package/dist/compiled/next-server/app-page-turbo-experimental.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/app-page-turbo.runtime.dev.js +3 -3
- package/dist/compiled/next-server/app-page-turbo.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/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.js +30 -21
- 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/draggable.js +243 -0
- package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/draggable.js.map +1 -0
- package/dist/esm/client/components/react-dev-overlay/ui/components/fader/index.js +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/fader/index.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/toast/styles.js +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/components/toast/styles.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/styles/base.js +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/styles/base.js.map +1 -1
- package/dist/esm/client/index.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/esm/shared/lib/canary-only.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/shared/lib/canary-only.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 +15 -15
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.4.0-canary.
|
82
|
+
}).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.4.0-canary.20"}`, '-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.').option('--turbo', 'Starts development mode using Turbopack.').option('--turbopack', 'Starts development mode using Turbopack.').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
@@ -376,7 +376,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
|
|
376
376
|
const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
|
377
377
|
buildMode: experimentalBuildMode,
|
378
378
|
isTurboBuild: String(isTurbopack),
|
379
|
-
version: "15.4.0-canary.
|
379
|
+
version: "15.4.0-canary.20"
|
380
380
|
});
|
381
381
|
_buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
|
382
382
|
_buildcontext.NextBuildContext.dir = dir;
|
@@ -758,7 +758,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
|
|
758
758
|
// Files outside of the distDir can be "type": "module"
|
759
759
|
await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
760
760
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
761
|
-
await (0, _builddiagnostics.recordFrameworkVersion)("15.4.0-canary.
|
761
|
+
await (0, _builddiagnostics.recordFrameworkVersion)("15.4.0-canary.20");
|
762
762
|
await (0, _builddiagnostics.updateBuildDiagnostics)({
|
763
763
|
buildStage: 'start'
|
764
764
|
});
|
package/dist/build/swc/index.js
CHANGED
@@ -123,7 +123,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
123
123
|
}
|
124
124
|
return newObj;
|
125
125
|
}
|
126
|
-
const nextVersion = "15.4.0-canary.
|
126
|
+
const nextVersion = "15.4.0-canary.20";
|
127
127
|
const ArchName = (0, _os.arch)();
|
128
128
|
const PlatformName = (0, _os.platform)();
|
129
129
|
function infoLog(...args) {
|
@@ -1653,7 +1653,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
1653
1653
|
isClient && new _copyfileplugin.CopyFilePlugin({
|
1654
1654
|
// file path to build output of `@next/polyfill-nomodule`
|
1655
1655
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
1656
|
-
cacheKey: "15.4.0-canary.
|
1656
|
+
cacheKey: "15.4.0-canary.20",
|
1657
1657
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
1658
1658
|
minimize: false,
|
1659
1659
|
info: {
|
@@ -1830,7 +1830,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
1830
1830
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
1831
1831
|
// - Next.js version
|
1832
1832
|
// - next.config.js keys that affect compilation
|
1833
|
-
version: `${__dirname}|${"15.4.0-canary.
|
1833
|
+
version: `${__dirname}|${"15.4.0-canary.20"}|${configVars}`,
|
1834
1834
|
cacheDirectory: _path.default.join(distDir, 'cache', 'webpack'),
|
1835
1835
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
1836
1836
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type
|
1
|
+
import { type OverlayState } from '../../../../shared';
|
2
2
|
import { type DevToolsScale } from './dev-tools-info/preferences';
|
3
3
|
export declare function DevToolsIndicator({ state, errorCount, isBuildError, setIsErrorOverlayOpen, ...props }: {
|
4
4
|
state: OverlayState;
|
@@ -15,5 +15,5 @@ declare const OVERLAYS: {
|
|
15
15
|
readonly Preferences: "preferences";
|
16
16
|
};
|
17
17
|
export type Overlays = (typeof OVERLAYS)[keyof typeof OVERLAYS];
|
18
|
-
export declare const DEV_TOOLS_INDICATOR_STYLES = "\n .dev-tools-indicator-menu {\n -webkit-font-smoothing: antialiased;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-menu);\n border-radius: var(--rounded-xl);\n position: absolute;\n font-family: var(--font-stack-sans);\n z-index: 1000;\n overflow: hidden;\n opacity: 0;\n outline: 0;\n min-width: 248px;\n transition: opacity var(--animate-out-duration-ms)\n var(--animate-out-timing-function);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n .dev-tools-indicator-inner {\n padding: 6px;\n width: 100%;\n }\n\n .dev-tools-indicator-item {\n display: flex;\n align-items: center;\n padding: 8px 6px;\n height: var(--size-36);\n border-radius: 6px;\n text-decoration: none !important;\n user-select: none;\n white-space: nowrap;\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: 0;\n }\n }\n\n .dev-tools-indicator-footer {\n background: var(--color-background-200);\n padding: 6px;\n border-top: 1px solid var(--color-gray-400);\n width: 100%;\n }\n\n .dev-tools-indicator-item[data-selected='true'] {\n cursor: pointer;\n background-color: var(--color-gray-200);\n }\n\n .dev-tools-indicator-label {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-1000);\n }\n\n .dev-tools-indicator-value {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-900);\n margin-left: auto;\n }\n\n .dev-tools-indicator-issue-count {\n --color-primary: var(--color-gray-800);\n --color-secondary: var(--color-gray-100);\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-width: var(--size-40);\n height: var(--size-24);\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-small);\n padding: 2px;\n color: var(--color-gray-1000);\n border-radius: 128px;\n font-weight: 500;\n font-size: var(--size-13);\n font-variant-numeric: tabular-nums;\n\n &[data-has-issues='true'] {\n --color-primary: var(--color-red-800);\n --color-secondary: var(--color-red-100);\n }\n\n .dev-tools-indicator-issue-count-indicator {\n width: var(--size-8);\n height: var(--size-8);\n background: var(--color-primary);\n box-shadow: 0 0 0 2px var(--color-secondary);\n border-radius: 50%;\n }\n }\n\n .dev-tools-indicator-shortcut {\n display: flex;\n gap: 4px;\n\n kbd {\n width: var(--size-20);\n height: var(--size-20);\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--rounded-md);\n border: 1px solid var(--color-gray-400);\n font-family: var(--font-stack-sans);\n background: var(--color-background-100);\n color: var(--color-gray-1000);\n text-align: center;\n font-size: var(--size-12);\n line-height: var(--size-16);\n }\n }\n";
|
18
|
+
export declare const DEV_TOOLS_INDICATOR_STYLES = "\n .dev-tools-indicator-menu {\n -webkit-font-smoothing: antialiased;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-menu);\n border-radius: var(--rounded-xl);\n position: absolute;\n font-family: var(--font-stack-sans);\n z-index: 1000;\n overflow: hidden;\n opacity: 0;\n outline: 0;\n min-width: 248px;\n transition: opacity var(--animate-out-duration-ms)\n var(--animate-out-timing-function);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n .dev-tools-indicator-inner {\n padding: 6px;\n width: 100%;\n }\n\n .dev-tools-indicator-item {\n display: flex;\n align-items: center;\n padding: 8px 6px;\n height: var(--size-36);\n border-radius: 6px;\n text-decoration: none !important;\n user-select: none;\n white-space: nowrap;\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: 0;\n }\n }\n\n .dev-tools-indicator-footer {\n background: var(--color-background-200);\n padding: 6px;\n border-top: 1px solid var(--color-gray-400);\n width: 100%;\n }\n\n .dev-tools-indicator-item[data-selected='true'] {\n cursor: pointer;\n background-color: var(--color-gray-200);\n }\n\n .dev-tools-indicator-label {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-1000);\n }\n\n .dev-tools-indicator-value {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-900);\n margin-left: auto;\n }\n\n .dev-tools-indicator-issue-count {\n --color-primary: var(--color-gray-800);\n --color-secondary: var(--color-gray-100);\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-width: var(--size-40);\n height: var(--size-24);\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-small);\n padding: 2px;\n color: var(--color-gray-1000);\n border-radius: 128px;\n font-weight: 500;\n font-size: var(--size-13);\n font-variant-numeric: tabular-nums;\n\n &[data-has-issues='true'] {\n --color-primary: var(--color-red-800);\n --color-secondary: var(--color-red-100);\n }\n\n .dev-tools-indicator-issue-count-indicator {\n width: var(--size-8);\n height: var(--size-8);\n background: var(--color-primary);\n box-shadow: 0 0 0 2px var(--color-secondary);\n border-radius: 50%;\n }\n }\n\n .dev-tools-indicator-shortcut {\n display: flex;\n gap: 4px;\n\n kbd {\n width: var(--size-20);\n height: var(--size-20);\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--rounded-md);\n border: 1px solid var(--color-gray-400);\n font-family: var(--font-stack-sans);\n background: var(--color-background-100);\n color: var(--color-gray-1000);\n text-align: center;\n font-size: var(--size-12);\n line-height: var(--size-16);\n }\n }\n\n .dev-tools-grabbing {\n cursor: grabbing;\n\n > * {\n pointer-events: none;\n }\n }\n";
|
19
19
|
export {};
|
@@ -22,6 +22,7 @@ _export(exports, {
|
|
22
22
|
});
|
23
23
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
24
24
|
const _jsxruntime = require("react/jsx-runtime");
|
25
|
+
const _shared = require("../../../../shared");
|
25
26
|
const _react = require("react");
|
26
27
|
const _toast = require("../../toast");
|
27
28
|
const _nextlogo = require("./next-logo");
|
@@ -34,6 +35,7 @@ const _gearicon = /*#__PURE__*/ _interop_require_default._(require("../../../ico
|
|
34
35
|
const _userpreferences = require("./dev-tools-info/user-preferences");
|
35
36
|
const _utils = require("./utils");
|
36
37
|
const _preferences = require("./dev-tools-info/preferences");
|
38
|
+
const _draggable = require("./draggable");
|
37
39
|
function DevToolsIndicator(param) {
|
38
40
|
let { state, errorCount, isBuildError, setIsErrorOverlayOpen, ...props } = param;
|
39
41
|
const [isDevToolsIndicatorVisible, setIsDevToolsIndicatorVisible] = (0, _react.useState)(true);
|
@@ -62,6 +64,7 @@ const OVERLAYS = {
|
|
62
64
|
Route: 'route',
|
63
65
|
Preferences: 'preferences'
|
64
66
|
};
|
67
|
+
const INDICATOR_PADDING = 20;
|
65
68
|
function DevToolsPopover(param) {
|
66
69
|
let { routerType, disabled, issueCount, isStaticRoute, isTurbopack, isBuildError, hide, setIsErrorOverlayOpen, scale, setScale } = param;
|
67
70
|
const menuRef = (0, _react.useRef)(null);
|
@@ -195,28 +198,34 @@ function DevToolsPopover(param) {
|
|
195
198
|
'--animate-out-timing-function': _utils.MENU_CURVE,
|
196
199
|
boxShadow: 'none',
|
197
200
|
zIndex: 2147483647,
|
198
|
-
|
199
|
-
|
200
|
-
left: 'initial',
|
201
|
-
[vertical]: '20px',
|
202
|
-
[horizontal]: '20px'
|
201
|
+
[vertical]: "" + INDICATOR_PADDING + "px",
|
202
|
+
[horizontal]: "" + INDICATOR_PADDING + "px"
|
203
203
|
},
|
204
204
|
children: [
|
205
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
205
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_draggable.Draggable, {
|
206
|
+
padding: INDICATOR_PADDING,
|
207
|
+
onDragStart: ()=>setOpen(null),
|
208
|
+
position: position,
|
209
|
+
setPosition: (p)=>{
|
210
|
+
localStorage.setItem(_shared.STORAGE_KEY_POSITION, p);
|
211
|
+
setPosition(p);
|
212
|
+
},
|
213
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_nextlogo.NextLogo, {
|
214
|
+
ref: triggerRef,
|
215
|
+
"aria-haspopup": "menu",
|
216
|
+
"aria-expanded": isMenuOpen,
|
217
|
+
"aria-controls": "nextjs-dev-tools-menu",
|
218
|
+
"aria-label": "" + (isMenuOpen ? 'Close' : 'Open') + " Next.js Dev Tools",
|
219
|
+
"data-nextjs-dev-tools-button": true,
|
220
|
+
disabled: disabled,
|
221
|
+
issueCount: issueCount,
|
222
|
+
onTriggerClick: onTriggerClick,
|
223
|
+
toggleErrorOverlay: toggleErrorOverlay,
|
224
|
+
isDevBuilding: (0, _initialize.useIsDevBuilding)(),
|
225
|
+
isDevRendering: (0, _devrenderindicator.useIsDevRendering)(),
|
226
|
+
isBuildError: isBuildError,
|
227
|
+
scale: scale
|
228
|
+
})
|
220
229
|
}),
|
221
230
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_routeinfo.RouteInfo, {
|
222
231
|
isOpen: isRouteInfoOpen,
|
@@ -386,7 +395,7 @@ function IssueCount(param) {
|
|
386
395
|
]
|
387
396
|
});
|
388
397
|
}
|
389
|
-
const DEV_TOOLS_INDICATOR_STYLES = "\n .dev-tools-indicator-menu {\n -webkit-font-smoothing: antialiased;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-menu);\n border-radius: var(--rounded-xl);\n position: absolute;\n font-family: var(--font-stack-sans);\n z-index: 1000;\n overflow: hidden;\n opacity: 0;\n outline: 0;\n min-width: 248px;\n transition: opacity var(--animate-out-duration-ms)\n var(--animate-out-timing-function);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n .dev-tools-indicator-inner {\n padding: 6px;\n width: 100%;\n }\n\n .dev-tools-indicator-item {\n display: flex;\n align-items: center;\n padding: 8px 6px;\n height: var(--size-36);\n border-radius: 6px;\n text-decoration: none !important;\n user-select: none;\n white-space: nowrap;\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: 0;\n }\n }\n\n .dev-tools-indicator-footer {\n background: var(--color-background-200);\n padding: 6px;\n border-top: 1px solid var(--color-gray-400);\n width: 100%;\n }\n\n .dev-tools-indicator-item[data-selected='true'] {\n cursor: pointer;\n background-color: var(--color-gray-200);\n }\n\n .dev-tools-indicator-label {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-1000);\n }\n\n .dev-tools-indicator-value {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-900);\n margin-left: auto;\n }\n\n .dev-tools-indicator-issue-count {\n --color-primary: var(--color-gray-800);\n --color-secondary: var(--color-gray-100);\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-width: var(--size-40);\n height: var(--size-24);\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-small);\n padding: 2px;\n color: var(--color-gray-1000);\n border-radius: 128px;\n font-weight: 500;\n font-size: var(--size-13);\n font-variant-numeric: tabular-nums;\n\n &[data-has-issues='true'] {\n --color-primary: var(--color-red-800);\n --color-secondary: var(--color-red-100);\n }\n\n .dev-tools-indicator-issue-count-indicator {\n width: var(--size-8);\n height: var(--size-8);\n background: var(--color-primary);\n box-shadow: 0 0 0 2px var(--color-secondary);\n border-radius: 50%;\n }\n }\n\n .dev-tools-indicator-shortcut {\n display: flex;\n gap: 4px;\n\n kbd {\n width: var(--size-20);\n height: var(--size-20);\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--rounded-md);\n border: 1px solid var(--color-gray-400);\n font-family: var(--font-stack-sans);\n background: var(--color-background-100);\n color: var(--color-gray-1000);\n text-align: center;\n font-size: var(--size-12);\n line-height: var(--size-16);\n }\n }\n";
|
398
|
+
const DEV_TOOLS_INDICATOR_STYLES = "\n .dev-tools-indicator-menu {\n -webkit-font-smoothing: antialiased;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-menu);\n border-radius: var(--rounded-xl);\n position: absolute;\n font-family: var(--font-stack-sans);\n z-index: 1000;\n overflow: hidden;\n opacity: 0;\n outline: 0;\n min-width: 248px;\n transition: opacity var(--animate-out-duration-ms)\n var(--animate-out-timing-function);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n .dev-tools-indicator-inner {\n padding: 6px;\n width: 100%;\n }\n\n .dev-tools-indicator-item {\n display: flex;\n align-items: center;\n padding: 8px 6px;\n height: var(--size-36);\n border-radius: 6px;\n text-decoration: none !important;\n user-select: none;\n white-space: nowrap;\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: 0;\n }\n }\n\n .dev-tools-indicator-footer {\n background: var(--color-background-200);\n padding: 6px;\n border-top: 1px solid var(--color-gray-400);\n width: 100%;\n }\n\n .dev-tools-indicator-item[data-selected='true'] {\n cursor: pointer;\n background-color: var(--color-gray-200);\n }\n\n .dev-tools-indicator-label {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-1000);\n }\n\n .dev-tools-indicator-value {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-900);\n margin-left: auto;\n }\n\n .dev-tools-indicator-issue-count {\n --color-primary: var(--color-gray-800);\n --color-secondary: var(--color-gray-100);\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-width: var(--size-40);\n height: var(--size-24);\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-small);\n padding: 2px;\n color: var(--color-gray-1000);\n border-radius: 128px;\n font-weight: 500;\n font-size: var(--size-13);\n font-variant-numeric: tabular-nums;\n\n &[data-has-issues='true'] {\n --color-primary: var(--color-red-800);\n --color-secondary: var(--color-red-100);\n }\n\n .dev-tools-indicator-issue-count-indicator {\n width: var(--size-8);\n height: var(--size-8);\n background: var(--color-primary);\n box-shadow: 0 0 0 2px var(--color-secondary);\n border-radius: 50%;\n }\n }\n\n .dev-tools-indicator-shortcut {\n display: flex;\n gap: 4px;\n\n kbd {\n width: var(--size-20);\n height: var(--size-20);\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--rounded-md);\n border: 1px solid var(--color-gray-400);\n font-family: var(--font-stack-sans);\n background: var(--color-background-100);\n color: var(--color-gray-1000);\n text-align: center;\n font-size: var(--size-12);\n line-height: var(--size-16);\n }\n }\n\n .dev-tools-grabbing {\n cursor: grabbing;\n\n > * {\n pointer-events: none;\n }\n }\n";
|
390
399
|
|
391
400
|
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
392
401
|
Object.defineProperty(exports.default, '__esModule', { value: true });
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.tsx"],"sourcesContent":["import type { CSSProperties, Dispatch, SetStateAction } from 'react'\nimport type { OverlayState } from '../../../../shared'\n\nimport { useState, useEffect, useRef, createContext, useContext } from 'react'\nimport { Toast } from '../../toast'\nimport { NextLogo } from './next-logo'\nimport { useIsDevBuilding } from '../../../../../../dev/dev-build-indicator/internal/initialize'\nimport { useIsDevRendering } from '../../../../utils/dev-indicator/dev-render-indicator'\nimport { useDelayedRender } from '../../../hooks/use-delayed-render'\nimport { TurbopackInfo } from './dev-tools-info/turbopack-info'\nimport { RouteInfo } from './dev-tools-info/route-info'\nimport GearIcon from '../../../icons/gear-icon'\nimport { UserPreferences } from './dev-tools-info/user-preferences'\nimport {\n MENU_CURVE,\n MENU_DURATION_MS,\n useClickOutside,\n useFocusTrap,\n} from './utils'\nimport {\n getInitialPosition,\n type DevToolsScale,\n} from './dev-tools-info/preferences'\n\n// TODO: add E2E tests to cover different scenarios\n\nexport function DevToolsIndicator({\n state,\n errorCount,\n isBuildError,\n setIsErrorOverlayOpen,\n ...props\n}: {\n state: OverlayState\n errorCount: number\n isBuildError: boolean\n setIsErrorOverlayOpen: (\n isErrorOverlayOpen: boolean | ((prev: boolean) => boolean)\n ) => void\n scale: DevToolsScale\n setScale: (value: DevToolsScale) => void\n}) {\n const [isDevToolsIndicatorVisible, setIsDevToolsIndicatorVisible] =\n useState(true)\n\n return (\n <DevToolsPopover\n routerType={state.routerType}\n semver={state.versionInfo.installed}\n issueCount={errorCount}\n isStaticRoute={state.staticIndicator}\n hide={() => {\n setIsDevToolsIndicatorVisible(false)\n fetch('/__nextjs_disable_dev_indicator', {\n method: 'POST',\n })\n }}\n setIsErrorOverlayOpen={setIsErrorOverlayOpen}\n isTurbopack={!!process.env.TURBOPACK}\n disabled={state.disableDevIndicator || !isDevToolsIndicatorVisible}\n isBuildError={isBuildError}\n {...props}\n />\n )\n}\n\n//////////////////////////////////////////////////////////////////////////////////////\n\ninterface C {\n closeMenu: () => void\n selectedIndex: number\n setSelectedIndex: Dispatch<SetStateAction<number>>\n}\n\nconst Context = createContext({} as C)\n\nconst OVERLAYS = {\n Root: 'root',\n Turbo: 'turbo',\n Route: 'route',\n Preferences: 'preferences',\n} as const\n\nexport type Overlays = (typeof OVERLAYS)[keyof typeof OVERLAYS]\n\nfunction DevToolsPopover({\n routerType,\n disabled,\n issueCount,\n isStaticRoute,\n isTurbopack,\n isBuildError,\n hide,\n setIsErrorOverlayOpen,\n scale,\n setScale,\n}: {\n routerType: 'pages' | 'app'\n disabled: boolean\n issueCount: number\n isStaticRoute: boolean\n semver: string | undefined\n isTurbopack: boolean\n isBuildError: boolean\n hide: () => void\n setIsErrorOverlayOpen: (\n isOverlayOpen: boolean | ((prev: boolean) => boolean)\n ) => void\n scale: DevToolsScale\n setScale: (value: DevToolsScale) => void\n}) {\n const menuRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n\n const [open, setOpen] = useState<Overlays | null>(null)\n const [position, setPosition] = useState(getInitialPosition())\n const [selectedIndex, setSelectedIndex] = useState(-1)\n\n const isMenuOpen = open === OVERLAYS.Root\n const isTurbopackInfoOpen = open === OVERLAYS.Turbo\n const isRouteInfoOpen = open === OVERLAYS.Route\n const isPreferencesOpen = open === OVERLAYS.Preferences\n\n const { mounted: menuMounted, rendered: menuRendered } = useDelayedRender(\n isMenuOpen,\n {\n // Intentionally no fade in, makes the UI feel more immediate\n enterDelay: 0,\n // Graceful fade out to confirm that the UI did not break\n exitDelay: MENU_DURATION_MS,\n }\n )\n\n // Features to make the menu accessible\n useFocusTrap(menuRef, triggerRef, isMenuOpen)\n useClickOutside(menuRef, triggerRef, isMenuOpen, closeMenu)\n\n useEffect(() => {\n if (open === null) {\n // Avoid flashing selected state\n const id = setTimeout(() => {\n setSelectedIndex(-1)\n }, MENU_DURATION_MS)\n return () => clearTimeout(id)\n }\n }, [open])\n\n function select(index: number | 'first' | 'last') {\n if (index === 'first') {\n setTimeout(() => {\n const all = menuRef.current?.querySelectorAll('[role=\"menuitem\"]')\n if (all) {\n const firstIndex = all[0].getAttribute('data-index')\n select(Number(firstIndex))\n }\n })\n return\n }\n\n if (index === 'last') {\n setTimeout(() => {\n const all = menuRef.current?.querySelectorAll('[role=\"menuitem\"]')\n if (all) {\n const lastIndex = all.length - 1\n select(lastIndex)\n }\n })\n return\n }\n\n const el = menuRef.current?.querySelector(\n `[data-index=\"${index}\"]`\n ) as HTMLElement\n\n if (el) {\n setSelectedIndex(index)\n el?.focus()\n }\n }\n\n function onMenuKeydown(e: React.KeyboardEvent<HTMLDivElement>) {\n e.preventDefault()\n\n switch (e.key) {\n case 'ArrowDown':\n const next = selectedIndex + 1\n select(next)\n break\n case 'ArrowUp':\n const prev = selectedIndex - 1\n select(prev)\n break\n case 'Home':\n select('first')\n break\n case 'End':\n select('last')\n break\n default:\n break\n }\n }\n\n function openErrorOverlay() {\n setOpen(null)\n if (issueCount > 0) {\n setIsErrorOverlayOpen(true)\n }\n }\n\n function toggleErrorOverlay() {\n setIsErrorOverlayOpen((prev) => !prev)\n }\n\n function openRootMenu() {\n setOpen((prevOpen) => {\n if (prevOpen === null) select('first')\n return OVERLAYS.Root\n })\n }\n\n function onTriggerClick() {\n if (open === OVERLAYS.Root) {\n setOpen(null)\n } else {\n openRootMenu()\n setTimeout(() => {\n select('first')\n })\n }\n }\n\n function closeMenu() {\n // Only close when we were on `Root`,\n // otherwise it will close other overlays\n setOpen((prevOpen) => {\n if (prevOpen === OVERLAYS.Root) {\n return null\n }\n return prevOpen\n })\n }\n\n function handleHideDevtools() {\n setOpen(null)\n hide()\n }\n\n const [vertical, horizontal] = position.split('-', 2)\n const popover = { [vertical]: 'calc(100% + 8px)', [horizontal]: 0 }\n\n return (\n <Toast\n data-nextjs-toast\n style={\n {\n '--animate-out-duration-ms': `${MENU_DURATION_MS}ms`,\n '--animate-out-timing-function': MENU_CURVE,\n boxShadow: 'none',\n zIndex: 2147483647,\n // Reset the toast component's default positions.\n bottom: 'initial',\n left: 'initial',\n [vertical]: '20px',\n [horizontal]: '20px',\n } as CSSProperties\n }\n >\n {/* Trigger */}\n <NextLogo\n ref={triggerRef}\n aria-haspopup=\"menu\"\n aria-expanded={isMenuOpen}\n aria-controls=\"nextjs-dev-tools-menu\"\n aria-label={`${isMenuOpen ? 'Close' : 'Open'} Next.js Dev Tools`}\n data-nextjs-dev-tools-button\n disabled={disabled}\n issueCount={issueCount}\n onTriggerClick={onTriggerClick}\n toggleErrorOverlay={toggleErrorOverlay}\n isDevBuilding={useIsDevBuilding()}\n isDevRendering={useIsDevRendering()}\n isBuildError={isBuildError}\n scale={scale}\n />\n\n {/* Route Info */}\n <RouteInfo\n isOpen={isRouteInfoOpen}\n close={openRootMenu}\n triggerRef={triggerRef}\n style={popover}\n routerType={routerType}\n routeType={isStaticRoute ? 'Static' : 'Dynamic'}\n />\n\n {/* Turbopack Info */}\n <TurbopackInfo\n isOpen={isTurbopackInfoOpen}\n close={openRootMenu}\n triggerRef={triggerRef}\n style={popover}\n />\n\n {/* Preferences */}\n <UserPreferences\n isOpen={isPreferencesOpen}\n close={openRootMenu}\n triggerRef={triggerRef}\n style={popover}\n hide={handleHideDevtools}\n setPosition={setPosition}\n position={position}\n scale={scale}\n setScale={setScale}\n />\n\n {/* Dropdown Menu */}\n {menuMounted && (\n <div\n ref={menuRef}\n id=\"nextjs-dev-tools-menu\"\n role=\"menu\"\n dir=\"ltr\"\n aria-orientation=\"vertical\"\n aria-label=\"Next.js Dev Tools Items\"\n tabIndex={-1}\n className=\"dev-tools-indicator-menu\"\n onKeyDown={onMenuKeydown}\n data-rendered={menuRendered}\n style={popover}\n >\n <Context.Provider\n value={{\n closeMenu,\n selectedIndex,\n setSelectedIndex,\n }}\n >\n <div className=\"dev-tools-indicator-inner\">\n {issueCount > 0 && (\n <MenuItem\n title={`${issueCount} ${issueCount === 1 ? 'issue' : 'issues'} found. Click to view details in the dev overlay.`}\n index={0}\n label=\"Issues\"\n value={<IssueCount>{issueCount}</IssueCount>}\n onClick={openErrorOverlay}\n />\n )}\n <MenuItem\n title={`Current route is ${isStaticRoute ? 'static' : 'dynamic'}.`}\n label=\"Route\"\n index={1}\n value={isStaticRoute ? 'Static' : 'Dynamic'}\n onClick={() => setOpen(OVERLAYS.Route)}\n data-nextjs-route-type={isStaticRoute ? 'static' : 'dynamic'}\n />\n {isTurbopack ? (\n <MenuItem\n title=\"Turbopack is enabled.\"\n label=\"Turbopack\"\n value=\"Enabled\"\n />\n ) : (\n <MenuItem\n index={2}\n title=\"Learn about Turbopack and how to enable it in your application.\"\n label=\"Try Turbopack\"\n value={<ChevronRight />}\n onClick={() => setOpen(OVERLAYS.Turbo)}\n />\n )}\n </div>\n\n <div className=\"dev-tools-indicator-footer\">\n <MenuItem\n data-preferences\n label=\"Preferences\"\n value={<GearIcon />}\n onClick={() => setOpen(OVERLAYS.Preferences)}\n index={isTurbopack ? 2 : 3}\n />\n </div>\n </Context.Provider>\n </div>\n )}\n </Toast>\n )\n}\n\nfunction ChevronRight() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n >\n <path\n fill=\"#666\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.50011 1.93945L6.03044 2.46978L10.8537 7.293C11.2442 7.68353 11.2442 8.31669 10.8537 8.70722L6.03044 13.5304L5.50011 14.0608L4.43945 13.0001L4.96978 12.4698L9.43945 8.00011L4.96978 3.53044L4.43945 3.00011L5.50011 1.93945Z\"\n />\n </svg>\n )\n}\n\nfunction MenuItem({\n index,\n label,\n value,\n onClick,\n href,\n ...props\n}: {\n index?: number\n title?: string\n label: string\n value: React.ReactNode\n href?: string\n onClick?: () => void\n}) {\n const isInteractive =\n typeof onClick === 'function' || typeof href === 'string'\n const { closeMenu, selectedIndex, setSelectedIndex } = useContext(Context)\n const selected = selectedIndex === index\n\n function click() {\n if (isInteractive) {\n onClick?.()\n closeMenu()\n if (href) {\n window.open(href, '_blank', 'noopener, noreferrer')\n }\n }\n }\n\n return (\n <div\n className=\"dev-tools-indicator-item\"\n data-index={index}\n data-selected={selected}\n onClick={click}\n // Needs `onMouseMove` instead of enter to work together\n // with keyboard and mouse input\n onMouseMove={() => {\n if (isInteractive && index !== undefined && selectedIndex !== index) {\n setSelectedIndex(index)\n }\n }}\n onMouseLeave={() => setSelectedIndex(-1)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n click()\n }\n }}\n role={isInteractive ? 'menuitem' : undefined}\n tabIndex={selected ? 0 : -1}\n {...props}\n >\n <span className=\"dev-tools-indicator-label\">{label}</span>\n <span className=\"dev-tools-indicator-value\">{value}</span>\n </div>\n )\n}\n\nfunction IssueCount({ children }: { children: number }) {\n return (\n <span\n className=\"dev-tools-indicator-issue-count\"\n data-has-issues={children > 0}\n >\n <span className=\"dev-tools-indicator-issue-count-indicator\" />\n {children}\n </span>\n )\n}\n\n//////////////////////////////////////////////////////////////////////////////////////\n\nexport const DEV_TOOLS_INDICATOR_STYLES = `\n .dev-tools-indicator-menu {\n -webkit-font-smoothing: antialiased;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-menu);\n border-radius: var(--rounded-xl);\n position: absolute;\n font-family: var(--font-stack-sans);\n z-index: 1000;\n overflow: hidden;\n opacity: 0;\n outline: 0;\n min-width: 248px;\n transition: opacity var(--animate-out-duration-ms)\n var(--animate-out-timing-function);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n .dev-tools-indicator-inner {\n padding: 6px;\n width: 100%;\n }\n\n .dev-tools-indicator-item {\n display: flex;\n align-items: center;\n padding: 8px 6px;\n height: var(--size-36);\n border-radius: 6px;\n text-decoration: none !important;\n user-select: none;\n white-space: nowrap;\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: 0;\n }\n }\n\n .dev-tools-indicator-footer {\n background: var(--color-background-200);\n padding: 6px;\n border-top: 1px solid var(--color-gray-400);\n width: 100%;\n }\n\n .dev-tools-indicator-item[data-selected='true'] {\n cursor: pointer;\n background-color: var(--color-gray-200);\n }\n\n .dev-tools-indicator-label {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-1000);\n }\n\n .dev-tools-indicator-value {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-900);\n margin-left: auto;\n }\n\n .dev-tools-indicator-issue-count {\n --color-primary: var(--color-gray-800);\n --color-secondary: var(--color-gray-100);\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-width: var(--size-40);\n height: var(--size-24);\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-small);\n padding: 2px;\n color: var(--color-gray-1000);\n border-radius: 128px;\n font-weight: 500;\n font-size: var(--size-13);\n font-variant-numeric: tabular-nums;\n\n &[data-has-issues='true'] {\n --color-primary: var(--color-red-800);\n --color-secondary: var(--color-red-100);\n }\n\n .dev-tools-indicator-issue-count-indicator {\n width: var(--size-8);\n height: var(--size-8);\n background: var(--color-primary);\n box-shadow: 0 0 0 2px var(--color-secondary);\n border-radius: 50%;\n }\n }\n\n .dev-tools-indicator-shortcut {\n display: flex;\n gap: 4px;\n\n kbd {\n width: var(--size-20);\n height: var(--size-20);\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--rounded-md);\n border: 1px solid var(--color-gray-400);\n font-family: var(--font-stack-sans);\n background: var(--color-background-100);\n color: var(--color-gray-1000);\n text-align: center;\n font-size: var(--size-12);\n line-height: var(--size-16);\n }\n }\n`\n"],"names":["DEV_TOOLS_INDICATOR_STYLES","DevToolsIndicator","state","errorCount","isBuildError","setIsErrorOverlayOpen","props","isDevToolsIndicatorVisible","setIsDevToolsIndicatorVisible","useState","DevToolsPopover","routerType","semver","versionInfo","installed","issueCount","isStaticRoute","staticIndicator","hide","fetch","method","isTurbopack","process","env","TURBOPACK","disabled","disableDevIndicator","Context","createContext","OVERLAYS","Root","Turbo","Route","Preferences","scale","setScale","menuRef","useRef","triggerRef","open","setOpen","position","setPosition","getInitialPosition","selectedIndex","setSelectedIndex","isMenuOpen","isTurbopackInfoOpen","isRouteInfoOpen","isPreferencesOpen","mounted","menuMounted","rendered","menuRendered","useDelayedRender","enterDelay","exitDelay","MENU_DURATION_MS","useFocusTrap","useClickOutside","closeMenu","useEffect","id","setTimeout","clearTimeout","select","index","all","current","querySelectorAll","firstIndex","getAttribute","Number","lastIndex","length","el","querySelector","focus","onMenuKeydown","e","preventDefault","key","next","prev","openErrorOverlay","toggleErrorOverlay","openRootMenu","prevOpen","onTriggerClick","handleHideDevtools","vertical","horizontal","split","popover","Toast","data-nextjs-toast","style","MENU_CURVE","boxShadow","zIndex","bottom","left","NextLogo","ref","aria-haspopup","aria-expanded","aria-controls","aria-label","data-nextjs-dev-tools-button","isDevBuilding","useIsDevBuilding","isDevRendering","useIsDevRendering","RouteInfo","isOpen","close","routeType","TurbopackInfo","UserPreferences","div","role","dir","aria-orientation","tabIndex","className","onKeyDown","data-rendered","Provider","value","MenuItem","title","label","IssueCount","onClick","data-nextjs-route-type","ChevronRight","data-preferences","GearIcon","svg","xmlns","width","height","viewBox","fill","path","fillRule","clipRule","d","href","isInteractive","useContext","selected","click","window","data-index","data-selected","onMouseMove","undefined","onMouseLeave","span","children","data-has-issues"],"mappings":";;;;;;;;;;;;;;;IAkeaA,0BAA0B;eAA1BA;;IAxcGC,iBAAiB;eAAjBA;;;;;uBAvBuD;uBACjD;0BACG;4BACQ;oCACC;kCACD;+BACH;2BACJ;mEACL;iCACW;uBAMzB;6BAIA;AAIA,SAASA,kBAAkB,KAejC;IAfiC,IAAA,EAChCC,KAAK,EACLC,UAAU,EACVC,YAAY,EACZC,qBAAqB,EACrB,GAAGC,OAUJ,GAfiC;IAgBhC,MAAM,CAACC,4BAA4BC,8BA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aAAajH,kBAAkBsB,OAAO;gBACnErB,iBAAiBqB;YACnB;QACF;QACA4F,cAAc,IAAMjH,iBAAiB,CAAC;QACtCgF,WAAW,CAAC9C;YACV,IAAIA,EAAEE,GAAG,KAAK,WAAWF,EAAEE,GAAG,KAAK,KAAK;gBACtCuE;YACF;QACF;QACAhC,MAAM6B,gBAAgB,aAAaQ;QACnClC,UAAU4B,WAAW,IAAI,CAAC;QACzB,GAAGjJ,KAAK;;0BAET,qBAACyJ;gBAAKnC,WAAU;0BAA6BO;;0BAC7C,qBAAC4B;gBAAKnC,WAAU;0BAA6BI;;;;AAGnD;AAEA,SAASI,WAAW,KAAkC;IAAlC,IAAA,EAAE4B,QAAQ,EAAwB,GAAlC;IAClB,qBACE,sBAACD;QACCnC,WAAU;QACVqC,mBAAiBD,WAAW;;0BAE5B,qBAACD;gBAAKnC,WAAU;;YACfoC;;;AAGP;AAIO,MAAMhK,6BAA8B","ignoreList":[0]}
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/client/components/react-dev-overlay/ui/components/errors/dev-tools-indicator/dev-tools-indicator.tsx"],"sourcesContent":["import type { CSSProperties, Dispatch, SetStateAction } from 'react'\nimport { STORAGE_KEY_POSITION, type OverlayState } from '../../../../shared'\n\nimport { useState, useEffect, useRef, createContext, useContext } from 'react'\nimport { Toast } from '../../toast'\nimport { NextLogo } from './next-logo'\nimport { useIsDevBuilding } from '../../../../../../dev/dev-build-indicator/internal/initialize'\nimport { useIsDevRendering } from '../../../../utils/dev-indicator/dev-render-indicator'\nimport { useDelayedRender } from '../../../hooks/use-delayed-render'\nimport { TurbopackInfo } from './dev-tools-info/turbopack-info'\nimport { RouteInfo } from './dev-tools-info/route-info'\nimport GearIcon from '../../../icons/gear-icon'\nimport { UserPreferences } from './dev-tools-info/user-preferences'\nimport {\n MENU_CURVE,\n MENU_DURATION_MS,\n useClickOutside,\n useFocusTrap,\n} from './utils'\nimport {\n getInitialPosition,\n type DevToolsScale,\n} from './dev-tools-info/preferences'\nimport { Draggable } from './draggable'\n\n// TODO: add E2E tests to cover different scenarios\n\nexport function DevToolsIndicator({\n state,\n errorCount,\n isBuildError,\n setIsErrorOverlayOpen,\n ...props\n}: {\n state: OverlayState\n errorCount: number\n isBuildError: boolean\n setIsErrorOverlayOpen: (\n isErrorOverlayOpen: boolean | ((prev: boolean) => boolean)\n ) => void\n scale: DevToolsScale\n setScale: (value: DevToolsScale) => void\n}) {\n const [isDevToolsIndicatorVisible, setIsDevToolsIndicatorVisible] =\n useState(true)\n\n return (\n <DevToolsPopover\n routerType={state.routerType}\n semver={state.versionInfo.installed}\n issueCount={errorCount}\n isStaticRoute={state.staticIndicator}\n hide={() => {\n setIsDevToolsIndicatorVisible(false)\n fetch('/__nextjs_disable_dev_indicator', {\n method: 'POST',\n })\n }}\n setIsErrorOverlayOpen={setIsErrorOverlayOpen}\n isTurbopack={!!process.env.TURBOPACK}\n disabled={state.disableDevIndicator || !isDevToolsIndicatorVisible}\n isBuildError={isBuildError}\n {...props}\n />\n )\n}\n\n//////////////////////////////////////////////////////////////////////////////////////\n\ninterface C {\n closeMenu: () => void\n selectedIndex: number\n setSelectedIndex: Dispatch<SetStateAction<number>>\n}\n\nconst Context = createContext({} as C)\n\nconst OVERLAYS = {\n Root: 'root',\n Turbo: 'turbo',\n Route: 'route',\n Preferences: 'preferences',\n} as const\n\nexport type Overlays = (typeof OVERLAYS)[keyof typeof OVERLAYS]\n\nconst INDICATOR_PADDING = 20\n\nfunction DevToolsPopover({\n routerType,\n disabled,\n issueCount,\n isStaticRoute,\n isTurbopack,\n isBuildError,\n hide,\n setIsErrorOverlayOpen,\n scale,\n setScale,\n}: {\n routerType: 'pages' | 'app'\n disabled: boolean\n issueCount: number\n isStaticRoute: boolean\n semver: string | undefined\n isTurbopack: boolean\n isBuildError: boolean\n hide: () => void\n setIsErrorOverlayOpen: (\n isOverlayOpen: boolean | ((prev: boolean) => boolean)\n ) => void\n scale: DevToolsScale\n setScale: (value: DevToolsScale) => void\n}) {\n const menuRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n\n const [open, setOpen] = useState<Overlays | null>(null)\n const [position, setPosition] = useState(getInitialPosition())\n const [selectedIndex, setSelectedIndex] = useState(-1)\n\n const isMenuOpen = open === OVERLAYS.Root\n const isTurbopackInfoOpen = open === OVERLAYS.Turbo\n const isRouteInfoOpen = open === OVERLAYS.Route\n const isPreferencesOpen = open === OVERLAYS.Preferences\n\n const { mounted: menuMounted, rendered: menuRendered } = useDelayedRender(\n isMenuOpen,\n {\n // Intentionally no fade in, makes the UI feel more immediate\n enterDelay: 0,\n // Graceful fade out to confirm that the UI did not break\n exitDelay: MENU_DURATION_MS,\n }\n )\n\n // Features to make the menu accessible\n useFocusTrap(menuRef, triggerRef, isMenuOpen)\n useClickOutside(menuRef, triggerRef, isMenuOpen, closeMenu)\n\n useEffect(() => {\n if (open === null) {\n // Avoid flashing selected state\n const id = setTimeout(() => {\n setSelectedIndex(-1)\n }, MENU_DURATION_MS)\n return () => clearTimeout(id)\n }\n }, [open])\n\n function select(index: number | 'first' | 'last') {\n if (index === 'first') {\n setTimeout(() => {\n const all = menuRef.current?.querySelectorAll('[role=\"menuitem\"]')\n if (all) {\n const firstIndex = all[0].getAttribute('data-index')\n select(Number(firstIndex))\n }\n })\n return\n }\n\n if (index === 'last') {\n setTimeout(() => {\n const all = menuRef.current?.querySelectorAll('[role=\"menuitem\"]')\n if (all) {\n const lastIndex = all.length - 1\n select(lastIndex)\n }\n })\n return\n }\n\n const el = menuRef.current?.querySelector(\n `[data-index=\"${index}\"]`\n ) as HTMLElement\n\n if (el) {\n setSelectedIndex(index)\n el?.focus()\n }\n }\n\n function onMenuKeydown(e: React.KeyboardEvent<HTMLDivElement>) {\n e.preventDefault()\n\n switch (e.key) {\n case 'ArrowDown':\n const next = selectedIndex + 1\n select(next)\n break\n case 'ArrowUp':\n const prev = selectedIndex - 1\n select(prev)\n break\n case 'Home':\n select('first')\n break\n case 'End':\n select('last')\n break\n default:\n break\n }\n }\n\n function openErrorOverlay() {\n setOpen(null)\n if (issueCount > 0) {\n setIsErrorOverlayOpen(true)\n }\n }\n\n function toggleErrorOverlay() {\n setIsErrorOverlayOpen((prev) => !prev)\n }\n\n function openRootMenu() {\n setOpen((prevOpen) => {\n if (prevOpen === null) select('first')\n return OVERLAYS.Root\n })\n }\n\n function onTriggerClick() {\n if (open === OVERLAYS.Root) {\n setOpen(null)\n } else {\n openRootMenu()\n setTimeout(() => {\n select('first')\n })\n }\n }\n\n function closeMenu() {\n // Only close when we were on `Root`,\n // otherwise it will close other overlays\n setOpen((prevOpen) => {\n if (prevOpen === OVERLAYS.Root) {\n return null\n }\n return prevOpen\n })\n }\n\n function handleHideDevtools() {\n setOpen(null)\n hide()\n }\n\n const [vertical, horizontal] = position.split('-', 2)\n const popover = { [vertical]: 'calc(100% + 8px)', [horizontal]: 0 }\n\n return (\n <Toast\n data-nextjs-toast\n style={\n {\n '--animate-out-duration-ms': `${MENU_DURATION_MS}ms`,\n '--animate-out-timing-function': MENU_CURVE,\n boxShadow: 'none',\n zIndex: 2147483647,\n [vertical]: `${INDICATOR_PADDING}px`,\n [horizontal]: `${INDICATOR_PADDING}px`,\n } as CSSProperties\n }\n >\n <Draggable\n padding={INDICATOR_PADDING}\n onDragStart={() => setOpen(null)}\n position={position}\n setPosition={(p) => {\n localStorage.setItem(STORAGE_KEY_POSITION, p)\n setPosition(p)\n }}\n >\n {/* Trigger */}\n <NextLogo\n ref={triggerRef}\n aria-haspopup=\"menu\"\n aria-expanded={isMenuOpen}\n aria-controls=\"nextjs-dev-tools-menu\"\n aria-label={`${isMenuOpen ? 'Close' : 'Open'} Next.js Dev Tools`}\n data-nextjs-dev-tools-button\n disabled={disabled}\n issueCount={issueCount}\n onTriggerClick={onTriggerClick}\n toggleErrorOverlay={toggleErrorOverlay}\n isDevBuilding={useIsDevBuilding()}\n isDevRendering={useIsDevRendering()}\n isBuildError={isBuildError}\n scale={scale}\n />\n </Draggable>\n\n {/* Route Info */}\n <RouteInfo\n isOpen={isRouteInfoOpen}\n close={openRootMenu}\n triggerRef={triggerRef}\n style={popover}\n routerType={routerType}\n routeType={isStaticRoute ? 'Static' : 'Dynamic'}\n />\n\n {/* Turbopack Info */}\n <TurbopackInfo\n isOpen={isTurbopackInfoOpen}\n close={openRootMenu}\n triggerRef={triggerRef}\n style={popover}\n />\n\n {/* Preferences */}\n <UserPreferences\n isOpen={isPreferencesOpen}\n close={openRootMenu}\n triggerRef={triggerRef}\n style={popover}\n hide={handleHideDevtools}\n setPosition={setPosition}\n position={position}\n scale={scale}\n setScale={setScale}\n />\n\n {/* Dropdown Menu */}\n {menuMounted && (\n <div\n ref={menuRef}\n id=\"nextjs-dev-tools-menu\"\n role=\"menu\"\n dir=\"ltr\"\n aria-orientation=\"vertical\"\n aria-label=\"Next.js Dev Tools Items\"\n tabIndex={-1}\n className=\"dev-tools-indicator-menu\"\n onKeyDown={onMenuKeydown}\n data-rendered={menuRendered}\n style={popover}\n >\n <Context.Provider\n value={{\n closeMenu,\n selectedIndex,\n setSelectedIndex,\n }}\n >\n <div className=\"dev-tools-indicator-inner\">\n {issueCount > 0 && (\n <MenuItem\n title={`${issueCount} ${issueCount === 1 ? 'issue' : 'issues'} found. Click to view details in the dev overlay.`}\n index={0}\n label=\"Issues\"\n value={<IssueCount>{issueCount}</IssueCount>}\n onClick={openErrorOverlay}\n />\n )}\n <MenuItem\n title={`Current route is ${isStaticRoute ? 'static' : 'dynamic'}.`}\n label=\"Route\"\n index={1}\n value={isStaticRoute ? 'Static' : 'Dynamic'}\n onClick={() => setOpen(OVERLAYS.Route)}\n data-nextjs-route-type={isStaticRoute ? 'static' : 'dynamic'}\n />\n {isTurbopack ? (\n <MenuItem\n title=\"Turbopack is enabled.\"\n label=\"Turbopack\"\n value=\"Enabled\"\n />\n ) : (\n <MenuItem\n index={2}\n title=\"Learn about Turbopack and how to enable it in your application.\"\n label=\"Try Turbopack\"\n value={<ChevronRight />}\n onClick={() => setOpen(OVERLAYS.Turbo)}\n />\n )}\n </div>\n\n <div className=\"dev-tools-indicator-footer\">\n <MenuItem\n data-preferences\n label=\"Preferences\"\n value={<GearIcon />}\n onClick={() => setOpen(OVERLAYS.Preferences)}\n index={isTurbopack ? 2 : 3}\n />\n </div>\n </Context.Provider>\n </div>\n )}\n </Toast>\n )\n}\n\nfunction ChevronRight() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n >\n <path\n fill=\"#666\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.50011 1.93945L6.03044 2.46978L10.8537 7.293C11.2442 7.68353 11.2442 8.31669 10.8537 8.70722L6.03044 13.5304L5.50011 14.0608L4.43945 13.0001L4.96978 12.4698L9.43945 8.00011L4.96978 3.53044L4.43945 3.00011L5.50011 1.93945Z\"\n />\n </svg>\n )\n}\n\nfunction MenuItem({\n index,\n label,\n value,\n onClick,\n href,\n ...props\n}: {\n index?: number\n title?: string\n label: string\n value: React.ReactNode\n href?: string\n onClick?: () => void\n}) {\n const isInteractive =\n typeof onClick === 'function' || typeof href === 'string'\n const { closeMenu, selectedIndex, setSelectedIndex } = useContext(Context)\n const selected = selectedIndex === index\n\n function click() {\n if (isInteractive) {\n onClick?.()\n closeMenu()\n if (href) {\n window.open(href, '_blank', 'noopener, noreferrer')\n }\n }\n }\n\n return (\n <div\n className=\"dev-tools-indicator-item\"\n data-index={index}\n data-selected={selected}\n onClick={click}\n // Needs `onMouseMove` instead of enter to work together\n // with keyboard and mouse input\n onMouseMove={() => {\n if (isInteractive && index !== undefined && selectedIndex !== index) {\n setSelectedIndex(index)\n }\n }}\n onMouseLeave={() => setSelectedIndex(-1)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n click()\n }\n }}\n role={isInteractive ? 'menuitem' : undefined}\n tabIndex={selected ? 0 : -1}\n {...props}\n >\n <span className=\"dev-tools-indicator-label\">{label}</span>\n <span className=\"dev-tools-indicator-value\">{value}</span>\n </div>\n )\n}\n\nfunction IssueCount({ children }: { children: number }) {\n return (\n <span\n className=\"dev-tools-indicator-issue-count\"\n data-has-issues={children > 0}\n >\n <span className=\"dev-tools-indicator-issue-count-indicator\" />\n {children}\n </span>\n )\n}\n\n//////////////////////////////////////////////////////////////////////////////////////\n\nexport const DEV_TOOLS_INDICATOR_STYLES = `\n .dev-tools-indicator-menu {\n -webkit-font-smoothing: antialiased;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-menu);\n border-radius: var(--rounded-xl);\n position: absolute;\n font-family: var(--font-stack-sans);\n z-index: 1000;\n overflow: hidden;\n opacity: 0;\n outline: 0;\n min-width: 248px;\n transition: opacity var(--animate-out-duration-ms)\n var(--animate-out-timing-function);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n .dev-tools-indicator-inner {\n padding: 6px;\n width: 100%;\n }\n\n .dev-tools-indicator-item {\n display: flex;\n align-items: center;\n padding: 8px 6px;\n height: var(--size-36);\n border-radius: 6px;\n text-decoration: none !important;\n user-select: none;\n white-space: nowrap;\n\n svg {\n width: var(--size-16);\n height: var(--size-16);\n }\n\n &:focus-visible {\n outline: 0;\n }\n }\n\n .dev-tools-indicator-footer {\n background: var(--color-background-200);\n padding: 6px;\n border-top: 1px solid var(--color-gray-400);\n width: 100%;\n }\n\n .dev-tools-indicator-item[data-selected='true'] {\n cursor: pointer;\n background-color: var(--color-gray-200);\n }\n\n .dev-tools-indicator-label {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-1000);\n }\n\n .dev-tools-indicator-value {\n font-size: var(--size-14);\n line-height: var(--size-20);\n color: var(--color-gray-900);\n margin-left: auto;\n }\n\n .dev-tools-indicator-issue-count {\n --color-primary: var(--color-gray-800);\n --color-secondary: var(--color-gray-100);\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-width: var(--size-40);\n height: var(--size-24);\n background: var(--color-background-100);\n border: 1px solid var(--color-gray-alpha-400);\n background-clip: padding-box;\n box-shadow: var(--shadow-small);\n padding: 2px;\n color: var(--color-gray-1000);\n border-radius: 128px;\n font-weight: 500;\n font-size: var(--size-13);\n font-variant-numeric: tabular-nums;\n\n &[data-has-issues='true'] {\n --color-primary: var(--color-red-800);\n --color-secondary: var(--color-red-100);\n }\n\n .dev-tools-indicator-issue-count-indicator {\n width: var(--size-8);\n height: var(--size-8);\n background: var(--color-primary);\n box-shadow: 0 0 0 2px var(--color-secondary);\n border-radius: 50%;\n }\n }\n\n .dev-tools-indicator-shortcut {\n display: flex;\n gap: 4px;\n\n kbd {\n width: var(--size-20);\n height: var(--size-20);\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--rounded-md);\n border: 1px solid var(--color-gray-400);\n font-family: var(--font-stack-sans);\n background: var(--color-background-100);\n color: var(--color-gray-1000);\n text-align: center;\n font-size: var(--size-12);\n line-height: var(--size-16);\n }\n }\n\n .dev-tools-grabbing {\n cursor: grabbing;\n\n > * {\n pointer-events: none;\n }\n }\n`\n"],"names":["DEV_TOOLS_INDICATOR_STYLES","DevToolsIndicator","state","errorCount","isBuildError","setIsErrorOverlayOpen","props","isDevToolsIndicatorVisible","setIsDevToolsIndicatorVisible","useState","DevToolsPopover","routerType","semver","versionInfo","installed","issueCount","isStaticRoute","staticIndicator","hide","fetch","method","isTurbopack","process","env","TURBOPACK","disabled","disableDevIndicator","Context","createContext","OVERLAYS","Root","Turbo","Route","Preferences","INDICATOR_PADDING","scale","setScale","menuRef","useRef","triggerRef","open","setOpen","position","setPosition","getInitialPosition","selectedIndex","setSelectedIndex","isMenuOpen","isTurbopackInfoOpen","isRouteInfoOpen","isPreferencesOpen","mounted","menuMounted","rendered","menuRendered","useDelayedRender","enterDelay","exitDelay","MENU_DURATION_MS","useFocusTrap","useClickOutside","closeMenu","useEffect","id","setTimeout","clearTimeout","select","index","all","current","querySelectorAll","firstIndex","getAttribute","Number","lastIndex","length","el","querySelector","focus","onMenuKeydown","e","preventDefault","key","next","prev","openErrorOverlay","toggleErrorOverlay","openRootMenu","prevOpen","onTriggerClick","handleHideDevtools","vertical","horizontal","split","popover","Toast","data-nextjs-toast","style","MENU_CURVE","boxShadow","zIndex","Draggable","padding","onDragStart","p","localStorage","setItem","STORAGE_KEY_POSITION","NextLogo","ref","aria-haspopup","aria-expanded","aria-controls","aria-label","data-nextjs-dev-tools-button","isDevBuilding","useIsDevBuilding","isDevRendering","useIsDevRendering","RouteInfo","isOpen","close","routeType","TurbopackInfo","UserPreferences","div","role","dir","aria-orientation","tabIndex","className","onKeyDown","data-rendered","Provider","value","MenuItem","title","label","IssueCount","onClick","data-nextjs-route-type","ChevronRight","data-preferences","GearIcon","svg","xmlns","width","height","viewBox","fill","path","fillRule","clipRule","d","href","isInteractive","useContext","selected","click","window","data-index","data-selected","onMouseMove","undefined","onMouseLeave","span","children","data-has-issues"],"mappings":";;;;;;;;;;;;;;;IA4eaA,0BAA0B;eAA1BA;;IAjdGC,iBAAiB;eAAjBA;;;;;wBA1BwC;uBAEe;uBACjD;0BACG;4BACQ;oCACC;kCACD;+BACH;2BACJ;mEACL;iCACW;uBAMzB;6BAIA;2BACmB;AAInB,SAASA,kBAAkB,KAejC;IAfiC,IAAA,EAChCC,KAAK,EACLC,UAAU,EACVC,YAAY,EACZC,qBAAqB,EACrB,GAAGC,OAUJ,GAfiC;IAgBhC,MAAM,CAACC,4BAA4BC,8BAA8B,GAC/DC,IAAAA,eAAQ,EAAC;IAEX,qBACE,qBAACC;QACCC,YAAYT,MAAMS,UAAU;QAC5BC,QAAQV,MAAMW,WAAW,CAACC,SAAS;QACnCC,YAAYZ;QACZa,eAAed,MAAMe,eAAe;QACpCC,MAAM;YACJV,8BAA8B;YAC9BW,MAAM,mCAAmC;gBACvCC,QAAQ;YACV;QACF;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OAAO;gBACnErB,iBAAiBqB;YACnB;QACF;QACAiG,cAAc,IAAMtH,iBAAiB,CAAC;QACtCqF,WAAW,CAACnD;YACV,IAAIA,EAAEE,GAAG,KAAK,WAAWF,EAAEE,GAAG,KAAK,KAAK;gBACtC4E;YACF;QACF;QACAhC,MAAM6B,gBAAgB,aAAaQ;QACnClC,UAAU4B,WAAW,IAAI,CAAC;QACzB,GAAGvJ,KAAK;;0BAET,qBAAC+J;gBAAKnC,WAAU;0BAA6BO;;0BAC7C,qBAAC4B;gBAAKnC,WAAU;0BAA6BI;;;;AAGnD;AAEA,SAASI,WAAW,KAAkC;IAAlC,IAAA,EAAE4B,QAAQ,EAAwB,GAAlC;IAClB,qBACE,sBAACD;QACCnC,WAAU;QACVqC,mBAAiBD,WAAW;;0BAE5B,qBAACD;gBAAKnC,WAAU;;YACfoC;;;AAGP;AAIO,MAAMtK,6BAA8B","ignoreList":[0]}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
interface Point {
|
2
|
+
x: number;
|
3
|
+
y: number;
|
4
|
+
}
|
5
|
+
type Corners = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
6
|
+
interface Corner {
|
7
|
+
corner: Corners;
|
8
|
+
translation: Point;
|
9
|
+
}
|
10
|
+
export declare function Draggable({ children, padding, position: currentCorner, setPosition: setCurrentCorner, onDragStart, }: {
|
11
|
+
children: React.ReactElement;
|
12
|
+
position: Corners;
|
13
|
+
padding: number;
|
14
|
+
setPosition: (position: Corners) => void;
|
15
|
+
onDragStart?: () => void;
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
17
|
+
interface UseDragOptions {
|
18
|
+
onDragStart?: () => void;
|
19
|
+
onDrag?: (translation: Point) => void;
|
20
|
+
onDragEnd?: (translation: Point, velocity: Point) => void;
|
21
|
+
onAnimationEnd?: (corner: Corner) => void;
|
22
|
+
threshold: number;
|
23
|
+
}
|
24
|
+
export declare function useDrag(options: UseDragOptions): {
|
25
|
+
ref: import("react").RefObject<HTMLDivElement | null>;
|
26
|
+
onPointerDown: (e: React.PointerEvent) => void;
|
27
|
+
animate: (corner: Corner) => void;
|
28
|
+
};
|
29
|
+
export {};
|
@@ -0,0 +1,271 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
0 && (module.exports = {
|
6
|
+
Draggable: null,
|
7
|
+
useDrag: null
|
8
|
+
});
|
9
|
+
function _export(target, all) {
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
11
|
+
enumerable: true,
|
12
|
+
get: all[name]
|
13
|
+
});
|
14
|
+
}
|
15
|
+
_export(exports, {
|
16
|
+
Draggable: function() {
|
17
|
+
return Draggable;
|
18
|
+
},
|
19
|
+
useDrag: function() {
|
20
|
+
return useDrag;
|
21
|
+
}
|
22
|
+
});
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
24
|
+
const _react = require("react");
|
25
|
+
function Draggable(param) {
|
26
|
+
let { children, padding, position: currentCorner, setPosition: setCurrentCorner, onDragStart } = param;
|
27
|
+
const { ref, animate, ...drag } = useDrag({
|
28
|
+
threshold: 5,
|
29
|
+
onDragStart,
|
30
|
+
onDragEnd,
|
31
|
+
onAnimationEnd
|
32
|
+
});
|
33
|
+
function onDragEnd(translation, velocity) {
|
34
|
+
const projectedPosition = {
|
35
|
+
x: translation.x + project(velocity.x),
|
36
|
+
y: translation.y + project(velocity.y)
|
37
|
+
};
|
38
|
+
const nearestCorner = getNearestCorner(projectedPosition);
|
39
|
+
animate(nearestCorner);
|
40
|
+
}
|
41
|
+
function onAnimationEnd(param) {
|
42
|
+
let { corner } = param;
|
43
|
+
// Unset drag translation
|
44
|
+
setTimeout(()=>{
|
45
|
+
var _ref_current;
|
46
|
+
(_ref_current = ref.current) == null ? void 0 : _ref_current.style.removeProperty('translate');
|
47
|
+
setCurrentCorner(corner);
|
48
|
+
});
|
49
|
+
}
|
50
|
+
function getNearestCorner(param) {
|
51
|
+
let { x, y } = param;
|
52
|
+
const allCorners = getCorners();
|
53
|
+
const distances = Object.entries(allCorners).map((param)=>{
|
54
|
+
let [key, translation] = param;
|
55
|
+
const distance = Math.sqrt((x - translation.x) ** 2 + (y - translation.y) ** 2);
|
56
|
+
return {
|
57
|
+
key,
|
58
|
+
distance
|
59
|
+
};
|
60
|
+
});
|
61
|
+
const min = Math.min(...distances.map((d)=>d.distance));
|
62
|
+
const nearest = distances.find((d)=>d.distance === min);
|
63
|
+
if (!nearest) {
|
64
|
+
// Safety fallback
|
65
|
+
return {
|
66
|
+
corner: currentCorner,
|
67
|
+
translation: allCorners[currentCorner]
|
68
|
+
};
|
69
|
+
}
|
70
|
+
return {
|
71
|
+
translation: allCorners[nearest.key],
|
72
|
+
corner: nearest.key
|
73
|
+
};
|
74
|
+
}
|
75
|
+
function getCorners() {
|
76
|
+
var _ref_current, _ref_current1;
|
77
|
+
const offset = padding * 2;
|
78
|
+
const triggerWidth = ((_ref_current = ref.current) == null ? void 0 : _ref_current.offsetWidth) || 0;
|
79
|
+
const triggerHeight = ((_ref_current1 = ref.current) == null ? void 0 : _ref_current1.offsetHeight) || 0;
|
80
|
+
function getAbsolutePosition(corner) {
|
81
|
+
const isRight = corner.includes('right');
|
82
|
+
const isBottom = corner.includes('bottom');
|
83
|
+
return {
|
84
|
+
x: isRight ? window.innerWidth - offset - triggerWidth : 0,
|
85
|
+
y: isBottom ? window.innerHeight - offset - triggerHeight : 0
|
86
|
+
};
|
87
|
+
}
|
88
|
+
const basePosition = getAbsolutePosition(currentCorner);
|
89
|
+
// Calculate all corner positions relative to the current corner
|
90
|
+
return {
|
91
|
+
'top-left': {
|
92
|
+
x: 0 - basePosition.x,
|
93
|
+
y: 0 - basePosition.y
|
94
|
+
},
|
95
|
+
'top-right': {
|
96
|
+
x: window.innerWidth - offset - triggerWidth - basePosition.x,
|
97
|
+
y: 0 - basePosition.y
|
98
|
+
},
|
99
|
+
'bottom-left': {
|
100
|
+
x: 0 - basePosition.x,
|
101
|
+
y: window.innerHeight - offset - triggerHeight - basePosition.y
|
102
|
+
},
|
103
|
+
'bottom-right': {
|
104
|
+
x: window.innerWidth - offset - triggerWidth - basePosition.x,
|
105
|
+
y: window.innerHeight - offset - triggerHeight - basePosition.y
|
106
|
+
}
|
107
|
+
};
|
108
|
+
}
|
109
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
110
|
+
ref: ref,
|
111
|
+
...drag,
|
112
|
+
style: {
|
113
|
+
touchAction: 'none'
|
114
|
+
},
|
115
|
+
children: children
|
116
|
+
});
|
117
|
+
}
|
118
|
+
function useDrag(options) {
|
119
|
+
const ref = (0, _react.useRef)(null);
|
120
|
+
const state = (0, _react.useRef)('idle');
|
121
|
+
const origin = (0, _react.useRef)({
|
122
|
+
x: 0,
|
123
|
+
y: 0
|
124
|
+
});
|
125
|
+
const translation = (0, _react.useRef)({
|
126
|
+
x: 0,
|
127
|
+
y: 0
|
128
|
+
});
|
129
|
+
const lastTimestamp = (0, _react.useRef)(0);
|
130
|
+
const velocities = (0, _react.useRef)([]);
|
131
|
+
function set(position) {
|
132
|
+
if (ref.current) {
|
133
|
+
translation.current = position;
|
134
|
+
ref.current.style.translate = position.x + "px " + position.y + "px";
|
135
|
+
}
|
136
|
+
}
|
137
|
+
function animate(corner) {
|
138
|
+
const el = ref.current;
|
139
|
+
if (el === null) return;
|
140
|
+
function listener(e) {
|
141
|
+
if (e.propertyName === 'translate') {
|
142
|
+
options.onAnimationEnd == null ? void 0 : options.onAnimationEnd.call(options, corner);
|
143
|
+
translation.current = {
|
144
|
+
x: 0,
|
145
|
+
y: 0
|
146
|
+
};
|
147
|
+
el.style.transition = '';
|
148
|
+
el.removeEventListener('transitionend', listener);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
// Generated from https://www.easing.dev/spring
|
152
|
+
el.style.transition = 'translate 491.22ms var(--timing-bounce)';
|
153
|
+
el.addEventListener('transitionend', listener);
|
154
|
+
set(corner.translation);
|
155
|
+
}
|
156
|
+
function onClick(e) {
|
157
|
+
if (state.current === 'drag-end') {
|
158
|
+
var _ref_current;
|
159
|
+
e.preventDefault();
|
160
|
+
e.stopPropagation();
|
161
|
+
state.current = 'idle';
|
162
|
+
(_ref_current = ref.current) == null ? void 0 : _ref_current.removeEventListener('click', onClick);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
function onPointerDown(e) {
|
166
|
+
var _ref_current;
|
167
|
+
origin.current = {
|
168
|
+
x: e.clientX,
|
169
|
+
y: e.clientY
|
170
|
+
};
|
171
|
+
state.current = 'press';
|
172
|
+
window.addEventListener('pointermove', onPointerMove);
|
173
|
+
window.addEventListener('pointerup', onPointerUp);
|
174
|
+
(_ref_current = ref.current) == null ? void 0 : _ref_current.addEventListener('click', onClick);
|
175
|
+
}
|
176
|
+
function onPointerMove(e) {
|
177
|
+
if (state.current === 'press') {
|
178
|
+
const dx = e.clientX - origin.current.x;
|
179
|
+
const dy = e.clientY - origin.current.y;
|
180
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
181
|
+
if (distance >= options.threshold) {
|
182
|
+
var _ref_current, _ref_current1;
|
183
|
+
state.current = 'drag';
|
184
|
+
(_ref_current = ref.current) == null ? void 0 : _ref_current.setPointerCapture(e.pointerId);
|
185
|
+
(_ref_current1 = ref.current) == null ? void 0 : _ref_current1.classList.add('dev-tools-grabbing');
|
186
|
+
options.onDragStart == null ? void 0 : options.onDragStart.call(options);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
if (state.current !== 'drag') return;
|
190
|
+
const currentPosition = {
|
191
|
+
x: e.clientX,
|
192
|
+
y: e.clientY
|
193
|
+
};
|
194
|
+
const dx = currentPosition.x - origin.current.x;
|
195
|
+
const dy = currentPosition.y - origin.current.y;
|
196
|
+
origin.current = currentPosition;
|
197
|
+
const newTranslation = {
|
198
|
+
x: translation.current.x + dx,
|
199
|
+
y: translation.current.y + dy
|
200
|
+
};
|
201
|
+
set(newTranslation);
|
202
|
+
// Keep a history of recent positions for velocity calculation
|
203
|
+
// Only store points that are at least 10ms apart to avoid too many samples
|
204
|
+
const now = Date.now();
|
205
|
+
const shouldAddToHistory = now - lastTimestamp.current >= 10;
|
206
|
+
if (shouldAddToHistory) {
|
207
|
+
velocities.current = [
|
208
|
+
...velocities.current.slice(-5),
|
209
|
+
{
|
210
|
+
position: currentPosition,
|
211
|
+
timestamp: now
|
212
|
+
}
|
213
|
+
];
|
214
|
+
}
|
215
|
+
lastTimestamp.current = now;
|
216
|
+
options.onDrag == null ? void 0 : options.onDrag.call(options, translation.current);
|
217
|
+
}
|
218
|
+
function onPointerUp(e) {
|
219
|
+
var _ref_current, _ref_current1;
|
220
|
+
state.current = state.current === 'drag' ? 'drag-end' : 'idle';
|
221
|
+
window.removeEventListener('pointermove', onPointerMove);
|
222
|
+
window.removeEventListener('pointerup', onPointerUp);
|
223
|
+
const velocity = calculateVelocity(velocities.current);
|
224
|
+
velocities.current = [];
|
225
|
+
(_ref_current = ref.current) == null ? void 0 : _ref_current.classList.remove('dev-tools-grabbing');
|
226
|
+
(_ref_current1 = ref.current) == null ? void 0 : _ref_current1.releasePointerCapture(e.pointerId);
|
227
|
+
options.onDragEnd == null ? void 0 : options.onDragEnd.call(options, translation.current, velocity);
|
228
|
+
}
|
229
|
+
return {
|
230
|
+
ref,
|
231
|
+
onPointerDown,
|
232
|
+
animate
|
233
|
+
};
|
234
|
+
}
|
235
|
+
function calculateVelocity(history) {
|
236
|
+
if (history.length < 2) {
|
237
|
+
return {
|
238
|
+
x: 0,
|
239
|
+
y: 0
|
240
|
+
};
|
241
|
+
}
|
242
|
+
const oldestPoint = history[0];
|
243
|
+
const latestPoint = history[history.length - 1];
|
244
|
+
const timeDelta = latestPoint.timestamp - oldestPoint.timestamp;
|
245
|
+
if (timeDelta === 0) {
|
246
|
+
return {
|
247
|
+
x: 0,
|
248
|
+
y: 0
|
249
|
+
};
|
250
|
+
}
|
251
|
+
// Calculate pixels per millisecond
|
252
|
+
const velocityX = (latestPoint.position.x - oldestPoint.position.x) / timeDelta;
|
253
|
+
const velocityY = (latestPoint.position.y - oldestPoint.position.y) / timeDelta;
|
254
|
+
// Convert to pixels per second for more intuitive values
|
255
|
+
return {
|
256
|
+
x: velocityX * 1000,
|
257
|
+
y: velocityY * 1000
|
258
|
+
};
|
259
|
+
}
|
260
|
+
function project(initialVelocity, decelerationRate) {
|
261
|
+
if (decelerationRate === void 0) decelerationRate = 0.999;
|
262
|
+
return initialVelocity / 1000 * decelerationRate / (1 - decelerationRate);
|
263
|
+
}
|
264
|
+
|
265
|
+
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
266
|
+
Object.defineProperty(exports.default, '__esModule', { value: true });
|
267
|
+
Object.assign(exports.default, exports);
|
268
|
+
module.exports = exports.default;
|
269
|
+
}
|
270
|
+
|
271
|
+
//# sourceMappingURL=draggable.js.map
|