aboutsummaryrefslogtreecommitdiffstats
path: root/src/devtools-protocol.lisp
blob: 2d6703322a7e6e00c4a8c1c05d6367c6ce42a7b4 (plain)
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
;;;; DevTools Protocol messages.

(in-package :extreload)

(defun target-get-targets-msg (call-id)
  "DevTools Protocol `Target.getTargets` message."
  (jsown:to-json
    `(:obj ("id" . ,call-id)
           ("method" . "Target.getTargets"))))

(defun target-attach-to-target-msg (call-id target-id)
  "DevTools Protocol `Target.attachToTarget` message."
  (jsown:to-json
    `(:obj ("id" . ,call-id)
           ("method" . "Target.attachToTarget")
           ("params" . (:obj ("targetId" . ,target-id)
                             ("flatten" . t))))))

(defun target-attached-to-target-msg-p (message)
  "Returns true if `message` is `Target.attachedToTarget`."
  (equal
    (json-obj-get message "method")
    "Target.attachedToTarget"))

(defun runtime-evaluate-msg (call-id session-id expression)
  "DevTools Protocol `Runtime.evaluate` message."
  (jsown:to-json
    `(:obj ("id" . ,call-id)
           ("sessionId" . ,session-id)
           ("method" . "Runtime.evaluate")
           ("params" . (:obj ("expression" . ,expression))))))

(defun runtime-evaluate-msg-p (message)
  "Returns true if `message` is a response to `Runtime.evaluate`."
  (jsown:keyp (json-obj-get message "result") "sessionId"))

(defun runtime-evaluate-exception-p (message)
  "Returns true if `message` describes a runtime exception"
  (jsown:keyp (json-obj-get message "result") "exceptionDetails"))

(defun parse-get-targets-response (response)
  "Parses a list of target info objects from the response to `Target.getTargets`."
  (let* ((result (json-obj-get response "result"))
         (targetInfos (json-obj-get result "targetInfos")))
    targetInfos))