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-15 13:29:01 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f613ff9862e6c3d2a1453ccf63abb6fa3a2192b3
f613ff98
1 parent
9c928285
added mobile debug
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
src/mobile_debug.js
src/mobile_debug.js
0 → 100644
View file @
f613ff9
let
address
=
'ws://localhost:8088'
;
let
server
=
new
WebSocket
(
address
);
let
idxSource
=
(
navigator
.
userAgent
.
match
(
/firefox|fxios/i
))?
2
:
3
;
class
MobileConsole
{
#
stack
=
[];
#
server
;
#
idxSource
;
constructor
(
address
)
{
this
.
#
server
=
new
globalThis
.
WebSocket
(
address
);
this
.
#
idxSource
=
(
navigator
.
userAgent
.
match
(
/firefox|fxios/i
))?
2
:
3
;
let
self
=
this
;
this
.
#
server
.
onopen
=
function
()
{
self
.
flush
();
}
}
#
currentPlace
()
{
let
err
=
new
Error
();
let
lst
=
err
.
stack
.
split
(
"\n"
);
return
lst
[
this
.
#
idxSource
];
}
#
send
(
data
)
{
if
(
server
.
readyState
===
WebSocket
.
OPEN
)
{
server
.
send
(
data
);
}
else
{
this
.
#
stack
.
push
(
data
);
}
}
#
flush
()
{
if
(
server
.
readyState
!==
WebSocket
.
OPEN
)
return
;
this
.
#
stack
.
forEach
(
elt
=>
server
.
send
(
elt
));
this
.
#
stack
=
[];
}
#
notify
(
type
)
{
let
self
=
this
;
return
function
()
{
let
obj
=
{
type
,
args
:
Array
.
from
(
arguments
),
context
:
self
.
#
currentPlace
()
};
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
)
{
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'
);
}
console
.
error
=
MobileConsole
.
error
;
console
.
warn
=
MobileConsole
.
warn
;
console
.
info
=
MobileConsole
.
info
;
console
.
log
=
MobileConsole
.
log
;
window
.
onerror
=
MobileConsole
.
runtimeException
;
console
.
tainted
=
true
;
Please
register
or
login
to post a comment