@tanstack/react-router-devtools 0.0.1-beta.2 → 0.0.1-beta.29
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/build/cjs/{packages/react-router-devtools/src/Explorer.js → Explorer.js} +7 -18
- package/build/cjs/Explorer.js.map +1 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -5
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/{packages/react-router-devtools/src/devtools.js → devtools.js} +46 -66
- package/build/cjs/devtools.js.map +1 -0
- package/build/cjs/{packages/react-router-devtools/src/index.js → index.js} +0 -0
- package/build/cjs/{packages/react-router-devtools/src/index.js.map → index.js.map} +0 -0
- package/build/cjs/{packages/react-router-devtools/src/styledComponents.js → styledComponents.js} +7 -3
- package/build/cjs/styledComponents.js.map +1 -0
- package/build/cjs/{packages/react-router-devtools/src/theme.js → theme.js} +4 -5
- package/build/cjs/theme.js.map +1 -0
- package/build/cjs/{packages/react-router-devtools/src/useLocalStorage.js → useLocalStorage.js} +0 -7
- package/build/cjs/useLocalStorage.js.map +1 -0
- package/build/cjs/{packages/react-router-devtools/src/useMediaQuery.js → useMediaQuery.js} +8 -8
- package/build/cjs/useMediaQuery.js.map +1 -0
- package/build/cjs/{packages/react-router-devtools/src/utils.js → utils.js} +11 -19
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +79 -960
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +3009 -3003
- package/build/types/index.d.ts +3 -3
- package/build/umd/index.development.js +85 -132
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +4 -3
- package/src/devtools.tsx +28 -13
- package/src/utils.ts +1 -3
- package/build/cjs/node_modules/date-fns/esm/_lib/assign/index.js +0 -30
- package/build/cjs/node_modules/date-fns/esm/_lib/assign/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/_lib/cloneObject/index.js +0 -22
- package/build/cjs/node_modules/date-fns/esm/_lib/cloneObject/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/_lib/defaultLocale/index.js +0 -20
- package/build/cjs/node_modules/date-fns/esm/_lib/defaultLocale/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/_lib/defaultOptions/index.js +0 -21
- package/build/cjs/node_modules/date-fns/esm/_lib/defaultOptions/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js +0 -33
- package/build/cjs/node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/_lib/requiredArgs/index.js +0 -22
- package/build/cjs/node_modules/date-fns/esm/_lib/requiredArgs/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/compareAsc/index.js +0 -67
- package/build/cjs/node_modules/date-fns/esm/compareAsc/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/formatDistanceStrict/index.js +0 -207
- package/build/cjs/node_modules/date-fns/esm/formatDistanceStrict/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/_lib/buildFormatLongFn/index.js +0 -26
- package/build/cjs/node_modules/date-fns/esm/locale/_lib/buildFormatLongFn/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/_lib/buildLocalizeFn/index.js +0 -39
- package/build/cjs/node_modules/date-fns/esm/locale/_lib/buildLocalizeFn/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/_lib/buildMatchFn/index.js +0 -65
- package/build/cjs/node_modules/date-fns/esm/locale/_lib/buildMatchFn/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/_lib/buildMatchPatternFn/index.js +0 -34
- package/build/cjs/node_modules/date-fns/esm/locale/_lib/buildMatchPatternFn/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/formatDistance/index.js +0 -105
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/formatDistance/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/formatLong/index.js +0 -52
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/formatLong/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/formatRelative/index.js +0 -31
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/formatRelative/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/localize/index.js +0 -164
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/localize/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/match/index.js +0 -116
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/_lib/match/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/index.js +0 -47
- package/build/cjs/node_modules/date-fns/esm/locale/en-US/index.js.map +0 -1
- package/build/cjs/node_modules/date-fns/esm/toDate/index.js +0 -70
- package/build/cjs/node_modules/date-fns/esm/toDate/index.js.map +0 -1
- package/build/cjs/packages/react-router-devtools/src/Explorer.js.map +0 -1
- package/build/cjs/packages/react-router-devtools/src/devtools.js.map +0 -1
- package/build/cjs/packages/react-router-devtools/src/styledComponents.js.map +0 -1
- package/build/cjs/packages/react-router-devtools/src/theme.js.map +0 -1
- package/build/cjs/packages/react-router-devtools/src/useLocalStorage.js.map +0 -1
- package/build/cjs/packages/react-router-devtools/src/useMediaQuery.js.map +0 -1
- package/build/cjs/packages/react-router-devtools/src/utils.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router-devtools",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.29",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router/",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
25
25
|
},
|
|
26
26
|
"module": "build/esm/index.js",
|
|
27
|
-
"main": "build/cjs/
|
|
27
|
+
"main": "build/cjs/index.js",
|
|
28
28
|
"browser": "build/umd/index.production.js",
|
|
29
29
|
"types": "build/types/index.d.ts",
|
|
30
30
|
"engines": {
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"build/**",
|
|
35
35
|
"src"
|
|
36
36
|
],
|
|
37
|
+
"sideEffects": false,
|
|
37
38
|
"peerDependencies": {
|
|
38
|
-
"@tanstack/react-router": "0.0.1-beta.
|
|
39
|
+
"@tanstack/react-router": "0.0.1-beta.29",
|
|
39
40
|
"react": ">=16",
|
|
40
41
|
"react-dom": ">=16"
|
|
41
42
|
},
|
package/src/devtools.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { Router, last } from '@tanstack/react-router'
|
|
2
|
+
import { Router, last, routerContext, invariant } from '@tanstack/react-router'
|
|
3
3
|
import { formatDistanceStrict } from 'date-fns'
|
|
4
4
|
|
|
5
5
|
import useLocalStorage from './useLocalStorage'
|
|
@@ -56,7 +56,7 @@ interface DevtoolsOptions {
|
|
|
56
56
|
/**
|
|
57
57
|
* A boolean variable indicating if the "lite" version of the library is being used
|
|
58
58
|
*/
|
|
59
|
-
router
|
|
59
|
+
router?: Router<any, any, any>
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
interface DevtoolsPanelOptions {
|
|
@@ -83,7 +83,7 @@ interface DevtoolsPanelOptions {
|
|
|
83
83
|
/**
|
|
84
84
|
* A boolean variable indicating if the "lite" version of the library is being used
|
|
85
85
|
*/
|
|
86
|
-
router
|
|
86
|
+
router?: Router<any, any, any>
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const isServer = typeof window === 'undefined'
|
|
@@ -97,8 +97,8 @@ function Logo(props: React.HTMLProps<HTMLDivElement>) {
|
|
|
97
97
|
display: 'flex',
|
|
98
98
|
alignItems: 'center',
|
|
99
99
|
flexDirection: 'column',
|
|
100
|
-
fontSize: '0.
|
|
101
|
-
fontWeight: '
|
|
100
|
+
fontSize: '0.8rem',
|
|
101
|
+
fontWeight: 'bolder',
|
|
102
102
|
lineHeight: '1',
|
|
103
103
|
}}
|
|
104
104
|
>
|
|
@@ -110,8 +110,16 @@ function Logo(props: React.HTMLProps<HTMLDivElement>) {
|
|
|
110
110
|
TANSTACK
|
|
111
111
|
</div>
|
|
112
112
|
<div
|
|
113
|
-
className="text-transparent bg-clip-text bg-gradient-to-r from-lime-500 to-emerald-500"
|
|
114
113
|
style={{
|
|
114
|
+
backgroundImage:
|
|
115
|
+
'linear-gradient(to right, var(--tw-gradient-stops))',
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
'--tw-gradient-from': '#84cc16',
|
|
118
|
+
'--tw-gradient-stops':
|
|
119
|
+
'var(--tw-gradient-from), var(--tw-gradient-to)',
|
|
120
|
+
'--tw-gradient-to': '#10b981',
|
|
121
|
+
WebkitBackgroundClip: 'text',
|
|
122
|
+
color: 'transparent',
|
|
115
123
|
letterSpacing: '0.1rem',
|
|
116
124
|
marginRight: '-0.2rem',
|
|
117
125
|
}}
|
|
@@ -398,10 +406,18 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
398
406
|
isOpen = true,
|
|
399
407
|
setIsOpen,
|
|
400
408
|
handleDragStart,
|
|
401
|
-
router,
|
|
409
|
+
router: userRouter,
|
|
402
410
|
...panelProps
|
|
403
411
|
} = props
|
|
404
412
|
|
|
413
|
+
const routerContextValue = React.useContext(routerContext)
|
|
414
|
+
const router = userRouter ?? routerContextValue?.router
|
|
415
|
+
|
|
416
|
+
invariant(
|
|
417
|
+
router,
|
|
418
|
+
'No router was found for the TanStack Router Devtools. Please place the devtools in the <RouterProvider> component tree or pass the router instance to the devtools manually.',
|
|
419
|
+
)
|
|
420
|
+
|
|
405
421
|
const rerender = React.useReducer(() => ({}), {})[1]
|
|
406
422
|
|
|
407
423
|
React.useEffect(() => {
|
|
@@ -447,7 +463,6 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
447
463
|
|
|
448
464
|
return (
|
|
449
465
|
<ThemeProvider theme={theme}>
|
|
450
|
-
<script src="https://cdn.tailwindcss.com"></script>
|
|
451
466
|
<Panel ref={ref} className="TanStackRouterDevtoolsPanel" {...panelProps}>
|
|
452
467
|
<style
|
|
453
468
|
dangerouslySetInnerHTML={{
|
|
@@ -521,8 +536,12 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
521
536
|
}}
|
|
522
537
|
>
|
|
523
538
|
<div
|
|
524
|
-
className="flex justify-start gap-2 p-2 items-center"
|
|
525
539
|
style={{
|
|
540
|
+
display: 'flex',
|
|
541
|
+
justifyContent: 'start',
|
|
542
|
+
gap: '1rem',
|
|
543
|
+
padding: '1rem',
|
|
544
|
+
alignItems: 'center',
|
|
526
545
|
background: theme.backgroundAlt,
|
|
527
546
|
}}
|
|
528
547
|
>
|
|
@@ -818,10 +837,6 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
818
837
|
<td style={{ opacity: '.5' }}>Status</td>
|
|
819
838
|
<td>{activeMatch.status}</td>
|
|
820
839
|
</tr>
|
|
821
|
-
<tr>
|
|
822
|
-
<td style={{ opacity: '.5' }}>Pending</td>
|
|
823
|
-
<td>{activeMatch.isPending.toString()}</td>
|
|
824
|
-
</tr>
|
|
825
840
|
<tr>
|
|
826
841
|
<td style={{ opacity: '.5' }}>Invalid</td>
|
|
827
842
|
<td>{activeMatch.isInvalid.toString()}</td>
|
package/src/utils.ts
CHANGED
|
@@ -26,9 +26,7 @@ type StyledComponent<T> = T extends 'button'
|
|
|
26
26
|
: never
|
|
27
27
|
|
|
28
28
|
export function getStatusColor(match: RouteMatch, theme: Theme) {
|
|
29
|
-
return match.
|
|
30
|
-
? theme.warning
|
|
31
|
-
: match.isFetching
|
|
29
|
+
return match.isFetching
|
|
32
30
|
? theme.active
|
|
33
31
|
: match.status === 'error'
|
|
34
32
|
? theme.danger
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router-devtools
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function assign(target, object) {
|
|
16
|
-
if (target == null) {
|
|
17
|
-
throw new TypeError('assign requires that input parameter not be null or undefined');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for (var property in object) {
|
|
21
|
-
if (Object.prototype.hasOwnProperty.call(object, property)) {
|
|
22
|
-
target[property] = object[property];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return target;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exports["default"] = assign;
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../../node_modules/date-fns/esm/_lib/assign/index.js"],"sourcesContent":["export default function assign(target, object) {\n if (target == null) {\n throw new TypeError('assign requires that input parameter not be null or undefined');\n }\n\n for (var property in object) {\n if (Object.prototype.hasOwnProperty.call(object, property)) {\n ;\n target[property] = object[property];\n }\n }\n\n return target;\n}"],"names":[],"mappings":";;;;;;;;;;;;;;AAAe,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE;AAC/C,EAAE,IAAI,MAAM,IAAI,IAAI,EAAE;AACtB,IAAI,MAAM,IAAI,SAAS,CAAC,+DAA+D,CAAC,CAAC;AACzF,GAAG;AACH;AACA,EAAE,KAAK,IAAI,QAAQ,IAAI,MAAM,EAAE;AAC/B,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE;AAEhE,MAAM,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1C,KAAK;AACL,GAAG;AACH;AACA,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router-devtools
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var index = require('../assign/index.js');
|
|
16
|
-
|
|
17
|
-
function cloneObject(object) {
|
|
18
|
-
return index["default"]({}, object);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports["default"] = cloneObject;
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../../node_modules/date-fns/esm/_lib/cloneObject/index.js"],"sourcesContent":["import assign from \"../assign/index.js\";\nexport default function cloneObject(object) {\n return assign({}, object);\n}"],"names":["assign"],"mappings":";;;;;;;;;;;;;;;;AACe,SAAS,WAAW,CAAC,MAAM,EAAE;AAC5C,EAAE,OAAOA,gBAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAC5B;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router-devtools
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var index = require('../../locale/en-US/index.js');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports["default"] = index["default"];
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router-devtools
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var defaultOptions = {};
|
|
16
|
-
function getDefaultOptions() {
|
|
17
|
-
return defaultOptions;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.getDefaultOptions = getDefaultOptions;
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../../node_modules/date-fns/esm/_lib/defaultOptions/index.js"],"sourcesContent":["var defaultOptions = {};\nexport function getDefaultOptions() {\n return defaultOptions;\n}\nexport function setDefaultOptions(newOptions) {\n defaultOptions = newOptions;\n}"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,IAAI,cAAc,GAAG,EAAE,CAAC;AACjB,SAAS,iBAAiB,GAAG;AACpC,EAAE,OAAO,cAAc,CAAC;AACxB;;;;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router-devtools
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
|
|
17
|
-
* They usually appear for dates that denote time before the timezones were introduced
|
|
18
|
-
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
|
|
19
|
-
* and GMT+01:00:00 after that date)
|
|
20
|
-
*
|
|
21
|
-
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
|
|
22
|
-
* which would lead to incorrect calculations.
|
|
23
|
-
*
|
|
24
|
-
* This function returns the timezone offset in milliseconds that takes seconds in account.
|
|
25
|
-
*/
|
|
26
|
-
function getTimezoneOffsetInMilliseconds(date) {
|
|
27
|
-
var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
|
|
28
|
-
utcDate.setUTCFullYear(date.getFullYear());
|
|
29
|
-
return date.getTime() - utcDate.getTime();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports["default"] = getTimezoneOffsetInMilliseconds;
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
package/build/cjs/node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../../node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js"],"sourcesContent":["/**\n * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.\n * They usually appear for dates that denote time before the timezones were introduced\n * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891\n * and GMT+01:00:00 after that date)\n *\n * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,\n * which would lead to incorrect calculations.\n *\n * This function returns the timezone offset in milliseconds that takes seconds in account.\n */\nexport default function getTimezoneOffsetInMilliseconds(date) {\n var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));\n utcDate.setUTCFullYear(date.getFullYear());\n return date.getTime() - utcDate.getTime();\n}"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAAS,+BAA+B,CAAC,IAAI,EAAE;AAC9D,EAAE,IAAI,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;AACvK,EAAE,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7C,EAAE,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;AAC5C;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router-devtools
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function requiredArgs(required, args) {
|
|
16
|
-
if (args.length < required) {
|
|
17
|
-
throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports["default"] = requiredArgs;
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../../node_modules/date-fns/esm/_lib/requiredArgs/index.js"],"sourcesContent":["export default function requiredArgs(required, args) {\n if (args.length < required) {\n throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');\n }\n}"],"names":[],"mappings":";;;;;;;;;;;;;;AAAe,SAAS,YAAY,CAAC,QAAQ,EAAE,IAAI,EAAE;AACrD,EAAE,IAAI,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE;AAC9B,IAAI,MAAM,IAAI,SAAS,CAAC,QAAQ,GAAG,WAAW,IAAI,QAAQ,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,GAAG,sBAAsB,GAAG,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;AAChI,GAAG;AACH;;;;"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router-devtools
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var index$1 = require('../toDate/index.js');
|
|
16
|
-
var index = require('../_lib/requiredArgs/index.js');
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @name compareAsc
|
|
20
|
-
* @category Common Helpers
|
|
21
|
-
* @summary Compare the two dates and return -1, 0 or 1.
|
|
22
|
-
*
|
|
23
|
-
* @description
|
|
24
|
-
* Compare the two dates and return 1 if the first date is after the second,
|
|
25
|
-
* -1 if the first date is before the second or 0 if dates are equal.
|
|
26
|
-
*
|
|
27
|
-
* @param {Date|Number} dateLeft - the first date to compare
|
|
28
|
-
* @param {Date|Number} dateRight - the second date to compare
|
|
29
|
-
* @returns {Number} the result of the comparison
|
|
30
|
-
* @throws {TypeError} 2 arguments required
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* // Compare 11 February 1987 and 10 July 1989:
|
|
34
|
-
* const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
|
|
35
|
-
* //=> -1
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* // Sort the array of dates:
|
|
39
|
-
* const result = [
|
|
40
|
-
* new Date(1995, 6, 2),
|
|
41
|
-
* new Date(1987, 1, 11),
|
|
42
|
-
* new Date(1989, 6, 10)
|
|
43
|
-
* ].sort(compareAsc)
|
|
44
|
-
* //=> [
|
|
45
|
-
* // Wed Feb 11 1987 00:00:00,
|
|
46
|
-
* // Mon Jul 10 1989 00:00:00,
|
|
47
|
-
* // Sun Jul 02 1995 00:00:00
|
|
48
|
-
* // ]
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
function compareAsc(dirtyDateLeft, dirtyDateRight) {
|
|
52
|
-
index["default"](2, arguments);
|
|
53
|
-
var dateLeft = index$1["default"](dirtyDateLeft);
|
|
54
|
-
var dateRight = index$1["default"](dirtyDateRight);
|
|
55
|
-
var diff = dateLeft.getTime() - dateRight.getTime();
|
|
56
|
-
|
|
57
|
-
if (diff < 0) {
|
|
58
|
-
return -1;
|
|
59
|
-
} else if (diff > 0) {
|
|
60
|
-
return 1; // Return 0 if diff is 0; return NaN if diff is NaN
|
|
61
|
-
} else {
|
|
62
|
-
return diff;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
exports["default"] = compareAsc;
|
|
67
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../node_modules/date-fns/esm/compareAsc/index.js"],"sourcesContent":["import toDate from \"../toDate/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name compareAsc\n * @category Common Helpers\n * @summary Compare the two dates and return -1, 0 or 1.\n *\n * @description\n * Compare the two dates and return 1 if the first date is after the second,\n * -1 if the first date is before the second or 0 if dates are equal.\n *\n * @param {Date|Number} dateLeft - the first date to compare\n * @param {Date|Number} dateRight - the second date to compare\n * @returns {Number} the result of the comparison\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Compare 11 February 1987 and 10 July 1989:\n * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))\n * //=> -1\n *\n * @example\n * // Sort the array of dates:\n * const result = [\n * new Date(1995, 6, 2),\n * new Date(1987, 1, 11),\n * new Date(1989, 6, 10)\n * ].sort(compareAsc)\n * //=> [\n * // Wed Feb 11 1987 00:00:00,\n * // Mon Jul 10 1989 00:00:00,\n * // Sun Jul 02 1995 00:00:00\n * // ]\n */\n\nexport default function compareAsc(dirtyDateLeft, dirtyDateRight) {\n requiredArgs(2, arguments);\n var dateLeft = toDate(dirtyDateLeft);\n var dateRight = toDate(dirtyDateRight);\n var diff = dateLeft.getTime() - dateRight.getTime();\n\n if (diff < 0) {\n return -1;\n } else if (diff > 0) {\n return 1; // Return 0 if diff is 0; return NaN if diff is NaN\n } else {\n return diff;\n }\n}"],"names":["requiredArgs","toDate"],"mappings":";;;;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAAS,UAAU,CAAC,aAAa,EAAE,cAAc,EAAE;AAClE,EAAEA,gBAAY,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAC7B,EAAE,IAAI,QAAQ,GAAGC,kBAAM,CAAC,aAAa,CAAC,CAAC;AACvC,EAAE,IAAI,SAAS,GAAGA,kBAAM,CAAC,cAAc,CAAC,CAAC;AACzC,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;AACtD;AACA,EAAE,IAAI,IAAI,GAAG,CAAC,EAAE;AAChB,IAAI,OAAO,CAAC,CAAC,CAAC;AACd,GAAG,MAAM,IAAI,IAAI,GAAG,CAAC,EAAE;AACvB,IAAI,OAAO,CAAC,CAAC;AACb,GAAG,MAAM;AACT,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH;;;;"}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router-devtools
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var index$7 = require('../_lib/defaultOptions/index.js');
|
|
16
|
-
var index$6 = require('../_lib/getTimezoneOffsetInMilliseconds/index.js');
|
|
17
|
-
var index$2 = require('../compareAsc/index.js');
|
|
18
|
-
var index$5 = require('../toDate/index.js');
|
|
19
|
-
var index$4 = require('../_lib/cloneObject/index.js');
|
|
20
|
-
var index$3 = require('../_lib/assign/index.js');
|
|
21
|
-
var index$1 = require('../locale/en-US/index.js');
|
|
22
|
-
var index = require('../_lib/requiredArgs/index.js');
|
|
23
|
-
|
|
24
|
-
var MILLISECONDS_IN_MINUTE = 1000 * 60;
|
|
25
|
-
var MINUTES_IN_DAY = 60 * 24;
|
|
26
|
-
var MINUTES_IN_MONTH = MINUTES_IN_DAY * 30;
|
|
27
|
-
var MINUTES_IN_YEAR = MINUTES_IN_DAY * 365;
|
|
28
|
-
/**
|
|
29
|
-
* @name formatDistanceStrict
|
|
30
|
-
* @category Common Helpers
|
|
31
|
-
* @summary Return the distance between the given dates in words.
|
|
32
|
-
*
|
|
33
|
-
* @description
|
|
34
|
-
* Return the distance between the given dates in words, using strict units.
|
|
35
|
-
* This is like `formatDistance`, but does not use helpers like 'almost', 'over',
|
|
36
|
-
* 'less than' and the like.
|
|
37
|
-
*
|
|
38
|
-
* | Distance between dates | Result |
|
|
39
|
-
* |------------------------|---------------------|
|
|
40
|
-
* | 0 ... 59 secs | [0..59] seconds |
|
|
41
|
-
* | 1 ... 59 mins | [1..59] minutes |
|
|
42
|
-
* | 1 ... 23 hrs | [1..23] hours |
|
|
43
|
-
* | 1 ... 29 days | [1..29] days |
|
|
44
|
-
* | 1 ... 11 months | [1..11] months |
|
|
45
|
-
* | 1 ... N years | [1..N] years |
|
|
46
|
-
*
|
|
47
|
-
* @param {Date|Number} date - the date
|
|
48
|
-
* @param {Date|Number} baseDate - the date to compare with
|
|
49
|
-
* @param {Object} [options] - an object with options.
|
|
50
|
-
* @param {Boolean} [options.addSuffix=false] - result indicates if the second date is earlier or later than the first
|
|
51
|
-
* @param {'second'|'minute'|'hour'|'day'|'month'|'year'} [options.unit] - if specified, will force a unit
|
|
52
|
-
* @param {'floor'|'ceil'|'round'} [options.roundingMethod='round'] - which way to round partial units
|
|
53
|
-
* @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
|
|
54
|
-
* @returns {String} the distance in words
|
|
55
|
-
* @throws {TypeError} 2 arguments required
|
|
56
|
-
* @throws {RangeError} `date` must not be Invalid Date
|
|
57
|
-
* @throws {RangeError} `baseDate` must not be Invalid Date
|
|
58
|
-
* @throws {RangeError} `options.roundingMethod` must be 'floor', 'ceil' or 'round'
|
|
59
|
-
* @throws {RangeError} `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'
|
|
60
|
-
* @throws {RangeError} `options.locale` must contain `formatDistance` property
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* // What is the distance between 2 July 2014 and 1 January 2015?
|
|
64
|
-
* const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))
|
|
65
|
-
* //=> '6 months'
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // What is the distance between 1 January 2015 00:00:15
|
|
69
|
-
* // and 1 January 2015 00:00:00?
|
|
70
|
-
* const result = formatDistanceStrict(
|
|
71
|
-
* new Date(2015, 0, 1, 0, 0, 15),
|
|
72
|
-
* new Date(2015, 0, 1, 0, 0, 0)
|
|
73
|
-
* )
|
|
74
|
-
* //=> '15 seconds'
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* // What is the distance from 1 January 2016
|
|
78
|
-
* // to 1 January 2015, with a suffix?
|
|
79
|
-
* const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
|
80
|
-
* addSuffix: true
|
|
81
|
-
* })
|
|
82
|
-
* //=> '1 year ago'
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* // What is the distance from 1 January 2016
|
|
86
|
-
* // to 1 January 2015, in minutes?
|
|
87
|
-
* const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {
|
|
88
|
-
* unit: 'minute'
|
|
89
|
-
* })
|
|
90
|
-
* //=> '525600 minutes'
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* // What is the distance from 1 January 2015
|
|
94
|
-
* // to 28 January 2015, in months, rounded up?
|
|
95
|
-
* const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {
|
|
96
|
-
* unit: 'month',
|
|
97
|
-
* roundingMethod: 'ceil'
|
|
98
|
-
* })
|
|
99
|
-
* //=> '1 month'
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
|
103
|
-
* import { eoLocale } from 'date-fns/locale/eo'
|
|
104
|
-
* const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
|
105
|
-
* locale: eoLocale
|
|
106
|
-
* })
|
|
107
|
-
* //=> '1 jaro'
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
function formatDistanceStrict(dirtyDate, dirtyBaseDate, options) {
|
|
111
|
-
var _ref, _options$locale, _options$roundingMeth;
|
|
112
|
-
|
|
113
|
-
index["default"](2, arguments);
|
|
114
|
-
var defaultOptions = index$7.getDefaultOptions();
|
|
115
|
-
var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : index$1["default"];
|
|
116
|
-
|
|
117
|
-
if (!locale.formatDistance) {
|
|
118
|
-
throw new RangeError('locale must contain localize.formatDistance property');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var comparison = index$2["default"](dirtyDate, dirtyBaseDate);
|
|
122
|
-
|
|
123
|
-
if (isNaN(comparison)) {
|
|
124
|
-
throw new RangeError('Invalid time value');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
var localizeOptions = index$3["default"](index$4["default"](options), {
|
|
128
|
-
addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix),
|
|
129
|
-
comparison: comparison
|
|
130
|
-
});
|
|
131
|
-
var dateLeft;
|
|
132
|
-
var dateRight;
|
|
133
|
-
|
|
134
|
-
if (comparison > 0) {
|
|
135
|
-
dateLeft = index$5["default"](dirtyBaseDate);
|
|
136
|
-
dateRight = index$5["default"](dirtyDate);
|
|
137
|
-
} else {
|
|
138
|
-
dateLeft = index$5["default"](dirtyDate);
|
|
139
|
-
dateRight = index$5["default"](dirtyBaseDate);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
var roundingMethod = String((_options$roundingMeth = options === null || options === void 0 ? void 0 : options.roundingMethod) !== null && _options$roundingMeth !== void 0 ? _options$roundingMeth : 'round');
|
|
143
|
-
var roundingMethodFn;
|
|
144
|
-
|
|
145
|
-
if (roundingMethod === 'floor') {
|
|
146
|
-
roundingMethodFn = Math.floor;
|
|
147
|
-
} else if (roundingMethod === 'ceil') {
|
|
148
|
-
roundingMethodFn = Math.ceil;
|
|
149
|
-
} else if (roundingMethod === 'round') {
|
|
150
|
-
roundingMethodFn = Math.round;
|
|
151
|
-
} else {
|
|
152
|
-
throw new RangeError("roundingMethod must be 'floor', 'ceil' or 'round'");
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
var milliseconds = dateRight.getTime() - dateLeft.getTime();
|
|
156
|
-
var minutes = milliseconds / MILLISECONDS_IN_MINUTE;
|
|
157
|
-
var timezoneOffset = index$6["default"](dateRight) - index$6["default"](dateLeft); // Use DST-normalized difference in minutes for years, months and days;
|
|
158
|
-
// use regular difference in minutes for hours, minutes and seconds.
|
|
159
|
-
|
|
160
|
-
var dstNormalizedMinutes = (milliseconds - timezoneOffset) / MILLISECONDS_IN_MINUTE;
|
|
161
|
-
var defaultUnit = options === null || options === void 0 ? void 0 : options.unit;
|
|
162
|
-
var unit;
|
|
163
|
-
|
|
164
|
-
if (!defaultUnit) {
|
|
165
|
-
if (minutes < 1) {
|
|
166
|
-
unit = 'second';
|
|
167
|
-
} else if (minutes < 60) {
|
|
168
|
-
unit = 'minute';
|
|
169
|
-
} else if (minutes < MINUTES_IN_DAY) {
|
|
170
|
-
unit = 'hour';
|
|
171
|
-
} else if (dstNormalizedMinutes < MINUTES_IN_MONTH) {
|
|
172
|
-
unit = 'day';
|
|
173
|
-
} else if (dstNormalizedMinutes < MINUTES_IN_YEAR) {
|
|
174
|
-
unit = 'month';
|
|
175
|
-
} else {
|
|
176
|
-
unit = 'year';
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
unit = String(defaultUnit);
|
|
180
|
-
} // 0 up to 60 seconds
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (unit === 'second') {
|
|
184
|
-
var seconds = roundingMethodFn(milliseconds / 1000);
|
|
185
|
-
return locale.formatDistance('xSeconds', seconds, localizeOptions); // 1 up to 60 mins
|
|
186
|
-
} else if (unit === 'minute') {
|
|
187
|
-
var roundedMinutes = roundingMethodFn(minutes);
|
|
188
|
-
return locale.formatDistance('xMinutes', roundedMinutes, localizeOptions); // 1 up to 24 hours
|
|
189
|
-
} else if (unit === 'hour') {
|
|
190
|
-
var hours = roundingMethodFn(minutes / 60);
|
|
191
|
-
return locale.formatDistance('xHours', hours, localizeOptions); // 1 up to 30 days
|
|
192
|
-
} else if (unit === 'day') {
|
|
193
|
-
var days = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_DAY);
|
|
194
|
-
return locale.formatDistance('xDays', days, localizeOptions); // 1 up to 12 months
|
|
195
|
-
} else if (unit === 'month') {
|
|
196
|
-
var months = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_MONTH);
|
|
197
|
-
return months === 12 && defaultUnit !== 'month' ? locale.formatDistance('xYears', 1, localizeOptions) : locale.formatDistance('xMonths', months, localizeOptions); // 1 year up to max Date
|
|
198
|
-
} else if (unit === 'year') {
|
|
199
|
-
var years = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_YEAR);
|
|
200
|
-
return locale.formatDistance('xYears', years, localizeOptions);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
throw new RangeError("unit must be 'second', 'minute', 'hour', 'day', 'month' or 'year'");
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
exports["default"] = formatDistanceStrict;
|
|
207
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../node_modules/date-fns/esm/formatDistanceStrict/index.js"],"sourcesContent":["import { getDefaultOptions } from \"../_lib/defaultOptions/index.js\";\nimport getTimezoneOffsetInMilliseconds from \"../_lib/getTimezoneOffsetInMilliseconds/index.js\";\nimport compareAsc from \"../compareAsc/index.js\";\nimport toDate from \"../toDate/index.js\";\nimport cloneObject from \"../_lib/cloneObject/index.js\";\nimport assign from \"../_lib/assign/index.js\";\nimport defaultLocale from \"../_lib/defaultLocale/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\nvar MILLISECONDS_IN_MINUTE = 1000 * 60;\nvar MINUTES_IN_DAY = 60 * 24;\nvar MINUTES_IN_MONTH = MINUTES_IN_DAY * 30;\nvar MINUTES_IN_YEAR = MINUTES_IN_DAY * 365;\n/**\n * @name formatDistanceStrict\n * @category Common Helpers\n * @summary Return the distance between the given dates in words.\n *\n * @description\n * Return the distance between the given dates in words, using strict units.\n * This is like `formatDistance`, but does not use helpers like 'almost', 'over',\n * 'less than' and the like.\n *\n * | Distance between dates | Result |\n * |------------------------|---------------------|\n * | 0 ... 59 secs | [0..59] seconds |\n * | 1 ... 59 mins | [1..59] minutes |\n * | 1 ... 23 hrs | [1..23] hours |\n * | 1 ... 29 days | [1..29] days |\n * | 1 ... 11 months | [1..11] months |\n * | 1 ... N years | [1..N] years |\n *\n * @param {Date|Number} date - the date\n * @param {Date|Number} baseDate - the date to compare with\n * @param {Object} [options] - an object with options.\n * @param {Boolean} [options.addSuffix=false] - result indicates if the second date is earlier or later than the first\n * @param {'second'|'minute'|'hour'|'day'|'month'|'year'} [options.unit] - if specified, will force a unit\n * @param {'floor'|'ceil'|'round'} [options.roundingMethod='round'] - which way to round partial units\n * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n * @returns {String} the distance in words\n * @throws {TypeError} 2 arguments required\n * @throws {RangeError} `date` must not be Invalid Date\n * @throws {RangeError} `baseDate` must not be Invalid Date\n * @throws {RangeError} `options.roundingMethod` must be 'floor', 'ceil' or 'round'\n * @throws {RangeError} `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'\n * @throws {RangeError} `options.locale` must contain `formatDistance` property\n *\n * @example\n * // What is the distance between 2 July 2014 and 1 January 2015?\n * const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))\n * //=> '6 months'\n *\n * @example\n * // What is the distance between 1 January 2015 00:00:15\n * // and 1 January 2015 00:00:00?\n * const result = formatDistanceStrict(\n * new Date(2015, 0, 1, 0, 0, 15),\n * new Date(2015, 0, 1, 0, 0, 0)\n * )\n * //=> '15 seconds'\n *\n * @example\n * // What is the distance from 1 January 2016\n * // to 1 January 2015, with a suffix?\n * const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {\n * addSuffix: true\n * })\n * //=> '1 year ago'\n *\n * @example\n * // What is the distance from 1 January 2016\n * // to 1 January 2015, in minutes?\n * const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {\n * unit: 'minute'\n * })\n * //=> '525600 minutes'\n *\n * @example\n * // What is the distance from 1 January 2015\n * // to 28 January 2015, in months, rounded up?\n * const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {\n * unit: 'month',\n * roundingMethod: 'ceil'\n * })\n * //=> '1 month'\n *\n * @example\n * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?\n * import { eoLocale } from 'date-fns/locale/eo'\n * const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {\n * locale: eoLocale\n * })\n * //=> '1 jaro'\n */\n\nexport default function formatDistanceStrict(dirtyDate, dirtyBaseDate, options) {\n var _ref, _options$locale, _options$roundingMeth;\n\n requiredArgs(2, arguments);\n var defaultOptions = getDefaultOptions();\n var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;\n\n if (!locale.formatDistance) {\n throw new RangeError('locale must contain localize.formatDistance property');\n }\n\n var comparison = compareAsc(dirtyDate, dirtyBaseDate);\n\n if (isNaN(comparison)) {\n throw new RangeError('Invalid time value');\n }\n\n var localizeOptions = assign(cloneObject(options), {\n addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix),\n comparison: comparison\n });\n var dateLeft;\n var dateRight;\n\n if (comparison > 0) {\n dateLeft = toDate(dirtyBaseDate);\n dateRight = toDate(dirtyDate);\n } else {\n dateLeft = toDate(dirtyDate);\n dateRight = toDate(dirtyBaseDate);\n }\n\n var roundingMethod = String((_options$roundingMeth = options === null || options === void 0 ? void 0 : options.roundingMethod) !== null && _options$roundingMeth !== void 0 ? _options$roundingMeth : 'round');\n var roundingMethodFn;\n\n if (roundingMethod === 'floor') {\n roundingMethodFn = Math.floor;\n } else if (roundingMethod === 'ceil') {\n roundingMethodFn = Math.ceil;\n } else if (roundingMethod === 'round') {\n roundingMethodFn = Math.round;\n } else {\n throw new RangeError(\"roundingMethod must be 'floor', 'ceil' or 'round'\");\n }\n\n var milliseconds = dateRight.getTime() - dateLeft.getTime();\n var minutes = milliseconds / MILLISECONDS_IN_MINUTE;\n var timezoneOffset = getTimezoneOffsetInMilliseconds(dateRight) - getTimezoneOffsetInMilliseconds(dateLeft); // Use DST-normalized difference in minutes for years, months and days;\n // use regular difference in minutes for hours, minutes and seconds.\n\n var dstNormalizedMinutes = (milliseconds - timezoneOffset) / MILLISECONDS_IN_MINUTE;\n var defaultUnit = options === null || options === void 0 ? void 0 : options.unit;\n var unit;\n\n if (!defaultUnit) {\n if (minutes < 1) {\n unit = 'second';\n } else if (minutes < 60) {\n unit = 'minute';\n } else if (minutes < MINUTES_IN_DAY) {\n unit = 'hour';\n } else if (dstNormalizedMinutes < MINUTES_IN_MONTH) {\n unit = 'day';\n } else if (dstNormalizedMinutes < MINUTES_IN_YEAR) {\n unit = 'month';\n } else {\n unit = 'year';\n }\n } else {\n unit = String(defaultUnit);\n } // 0 up to 60 seconds\n\n\n if (unit === 'second') {\n var seconds = roundingMethodFn(milliseconds / 1000);\n return locale.formatDistance('xSeconds', seconds, localizeOptions); // 1 up to 60 mins\n } else if (unit === 'minute') {\n var roundedMinutes = roundingMethodFn(minutes);\n return locale.formatDistance('xMinutes', roundedMinutes, localizeOptions); // 1 up to 24 hours\n } else if (unit === 'hour') {\n var hours = roundingMethodFn(minutes / 60);\n return locale.formatDistance('xHours', hours, localizeOptions); // 1 up to 30 days\n } else if (unit === 'day') {\n var days = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_DAY);\n return locale.formatDistance('xDays', days, localizeOptions); // 1 up to 12 months\n } else if (unit === 'month') {\n var months = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_MONTH);\n return months === 12 && defaultUnit !== 'month' ? locale.formatDistance('xYears', 1, localizeOptions) : locale.formatDistance('xMonths', months, localizeOptions); // 1 year up to max Date\n } else if (unit === 'year') {\n var years = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_YEAR);\n return locale.formatDistance('xYears', years, localizeOptions);\n }\n\n throw new RangeError(\"unit must be 'second', 'minute', 'hour', 'day', 'month' or 'year'\");\n}"],"names":["requiredArgs","getDefaultOptions","defaultLocale","compareAsc","assign","cloneObject","toDate","getTimezoneOffsetInMilliseconds"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAI,sBAAsB,GAAG,IAAI,GAAG,EAAE,CAAC;AACvC,IAAI,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC;AAC7B,IAAI,gBAAgB,GAAG,cAAc,GAAG,EAAE,CAAC;AAC3C,IAAI,eAAe,GAAG,cAAc,GAAG,GAAG,CAAC;AAC3C;AACA;AAC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