FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-inspector/front-end-node/Overrides.js at master · dshaw/node-inspector · GitHub
dshaw
node-inspector
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node-inspector
/
front-end-node
/
Overrides.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
158 lines (131 loc) · 5.02 KB
Breadcrumbs
node-inspector
/
front-end-node
/
Overrides.js
Copy path
File metadata and controls
158 lines (131 loc) · 5.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Wire up websocket to talk to backend
WebInspector
.
loaded
=
function
(
)
{
WebInspector
.
socket
=
io
.
connect
(
'http://'
+
window
.
location
.
host
+
'/'
)
;
WebInspector
.
socket
.
on
(
'message'
,
onWebSocketMessage
)
;
WebInspector
.
socket
.
on
(
'error'
,
function
(
error
)
{
console
.
error
(
error
)
;
}
)
;
WebInspector
.
socket
.
on
(
'connect'
,
onWebSocketConnected
)
;
}
;
var
_inspectorInitialized
=
false
;
function
onWebSocketConnected
(
)
{
if
(
_inspectorInitialized
)
return
;
InspectorFrontendHost
.
sendMessageToBackend
=
WebInspector
.
socket
.
send
.
bind
(
WebInspector
.
socket
)
;
WebInspector
.
dockController
=
new
WebInspector
.
DockController
(
)
;
WebInspector
.
doLoadedDone
(
)
;
_inspectorInitialized
=
true
;
}
function
onWebSocketMessage
(
message
)
{
if
(
!
message
)
return
;
if
(
message
===
'showConsole'
)
{
WebInspector
.
showConsole
(
)
;
}
else
{
InspectorBackend
.
dispatch
(
message
)
;
}
}
// Disable HTML & CSS inspections
WebInspector
.
queryParamsObject
[
'isSharedWorker'
]
=
true
;
// disable everything besides scripts and console
// that means 'profiles' and 'timeline' at the moment
WebInspector
.
_orig_panelDescriptors
=
WebInspector
.
_panelDescriptors
;
WebInspector
.
_panelDescriptors
=
function
(
)
{
var
panelDescriptors
=
this
.
_orig_panelDescriptors
(
)
;
return
panelDescriptors
.
filter
(
function
(
pd
)
{
return
[
'scripts'
,
'console'
]
.
indexOf
(
pd
.
name
(
)
)
!=
-
1
;
}
)
;
}
;
// Patch the expression used as an initial value for a new watch.
// DevTools' value "\n" breaks the debugger protocol.
importScript
(
'WatchExpressionsSidebarPane.js'
)
;
WebInspector
.
WatchExpressionsSection
.
NewWatchExpression
=
"''"
;
Preferences
.
localizeUI
=
false
;
Preferences
.
applicationTitle
=
'Node Inspector'
;
WebInspector
.
_platformFlavor
=
WebInspector
.
PlatformFlavor
.
MacLeopard
;
// Front-end uses `eval location.href` to get url of inspected page
// This does not work in node.js from obvious reasons, and cause
// a 'null' message to be printed in front-end console.
// Since Preferences.applicationTitle does not include inspected url,
// we can return arbitrary string as inspected URL.
WebInspector
.
WorkerManager
.
_calculateWorkerInspectorTitle
=
function
(
)
{
InspectorFrontendHost
.
inspectedURLChanged
(
''
)
;
}
;
// Do not offer download of the edited file when saving changes to V8.
// DevTools' implementation changes window.location which closes
// web-socket connection to the server and thus breaks the inspector.
InspectorFrontendHost
.
close
=
function
(
url
,
content
,
forceSaveAs
)
{
delete
this
.
_fileBuffers
[
url
]
;
}
;
// Front-end intercepts Cmd+R, Ctrl+R and F5 keys and reloads the debugged
// page instead of the front-end page. We want to disable this behaviour.
WebInspector
.
_orig_documentKeyDown
=
WebInspector
.
documentKeyDown
;
WebInspector
.
documentKeyDown
=
function
(
event
)
{
switch
(
event
.
keyIdentifier
)
{
case
'U+0052'
:
// R key
case
'F5'
:
return
;
}
WebInspector
.
_orig_documentKeyDown
(
event
)
;
}
;
var
orig_createResourceFromFramePayload
=
WebInspector
.
ResourceTreeModel
.
prototype
.
_createResourceFromFramePayload
;
WebInspector
.
ResourceTreeModel
.
prototype
.
_createResourceFromFramePayload
=
function
(
frame
,
url
,
type
,
mimeType
)
{
// Force Script type for all node frames.
// Front-end assigns Document type (i.e. HTML) to our main script file.
if
(
frame
.
_isNodeInspectorScript
)
{
type
=
WebInspector
.
resourceTypes
.
Script
;
}
return
orig_createResourceFromFramePayload
(
frame
,
url
,
type
,
mimeType
)
;
}
;
var
_orig_loadXHR
=
loadXHR
;
var
loadXHR
=
function
patchedLoadXHR
(
url
,
async
,
callback
)
{
var
match
=
url
.
match
(
/
^
f
i
l
e
:
\/
\/
(
.
*
)
$
/
)
;
if
(
match
)
{
var
encodedPath
=
match
[
1
]
.
split
(
'/'
)
.
map
(
encodeURIComponent
)
.
join
(
'/'
)
;
url
=
'/file-resource/'
+
encodedPath
;
}
return
_orig_loadXHR
(
url
,
async
,
callback
)
;
}
//
// Open the main application file on startup
//
WebInspector
.
notifications
.
addEventListener
(
WebInspector
.
Events
.
InspectorLoaded
,
function
(
)
{
WebInspector
.
resourceTreeModel
.
addEventListener
(
WebInspector
.
ResourceTreeModel
.
EventTypes
.
CachedResourcesLoaded
,
showMainAppFile
,
null
)
;
}
,
null
)
;
function
showMainAppFile
(
)
{
var
fileTabs
=
WebInspector
.
showPanel
(
'scripts'
)
.
_editorContainer
.
_files
;
if
(
Object
.
keys
(
fileTabs
)
.
length
>
0
)
{
// Some files are already opened - do not change user's workspace
return
;
}
var
uiSourceCodes
=
getAllUiSourceCodes
(
)
;
var
uriToShow
=
WebInspector
.
inspectedPageURL
;
for
(
var
i
in
uiSourceCodes
)
{
if
(
uiSourceCodes
[
i
]
.
uri
(
)
!==
uriToShow
)
continue
;
WebInspector
.
showPanel
(
'scripts'
)
.
showUISourceCode
(
uiSourceCodes
[
i
]
)
;
return
true
;
}
console
.
error
(
'Cannot show the main application file '
,
uriToShow
)
;
}
function
getAllUiSourceCodes
(
)
{
// Based on FilteredItemSectionDialog.js > SelectUISourceCodeDialog()
var
projects
=
WebInspector
.
workspace
.
projects
(
)
;
var
uiSourceCodes
=
[
]
;
var
projectFiles
;
for
(
var
i
=
0
;
i
<
projects
.
length
;
++
i
)
{
projectFiles
=
projects
[
i
]
.
uiSourceCodes
(
)
.
filter
(
function
(
p
)
{
return
p
.
name
(
)
;
}
)
;
uiSourceCodes
=
uiSourceCodes
.
concat
(
projectFiles
)
;
}
return
uiSourceCodes
;
}
Back
|
FazBrowse Home
|
New Git URL