CrossClj

org.clojure/clojurescript cljs.repl.browser 1.10.312

SourceDocs



RECENT
    VARS
    -main
    add-in-order
    browser-eval
    browser-state
    compile-client-js
    constrain-order
    create-client-js-file
    es
    ext->mime-type
    handle-post
    load-javascript
    mime-type->encoding
    ordering
    repl-client-js
    repl-env
    return-value
    run-in-order
    send-for-eval
    send-repl-client-page
    send-static
    set-return-value-fn

    \"\n \"\"\n \"\")\n \"text/html\"))\n\n\"ç@_send-static\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@dsend-staticç@/fun/cljs.repl.browser/send-static.html\" [{path :path :as request} conn opts]\n (if (\"ç@aandç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_and\" (:static-dir opts)\n (\"ç@anot=ç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_not%3D\" \"/favicon.ico\" path))\n (\"ç@aletç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_let\" [path (if (\"ç@a=ç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_%3D\" \"/\" path) \"/index.html\" path)\n st-dir (:static-dir opts)\n local-path\n (\"ç@acond->ç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_cond-%3E\"\n (\"ç@aseqç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_seq\" (\"ç@aforç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_for\" [x (if (\"ç@astring?ç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_string%3F\" st-dir) [st-dir] st-dir)\n :when (\"çç@.existsç@docs.oracle.com/javase/8/docs/api/java/io/File.html#exists--\" (\"ç@aio/fileç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.java.io.html#_file\" (\"ç@astrç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_str\" x path)))]\n (\"ç@astrç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_str\" x path)))\n (\"ç@acomplementç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_complement\" \"ç@anil?ç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_nil%3F\") \"ç@afirstç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_first\")\n local-path\n (if (\"ç@anil?ç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_nil%3F\" local-path)\n (\"ç@acondç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_cond\"\n (\"ç@are-findç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_re-find\" #\".jar\" path)\n (\"ç@aio/resourceç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.java.io.html#_resource\" (\"ç@asecondç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_second\" (\"ç@astring/splitç@/ns/org.clojure/clojurescript/1.10.312/clojure.string.html#_split\" path #\".jar!/\")))\n (\"ç@are-findç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_re-find\" (Pattern/compile (\"çç@System/getPropertyç@docs.oracle.com/javase/8/docs/api/java/lang/System.html#getProperty-java.lang.String-\" \"user.dir\")) path)\n (\"ç@aio/fileç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.java.io.html#_file\" (\"ç@astring/replaceç@/ns/org.clojure/clojurescript/1.10.312/clojure.string.html#_replace\" path (\"ç@astrç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_str\" (\"çç@System/getPropertyç@docs.oracle.com/javase/8/docs/api/java/lang/System.html#getProperty-java.lang.String-\" \"user.dir\") \"/\") \"\"))\n :else nil)\n local-path)]\n (if local-path\n (\"ç@aif-letç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_if-let\" [ext (\"ç@asomeç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_some\" #(if (.endsWith path %) %) (\"ç@akeysç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_keys\" \"ç@pext->mime-typeç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_ext-%3Emime-type\"))]\n (\"ç@aletç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_let\" [mime-type (\"ç@pext->mime-typeç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_ext-%3Emime-type\" ext \"text/plain\")\n encoding (\"ç@pmime-type->encodingç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_mime-type-%3Eencoding\" mime-type \"UTF-8\")]\n (server/send-and-close\n conn\n 200\n (\"ç@aslurpç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_slurp\" local-path :encoding encoding)\n mime-type\n encoding))\n (server/send-and-close conn 200 (\"ç@aslurpç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_slurp\" local-path) \"text/plain\"))\n (server/send-404 conn path)))\n (server/send-404 conn path)))\n\n(server/dispatch-on :get\n (\"ç@afnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_fn\" [{:keys [path]} _ _]\n (.startsWith path \"/repl\"))\n \"ç@psend-repl-client-pageç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_send-repl-client-page\")\n\n(server/dispatch-on :get\n (\"ç@afnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_fn\" [{:keys [path]} _ _]\n (\"ç@aorç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_or\" (\"ç@a=ç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_%3D\" path \"/\") (\"ç@asomeç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_some\" #(.endsWith path %) (\"ç@akeysç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_keys\" \"ç@pext->mime-typeç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_ext-%3Emime-type\"))))\n \"ç@psend-staticç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_send-static\")\n\n\"ç@_handle-post\"(\"ç@adefmultiç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defmulti\" \"ç@dhandle-postç@/fun/cljs.repl.browser/handle-post.html\" (\"ç@afnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_fn\" [m _ _ ] (:type m)))\n\n(server/dispatch-on :post (\"ç@aconstantlyç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_constantly\" true) \"ç@phandle-postç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_handle-post\")\n\n(defmethod handle-post :ready [_ conn _]\n (send-via es ordering (fn [_] {:expecting nil :fns {}}))\n (send-for-eval conn\n (binding [ana/*cljs-warnings*\n (assoc ana/*cljs-warnings*\n :undeclared-var false)]\n (cljsc/-compile\n '[(set! *print-fn* clojure.browser.repl/repl-print)\n (set! *print-err-fn* clojure.browser.repl/repl-print)\n (set! *print-newline* true)\n (when (pos? (count clojure.browser.repl/print-queue))\n (clojure.browser.repl/flush-print-queue!\n @clojure.browser.repl/xpc-connection))] {}))\n identity))\n\n\"ç@_add-in-order\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@dadd-in-orderç@/fun/cljs.repl.browser/add-in-order.html\" [{:keys [expecting fns]} order f]\n {:expecting (\"ç@aorç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_or\" expecting order)\n :fns (\"ç@aassocç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_assoc\" fns order f)})\n\n\"ç@_run-in-order\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@drun-in-orderç@/fun/cljs.repl.browser/run-in-order.html\" [{:keys [expecting fns]}]\n (\"ç@aloopç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_loop\" [order expecting fns fns]\n (\"ç@aif-letç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_if-let\" [f (\"ç@agetç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_get\" fns order)]\n (do\n (f)\n (recur (\"ç@aincç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_inc\" order) (\"ç@adissocç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_dissoc\" fns order)))\n {:expecting order :fns fns})))\n\n\"ç@_constrain-order\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@dconstrain-orderç@/fun/cljs.repl.browser/constrain-order.html\"\n \"Elements to be printed in the REPL will arrive out of order. Ensure\n that they are printed in the correct order.\"\n [order f]\n (\"ç@asend-viaç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_send-via\" \"ç@pesç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_es\" \"ç@porderingç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_ordering\" \"ç@padd-in-orderç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_add-in-order\" order f)\n (\"ç@asend-viaç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_send-via\" \"ç@pesç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_es\" \"ç@porderingç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_ordering\" \"ç@prun-in-orderç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_run-in-order\"))\n\n(\"ç@adefmethodç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defmethod\" handle-post :print [{:keys [content order]} conn _ ]\n (\"ç@pconstrain-orderç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_constrain-order\" order\n (\"ç@afnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_fn\" []\n (\"ç@aprintç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_print\" (\"ç@aread-stringç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_read-string\" content))\n (\"çç@.flushç@docs.oracle.com/javase/8/docs/api/java/io/Writer.html#flush--\" \"ç@a*out*ç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_*out*\")))\n (server/send-and-close conn 200 \"ignore__\"))\n\n(\"ç@adefmethodç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defmethod\" handle-post :result [{:keys [content order]} conn _ ]\n (\"ç@pconstrain-orderç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_constrain-order\" order\n (\"ç@afnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_fn\" []\n (\"ç@preturn-valueç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_return-value\" content)\n (server/set-connection conn))))\n\n\"ç@_browser-eval\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@dbrowser-evalç@/fun/cljs.repl.browser/browser-eval.html\"\n \"Given a string of JavaScript, evaluate it in the browser and return a map representing the\n result of the evaluation. The map will contain the keys :type and :value. :type can be\n :success, :exception, or :error. :success means that the JavaScript was evaluated without\n exception and :value will contain the return value of the evaluation. :exception means that\n there was an exception in the browser while evaluating the JavaScript and :value will\n contain the error message. :error means that some other error has occured.\"\n [form]\n (\"ç@aletç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_let\" [return-value (\"ç@apromiseç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_promise\")]\n (\"ç@psend-for-evalç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_send-for-eval\" form\n (\"ç@afnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_fn\" [val] (\"ç@adeliverç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_deliver\" return-value val)))\n (\"ç@aletç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_let\" [ret @return-value]\n (try\n (\"ç@aread-stringç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_read-string\" ret)\n (catch \"çç@Exceptionç@docs.oracle.com/javase/8/docs/api/java/lang/Exception.html\" e\n {:status :error\n :value (\"ç@astrç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_str\" \"Could not read return value: \" ret)})))))\n\n\"ç@_load-javascript\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@dload-javascriptç@/fun/cljs.repl.browser/load-javascript.html\"\n \"Accepts a REPL environment, a list of namespaces, and a URL for a\n JavaScript file which contains the implementation for the list of\n namespaces. Will load the JavaScript file into the REPL environment\n if any of the namespaces have not already been loaded from the\n ClojureScript REPL.\"\n [repl-env provides url]\n (\"ç@pbrowser-evalç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_browser-eval\" (\"ç@aslurpç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_slurp\" url)))\n\n\n;; =============================================================================\n;; BrowserEnv\n\n\"ç@_compile-client-js\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@dcompile-client-jsç@/fun/cljs.repl.browser/compile-client-js.html\" [opts]\n (\"ç@aletç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_let\" [copts {:optimizations (:optimizations opts)\n :output-dir (:working-dir opts)}]\n ;; we're inside the REPL process where cljs.env/*compiler* is already\n ;; established, need to construct a new one to avoid mutating the one\n ;; the REPL uses\n (\"ç@acljsc/buildç@/ns/org.clojure/clojurescript/1.10.312/cljs.closure.html#_build\"\n '[(ns clojure.browser.repl.client\n (:require [goog.events :as event]\n [clojure.browser.repl :as repl]))\n (defn start [url]\n (event/listen js/window\n \"load\"\n (fn []\n (repl/start-evaluator url))))]\n copts (\"ç@aenv/default-compiler-envç@/ns/org.clojure/clojurescript/1.10.312/cljs.env.html#_default-compiler-env\" copts))))\n\n\"ç@_create-client-js-file\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@dcreate-client-js-fileç@/fun/cljs.repl.browser/create-client-js-file.html\" [opts file-path]\n (\"ç@aletç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_let\" [file (\"ç@aio/fileç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.java.io.html#_file\" file-path)]\n (\"ç@awhenç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_when\" (\"ç@anotç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_not\" (\"çç@.existsç@docs.oracle.com/javase/8/docs/api/java/io/File.html#exists--\" file))\n (\"ç@aspitç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_spit\" file (\"ç@pcompile-client-jsç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_compile-client-js\" opts)))\n file))\n\n(defn setup [{:keys [working-dir] :as repl-env} opts]\n (binding [browser-state (:browser-state repl-env)\n ordering (:ordering repl-env)\n es (:es repl-env)\n server/state (:server-state repl-env)]\n (repl/err-out (println \"Compiling client js ...\"))\n (swap! browser-state\n (fn [old]\n (assoc old :client-js\n (create-client-js-file\n repl-env (io/file working-dir \"client.js\")))))\n opts\n (repl/err-out\n (println \"Serving HTTP on\" (:host repl-env) \"port\" (:port repl-env))\n (println \"Listening for browser REPL connect ...\"))\n (server/start repl-env)))\n\n(defrecord BrowserEnv []\n repl/IJavaScriptEnv\n (-setup [this opts]\n (setup this opts))\n (-evaluate [this _ _ js]\n (binding [browser-state (:browser-state this)\n ordering (:ordering this)\n es (:es this)\n server/state (:server-state this)]\n (browser-eval js)))\n (-load [this provides url]\n (load-javascript this provides url))\n (-tear-down [this]\n (binding [server/state (:server-state this)]\n (server/stop))\n (.shutdown (:es this)))\n repl/IReplEnvOptions\n (-repl-options [this]\n {:repl-requires\n '[[clojure.browser.repl]]})\n repl/IParseStacktrace\n (-parse-stacktrace [this st err opts]\n (st/parse-stacktrace this st err opts))\n repl/IGetError\n (-get-error [this e env opts]\n (edn/read-string\n (repl/evaluate-form this env \"\"\n `(when ~e\n (pr-str\n {:ua-product (clojure.browser.repl/get-ua-product)\n :value (str ~e)\n :stacktrace (.-stack ~e)}))))))\n\n(defn repl-env*\n [{:keys [output-dir] :as opts}]\n (merge (BrowserEnv.)\n {:host \"localhost\"\n :port 9000\n :working-dir (->> [\".repl\" (util/clojurescript-version)]\n (remove empty?) (string/join \"-\"))\n :serve-static true\n :static-dir (cond-> [\".\" \"out/\"] output-dir (conj output-dir))\n :preloaded-libs []\n :optimizations :simple\n :src \"src/\"\n :browser-state (atom {:return-value-fn nil\n :client-js nil})\n :ordering (agent {:expecting nil :fns {}})\n :es (Executors/newFixedThreadPool 16)\n :server-state\n (atom\n {:socket nil\n :connection nil\n :promised-conn nil})}\n opts))\n\n\"ç@_repl-env\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@drepl-envç@/fun/cljs.repl.browser/repl-env.html\"\n \"Create a browser-connected REPL environment.\n\n Options:\n\n port: The port on which the REPL server will run. Defaults to 9000.\n working-dir: The directory where the compiled REPL client JavaScript will\n be stored. Defaults to \\\".repl\\\" with a ClojureScript version\n suffix, eg. \\\".repl-0.0-2138\\\".\n serve-static: Should the REPL server attempt to serve static content?\n Defaults to true.\n static-dir: List of directories to search for static content. Defaults to\n [\\\".\\\" \\\"out/\\\"].\n optimizations: The level of optimization to use when compiling the client\n end of the REPL. Defaults to :simple.\n src: The source directory containing user-defined cljs files. Used to\n support reflection. Defaults to \\\"src/\\\".\n \"\n [& {:as opts}]\n (\"ç@prepl-env*ç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_repl-env*\" opts))\n\n\"ç@_-main\"(\"ç@adefnç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_defn\" \"ç@d-mainç@/fun/cljs.repl.browser/-main.html\" []\n (repl/repl (\"ç@prepl-envç@/ns/org.clojure/clojurescript/1.10.312/cljs.repl.browser.html#_repl-env\")))\n\n(\"ç@acommentç@/ns/org.clojure/clojure/1.10.0-alpha4/clojure.core.html#_comment\"\n\n (require '[cljs.repl :as repl])\n (require '[cljs.repl.browser :as browser])\n (def env (browser/repl-env))\n (repl/repl env)\n ;; simulate the browser with curl\n ;; curl -v -d \"ready\" http://127.0.0.1:9000\n ClojureScript:> (+ 1 1)\n ;; curl -v -d \"2\" http://127.0.0.1:9000\n\n )\n");