Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
html2pdf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Lukas Niegsch
html2pdf
Commits
d97d8849
Commit
d97d8849
authored
Jul 25, 2022
by
lukas.niegsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed attach/detach + instant event loading problems
parent
d9f6a733
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
24 deletions
+18
-24
gadget_converter.js
gadget_converter.js
+4
-5
gadget_devtools.js
gadget_devtools.js
+14
-19
No files found.
gadget_converter.js
View file @
d97d8849
...
...
@@ -35,10 +35,6 @@
var
targetId
;
var
sessionId
;
var
base64data
;
/**
* todo: detaching should reset session properly
* todo: close target stops receiving messages ...
*/
return
gadget
.
getDeclaredGadget
(
"
devtools
"
)
.
push
(
function
(
subgadget
)
{
return
subgadget
.
getDevtools
();
...
...
@@ -76,7 +72,10 @@
})
.
push
(
function
(
result
)
{
base64data
=
result
.
data
;
// return devtools.Target.closeTarget({targetId: targetId});
return
devtools
.
Target
.
detachFromTarget
({
sessionId
:
sessionId
});
})
.
push
(
function
()
{
return
devtools
.
Target
.
closeTarget
({
targetId
:
targetId
});
})
.
push
(
function
()
{
return
base64data
;
...
...
gadget_devtools.js
View file @
d97d8849
...
...
@@ -69,6 +69,7 @@ var BROWSER_PASSWORD = "ignored";
method
:
`
${
domain
.
domain
}
.
${
method
.
name
}
`
,
params
:
params
,
}
console
.
log
(
command
);
var
message
=
JSON
.
stringify
(
command
);
gadget
.
state
.
websocket
.
send
(
message
);
var
handler
=
{
...
...
@@ -78,6 +79,7 @@ var BROWSER_PASSWORD = "ignored";
error
:
reject
}
gadget
.
state
.
handlers
.
add
(
handler
);
return
gadget
.
changeState
({
update
:
true
});
}
return
RSVP
.
Queue
().
push
(
function
()
{
return
RSVP
.
Promise
(
callback
);
...
...
@@ -103,6 +105,7 @@ var BROWSER_PASSWORD = "ignored";
error
:
reject
}
gadget
.
state
.
handlers
.
add
(
handler
);
return
gadget
.
changeState
({
update
:
true
});
}
return
RSVP
.
Queue
().
push
(
function
()
{
return
RSVP
.
Promise
(
callback
);
...
...
@@ -140,14 +143,9 @@ var BROWSER_PASSWORD = "ignored";
}
let
detachFromTarget
=
devtoolsAPI
.
Target
.
detachFromTarget
;
devtoolsAPI
.
Target
.
detachFromTarget
=
(
params
)
=>
{
var
response
;
return
detachFromTarget
(
params
)
.
push
(
function
(
result
)
{
response
=
result
;
return
gadget
.
changeState
({
sessionId
:
gadget
.
state
.
browserId
});
})
return
gadget
.
changeState
({
sessionId
:
undefined
})
.
push
(
function
()
{
return
response
;
return
detachFromTarget
(
params
)
;
})
}
return
gadget
.
changeState
({
devtools
:
devtoolsAPI
});
...
...
@@ -185,14 +183,14 @@ var BROWSER_PASSWORD = "ignored";
* @param {object} message The message that contains the result data.
* @param {object} gadget The gadget that contains all the handlers.
*/
function
handleMethodMessage
(
gadget
,
message
)
{
function
handleMethodMessage
(
gadget
,
message
)
{
for
(
let
it
=
gadget
.
state
.
handlers
.
values
(),
handler
=
null
;
handler
=
it
.
next
().
value
;)
{
if
(
handler
.
id
!=
message
.
id
)
{
continue
;
}
gadget
.
state
.
handlers
.
delete
(
handler
);
gadget
.
state
.
messages
.
delete
(
message
);
if
(
'
error
'
in
message
)
{
handler
.
error
(
message
.
error
);
...
...
@@ -207,9 +205,12 @@ var BROWSER_PASSWORD = "ignored";
* @param {object} message The message that contains the event data.
* @param {object} gadget The gadget that contains all the handlers.
*/
function
handleEventMessage
(
gadget
,
message
)
{
function
handleEventMessage
(
gadget
,
message
)
{
for
(
let
it
=
gadget
.
state
.
handlers
.
values
(),
handler
=
null
;
handler
=
it
.
next
().
value
;)
{
setTimeout
(
function
()
{
gadget
.
state
.
messages
.
delete
(
message
);
},
5000
);
if
(
handler
.
method
!=
message
.
method
)
{
continue
;
}
...
...
@@ -221,8 +222,8 @@ var BROWSER_PASSWORD = "ignored";
rJS
(
window
)
.
setState
({
update
:
false
,
websocket
:
null
,
browserId
:
undefined
,
sessionId
:
undefined
,
nextIndex
:
0
,
handlers
:
null
,
...
...
@@ -236,11 +237,6 @@ var BROWSER_PASSWORD = "ignored";
return
getBrowserJSON
(
"
json/version
"
)
.
push
(
function
(
result
)
{
var
browserUrl
=
result
.
webSocketDebuggerUrl
;
// todo: somehow fetch browser id:
// -> not: browserUrl.split("/").slice(-1)[0]
// -> not: Target.getTargets()[x].browserContextId
// -> not: reopen new websocket on Target.detachFromTarget()
gadget
.
state
.
browserId
=
undefined
;
return
updateWebsocket
(
gadget
,
browserUrl
);
})
.
push
(
function
()
{
...
...
@@ -263,16 +259,15 @@ var BROWSER_PASSWORD = "ignored";
})
.
onStateChange
(
function
()
{
var
gadget
=
this
;
gadget
.
state
.
update
=
false
;
for
(
let
it
=
gadget
.
state
.
messages
.
values
(),
message
=
null
;
message
=
it
.
next
().
value
;)
{
console
.
log
(
message
);
if
(
message
.
hasOwnProperty
(
"
id
"
))
{
handleMethodMessage
(
gadget
,
message
);
}
if
(
message
.
hasOwnProperty
(
"
method
"
))
{
handleEventMessage
(
gadget
,
message
);
}
gadget
.
state
.
messages
.
delete
(
message
);
}
})
}(
window
,
rJS
,
RSVP
));
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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