Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
6deaffbd
Commit
6deaffbd
authored
7 years ago
by
Luca
Browse files
Options
Download
Email Patches
Plain Diff
Updated react-error-overlay to latest Flow (0.54.0)
parent
e8b58edf
1 merge request
!3065
Updated react-error-overlay to latest Flow (0.54.0)
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
packages/react-error-overlay/package.json
+1
-1
packages/react-error-overlay/package.json
packages/react-error-overlay/src/__tests__/__snapshots__/unmapper.js.snap
+14
-7
...rror-overlay/src/__tests__/__snapshots__/unmapper.js.snap
packages/react-error-overlay/src/components/Collapsible.js
+10
-1
packages/react-error-overlay/src/components/Collapsible.js
packages/react-error-overlay/src/components/ErrorOverlay.js
+12
-2
packages/react-error-overlay/src/components/ErrorOverlay.js
packages/react-error-overlay/src/containers/CompileErrorContainer.js
+5
-1
...act-error-overlay/src/containers/CompileErrorContainer.js
packages/react-error-overlay/src/containers/RuntimeError.js
+1
-0
packages/react-error-overlay/src/containers/RuntimeError.js
packages/react-error-overlay/src/containers/RuntimeErrorContainer.js
+12
-1
...act-error-overlay/src/containers/RuntimeErrorContainer.js
packages/react-error-overlay/src/containers/StackFrame.js
+16
-3
packages/react-error-overlay/src/containers/StackFrame.js
packages/react-error-overlay/src/containers/StackFrameCodeBlock.js
+6
-2
...react-error-overlay/src/containers/StackFrameCodeBlock.js
packages/react-error-overlay/src/containers/StackTrace.js
+9
-1
packages/react-error-overlay/src/containers/StackTrace.js
packages/react-error-overlay/src/index.js
+3
-3
packages/react-error-overlay/src/index.js
packages/react-error-overlay/src/listenToRuntimeErrors.js
+2
-5
packages/react-error-overlay/src/listenToRuntimeErrors.js
packages/react-error-overlay/src/utils/getSourceMap.js
+1
-1
packages/react-error-overlay/src/utils/getSourceMap.js
with
92 additions
and
28 deletions
+92
-28
packages/react-error-overlay/package.json
+
1
-
1
View file @
6deaffbd
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
"eslint-plugin-import"
:
"2.7.0"
,
"eslint-plugin-import"
:
"2.7.0"
,
"eslint-plugin-jsx-a11y"
:
"5.1.1"
,
"eslint-plugin-jsx-a11y"
:
"5.1.1"
,
"eslint-plugin-react"
:
"7.1.0"
,
"eslint-plugin-react"
:
"7.1.0"
,
"flow-bin"
:
"0.5
2
.0"
,
"flow-bin"
:
"
^
0.5
4
.0"
,
"jest"
:
"20.0.4"
,
"jest"
:
"20.0.4"
,
"jest-fetch-mock"
:
"1.2.1"
"jest-fetch-mock"
:
"1.2.1"
},
},
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/__tests__/__snapshots__/unmapper.js.snap
+
14
-
7
View file @
6deaffbd
...
@@ -46,37 +46,44 @@ Array [
...
@@ -46,37 +46,44 @@ Array [
],
],
"_scriptCode": Array [
"_scriptCode": Array [
ScriptLine {
ScriptLine {
"content": " },",
"content": " },
",
"highlight": false,
"highlight": false,
"lineNumber": 41463,
"lineNumber": 41463,
},
},
ScriptLine {
ScriptLine {
"content": " [1, 2].map(function (v) {",
"content": " [1, 2].map(function (v) {
",
"highlight": false,
"highlight": false,
"lineNumber": 41464,
"lineNumber": 41464,
},
},
ScriptLine {
ScriptLine {
"content": " return _react2.default.createElement(",
"content": " return _react2.default.createElement(
",
"highlight": false,
"highlight": false,
"lineNumber": 41465,
"lineNumber": 41465,
},
},
ScriptLine {
ScriptLine {
"content": " 'div',",
"content": " 'div',
",
"highlight": true,
"highlight": true,
"lineNumber": 41466,
"lineNumber": 41466,
},
},
ScriptLine {
ScriptLine {
"content": " {",
"content": " {
",
"highlight": false,
"highlight": false,
"lineNumber": 41467,
"lineNumber": 41467,
},
},
ScriptLine {
ScriptLine {
"content": " __source: {",
"content": " __source: {
",
"highlight": false,
"highlight": false,
"lineNumber": 41468,
"lineNumber": 41468,
},
},
ScriptLine {
ScriptLine {
"content": " fileName: _jsxFileName,",
"content": " fileName: _jsxFileName,
",
"highlight": false,
"highlight": false,
"lineNumber": 41469,
"lineNumber": 41469,
},
},
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/components/Collapsible.js
+
10
-
1
View file @
6deaffbd
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
/* @flow */
/* @flow */
import
React
,
{
Component
}
from
'
react
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
type
{
Element
}
from
'
react
'
;
import
{
black
}
from
'
../styles
'
;
import
{
black
}
from
'
../styles
'
;
const
_collapsibleStyle
=
{
const
_collapsibleStyle
=
{
...
@@ -35,7 +36,15 @@ const collapsibleExpandedStyle = {
...
@@ -35,7 +36,15 @@ const collapsibleExpandedStyle = {
marginBottom
:
'
0.6em
'
,
marginBottom
:
'
0.6em
'
,
};
};
class
Collapsible
extends
Component
{
type
Props
=
{
|
children
:
Element
<
any
>
[]
|
};
type
State
=
{
|
collapsed
:
boolean
|
};
class
Collapsible
extends
Component
<
Props
,
State
>
{
state
=
{
state
=
{
collapsed
:
true
,
collapsed
:
true
,
};
};
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/components/ErrorOverlay.js
+
12
-
2
View file @
6deaffbd
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
/* @flow */
/* @flow */
import
React
,
{
Component
}
from
'
react
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
type
{
Node
}
from
'
react
'
;
import
{
black
}
from
'
../styles
'
;
import
{
black
}
from
'
../styles
'
;
const
overlayStyle
=
{
const
overlayStyle
=
{
...
@@ -31,10 +32,19 @@ const overlayStyle = {
...
@@ -31,10 +32,19 @@ const overlayStyle = {
color
:
black
,
color
:
black
,
};
};
class
ErrorOverlay
extends
Component
{
type
Props
=
{
|
children
:
Node
,
shortcutHandler
?:
(
eventKey
:
string
)
=>
void
|
};
type
State
=
{
|
collapsed
:
boolean
|
};
class
ErrorOverlay
extends
Component
<
Props
,
State
>
{
iframeWindow
:
window
=
null
;
iframeWindow
:
window
=
null
;
getIframeWindow
=
(
element
:
HTMLDivElement
)
=>
{
getIframeWindow
=
(
element
:
?
HTMLDivElement
)
=>
{
if
(
element
)
{
if
(
element
)
{
const
document
=
element
.
ownerDocument
;
const
document
=
element
.
ownerDocument
;
this
.
iframeWindow
=
document
.
defaultView
;
this
.
iframeWindow
=
document
.
defaultView
;
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/containers/CompileErrorContainer.js
+
5
-
1
View file @
6deaffbd
...
@@ -15,7 +15,11 @@ import Header from '../components/Header';
...
@@ -15,7 +15,11 @@ import Header from '../components/Header';
import
CodeBlock
from
'
../components/CodeBlock
'
;
import
CodeBlock
from
'
../components/CodeBlock
'
;
import
generateAnsiHTML
from
'
../utils/generateAnsiHTML
'
;
import
generateAnsiHTML
from
'
../utils/generateAnsiHTML
'
;
class
CompileErrorContainer
extends
PureComponent
{
type
Props
=
{
|
error
:
string
|
};
class
CompileErrorContainer
extends
PureComponent
<
Props
,
void
>
{
render
()
{
render
()
{
const
{
error
}
=
this
.
props
;
const
{
error
}
=
this
.
props
;
return
(
return
(
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/containers/RuntimeError.js
+
1
-
0
View file @
6deaffbd
...
@@ -65,4 +65,5 @@ function RuntimeError({ errorRecord, launchEditorEndpoint }: Props) {
...
@@ -65,4 +65,5 @@ function RuntimeError({ errorRecord, launchEditorEndpoint }: Props) {
);
);
}
}
export
type
{
ErrorRecord
};
export
default
RuntimeError
;
export
default
RuntimeError
;
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/containers/RuntimeErrorContainer.js
+
12
-
1
View file @
6deaffbd
...
@@ -14,8 +14,19 @@ import CloseButton from '../components/CloseButton';
...
@@ -14,8 +14,19 @@ import CloseButton from '../components/CloseButton';
import
NavigationBar
from
'
../components/NavigationBar
'
;
import
NavigationBar
from
'
../components/NavigationBar
'
;
import
RuntimeError
from
'
./RuntimeError
'
;
import
RuntimeError
from
'
./RuntimeError
'
;
import
Footer
from
'
../components/Footer
'
;
import
Footer
from
'
../components/Footer
'
;
import
type
{
ErrorRecord
}
from
'
./RuntimeError
'
;
class
RuntimeErrorContainer
extends
PureComponent
{
type
Props
=
{
|
errorRecords
:
ErrorRecord
[],
close
:
()
=>
void
,
launchEditorEndpoint
:
?
string
|
};
type
State
=
{
|
currentIndex
:
number
|
};
class
RuntimeErrorContainer
extends
PureComponent
<
Props
,
State
>
{
state
=
{
state
=
{
currentIndex
:
0
,
currentIndex
:
0
,
};
};
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/containers/StackFrame.js
+
16
-
3
View file @
6deaffbd
...
@@ -12,6 +12,7 @@ import React, { Component } from 'react';
...
@@ -12,6 +12,7 @@ import React, { Component } from 'react';
import
CodeBlock
from
'
./StackFrameCodeBlock
'
;
import
CodeBlock
from
'
./StackFrameCodeBlock
'
;
import
{
getPrettyURL
}
from
'
../utils/getPrettyURL
'
;
import
{
getPrettyURL
}
from
'
../utils/getPrettyURL
'
;
import
{
darkGray
}
from
'
../styles
'
;
import
{
darkGray
}
from
'
../styles
'
;
import
type
{
StackFrame
as
StackFrameType
}
from
'
../utils/stack-frame
'
;
const
linkStyle
=
{
const
linkStyle
=
{
fontSize
:
'
0.9em
'
,
fontSize
:
'
0.9em
'
,
...
@@ -43,7 +44,19 @@ const toggleStyle = {
...
@@ -43,7 +44,19 @@ const toggleStyle = {
lineHeight
:
'
1.5
'
,
lineHeight
:
'
1.5
'
,
};
};
class
StackFrame
extends
Component
{
type
Props
=
{
|
frame
:
StackFrameType
,
launchEditorEndpoint
:
?
string
,
contextSize
:
number
,
critical
:
boolean
,
showCode
:
boolean
|
};
type
State
=
{
|
compiled
:
boolean
|
};
class
StackFrame
extends
Component
<
Props
,
State
>
{
state
=
{
state
=
{
compiled
:
false
,
compiled
:
false
,
};
};
...
@@ -74,7 +87,7 @@ class StackFrame extends Component {
...
@@ -74,7 +87,7 @@ class StackFrame extends Component {
}
}
openInEditor
=
()
=>
{
openInEditor
=
()
=>
{
if
(
!
this
.
canOpenInEditor
()
)
{
if
(
!
this
.
props
.
launchEditorEndpoint
)
{
return
;
return
;
}
}
const
{
const
{
...
@@ -90,7 +103,7 @@ class StackFrame extends Component {
...
@@ -90,7 +103,7 @@ class StackFrame extends Component {
).
then
(()
=>
{},
()
=>
{});
).
then
(()
=>
{},
()
=>
{});
};
};
onKeyDown
=
(
e
:
SyntheticKeyboardEvent
)
=>
{
onKeyDown
=
(
e
:
SyntheticKeyboardEvent
<>
)
=>
{
if
(
e
.
key
===
'
Enter
'
)
{
if
(
e
.
key
===
'
Enter
'
)
{
this
.
openInEditor
();
this
.
openInEditor
();
}
}
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/containers/StackFrameCodeBlock.js
+
6
-
2
View file @
6deaffbd
...
@@ -21,12 +21,16 @@ import codeFrame from 'babel-code-frame';
...
@@ -21,12 +21,16 @@ import codeFrame from 'babel-code-frame';
type
StackFrameCodeBlockPropsType
=
{
|
type
StackFrameCodeBlockPropsType
=
{
|
lines
:
ScriptLine
[],
lines
:
ScriptLine
[],
lineNum
:
number
,
lineNum
:
number
,
columnNum
:
number
,
columnNum
:
?
number
,
contextSize
:
number
,
contextSize
:
number
,
main
:
boolean
,
main
:
boolean
,
|
};
|
};
function
StackFrameCodeBlock
(
props
:
StackFrameCodeBlockPropsType
)
{
// Exact type workaround for spread operator.
// See: https://github.com/facebook/flow/issues/2405
type
Exact
<
T
>
=
$Shape
<
T
>
;
function
StackFrameCodeBlock
(
props
:
Exact
<
StackFrameCodeBlockPropsType
>
)
{
const
{
lines
,
lineNum
,
columnNum
,
contextSize
,
main
}
=
props
;
const
{
lines
,
lineNum
,
columnNum
,
contextSize
,
main
}
=
props
;
const
sourceCode
=
[];
const
sourceCode
=
[];
let
whiteSpace
=
Infinity
;
let
whiteSpace
=
Infinity
;
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/containers/StackTrace.js
+
9
-
1
View file @
6deaffbd
...
@@ -13,6 +13,7 @@ import StackFrame from './StackFrame';
...
@@ -13,6 +13,7 @@ import StackFrame from './StackFrame';
import
Collapsible
from
'
../components/Collapsible
'
;
import
Collapsible
from
'
../components/Collapsible
'
;
import
{
isInternalFile
}
from
'
../utils/isInternalFile
'
;
import
{
isInternalFile
}
from
'
../utils/isInternalFile
'
;
import
{
isBultinErrorName
}
from
'
../utils/isBultinErrorName
'
;
import
{
isBultinErrorName
}
from
'
../utils/isBultinErrorName
'
;
import
type
{
StackFrame
as
StackFrameType
}
from
'
../utils/stack-frame
'
;
const
traceStyle
=
{
const
traceStyle
=
{
fontSize
:
'
1em
'
,
fontSize
:
'
1em
'
,
...
@@ -21,7 +22,14 @@ const traceStyle = {
...
@@ -21,7 +22,14 @@ const traceStyle = {
overflow
:
'
auto
'
,
overflow
:
'
auto
'
,
};
};
class
StackTrace
extends
Component
{
type
Props
=
{
|
stackFrames
:
StackFrameType
[],
errorName
:
string
,
contextSize
:
number
,
launchEditorEndpoint
:
?
string
,
|
};
class
StackTrace
extends
Component
<
Props
>
{
renderFrames
()
{
renderFrames
()
{
const
{
const
{
stackFrames
,
stackFrames
,
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/index.js
+
3
-
3
View file @
6deaffbd
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
/* @flow */
/* @flow */
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
Element
}
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
ReactDOM
from
'
react-dom
'
;
import
CompileErrorContainer
from
'
./containers/CompileErrorContainer
'
;
import
CompileErrorContainer
from
'
./containers/CompileErrorContainer
'
;
import
RuntimeErrorContainer
from
'
./containers/RuntimeErrorContainer
'
;
import
RuntimeErrorContainer
from
'
./containers/RuntimeErrorContainer
'
;
...
@@ -21,13 +22,12 @@ import type { ErrorRecord } from './listenToRuntimeErrors';
...
@@ -21,13 +22,12 @@ import type { ErrorRecord } from './listenToRuntimeErrors';
type
RuntimeReportingOptions
=
{
|
type
RuntimeReportingOptions
=
{
|
onError
:
()
=>
void
,
onError
:
()
=>
void
,
launchEditorEndpoint
:
string
,
launchEditorEndpoint
:
string
,
filename
?:
string
,
|
};
|
};
let
iframe
:
null
|
HTMLIFrameElement
=
null
;
let
iframe
:
null
|
HTMLIFrameElement
=
null
;
let
isLoadingIframe
:
boolean
=
false
;
let
isLoadingIframe
:
boolean
=
false
;
let
renderedElement
:
null
|
React
.
Element
<
any
>
=
null
;
let
renderedElement
:
null
|
Element
<
any
>
=
null
;
let
currentBuildError
:
null
|
string
=
null
;
let
currentBuildError
:
null
|
string
=
null
;
let
currentRuntimeErrorRecords
:
Array
<
ErrorRecord
>
=
[];
let
currentRuntimeErrorRecords
:
Array
<
ErrorRecord
>
=
[];
let
currentRuntimeErrorOptions
:
null
|
RuntimeReportingOptions
=
null
;
let
currentRuntimeErrorOptions
:
null
|
RuntimeReportingOptions
=
null
;
...
@@ -56,7 +56,7 @@ export function startReportingRuntimeErrors(options: RuntimeReportingOptions) {
...
@@ -56,7 +56,7 @@ export function startReportingRuntimeErrors(options: RuntimeReportingOptions) {
}
finally
{
}
finally
{
handleRuntimeError
(
errorRecord
);
handleRuntimeError
(
errorRecord
);
}
}
}
,
options
.
filename
);
});
}
}
function
handleRuntimeError
(
errorRecord
)
{
function
handleRuntimeError
(
errorRecord
)
{
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/listenToRuntimeErrors.js
+
2
-
5
View file @
6deaffbd
...
@@ -39,10 +39,7 @@ export type ErrorRecord = {|
...
@@ -39,10 +39,7 @@ export type ErrorRecord = {|
stackFrames
:
StackFrame
[],
stackFrames
:
StackFrame
[],
|
};
|
};
export
function
listenToRuntimeErrors
(
export
function
listenToRuntimeErrors
(
crash
:
ErrorRecord
=>
void
)
{
crash
:
ErrorRecord
=>
void
,
filename
:
string
=
'
/static/js/bundle.js
'
)
{
function
crashWithFrames
(
error
:
Error
,
unhandledRejection
=
false
)
{
function
crashWithFrames
(
error
:
Error
,
unhandledRejection
=
false
)
{
getStackFrames
(
error
,
unhandledRejection
,
CONTEXT_SIZE
)
getStackFrames
(
error
,
unhandledRejection
,
CONTEXT_SIZE
)
.
then
(
stackFrames
=>
{
.
then
(
stackFrames
=>
{
...
@@ -71,7 +68,7 @@ export function listenToRuntimeErrors(
...
@@ -71,7 +68,7 @@ export function listenToRuntimeErrors(
{
{
message
:
data
.
message
,
message
:
data
.
message
,
stack
:
data
.
stack
,
stack
:
data
.
stack
,
__unmap_source
:
filename
,
__unmap_source
:
'
/static/js/bundle.js
'
,
},
},
false
false
);
);
...
...
This diff is collapsed.
Click to expand it.
packages/react-error-overlay/src/utils/getSourceMap.js
+
1
-
1
View file @
6deaffbd
...
@@ -77,7 +77,7 @@ class SourceMap {
...
@@ -77,7 +77,7 @@ class SourceMap {
}
}
}
}
function
extractSourceMapUrl
(
fileUri
:
string
,
fileContents
:
string
)
{
function
extractSourceMapUrl
(
fileUri
:
string
,
fileContents
:
string
)
:
Promise
<
string
>
{
const
regex
=
/
\/\/[
#@
]
?
sourceMappingURL=
([^\s
'"
]
+
)\s
*$/gm
;
const
regex
=
/
\/\/[
#@
]
?
sourceMappingURL=
([^\s
'"
]
+
)\s
*$/gm
;
let
match
=
null
;
let
match
=
null
;
for
(;;)
{
for
(;;)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets