epc server has been added to john_titor client

This commit is contained in:
Sameer Rahmani 2019-01-14 16:20:48 +00:00
parent 031cbfd031
commit c1e58af798
12 changed files with 172 additions and 99 deletions

View File

@ -1,6 +1,6 @@
{:source-paths ["src"]
:dependencies [[cljs-http "0.1.45"]
[cider/cider-nrepl "0.18.0-SNAPSHOT"]]
:dependencies [[cljs-http "0.1.45"]]
:nrepl {:port 8282}
:builds

View File

@ -0,0 +1,8 @@
(ns john-titor.commands
(:require
[john-titor.commands.protocols :as impl]
[john-titor.commands.echo :as echo]))
(defn router
[server]
(impl/init (echo/->EchoCommand) server))

View File

@ -0,0 +1,11 @@
(ns john-titor.commands.echo
(:require
[john-titor.commands.protocols :as proto :refer [defcommand]]))
(defn- echo [msg]
(str msg "/" msg))
(deftype EchoCommand []
proto/CommandRouter
(init [_ server]
(defcommand server "echo" #(echo %))))

View File

@ -0,0 +1,8 @@
(ns john-titor.commands.protocols)
(defn defcommand [server command-name f]
(.defineMethod server command-name f))
(defprotocol CommandRouter
(init [_ server]
"Define all the commands using the given `server`."))

View File

@ -1,12 +1,16 @@
(ns john-titor.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require
["xhr2" :as xhr2]
[cljs-http.client :as http]
[cljs.core.async :refer [<!]]))
["elrpc" :as epc]
[john-titor.commands :as commands]))
(set! js/XMLHttpRequest xhr2)
(defn main
[])
[]
(.then (.startServer epc)
(fn [server]
(commands/router server)
(.wait server))))

View File

@ -0,0 +1,7 @@
(ns john-titor.utils
(:require
[clojure.core.async :refer [take!]]))
(defn wait-for
[ch]
(take! ch))

View File

@ -2,13 +2,13 @@
(function(){
var SHADOW_IMPORT_PATH = __dirname + '/../.shadow-cljs/builds/app/dev/out/cljs-runtime';
if (__dirname == '.') { SHADOW_IMPORT_PATH = "/home/lxsameer/.fg42/john_titor/.shadow-cljs/builds/app/dev/out/cljs-runtime"; }
if (__dirname == '.') { SHADOW_IMPORT_PATH = "/Users/sameer.rahmani/.fg42/john_titor/.shadow-cljs/builds/app/dev/out/cljs-runtime"; }
global.$CLJS = global;
try {require('source-map-support').install();} catch (e) {console.warn('no "source-map-support" (run "npm install source-map-support --save-dev" to get it)');}
global.CLOSURE_NO_DEPS = true;
global.CLOSURE_DEFINES = {"shadow.cljs.devtools.client.env.repl_pprint":false,"shadow.cljs.devtools.client.env.devtools_url":"","shadow.cljs.devtools.client.env.autoload":false,"shadow.cljs.devtools.client.env.proc_id":"0f38fe63-c013-429e-93ab-1c6a32c04ef0","goog.ENABLE_DEBUG_LOADER":false,"shadow.cljs.devtools.client.env.server_port":9630,"shadow.cljs.devtools.client.env.use_document_host":true,"shadow.cljs.devtools.client.env.module_format":"goog","goog.LOCALE":"en","shadow.cljs.devtools.client.env.build_id":"app","shadow.cljs.devtools.client.env.ignore_warnings":false,"goog.DEBUG":true,"cljs.core._STAR_target_STAR_":"nodejs","shadow.cljs.devtools.client.env.ssl":false,"shadow.cljs.devtools.client.env.enabled":true,"shadow.cljs.devtools.client.env.server_host":"localhost","goog.TRANSPILE":"never"};
global.CLOSURE_DEFINES = {"shadow.cljs.devtools.client.env.repl_pprint":false,"shadow.cljs.devtools.client.env.devtools_url":"","shadow.cljs.devtools.client.env.autoload":false,"shadow.cljs.devtools.client.env.proc_id":"e01e0e97-fd19-4247-a69e-568995e2aeb7","goog.ENABLE_DEBUG_LOADER":false,"shadow.cljs.devtools.client.env.server_port":9630,"shadow.cljs.devtools.client.env.use_document_host":true,"shadow.cljs.devtools.client.env.module_format":"goog","goog.LOCALE":"en","shadow.cljs.devtools.client.env.build_id":"app","shadow.cljs.devtools.client.env.ignore_warnings":false,"goog.DEBUG":true,"cljs.core._STAR_target_STAR_":"nodejs","shadow.cljs.devtools.client.env.ssl":false,"shadow.cljs.devtools.client.env.enabled":true,"shadow.cljs.devtools.client.env.server_host":"localhost","goog.TRANSPILE":"never"};
var goog = global.goog = {};
@ -3040,97 +3040,10 @@ SHADOW_IMPORT("cljs.tools.reader.edn.js");
SHADOW_IMPORT("cljs.reader.js");
SHADOW_IMPORT("shadow.cljs.devtools.client.node.js");
SHADOW_IMPORT("shadow.js.shim.module$xhr2.js");
SHADOW_IMPORT("goog.net.eventtype.js");
SHADOW_IMPORT("goog.net.errorcode.js");
SHADOW_IMPORT("goog.promise.thenable.js");
SHADOW_IMPORT("goog.async.freelist.js");
SHADOW_IMPORT("goog.async.workqueue.js");
SHADOW_IMPORT("goog.debug.entrypointregistry.js");
SHADOW_IMPORT("goog.dom.htmlelement.js");
SHADOW_IMPORT("goog.dom.tagname.js");
SHADOW_IMPORT("goog.labs.useragent.util.js");
SHADOW_IMPORT("goog.labs.useragent.browser.js");
SHADOW_IMPORT("goog.labs.useragent.engine.js");
SHADOW_IMPORT("goog.async.nexttick.js");
SHADOW_IMPORT("goog.async.run.js");
SHADOW_IMPORT("goog.promise.resolver.js");
SHADOW_IMPORT("goog.promise.promise.js");
SHADOW_IMPORT("goog.disposable.idisposable.js");
SHADOW_IMPORT("goog.disposable.disposable.js");
SHADOW_IMPORT("goog.labs.useragent.platform.js");
SHADOW_IMPORT("goog.useragent.useragent.js");
SHADOW_IMPORT("goog.events.browserfeature.js");
SHADOW_IMPORT("goog.events.eventid.js");
SHADOW_IMPORT("goog.events.event.js");
SHADOW_IMPORT("goog.events.eventtype.js");
SHADOW_IMPORT("goog.events.browserevent.js");
SHADOW_IMPORT("goog.events.listenable.js");
SHADOW_IMPORT("goog.events.listener.js");
SHADOW_IMPORT("goog.events.listenermap.js");
SHADOW_IMPORT("goog.events.events.js");
SHADOW_IMPORT("goog.events.eventtarget.js");
SHADOW_IMPORT("goog.timer.timer.js");
SHADOW_IMPORT("goog.json.json.js");
SHADOW_IMPORT("goog.json.hybrid.js");
SHADOW_IMPORT("goog.debug.errorcontext.js");
SHADOW_IMPORT("goog.debug.debug.js");
SHADOW_IMPORT("goog.debug.logrecord.js");
SHADOW_IMPORT("goog.debug.logbuffer.js");
SHADOW_IMPORT("goog.debug.logger.js");
SHADOW_IMPORT("goog.log.log.js");
SHADOW_IMPORT("goog.net.httpstatus.js");
SHADOW_IMPORT("goog.net.xhrlike.js");
SHADOW_IMPORT("goog.net.xmlhttpfactory.js");
SHADOW_IMPORT("goog.net.wrapperxmlhttpfactory.js");
SHADOW_IMPORT("goog.net.xmlhttp.js");
SHADOW_IMPORT("goog.net.xhrio.js");
SHADOW_IMPORT("goog.dom.tags.js");
SHADOW_IMPORT("goog.string.typedstring.js");
SHADOW_IMPORT("goog.string.const.js");
SHADOW_IMPORT("goog.html.safescript.js");
SHADOW_IMPORT("goog.fs.url.js");
SHADOW_IMPORT("goog.i18n.bidi.js");
SHADOW_IMPORT("goog.html.trustedresourceurl.js");
SHADOW_IMPORT("goog.html.safeurl.js");
SHADOW_IMPORT("goog.html.safestyle.js");
SHADOW_IMPORT("goog.html.safestylesheet.js");
SHADOW_IMPORT("goog.html.safehtml.js");
SHADOW_IMPORT("goog.html.legacyconversions.js");
SHADOW_IMPORT("goog.mochikit.async.deferred.js");
SHADOW_IMPORT("goog.dom.browserfeature.js");
SHADOW_IMPORT("goog.dom.asserts.js");
SHADOW_IMPORT("goog.dom.safe.js");
SHADOW_IMPORT("goog.html.uncheckedconversions.js");
SHADOW_IMPORT("goog.math.coordinate.js");
SHADOW_IMPORT("goog.math.size.js");
SHADOW_IMPORT("goog.dom.dom.js");
SHADOW_IMPORT("goog.net.jsloader.js");
SHADOW_IMPORT("goog.net.jsonp.js");
SHADOW_IMPORT("com.cognitect.transit.util.js");
SHADOW_IMPORT("com.cognitect.transit.delimiters.js");
SHADOW_IMPORT("com.cognitect.transit.caching.js");
SHADOW_IMPORT("com.cognitect.transit.eq.js");
SHADOW_IMPORT("com.cognitect.transit.types.js");
SHADOW_IMPORT("com.cognitect.transit.impl.decoder.js");
SHADOW_IMPORT("com.cognitect.transit.impl.reader.js");
SHADOW_IMPORT("com.cognitect.transit.handlers.js");
SHADOW_IMPORT("com.cognitect.transit.impl.writer.js");
SHADOW_IMPORT("com.cognitect.transit.js");
SHADOW_IMPORT("cognitect.transit.js");
SHADOW_IMPORT("goog.crypt.crypt.js");
SHADOW_IMPORT("goog.useragent.product.js");
SHADOW_IMPORT("goog.crypt.base64.js");
SHADOW_IMPORT("no.en.core.js");
SHADOW_IMPORT("cljs_http.util.js");
SHADOW_IMPORT("cljs.core.async.impl.protocols.js");
SHADOW_IMPORT("cljs.core.async.impl.buffers.js");
SHADOW_IMPORT("cljs.core.async.impl.dispatch.js");
SHADOW_IMPORT("cljs.core.async.impl.channels.js");
SHADOW_IMPORT("cljs.core.async.impl.timers.js");
SHADOW_IMPORT("cljs.core.async.impl.ioc_helpers.js");
SHADOW_IMPORT("cljs.core.async.js");
SHADOW_IMPORT("cljs_http.core.js");
SHADOW_IMPORT("cljs_http.client.js");
SHADOW_IMPORT("shadow.js.shim.module$elrpc.js");
SHADOW_IMPORT("john_titor.commands.protocols.js");
SHADOW_IMPORT("john_titor.commands.echo.js");
SHADOW_IMPORT("john_titor.commands.js");
SHADOW_IMPORT("john_titor.core.js");
SHADOW_IMPORT("shadow.module.main.append.js");

View File

@ -0,0 +1,22 @@
;;; john_titor --- RPC client for john_titor
;;; Commentary:
;;; Code:
(require 'fpkg)
(require 'fg42/extension)
(require 'extensions/john_titor/init)
;; Dependencies ----------------------------------
(depends-on 'emacs-epc)
(defun john_titor-doc ()
"TBD"
"TBD")
;; Extension -------------------------------------
(extension john_titor
:version "2.32"
:on-initialize extensions/john_titor-initialize
:docs "lib/extensions/john_titor/readme.org")
(provide 'extensions/john_titor)
;;; john_titor.el ends here

View File

@ -0,0 +1,30 @@
;;; john_title --- Enables RPC for john titor client
;;; Commentary:
;;; Code:
(defvar epc-connection nil
"The EPC connection to the john titor client.")
(defun john_titor/connect ()
"Connect to john titor via RPC."
(interactive)
(setq epc-connection
(epc:start-epc "node" '("../../..//john_titor/target/main.js"))))
(message "%S" (epc:call-sync epc-connection 'echo '(10)))
(defun john_titor/disconnect ()
"Disconnect from the john titor client."
(interactive)
(epc:stop-epc epc-connection))
;;;###autoload
(defun extensions/john_titor-initialize ()
"Initialize the john_titor extention."
(require 'epc)
(if (nilp epc-connection)
(john_titor/connect)))
(provide 'extensions/john_titor/init)
;;; init.el ends here

View File

@ -0,0 +1 @@
sameer.rahmani@MacBook-Pro-4.local.2114

View File

@ -0,0 +1,28 @@
;;; john_title --- Enables RPC for john titor client
;;; Commentary:
;;; Code:
(defvar epc-connection nil
"The EPC connection to the john titor client.")
(defun john_titor/connect ()
"Connect to john titor via RPC."
(interactive)
(setq epc-connection
(epc:start-epc "node" '("~/.fg42/john_titor/target/main.js"))))
(defun john_titor/disconnect ()
"Disconnect from the john titor client."
(interactive)
(epc:stop-epc epc-connection))
;;;###autoload
(defun extensions/john_titor-initialize ()
"Initialize the john_titor extention."
(require 'epc)
(if (nilp epc-connection)
(john_titor/connect)))
(provide 'extensions/john_titor/init)
;;; init.el ends here

View File

@ -0,0 +1,41 @@
(require 'dracula-theme)
(defun themes/color-theme-doom-one-spaceline-faces (face active)
(cond
((eq 'face1 face) (if active 'minibuffer-prompt 'powerline-inactive1))
((eq 'face2 face) (if active 'success 'mode-line-inactive))
((eq 'line face) (if active 'shadow 'shadow))
((eq 'highlight face) (if active 'match 'shadow))))
(defun themes/color-theme-doom-one ()
(interactive)
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-one t)
(custom-theme-set-faces
'doom-one
'(font-lock-comment-face ((t (:foreground "#8B9298"))))
'(font-lock-comment-delimiter-face ((t (:foreground "#5B6268")))))
(enable-theme 'doom-one)
;; brighten buffers (that represent real files)
(add-hook 'after-change-major-mode-hook #'turn-on-solaire-mode)
;; You can do similar with the minibuffer when it is activated:
(add-hook 'minibuffer-setup-hook #'solaire-mode-in-minibuffer)
;; ...if you use auto-revert-mode:
(add-hook 'after-revert-hook #'turn-on-solaire-mode)
;; To enable solaire-mode unconditionally for certain modes:
(add-hook 'ediff-prepare-buffer-hook #'solaire-mode)
;; Enable custom neotree theme
(doom-themes-neotree-config))
(provide 'themes/color-theme-doom-one)