5 Commits

Author SHA1 Message Date
  Nicolas Petton 8432296709
* .github/FUNDING.yml: Setup for Liberapay 1 month ago
  zerabba 32487a432d Fix github issue #256 5 months ago
  Trevor Murphy 1dd308da49 Disconnect the debugging client when the NodeJS server requests it. 1 month ago
  Trevor Murphy 0535461fe8 Add elisp and js support for disconnecting from the server. 1 month ago
  Trevor Murphy 338eb2ee20 FIX: Define fringe bitmaps even when run in daemon mode. 1 month ago
6 changed files with 56 additions and 17 deletions
Split View
  1. +2
    -2
      .github/FUNDING.yml
  2. +2
    -2
      indium-breakpoint.el
  3. +9
    -2
      indium-client.el
  4. +20
    -11
      indium-nodejs.el
  5. +12
    -0
      server/README.md
  6. +11
    -0
      server/server/connection.js

+ 2
- 2
.github/FUNDING.yml View File

@ -1,12 +1,12 @@
# These are supported funding model platforms
github: [NiolasPetton] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
liberapay: NicolasPetton # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

+ 2
- 2
indium-breakpoint.el View File

@ -214,11 +214,11 @@ overlay."
(when-let ((brk (overlay-get ov 'indium-breakpoint)))
(funcall fn brk ov)))))
(when (and (fboundp 'define-fringe-bitmap) (display-images-p))
(when (fboundp 'define-fringe-bitmap)
(define-fringe-bitmap 'indium-breakpoint-resolved
"\x3c\x7e\xff\xff\xff\xff\x7e\x3c")
(define-fringe-bitmap 'indium-breakpoint-unresolved
"\x3c\x42\x81\x81\x81\x81\x42\x3c"))
"\x3c\x42\x81\x81\x81\x81\x42\x3c"))
(provide 'indium-breakpoint)
;;; indium-breakpoint.el ends here

+ 9
- 2
indium-client.el View File

@ -149,6 +149,14 @@ Once the client is connected, run the hook `indium-client-connected-hook'."
(lambda (&rest _)
(run-hooks 'indium-client-connected-hook))))
(defun indium-client-disconnect (&optional callback)
"Disconnect from the runtime, but do not stop the indium process.
When non-nil, evaluate CALLBACK with the result."
(indium-client-send `((type . "connection")
(payload . ((action . "disconnect"))))
callback))
(defun indium-client-evaluate (expression &optional frame callback)
"Evaluate EXPRESSION in the context of FRAME.
@ -337,8 +345,7 @@ PAYLOAD is an alist with the details of the notification."
(defun indium-client--convert-path (path)
"Convert PATH to a system path that the server component understands."
(when (eq system-type 'windows-nt)
(setq path (replace-regexp-in-string "/" "\\" path nil t))
(setq path (replace-regexp-in-string "^\\([a-z]\\):" #'capitalize path)))
(setq path (replace-regexp-in-string "/" "\\" path nil t)))
path)
(provide 'indium-client)


+ 20
- 11
indium-nodejs.el View File

@ -35,6 +35,7 @@
(require 'subr-x)
(declare-function indium-client-connect "indium-client.el")
(declare-function indium-client-disconnect "indium-client.el")
(defun indium-launch-nodejs (conf)
"Start a NodeJS process.
@ -81,21 +82,29 @@ otherwise use Node's default port (9229)."
(defun indium-nodejs--process-filter-function (conf)
"Return a process filter function for CONF.
The function detects the socket URL to connect to from the
process output."
The function watches the process output to determine when to connect and
disconnect from the process."
(let ((connected))
(lambda (process output)
;; Append output to the process buffer
(with-current-buffer (process-buffer process)
(goto-char (point-max))
(insert output))
(when (and (not connected)
(string-match-p "Debugger listening on" output))
;; Node will keep outputting the "Debugger listening on" message after
;; each deconnection, so only try to connect one.
(setq connected t)
(let-alist conf
(indium-client-connect (file-name-directory .projectFile) .name))))))
(goto-char (point-max))
(insert output))
(cond
((and (not connected)
(string-match-p "Debugger listening on" output))
;; Node will keep outputting the "Debugger listening on" message after
;; each deconnection, so only try to connect one.
(setq connected t)
(let-alist conf
(indium-client-connect (file-name-directory .projectFile) .name)))
((string-match-p "Waiting for the debugger to disconnect" output)
;; When Node receives a signal to exit, it first waits for all
;; debuggers to disconnect before shutting down. Watch for the
;; "Waiting for the debugger to disconnect" message and then do so.
(setq connected nil)
(indium-client-disconnect))))))
(provide 'indium-nodejs)
;;; indium-nodejs.el ends here

+ 12
- 0
server/README.md View File

@ -116,6 +116,18 @@ Array of configurations.
No payload.
#### disconnect
*Request payload:*
| Key | Type or value | Description |
|:-------|:---------------|:------------|
| action | `"disconnect"` | Action type |
*Successful response payload:*
No payload.
#### close
*Request payload:*


+ 11
- 0
server/server/connection.js View File

@ -5,6 +5,8 @@ const connection = (data = {}, { success, error, stop }) => {
switch(data.action) {
case "connect":
return connect(data, { success, error });
case "disconnect":
return disconnect({ success, error });
case "close":
return stop();
default:
@ -61,4 +63,13 @@ const connectToNode = async (options = {}, { success, error }) => {
success("Connected to Node!");
};
const disconnect = async ({ success, error }) => {
try {
await adapter.disconnect();
} catch(e) {
return error(e.message);
}
success("Disconnected");
};
module.exports = connection;

Loading…
Cancel
Save