Toggle navigation
Toggle navigation
This project
Loading...
Sign in
arcs
/
arcs.js
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Yves Didier
2024-03-17 23:17:15 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
15b3c4b52310ba2c70bd25e4f452eb336ce26aaf
15b3c4b5
1 parent
320f9852
bug removal in remote console
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
14 deletions
src/mobile_debug.js → src/remote_console.js
src/remoteconsole.js
src/
mobile_debug
.js
→
src/
remote_console
.js
View file @
15b3c4b
let
address
=
'ws://localhost:8088'
;
class
Mobil
eConsole
{
class
ARCSRemot
eConsole
{
#
stack
=
[];
#
server
;
#
idxSource
;
constructor
(
address
)
{
this
.
#
server
=
new
globalThis
.
WebSocket
(
address
);
this
.
#
idxSource
=
(
navigator
.
userAgent
.
match
(
/firefox|fxios/i
))?
2
:
3
;
this
.
#
idxSource
=
(
globalThis
.
navigator
.
userAgent
.
match
(
/firefox|fxios/i
))?
2
:
3
;
let
self
=
this
;
this
.
#
server
.
onopen
=
function
()
{
...
...
@@ -15,7 +14,6 @@ class MobileConsole {
}
}
#
currentPlace
()
{
let
err
=
new
Error
();
let
lst
=
err
.
stack
.
split
(
"\n"
);
...
...
@@ -68,16 +66,19 @@ class MobileConsole {
warn
=
this
.
notify
(
'warn'
);
error
=
this
.
notify
(
'error'
);
static
init
(
address
)
{
let
_address
=
address
||
'ws://localhost:8088'
;
const
remoteConsole
=
new
ARCSRemoteConsole
(
address
);
}
const
console
=
globalThis
.
console
;
console
.
error
=
remoteConsole
.
error
;
console
.
warn
=
remoteConsole
.
warn
;
console
.
info
=
remoteConsole
.
info
;
console
.
log
=
remoteConsole
.
log
;
console
.
tainted
=
true
;
const
window
=
globalThis
.
window
;
window
.
onerror
=
remoteConsole
.
runtimeException
;
}
console
.
error
=
MobileConsole
.
error
;
console
.
warn
=
MobileConsole
.
warn
;
console
.
info
=
MobileConsole
.
info
;
console
.
log
=
MobileConsole
.
log
;
window
.
onerror
=
MobileConsole
.
runtimeException
;
console
.
tainted
=
true
;
}
...
...
src/remoteconsole.js
0 → 100644
View file @
15b3c4b
class
RemoteConsole
{
#
stack
=
[];
#
server
;
#
idxSource
;
_log
=
globalThis
.
console
.
log
;
_info
=
globalThis
.
console
.
info
;
_warn
=
globalThis
.
console
.
warn
;
_error
=
globalThis
.
console
.
error
;
constructor
(
address
)
{
let
self
=
this
;
console
.
error
=
this
.
error
;
console
.
warn
=
this
.
warn
;
console
.
info
=
this
.
info
;
console
.
log
=
this
.
log
;
console
.
tainted
=
true
;
if
(
globalThis
.
window
)
{
globalThis
.
window
.
onerror
=
this
.
runtimeException
;
}
if
(
globalThis
.
WebSocket
&&
globalThis
.
navigator
)
{
this
.
#
server
=
new
globalThis
.
WebSocket
(
address
);
this
.
#
idxSource
=
(
globalThis
.
navigator
.
userAgent
.
match
(
/firefox|fxios/i
))?
2
:
3
;
this
.
#
server
.
onopen
=
function
()
{
self
.
flush
();
}
}
}
#
currentPlace
()
{
let
err
=
new
Error
();
let
lst
=
err
.
stack
.
split
(
"\n"
);
return
lst
[
this
.
#
idxSource
];
}
#
send
(
data
)
{
if
(
!
this
.
#
server
)
return
;
if
(
this
.
#
server
.
readyState
===
WebSocket
.
OPEN
)
{
this
.
#
server
.
send
(
data
);
}
else
{
this
.
#
stack
.
push
(
data
);
}
}
#
flush
()
{
if
(
!
this
.
#
server
)
return
;
if
(
this
.
#
server
.
readyState
!==
WebSocket
.
OPEN
)
return
;
this
.
#
stack
.
forEach
(
elt
=>
this
.
#
server
.
send
(
elt
));
this
.
#
stack
=
[];
}
#
notify
(
type
)
{
let
self
=
this
;
return
function
()
{
let
obj
=
{
type
,
args
:
Array
.
from
(
arguments
),
context
:
self
.
#
currentPlace
()
};
self
[
`_
${
type
}
`
].
apply
(
globalThis
.
console
,
obj
.
args
);
let
serializedObject
=
""
;
try
{
serializedObject
=
JSON
.
stringify
(
obj
);
}
catch
(
e
)
{
obj
.
args
=
[
'Argument(s) not serializable'
];
serializedObject
=
JSON
.
stringify
(
obj
);
}
self
.
#
send
(
serializedObject
);
};
}
#
runtimeException
(
msg
,
url
,
line
,
column
,
err
)
{
if
(
!
this
.
#
server
)
return
false
;
this
.
#
server
.
send
(
JSON
.
stringify
(
{
type
:
"exception"
,
args
:
[{
message
:
msg
,
url
:
url
,
line
:
line
,
column
:
column
}]
}
)
);
return
false
;
}
log
=
this
.
#
notify
(
'log'
);
info
=
this
.
#
notify
(
'info'
);
warn
=
this
.
#
notify
(
'warn'
);
error
=
this
.
#
notify
(
'error'
);
};
export
default
RemoteConsole
;
Please
register
or
login
to post a comment