-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(v1.3.0): support locate source code
- Loading branch information
blucas.wu
committed
Aug 15, 2023
1 parent
a6ca87c
commit 1d54b8a
Showing
32 changed files
with
1,019 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2022-present Blucas | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
root=$(pwd) | ||
|
||
# SDK | ||
target_sdk="${root}/public/page-spy" | ||
mkdir -p "$target_sdk" | ||
cp "${root}/node_modules/@huolala-tech/page-spy/dist/index.min.js" "${root}/public/page-spy/index.min.js" | ||
|
||
# source-map | ||
target_sourcemap="${root}/public/source-map" | ||
mkdir -p "$target_sourcemap" | ||
cp "${root}/node_modules/source-map/dist/source-map.js" "${root}/public/source-map/source-map.min.js" | ||
cp "${root}/node_modules/source-map/lib/mappings.wasm" "${root}/public/source-map/mappings.wasm" | ||
|
||
# shiki | ||
cp -R "${root}/node_modules/shiki" "${root}/public/shiki" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.block-title { | ||
position: relative; | ||
padding-left: 16px; | ||
&::before { | ||
content: ' '; | ||
display: block; | ||
position: absolute; | ||
left: 0; | ||
top: 50%; | ||
width: 4px; | ||
height: 60%; | ||
transform: translateY(-50%); | ||
background-color: @primary-color; | ||
} | ||
~ .block-title { | ||
margin-top: 32px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Typography } from 'antd'; | ||
import type { TitleProps } from 'antd/lib/typography/Title'; | ||
import './index.less'; | ||
|
||
const { Title } = Typography; | ||
|
||
export const BlockTitle = ({ | ||
title, | ||
level = 3, | ||
}: { | ||
title: React.ReactNode; | ||
level?: TitleProps['level']; | ||
}) => { | ||
return ( | ||
<div className="block-title"> | ||
<Title level={level} style={{ color: 'rgba(0, 0, 0, 0.65)' }}> | ||
{title} | ||
</Title> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import ReactDOM from 'react-dom'; | ||
import ReactDOM from 'react-dom/client'; | ||
import { App } from './App'; | ||
import '@/assets/style/union.less'; | ||
import '@/assets/style/initial.css'; | ||
import '@/assets/locales/index'; | ||
|
||
ReactDOM.render(<App />, document.querySelector('#root')); | ||
const root = ReactDOM.createRoot(document.querySelector('#root')!); | ||
|
||
root.render(<App />); |
19 changes: 19 additions & 0 deletions
19
src/pages/Devtools/ConsolePanel/components/ConsoleNode/ErrorTrace/index.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.error-trace { | ||
display: flex; | ||
flex-wrap: nowrap; | ||
align-items: flex-start; | ||
|
||
&-node { | ||
flex: 1; | ||
padding-inline: 8px; | ||
} | ||
|
||
&-icon { | ||
color: #bbb; | ||
font-size: 20px; | ||
cursor: pointer; | ||
&:hover { | ||
color: #999; | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/pages/Devtools/ConsolePanel/components/ConsoleNode/ErrorTrace/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { SpyConsole } from '@huolala-tech/page-spy'; | ||
import { ReactComponent as ErrorStackSvg } from '@/assets/image/error-stack.svg'; | ||
import './index.less'; | ||
import Icon from '@ant-design/icons'; | ||
import { useCallback } from 'react'; | ||
import ErrorStackParser from 'error-stack-parser'; | ||
|
||
export type RequiredFrames = Required<StackFrame>[]; | ||
|
||
export const isErrorTraceNode = ( | ||
item: SpyConsole.DataItem, | ||
): item is RRequired<SpyConsole.DataItem> => { | ||
if ( | ||
item.logType === 'error' && | ||
item.logs.length === 1 && | ||
item.errorDetail && | ||
item.errorDetail.stack | ||
) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
|
||
export const ErrorTraceNode = ({ | ||
data, | ||
}: { | ||
data: RRequired<SpyConsole.DataItem>; | ||
}) => { | ||
const onPopupDetail = useCallback(() => { | ||
if (!data.errorDetail.stack) { | ||
return; | ||
} | ||
|
||
const error = new Error(); | ||
|
||
const { name, message, stack } = data.errorDetail; | ||
error.name = name; | ||
error.message = message; | ||
error.stack = stack; | ||
const frames = ErrorStackParser.parse(error).filter( | ||
({ fileName, lineNumber, columnNumber }) => { | ||
return [fileName, lineNumber, columnNumber].every(Boolean); | ||
}, | ||
) as RequiredFrames; | ||
if (!frames.length) return; | ||
|
||
window.dispatchEvent( | ||
new CustomEvent('source-code-detail', { | ||
detail: { | ||
error, | ||
frames, | ||
}, | ||
}), | ||
); | ||
}, [data.errorDetail]); | ||
|
||
return ( | ||
<div className="error-trace"> | ||
<Icon | ||
component={ErrorStackSvg} | ||
className="error-trace-icon" | ||
onClick={onPopupDetail} | ||
/> | ||
<div className="error-trace-node"> | ||
<code>{data.errorDetail.stack}</code> | ||
</div> | ||
</div> | ||
); | ||
}; |
1 change: 0 additions & 1 deletion
1
src/pages/Devtools/ConsolePanel/components/ConsoleNode/index.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.console-node { | ||
margin-right: 7px; | ||
font-size: 12px; | ||
word-break: break-word; | ||
&.origin { | ||
color: #323941; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.