@contember/react-devbar 2.1.0-alpha.30 → 2.1.0-alpha.35
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/package.json +11 -11
- package/src/errorHandling.tsx +1 -8
- package/src/hooks/useCopyErrorMarkdown.ts +3 -4
- package/src/hooks/useParsedStacktrace.ts +1 -1
- package/src/ui/DevBar/DevBar.tsx +6 -12
- package/src/ui/DevError/DevErrorBadge.tsx +0 -1
- package/src/ui/DevError/DevErrorCopy.tsx +2 -3
- package/src/ui/DevError/DevErrorInner.tsx +26 -26
- package/src/ui/DevError/DevErrorList.tsx +16 -15
- package/src/ui/DevError/StackTrace.tsx +1 -4
- package/dist/development/index.cjs +0 -17
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -17
- package/dist/development/index.js.map +0 -1
- package/dist/development/src/DevErrorManager.cjs +0 -110
- package/dist/development/src/DevErrorManager.cjs.map +0 -1
- package/dist/development/src/DevErrorManager.js +0 -110
- package/dist/development/src/DevErrorManager.js.map +0 -1
- package/dist/development/src/errorHandling.cjs +0 -75
- package/dist/development/src/errorHandling.cjs.map +0 -1
- package/dist/development/src/errorHandling.js +0 -58
- package/dist/development/src/errorHandling.js.map +0 -1
- package/dist/development/src/hooks/useCopyErrorMarkdown.cjs +0 -101
- package/dist/development/src/hooks/useCopyErrorMarkdown.cjs.map +0 -1
- package/dist/development/src/hooks/useCopyErrorMarkdown.js +0 -101
- package/dist/development/src/hooks/useCopyErrorMarkdown.js.map +0 -1
- package/dist/development/src/hooks/useParsedStacktrace.cjs +0 -67
- package/dist/development/src/hooks/useParsedStacktrace.cjs.map +0 -1
- package/dist/development/src/hooks/useParsedStacktrace.js +0 -45
- package/dist/development/src/hooks/useParsedStacktrace.js.map +0 -1
- package/dist/development/src/ui/DevBar/DevBar.cjs +0 -193
- package/dist/development/src/ui/DevBar/DevBar.cjs.map +0 -1
- package/dist/development/src/ui/DevBar/DevBar.js +0 -193
- package/dist/development/src/ui/DevBar/DevBar.js.map +0 -1
- package/dist/development/src/ui/DevError/DevError.cjs +0 -33
- package/dist/development/src/ui/DevError/DevError.cjs.map +0 -1
- package/dist/development/src/ui/DevError/DevError.js +0 -33
- package/dist/development/src/ui/DevError/DevError.js.map +0 -1
- package/dist/development/src/ui/DevError/DevErrorBadge.cjs +0 -21
- package/dist/development/src/ui/DevError/DevErrorBadge.cjs.map +0 -1
- package/dist/development/src/ui/DevError/DevErrorBadge.js +0 -21
- package/dist/development/src/ui/DevError/DevErrorBadge.js.map +0 -1
- package/dist/development/src/ui/DevError/DevErrorCopy.cjs +0 -36
- package/dist/development/src/ui/DevError/DevErrorCopy.cjs.map +0 -1
- package/dist/development/src/ui/DevError/DevErrorCopy.js +0 -36
- package/dist/development/src/ui/DevError/DevErrorCopy.js.map +0 -1
- package/dist/development/src/ui/DevError/DevErrorInner.cjs +0 -79
- package/dist/development/src/ui/DevError/DevErrorInner.cjs.map +0 -1
- package/dist/development/src/ui/DevError/DevErrorInner.js +0 -79
- package/dist/development/src/ui/DevError/DevErrorInner.js.map +0 -1
- package/dist/development/src/ui/DevError/DevErrorList.cjs +0 -119
- package/dist/development/src/ui/DevError/DevErrorList.cjs.map +0 -1
- package/dist/development/src/ui/DevError/DevErrorList.js +0 -119
- package/dist/development/src/ui/DevError/DevErrorList.js.map +0 -1
- package/dist/development/src/ui/DevError/StackTrace.cjs +0 -82
- package/dist/development/src/ui/DevError/StackTrace.cjs.map +0 -1
- package/dist/development/src/ui/DevError/StackTrace.js +0 -82
- package/dist/development/src/ui/DevError/StackTrace.js.map +0 -1
- package/dist/production/index.cjs +0 -17
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.js +0 -17
- package/dist/production/index.js.map +0 -1
- package/dist/production/src/errorHandling.cjs +0 -59
- package/dist/production/src/errorHandling.cjs.map +0 -1
- package/dist/production/src/errorHandling.js +0 -42
- package/dist/production/src/errorHandling.js.map +0 -1
- package/dist/production/src/hooks/useCopyErrorMarkdown.cjs +0 -101
- package/dist/production/src/hooks/useCopyErrorMarkdown.cjs.map +0 -1
- package/dist/production/src/hooks/useCopyErrorMarkdown.js +0 -101
- package/dist/production/src/hooks/useCopyErrorMarkdown.js.map +0 -1
- package/dist/production/src/hooks/useParsedStacktrace.cjs +0 -67
- package/dist/production/src/hooks/useParsedStacktrace.cjs.map +0 -1
- package/dist/production/src/hooks/useParsedStacktrace.js +0 -45
- package/dist/production/src/hooks/useParsedStacktrace.js.map +0 -1
- package/dist/production/src/ui/DevBar/DevBar.cjs +0 -125
- package/dist/production/src/ui/DevBar/DevBar.cjs.map +0 -1
- package/dist/production/src/ui/DevBar/DevBar.js +0 -125
- package/dist/production/src/ui/DevBar/DevBar.js.map +0 -1
- package/dist/production/src/ui/DevError/DevError.cjs +0 -13
- package/dist/production/src/ui/DevError/DevError.cjs.map +0 -1
- package/dist/production/src/ui/DevError/DevError.js +0 -13
- package/dist/production/src/ui/DevError/DevError.js.map +0 -1
- package/dist/production/src/ui/DevError/DevErrorBadge.cjs +0 -13
- package/dist/production/src/ui/DevError/DevErrorBadge.cjs.map +0 -1
- package/dist/production/src/ui/DevError/DevErrorBadge.js +0 -13
- package/dist/production/src/ui/DevError/DevErrorBadge.js.map +0 -1
- package/dist/production/src/ui/DevError/DevErrorCopy.cjs +0 -28
- package/dist/production/src/ui/DevError/DevErrorCopy.cjs.map +0 -1
- package/dist/production/src/ui/DevError/DevErrorCopy.js +0 -28
- package/dist/production/src/ui/DevError/DevErrorCopy.js.map +0 -1
- package/dist/production/src/ui/DevError/DevErrorInner.cjs +0 -23
- package/dist/production/src/ui/DevError/DevErrorInner.cjs.map +0 -1
- package/dist/production/src/ui/DevError/DevErrorInner.js +0 -23
- package/dist/production/src/ui/DevError/DevErrorInner.js.map +0 -1
- package/dist/production/src/ui/DevError/DevErrorList.cjs +0 -51
- package/dist/production/src/ui/DevError/DevErrorList.cjs.map +0 -1
- package/dist/production/src/ui/DevError/DevErrorList.js +0 -51
- package/dist/production/src/ui/DevError/DevErrorList.js.map +0 -1
- package/dist/production/src/ui/DevError/StackTrace.cjs +0 -39
- package/dist/production/src/ui/DevError/StackTrace.cjs.map +0 -1
- package/dist/production/src/ui/DevError/StackTrace.js +0 -39
- package/dist/production/src/ui/DevError/StackTrace.js.map +0 -1
- package/dist/types/DevErrorManager.d.ts +0 -15
- package/dist/types/DevErrorManager.d.ts.map +0 -1
- package/dist/types/errorHandling.d.ts +0 -6
- package/dist/types/errorHandling.d.ts.map +0 -1
- package/dist/types/hooks/useCopyErrorMarkdown.d.ts +0 -12
- package/dist/types/hooks/useCopyErrorMarkdown.d.ts.map +0 -1
- package/dist/types/hooks/useParsedStacktrace.d.ts +0 -10
- package/dist/types/hooks/useParsedStacktrace.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/dist/types/ui/DevBar/DevBar.d.ts +0 -13
- package/dist/types/ui/DevBar/DevBar.d.ts.map +0 -1
- package/dist/types/ui/DevBar/index.d.ts +0 -2
- package/dist/types/ui/DevBar/index.d.ts.map +0 -1
- package/dist/types/ui/DevError/DevError.d.ts +0 -6
- package/dist/types/ui/DevError/DevError.d.ts.map +0 -1
- package/dist/types/ui/DevError/DevErrorBadge.d.ts +0 -7
- package/dist/types/ui/DevError/DevErrorBadge.d.ts.map +0 -1
- package/dist/types/ui/DevError/DevErrorCopy.d.ts +0 -6
- package/dist/types/ui/DevError/DevErrorCopy.d.ts.map +0 -1
- package/dist/types/ui/DevError/DevErrorInner.d.ts +0 -7
- package/dist/types/ui/DevError/DevErrorInner.d.ts.map +0 -1
- package/dist/types/ui/DevError/DevErrorList.d.ts +0 -13
- package/dist/types/ui/DevError/DevErrorList.d.ts.map +0 -1
- package/dist/types/ui/DevError/StackTrace.d.ts +0 -5
- package/dist/types/ui/DevError/StackTrace.d.ts.map +0 -1
- package/dist/types/ui/DevError/index.d.ts +0 -5
- package/dist/types/ui/DevError/index.d.ts.map +0 -1
- package/dist/types/ui/DevError/types.d.ts +0 -15
- package/dist/types/ui/DevError/types.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/react-devbar",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.1.0-alpha.
|
|
4
|
+
"version": "2.1.0-alpha.35",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -33,22 +33,22 @@
|
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
36
|
-
"url": "https://github.com/contember/
|
|
36
|
+
"url": "git+https://github.com/contember/contember.git",
|
|
37
37
|
"directory": "packages/react-devbar"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@contember/react-utils": "
|
|
41
|
-
"@contember/utilities": "
|
|
42
|
-
"buffer": "
|
|
40
|
+
"@contember/react-utils": "workspace:*",
|
|
41
|
+
"@contember/utilities": "workspace:*",
|
|
42
|
+
"buffer": "catalog:"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"react": "
|
|
46
|
-
"react-dom": "
|
|
45
|
+
"react": "catalog:",
|
|
46
|
+
"react-dom": "catalog:"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/react": "
|
|
50
|
-
"@types/react-dom": "
|
|
51
|
-
"react": "
|
|
52
|
-
"react-dom": "
|
|
49
|
+
"@types/react": "catalog:",
|
|
50
|
+
"@types/react-dom": "catalog:",
|
|
51
|
+
"react": "catalog:",
|
|
52
|
+
"react-dom": "catalog:"
|
|
53
53
|
}
|
|
54
54
|
}
|
package/src/errorHandling.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as ReactDOM from 'react-dom'
|
|
2
1
|
import { Buffer } from 'buffer'
|
|
3
2
|
import { DevErrorManager, ErrorBus } from './DevErrorManager'
|
|
4
3
|
import { ReactElement } from 'react'
|
|
@@ -9,11 +8,7 @@ const getErrorContainer = () => {
|
|
|
9
8
|
const errorElementId = '__contember__dev__error__container__element'
|
|
10
9
|
let errorContainer = document.getElementById(errorElementId)
|
|
11
10
|
|
|
12
|
-
if (errorContainer) {
|
|
13
|
-
// eslint-disable-next-line react/no-deprecated
|
|
14
|
-
ReactDOM.unmountComponentAtNode(errorContainer)
|
|
15
|
-
|
|
16
|
-
} else {
|
|
11
|
+
if (!errorContainer) {
|
|
17
12
|
errorContainer = document.createElement('div')
|
|
18
13
|
errorContainer.id = errorElementId
|
|
19
14
|
document.body.appendChild(errorContainer)
|
|
@@ -24,7 +19,6 @@ const getErrorContainer = () => {
|
|
|
24
19
|
|
|
25
20
|
const devErrorHandler = (renderer: ErrorReactRenderer): TryRun => {
|
|
26
21
|
const errorBus = new ErrorBus()
|
|
27
|
-
|
|
28
22
|
;(window as any).Buffer = Buffer
|
|
29
23
|
window.addEventListener('error', e => {
|
|
30
24
|
if (e.message.startsWith('ResizeObserver')) {
|
|
@@ -77,7 +71,6 @@ const prodErrorHandler = (renderer: ErrorReactRenderer): TryRun => {
|
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
|
|
80
|
-
|
|
81
74
|
export const createErrorHandler = (renderer: ErrorReactRenderer) => {
|
|
82
75
|
if (import.meta.env.DEV) {
|
|
83
76
|
return devErrorHandler(renderer)
|
|
@@ -99,11 +99,12 @@ type CopyMarkdownProps = {
|
|
|
99
99
|
|
|
100
100
|
export const useCopyErrorMarkdown = ({ currentError, currentErrorSource }: CopyMarkdownProps) => {
|
|
101
101
|
const [copyStatus, setCopyStatus] = useState<'idle' | 'copying' | 'success' | 'error'>('idle')
|
|
102
|
-
|
|
102
|
+
|
|
103
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: intentional
|
|
103
104
|
useEffect(() => {
|
|
104
105
|
setCopyStatus('idle')
|
|
105
106
|
}, [currentError])
|
|
106
|
-
|
|
107
|
+
|
|
107
108
|
const handleCopyMarkdown = async () => {
|
|
108
109
|
setCopyStatus('copying')
|
|
109
110
|
try {
|
|
@@ -116,8 +117,6 @@ export const useCopyErrorMarkdown = ({ currentError, currentErrorSource }: CopyM
|
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
121
120
|
const isClipboardSupported = !!navigator?.clipboard
|
|
122
121
|
|
|
123
122
|
return {
|
|
@@ -36,7 +36,7 @@ export const useProcessedError = (e: ErrorType): ProcessedError => {
|
|
|
36
36
|
cause: e instanceof Error && 'cause' in e && (e as any).cause !== undefined ? await createErrorWithStackTrace((e as any).cause) : undefined,
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
(async () => {
|
|
39
|
+
;(async () => {
|
|
40
40
|
setError(await createErrorWithStackTrace(e))
|
|
41
41
|
})()
|
|
42
42
|
}, [e])
|
package/src/ui/DevBar/DevBar.tsx
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useId,
|
|
3
|
-
useOnElementClickOutsideCallback,
|
|
4
|
-
useReferentiallyStableCallback,
|
|
5
|
-
useWindowSize,
|
|
6
|
-
} from '@contember/react-utils'
|
|
1
|
+
import { useId, useOnElementClickOutsideCallback, useReferentiallyStableCallback, useWindowSize } from '@contember/react-utils'
|
|
7
2
|
import { dataAttribute } from '@contember/utilities'
|
|
8
3
|
import { type PropsWithChildren, type ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
|
9
4
|
|
|
@@ -22,6 +17,7 @@ export const DevBar = ({
|
|
|
22
17
|
setExpanded(expanded => !expanded)
|
|
23
18
|
})
|
|
24
19
|
|
|
20
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: intentional
|
|
25
21
|
useEffect(() => {
|
|
26
22
|
function handleKeyDown(event: KeyboardEvent) {
|
|
27
23
|
if (event.code === 'KeyJ' && (event.ctrlKey || event.metaKey)) {
|
|
@@ -96,12 +92,10 @@ export const DevPanel = ({ heading, icon, children, preview }: DevPanelProps) =>
|
|
|
96
92
|
|
|
97
93
|
const handleClickOutside = (event: MouseEvent) => {
|
|
98
94
|
const rect = dialog.getBoundingClientRect()
|
|
99
|
-
const isInDialog =
|
|
100
|
-
rect.top
|
|
101
|
-
|
|
102
|
-
rect.left
|
|
103
|
-
event.clientX <= rect.left + rect.width
|
|
104
|
-
)
|
|
95
|
+
const isInDialog = rect.top <= event.clientY
|
|
96
|
+
&& event.clientY <= rect.top + rect.height
|
|
97
|
+
&& rect.left <= event.clientX
|
|
98
|
+
&& event.clientX <= rect.left + rect.width
|
|
105
99
|
|
|
106
100
|
if (!isInDialog) {
|
|
107
101
|
dialog.close()
|
|
@@ -19,13 +19,12 @@ export const DevErrorCopy = ({ currentError, currentErrorSource }: {
|
|
|
19
19
|
disabled={copyStatus === 'copying'}
|
|
20
20
|
title="Copy current error as Markdown"
|
|
21
21
|
>
|
|
22
|
-
{
|
|
22
|
+
{{
|
|
23
23
|
success: 'Copied!',
|
|
24
24
|
copying: 'Copying...',
|
|
25
25
|
error: '❌ Copy Failed',
|
|
26
26
|
idle: 'Copy as Markdown',
|
|
27
|
-
}[copyStatus]
|
|
27
|
+
}[copyStatus]}
|
|
28
28
|
</button>
|
|
29
29
|
)
|
|
30
|
-
|
|
31
30
|
}
|
|
@@ -6,42 +6,42 @@ export interface DevErrorInnerProps {
|
|
|
6
6
|
level?: number
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
const className = (cls?: string | null) => cls ? `cui-devError-${cls}` : 'cui-devError'
|
|
11
10
|
|
|
12
11
|
export function DevErrorInner({ error, level = 1 }: DevErrorInnerProps) {
|
|
13
|
-
|
|
14
12
|
let errorObject: Error | undefined = error.error instanceof Error ? error.error : undefined
|
|
15
13
|
|
|
16
14
|
return (
|
|
17
15
|
<>
|
|
18
16
|
<div className={className('header')}>
|
|
19
|
-
{errorObject
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
{errorObject
|
|
18
|
+
? (
|
|
19
|
+
<>
|
|
20
|
+
<h1 className={className('errorName')}>{errorObject.name}</h1>
|
|
21
|
+
{error.cause && <a href={`#error-${level}`} className={className('causeLink')}>caused by ></a>}
|
|
22
|
+
{errorObject.message && <h2 className={className('errorMessage')}>{errorObject.message}</h2>}
|
|
23
|
+
{'details' in errorObject && <div className={className('errorDetails')}>{(errorObject as any).details}</div>}
|
|
24
|
+
</>
|
|
25
|
+
)
|
|
26
|
+
: <h1 className={className('errorName')}>Unknown error</h1>}
|
|
29
27
|
</div>
|
|
30
|
-
{error.parsedStackStrace ?
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<div className={className('stack-dump')}>{errorObject.stack}</div>
|
|
35
|
-
</div>
|
|
36
|
-
) : null}
|
|
37
|
-
{error.cause ? (
|
|
38
|
-
<>
|
|
39
|
-
<div className={className('causedBy')} id={`error-${level}`}>
|
|
40
|
-
Caused by
|
|
28
|
+
{error.parsedStackStrace ? <StackTrace stackTrace={error.parsedStackStrace} /> : errorObject?.stack
|
|
29
|
+
? (
|
|
30
|
+
<div className={className('stack')}>
|
|
31
|
+
<div className={className('stack-dump')}>{errorObject.stack}</div>
|
|
41
32
|
</div>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
)
|
|
34
|
+
: null}
|
|
35
|
+
{error.cause
|
|
36
|
+
? (
|
|
37
|
+
<>
|
|
38
|
+
<div className={className('causedBy')} id={`error-${level}`}>
|
|
39
|
+
Caused by
|
|
40
|
+
</div>
|
|
41
|
+
<DevErrorInner error={error.cause} level={level + 1} />
|
|
42
|
+
</>
|
|
43
|
+
)
|
|
44
|
+
: null}
|
|
45
45
|
</>
|
|
46
46
|
)
|
|
47
47
|
}
|
|
@@ -26,7 +26,6 @@ export function DevErrorList({
|
|
|
26
26
|
onPrevious,
|
|
27
27
|
onClear,
|
|
28
28
|
}: DevErrorListProps) {
|
|
29
|
-
|
|
30
29
|
useEffect(() => {
|
|
31
30
|
document.body.classList.add('cui-devError-body')
|
|
32
31
|
return () => {
|
|
@@ -43,21 +42,23 @@ export function DevErrorList({
|
|
|
43
42
|
<DevErrorCopy currentError={currentError} currentErrorSource={currentErrorSource} />
|
|
44
43
|
</div>
|
|
45
44
|
<div className={className('actions')}>
|
|
46
|
-
{errorCount > 1
|
|
47
|
-
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
{errorCount > 1
|
|
46
|
+
? (
|
|
47
|
+
<div className={className('switcher')}>
|
|
48
|
+
<p className={className('errorCount')}>
|
|
49
|
+
Error {currentErrorIndex + 1} of {errorCount}
|
|
50
|
+
</p>
|
|
51
|
+
<div className={className('switcherButtons')}>
|
|
52
|
+
<button type="button" className={className('switcherButton')} onClick={onPrevious}>
|
|
53
|
+
←
|
|
54
|
+
</button>
|
|
55
|
+
<button type="button" className={className('switcherButton')} onClick={onNext}>
|
|
56
|
+
→
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
58
59
|
</div>
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
)
|
|
61
|
+
: null}
|
|
61
62
|
<div className={className('close')}>
|
|
62
63
|
<button type="button" className={className('closeButton')} onClick={onClose}>
|
|
63
64
|
✕
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { ParsedStackFrame, ParsedStackTrace } from './types'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
const className = (cls?: string | null) => cls ? `cui-devError-${cls}` : 'cui-devError'
|
|
5
4
|
export const StackTrace = ({ stackTrace }: { stackTrace: ParsedStackTrace }) => {
|
|
6
5
|
return (
|
|
7
6
|
<div className={className('stack')}>
|
|
8
|
-
{stackTrace.map((it, index) =>
|
|
9
|
-
<StackFrame stackFrame={it} key={index} />
|
|
10
|
-
))}
|
|
7
|
+
{stackTrace.map((it, index) => <StackFrame stackFrame={it} key={index} />)}
|
|
11
8
|
</div>
|
|
12
9
|
)
|
|
13
10
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const errorHandling = require("./src/errorHandling.cjs");
|
|
4
|
-
const useParsedStacktrace = require("./src/hooks/useParsedStacktrace.cjs");
|
|
5
|
-
const DevBar = require("./src/ui/DevBar/DevBar.cjs");
|
|
6
|
-
const DevError = require("./src/ui/DevError/DevError.cjs");
|
|
7
|
-
const DevErrorList = require("./src/ui/DevError/DevErrorList.cjs");
|
|
8
|
-
const DevErrorBadge = require("./src/ui/DevError/DevErrorBadge.cjs");
|
|
9
|
-
exports.createErrorHandler = errorHandling.createErrorHandler;
|
|
10
|
-
exports.parseStacktrace = useParsedStacktrace.parseStacktrace;
|
|
11
|
-
exports.useProcessedError = useParsedStacktrace.useProcessedError;
|
|
12
|
-
exports.DevBar = DevBar.DevBar;
|
|
13
|
-
exports.DevPanel = DevBar.DevPanel;
|
|
14
|
-
exports.DevError = DevError.DevError;
|
|
15
|
-
exports.DevErrorList = DevErrorList.DevErrorList;
|
|
16
|
-
exports.DevErrorBadge = DevErrorBadge.DevErrorBadge;
|
|
17
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createErrorHandler } from "./src/errorHandling.js";
|
|
2
|
-
import { parseStacktrace, useProcessedError } from "./src/hooks/useParsedStacktrace.js";
|
|
3
|
-
import { DevBar, DevPanel } from "./src/ui/DevBar/DevBar.js";
|
|
4
|
-
import { DevError } from "./src/ui/DevError/DevError.js";
|
|
5
|
-
import { DevErrorList } from "./src/ui/DevError/DevErrorList.js";
|
|
6
|
-
import { DevErrorBadge } from "./src/ui/DevError/DevErrorBadge.js";
|
|
7
|
-
export {
|
|
8
|
-
DevBar,
|
|
9
|
-
DevError,
|
|
10
|
-
DevErrorBadge,
|
|
11
|
-
DevErrorList,
|
|
12
|
-
DevPanel,
|
|
13
|
-
createErrorHandler,
|
|
14
|
-
parseStacktrace,
|
|
15
|
-
useProcessedError
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const useParsedStacktrace = require("./hooks/useParsedStacktrace.cjs");
|
|
6
|
-
const DevErrorBadge = require("./ui/DevError/DevErrorBadge.cjs");
|
|
7
|
-
const DevErrorList = require("./ui/DevError/DevErrorList.cjs");
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
-
class ErrorBus {
|
|
12
|
-
constructor() {
|
|
13
|
-
__publicField(this, "queue", []);
|
|
14
|
-
__publicField(this, "listener", null);
|
|
15
|
-
}
|
|
16
|
-
async handleError(source, error) {
|
|
17
|
-
const boxedError = { error, source };
|
|
18
|
-
if (!this.listener) {
|
|
19
|
-
this.queue.push(boxedError);
|
|
20
|
-
} else {
|
|
21
|
-
this.listener(boxedError);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
register(listener) {
|
|
25
|
-
this.listener = listener;
|
|
26
|
-
this.queue.forEach(listener);
|
|
27
|
-
this.queue = [];
|
|
28
|
-
return () => {
|
|
29
|
-
this.listener = null;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const compareErrors = (a, b) => {
|
|
34
|
-
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
if (!("stack" in a) || !("stack" in b) || !("message" in a) || !("message" in b)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (a.message !== b.message) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
if (a.stack !== b.stack) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
47
|
-
};
|
|
48
|
-
function DevErrorManager(props) {
|
|
49
|
-
const [errors, setErrors] = React.useState([]);
|
|
50
|
-
const [errIndex, setErrorIndex] = React.useState(0);
|
|
51
|
-
const [open, setOpen] = React.useState(false);
|
|
52
|
-
React.useEffect(
|
|
53
|
-
() => {
|
|
54
|
-
return props.bus.register((err) => {
|
|
55
|
-
setTimeout(
|
|
56
|
-
() => {
|
|
57
|
-
setErrors((errors2) => {
|
|
58
|
-
return !errors2.find((it) => compareErrors(it.error, err.error)) ? [err, ...errors2] : errors2;
|
|
59
|
-
});
|
|
60
|
-
setOpen(true);
|
|
61
|
-
},
|
|
62
|
-
0
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
[props.bus]
|
|
67
|
-
);
|
|
68
|
-
const currentError = errors[errIndex];
|
|
69
|
-
const processedError = useParsedStacktrace.useProcessedError(currentError?.error);
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
}, []);
|
|
72
|
-
if (!currentError) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const onPrevious = () => setErrorIndex((it) => Math.max(0, it - 1));
|
|
76
|
-
const onNext = () => setErrorIndex((it) => Math.min(errors.length - 1, it + 1));
|
|
77
|
-
const onClose = () => setOpen(false);
|
|
78
|
-
const onClear = () => setErrors([]);
|
|
79
|
-
if (!open) {
|
|
80
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(DevErrorBadge.DevErrorBadge, { errorCount: errors.length, onOpen: () => setOpen(true), onClear }, void 0, false, {
|
|
81
|
-
fileName: "/home/runner/work/contember/contember/packages/react-devbar/src/DevErrorManager.tsx",
|
|
82
|
-
lineNumber: 94,
|
|
83
|
-
columnNumber: 10
|
|
84
|
-
}, this);
|
|
85
|
-
}
|
|
86
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
87
|
-
DevErrorList.DevErrorList,
|
|
88
|
-
{
|
|
89
|
-
currentError: processedError,
|
|
90
|
-
currentErrorSource: currentError.source,
|
|
91
|
-
currentErrorIndex: errIndex,
|
|
92
|
-
errorCount: errors.length,
|
|
93
|
-
onPrevious,
|
|
94
|
-
onNext,
|
|
95
|
-
onClose,
|
|
96
|
-
onClear
|
|
97
|
-
},
|
|
98
|
-
void 0,
|
|
99
|
-
false,
|
|
100
|
-
{
|
|
101
|
-
fileName: "/home/runner/work/contember/contember/packages/react-devbar/src/DevErrorManager.tsx",
|
|
102
|
-
lineNumber: 97,
|
|
103
|
-
columnNumber: 3
|
|
104
|
-
},
|
|
105
|
-
this
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
exports.DevErrorManager = DevErrorManager;
|
|
109
|
-
exports.ErrorBus = ErrorBus;
|
|
110
|
-
//# sourceMappingURL=DevErrorManager.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DevErrorManager.cjs","sources":["../../../../packages/react-devbar/src/DevErrorManager.tsx"],"sourcesContent":["import { DevErrorBadge, DevErrorList, ErrorType } from './ui/DevError'\nimport { useEffect, useState } from 'react'\nimport { useProcessedError } from './hooks/useParsedStacktrace'\n\nexport class ErrorBus {\n\tprivate queue: { error: ErrorType; source: string }[] = []\n\tprivate listener: null | ((error: { error: ErrorType; source: string }) => void) = null\n\n\tasync handleError(source: string, error: ErrorType) {\n\t\tconst boxedError = { error, source }\n\n\t\tif (!this.listener) {\n\t\t\tthis.queue.push(boxedError)\n\t\t} else {\n\t\t\tthis.listener(boxedError)\n\t\t}\n\t}\n\n\tregister(listener: (error: { error: ErrorType; source: string }) => void): () => void {\n\t\tthis.listener = listener\n\t\tthis.queue.forEach(listener)\n\t\tthis.queue = []\n\t\treturn () => {\n\t\t\tthis.listener = null\n\t\t}\n\t}\n}\n\nexport interface DevErrorManagerProps {\n\tbus: ErrorBus\n}\n\nconst compareErrors = (a: ErrorType, b: ErrorType) => {\n\tif (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n\t\treturn false\n\t}\n\tif (!('stack' in a) || !('stack' in b) || !('message' in a) || !('message' in b)) {\n\t\treturn false\n\t}\n\tif (a.message !== b.message) {\n\t\treturn false\n\t}\n\tif (a.stack !== b.stack) {\n\t\treturn false\n\t}\n\treturn true\n}\n\nexport function DevErrorManager(props: DevErrorManagerProps) {\n\tconst [errors, setErrors] = useState<{ error: ErrorType; source: string }[]>([])\n\tconst [errIndex, setErrorIndex] = useState(0)\n\tconst [open, setOpen] = useState(false)\n\n\tuseEffect(\n\t\t() => {\n\t\t\treturn props.bus.register(err => {\n\t\t\t\tsetTimeout(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tsetErrors(errors => {\n\t\t\t\t\t\t\treturn !errors.find(it => compareErrors(it.error, err.error)) ? [err, ...errors] : errors\n\t\t\t\t\t\t})\n\t\t\t\t\t\tsetOpen(true)\n\t\t\t\t\t},\n\t\t\t\t\t0,\n\t\t\t\t)\n\t\t\t})\n\t\t},\n\t\t[props.bus],\n\t)\n\n\tconst currentError = errors[errIndex]\n\tconst processedError = useProcessedError(currentError?.error)\n\n\tuseEffect(() => {\n\t\tif (import.meta.hot) {\n\t\t\tconst cb = () => {\n\t\t\t\tsetOpen(false)\n\t\t\t}\n\t\t\timport.meta.hot.on('vite:afterUpdate', cb)\n\t\t\treturn () => {\n\t\t\t\timport.meta.hot?.off('vite:afterUpdate', cb)\n\t\t\t}\n\t\t}\n\t}, [])\n\n\tif (!currentError) {\n\t\treturn null\n\t}\n\tconst onPrevious = () => setErrorIndex(it => Math.max(0, it - 1))\n\tconst onNext = () => setErrorIndex(it => Math.min(errors.length - 1, it + 1))\n\tconst onClose = () => setOpen(false)\n\tconst onClear = () => setErrors([])\n\tif (!open) {\n\t\treturn <DevErrorBadge errorCount={errors.length} onOpen={() => setOpen(true)} onClear={onClear} />\n\t}\n\treturn (\n\t\t<DevErrorList\n\t\t\tcurrentError={processedError}\n\t\t\tcurrentErrorSource={currentError.source}\n\t\t\tcurrentErrorIndex={errIndex}\n\t\t\terrorCount={errors.length}\n\t\t\tonPrevious={onPrevious}\n\t\t\tonNext={onNext}\n\t\t\tonClose={onClose}\n\t\t\tonClear={onClear}\n\t\t/>\n\t)\n}\n"],"names":["useState","useEffect","errors","useProcessedError","jsxDEV","DevErrorBadge","DevErrorList"],"mappings":";;;;;;;;;;AAIO,MAAM,SAAS;AAAA,EAAf,cAAA;AACN,kBAAA,MAAQ,SAAgD,EAAC;AACzD,kBAAA,MAAQ,YAA2E,IAAA;AAAA,EAAA;AAAA,EAEnF,MAAM,YAAY,QAAgB,OAAkB;AAC7C,UAAA,aAAa,EAAE,OAAO,OAAO;AAE/B,QAAA,CAAC,KAAK,UAAU;AACd,WAAA,MAAM,KAAK,UAAU;AAAA,IAAA,OACpB;AACN,WAAK,SAAS,UAAU;AAAA,IAAA;AAAA,EACzB;AAAA,EAGD,SAAS,UAA6E;AACrF,SAAK,WAAW;AACX,SAAA,MAAM,QAAQ,QAAQ;AAC3B,SAAK,QAAQ,CAAC;AACd,WAAO,MAAM;AACZ,WAAK,WAAW;AAAA,IACjB;AAAA,EAAA;AAEF;AAMA,MAAM,gBAAgB,CAAC,GAAc,MA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AAM,OAAA,KAAK,IAAI,OAAO,SAAS,GAAG,KAAK,CAAC,CAAC;AACtE,QAAA,UAAU,MAAM,QAAQ,KAAK;AACnC,QAAM,UAAU,MAAM,UAAU,EAAE;AAClC,MAAI,CAAC,MAAM;AACH,WAACG,8BAAA,OAAAC,cAAA,eAAc,EAAA,YAAY,OAAO,QAAQ,QAAQ,MAAM,QAAQ,IAAI,GAAG,QAAvE,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,OAAyF,IAAA;AAAA,EAAA;AAGhG,SAAAD,8BAAA;AAAA,IAACE,aAAA;AAAA,IAAA;AAAA,MACA,cAAc;AAAA,MACd,oBAAoB,aAAa;AAAA,MACjC,mBAAmB;AAAA,MACnB,YAAY,OAAO;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IARD;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAA;AAAA,EASA;AAEF;;;"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
|
-
import { useProcessedError } from "./hooks/useParsedStacktrace.js";
|
|
4
|
-
import { DevErrorBadge } from "./ui/DevError/DevErrorBadge.js";
|
|
5
|
-
import { DevErrorList } from "./ui/DevError/DevErrorList.js";
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9
|
-
class ErrorBus {
|
|
10
|
-
constructor() {
|
|
11
|
-
__publicField(this, "queue", []);
|
|
12
|
-
__publicField(this, "listener", null);
|
|
13
|
-
}
|
|
14
|
-
async handleError(source, error) {
|
|
15
|
-
const boxedError = { error, source };
|
|
16
|
-
if (!this.listener) {
|
|
17
|
-
this.queue.push(boxedError);
|
|
18
|
-
} else {
|
|
19
|
-
this.listener(boxedError);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
register(listener) {
|
|
23
|
-
this.listener = listener;
|
|
24
|
-
this.queue.forEach(listener);
|
|
25
|
-
this.queue = [];
|
|
26
|
-
return () => {
|
|
27
|
-
this.listener = null;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const compareErrors = (a, b) => {
|
|
32
|
-
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
if (!("stack" in a) || !("stack" in b) || !("message" in a) || !("message" in b)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
if (a.message !== b.message) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
if (a.stack !== b.stack) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
};
|
|
46
|
-
function DevErrorManager(props) {
|
|
47
|
-
const [errors, setErrors] = useState([]);
|
|
48
|
-
const [errIndex, setErrorIndex] = useState(0);
|
|
49
|
-
const [open, setOpen] = useState(false);
|
|
50
|
-
useEffect(
|
|
51
|
-
() => {
|
|
52
|
-
return props.bus.register((err) => {
|
|
53
|
-
setTimeout(
|
|
54
|
-
() => {
|
|
55
|
-
setErrors((errors2) => {
|
|
56
|
-
return !errors2.find((it) => compareErrors(it.error, err.error)) ? [err, ...errors2] : errors2;
|
|
57
|
-
});
|
|
58
|
-
setOpen(true);
|
|
59
|
-
},
|
|
60
|
-
0
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
[props.bus]
|
|
65
|
-
);
|
|
66
|
-
const currentError = errors[errIndex];
|
|
67
|
-
const processedError = useProcessedError(currentError?.error);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
}, []);
|
|
70
|
-
if (!currentError) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
const onPrevious = () => setErrorIndex((it) => Math.max(0, it - 1));
|
|
74
|
-
const onNext = () => setErrorIndex((it) => Math.min(errors.length - 1, it + 1));
|
|
75
|
-
const onClose = () => setOpen(false);
|
|
76
|
-
const onClear = () => setErrors([]);
|
|
77
|
-
if (!open) {
|
|
78
|
-
return /* @__PURE__ */ jsxDEV(DevErrorBadge, { errorCount: errors.length, onOpen: () => setOpen(true), onClear }, void 0, false, {
|
|
79
|
-
fileName: "/home/runner/work/contember/contember/packages/react-devbar/src/DevErrorManager.tsx",
|
|
80
|
-
lineNumber: 94,
|
|
81
|
-
columnNumber: 10
|
|
82
|
-
}, this);
|
|
83
|
-
}
|
|
84
|
-
return /* @__PURE__ */ jsxDEV(
|
|
85
|
-
DevErrorList,
|
|
86
|
-
{
|
|
87
|
-
currentError: processedError,
|
|
88
|
-
currentErrorSource: currentError.source,
|
|
89
|
-
currentErrorIndex: errIndex,
|
|
90
|
-
errorCount: errors.length,
|
|
91
|
-
onPrevious,
|
|
92
|
-
onNext,
|
|
93
|
-
onClose,
|
|
94
|
-
onClear
|
|
95
|
-
},
|
|
96
|
-
void 0,
|
|
97
|
-
false,
|
|
98
|
-
{
|
|
99
|
-
fileName: "/home/runner/work/contember/contember/packages/react-devbar/src/DevErrorManager.tsx",
|
|
100
|
-
lineNumber: 97,
|
|
101
|
-
columnNumber: 3
|
|
102
|
-
},
|
|
103
|
-
this
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
export {
|
|
107
|
-
DevErrorManager,
|
|
108
|
-
ErrorBus
|
|
109
|
-
};
|
|
110
|
-
//# sourceMappingURL=DevErrorManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DevErrorManager.js","sources":["../../../../packages/react-devbar/src/DevErrorManager.tsx"],"sourcesContent":["import { DevErrorBadge, DevErrorList, ErrorType } from './ui/DevError'\nimport { useEffect, useState } from 'react'\nimport { useProcessedError } from './hooks/useParsedStacktrace'\n\nexport class ErrorBus {\n\tprivate queue: { error: ErrorType; source: string }[] = []\n\tprivate listener: null | ((error: { error: ErrorType; source: string }) => void) = null\n\n\tasync handleError(source: string, error: ErrorType) {\n\t\tconst boxedError = { error, source }\n\n\t\tif (!this.listener) {\n\t\t\tthis.queue.push(boxedError)\n\t\t} else {\n\t\t\tthis.listener(boxedError)\n\t\t}\n\t}\n\n\tregister(listener: (error: { error: ErrorType; source: string }) => void): () => void {\n\t\tthis.listener = listener\n\t\tthis.queue.forEach(listener)\n\t\tthis.queue = []\n\t\treturn () => {\n\t\t\tthis.listener = null\n\t\t}\n\t}\n}\n\nexport interface DevErrorManagerProps {\n\tbus: ErrorBus\n}\n\nconst compareErrors = (a: ErrorType, b: ErrorType) => {\n\tif (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n\t\treturn false\n\t}\n\tif (!('stack' in a) || !('stack' in b) || !('message' in a) || !('message' in b)) {\n\t\treturn false\n\t}\n\tif (a.message !== b.message) {\n\t\treturn false\n\t}\n\tif (a.stack !== b.stack) {\n\t\treturn false\n\t}\n\treturn true\n}\n\nexport function DevErrorManager(props: DevErrorManagerProps) {\n\tconst [errors, setErrors] = useState<{ error: ErrorType; source: string }[]>([])\n\tconst [errIndex, setErrorIndex] = useState(0)\n\tconst [open, setOpen] = useState(false)\n\n\tuseEffect(\n\t\t() => {\n\t\t\treturn props.bus.register(err => {\n\t\t\t\tsetTimeout(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tsetErrors(errors => {\n\t\t\t\t\t\t\treturn !errors.find(it => compareErrors(it.error, err.error)) ? [err, ...errors] : errors\n\t\t\t\t\t\t})\n\t\t\t\t\t\tsetOpen(true)\n\t\t\t\t\t},\n\t\t\t\t\t0,\n\t\t\t\t)\n\t\t\t})\n\t\t},\n\t\t[props.bus],\n\t)\n\n\tconst currentError = errors[errIndex]\n\tconst processedError = useProcessedError(currentError?.error)\n\n\tuseEffect(() => {\n\t\tif (import.meta.hot) {\n\t\t\tconst cb = () => {\n\t\t\t\tsetOpen(false)\n\t\t\t}\n\t\t\timport.meta.hot.on('vite:afterUpdate', cb)\n\t\t\treturn () => {\n\t\t\t\timport.meta.hot?.off('vite:afterUpdate', cb)\n\t\t\t}\n\t\t}\n\t}, [])\n\n\tif (!currentError) {\n\t\treturn null\n\t}\n\tconst onPrevious = () => setErrorIndex(it => Math.max(0, it - 1))\n\tconst onNext = () => setErrorIndex(it => Math.min(errors.length - 1, it + 1))\n\tconst onClose = () => setOpen(false)\n\tconst onClear = () => setErrors([])\n\tif (!open) {\n\t\treturn <DevErrorBadge errorCount={errors.length} onOpen={() => setOpen(true)} onClear={onClear} />\n\t}\n\treturn (\n\t\t<DevErrorList\n\t\t\tcurrentError={processedError}\n\t\t\tcurrentErrorSource={currentError.source}\n\t\t\tcurrentErrorIndex={errIndex}\n\t\t\terrorCount={errors.length}\n\t\t\tonPrevious={onPrevious}\n\t\t\tonNext={onNext}\n\t\t\tonClose={onClose}\n\t\t\tonClear={onClear}\n\t\t/>\n\t)\n}\n"],"names":["errors"],"mappings":";;;;;;;;AAIO,MAAM,SAAS;AAAA,EAAf,cAAA;AACN,kBAAA,MAAQ,SAAgD,EAAC;AACzD,kBAAA,MAAQ,YAA2E,IAAA;AAAA,EAAA;AAAA,EAEnF,MAAM,YAAY,QAAgB,OAAkB;AAC7C,UAAA,aAAa,EAAE,OAAO,OAAO;AAE/B,QAAA,CAAC,KAAK,UAAU;AACd,WAAA,MAAM,KAAK,UAAU;AAAA,IAAA,OACpB;AACN,WAAK,SAAS,UAAU;AAAA,IAAA;AAAA,EACzB;AAAA,EAGD,SAAS,UAA6E;AACrF,SAAK,WAAW;AACX,SAAA,MAAM,QAAQ,QAAQ;AAC3B,SAAK,QAAQ,CAAC;AACd,WAAO,MAAM;AACZ,WAAK,WAAW;AAAA,IACjB;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