;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\207" [require cl json web-server] 2) #@39 web-server process of the web socket. (defvar take-off-web-socket-process nil (#$ . 172)) #@12 Web server (defvar take-off-server nil (#$ . 268)) (defvar take-off-docroot (file-name-directory load-file-name)) #@27 Serve file to the request (defalias 'take-off-serve-file #[(request file) "\305\n\306P!\307 \f\"\2030\310\f!\203#\311\312 \313\"\305\f \"\314#\2026\315\312 \313\"\305\f \"\"\2026\316\312 \313\"!*\207" [request #1=#:object take-off-docroot serve-path file expand-file-name "front" ws-in-directory-p file-directory-p ws-send-directory-list slot-value process "^[^.]" ws-send-file ws-send-404] 5 (#$ . 388)]) #@41 Handler that serve all the static files (defalias 'take-off-static-files #[(request) "\302\303\304 \305\"\236A\306\307O\")\207" [request #1=#:object take-off-serve-file :GET slot-value headers 1 nil] 6 (#$ . 807)]) (defalias 'take-off-set-window-pos #[(window hashtable) "\302\303\304\305!#\210 \207" [window hashtable mapcar* #[(key val) "\303 \n#\207" [key val hashtable puthash] 4] (:left :top :right :bottom) window-inside-edges] 5]) #@74 Add window's point location to hashtable if window is the current window (defalias 'take-off-set-point-pos #[(window hashtable) "\306 =\205@\307 \310 \211@\nA@\311\312!\313# @\\\f A@\\\314\315 #\210\314\316 @ #\210\314\317 A@ #.\207" [window pointhash inside-edges left top pos-point-relative selected-window make-hash-table window-inside-edges pos-visible-in-window-p window-point t puthash :point :x :y x-point y-point hashtable] 5 (#$ . 1256)]) #@69 Return a json value representing the current visible state of emacs (defalias 'take-off-visible-data #[nil "\301 \302\303\304 #\210\302\305\306 #\210\302\307\310\311\312 \"#\210\313!)\207" [windows-data make-hash-table puthash :width frame-width :height frame-height :windows mapcar #[(window) "r\304!q\210\305 \306 \"\210\307 \"\210\310\311\n #\210\310\312\313\314!\315!\" #\210\310\316\317 \320# #\210 *\207" [window hash tab-width mode-line-format window-buffer make-hash-table take-off-set-window-pos take-off-set-point-pos puthash :tabWidth :text buffer-substring-no-properties window-start window-end :modeLine format-mode-line t] 6] window-list json-encode] 5 (#$ . 1727)]) #@54 Handle web-socket requests sent by the browser agent (defalias 'take-off-web-socket-receive #[(proc string) "\3051 \306!0\202 \210\307\302 \236\205\302 \236A\303 \236\205#\303 \236A\n\203.\310\311\n!!\210 \2038\312\313 !!\210\314\f\315\316 !\"+\207" [string json key code proc (end-of) json-read-from-string nil execute-kbd-macro kbd eval-expression read process-send-string ws-web-socket-frame take-off-visible-data] 4 (#$ . 2426)]) (defalias 'take-off-change-hook-function #[(beginning end length) "\205 \301\302\303 !\"\207" [take-off-web-socket-process process-send-string ws-web-socket-frame take-off-visible-data] 4]) #@82 Open a web socket connection Assumes request is a web socket connection request. (defalias 'take-off-web-socket-connect #[(request) "\303\304\"\203\305\306 \307\"\202\"\310\306 \307\"\311\312#\210\313\306 \307\"\314\")\207" [request #1=#:object take-off-web-socket-process ws-web-socket-connect take-off-web-socket-receive :keep-alive slot-value process ws-response-header 501 ("Content-Type" . "text/html") ws-send "Unable to create socket"] 4 (#$ . 3070)]) (defalias 'take-off-is-socket-request #[(request) "\301\302\303\304\305\"\236A\"\207" [request string-prefix-p "/socket" :GET eieio-oref headers] 6]) #@60 Start a web server that allows remote web access to emacs. (defalias 'take-off-start #[(port) "\302\303\"\211\207" [port take-off-server ws-start ((take-off-is-socket-request . take-off-web-socket-connect) ((:GET . "^/$") lambda (request) (take-off-serve-file request "emacs.html")) ((:GET . ".*") . take-off-static-files) ((lambda (request) t) lambda (request) (with-slots (process headers) request (ws-response-header process 200 '("Content-Type" . "text/plain")) (process-send-string process "Default handler\n"))))] 3 (#$ . 3693) "nPort number: "]) #@22 Stop the web server. (defalias 'take-off-stop #[nil "\205\302!\210\303 \203\304\305\306\"\210\303\211\207" [take-off-server take-off-web-socket-process ws-stop nil remove-hook after-change-functions take-off-change-hook-function] 3 (#$ . 4254) nil]) (provide 'take-off)