Liking cljdoc? Tell your friends :D

cider.piggieback.cljs

The ClojureScript implementation of Piggieback's nREPL middleware.

Loaded lazily by cider.piggieback, and only when ClojureScript is on the classpath. All of Piggieback's coupling to the ClojureScript compiler internals (cljs.repl, cljs.analyzer, cljs.env, cljs.closure, cljs.tagged-literals) lives here, so the public cider.piggieback namespace carries no hard dependency on ClojureScript.

The session-state dynamic vars and two pure helpers (forwarding-writer, UnknownTaggedLiteral) live in cider.piggieback, referred to here as pb.

The ClojureScript implementation of Piggieback's nREPL middleware.

Loaded lazily by `cider.piggieback`, and only when ClojureScript is on the
classpath. All of Piggieback's coupling to the ClojureScript compiler
internals (`cljs.repl`, `cljs.analyzer`, `cljs.env`, `cljs.closure`,
`cljs.tagged-literals`) lives here, so the public `cider.piggieback` namespace
carries no hard dependency on ClojureScript.

The session-state dynamic vars and two pure helpers (`forwarding-writer`,
`UnknownTaggedLiteral`) live in `cider.piggieback`, referred to here as `pb`.
raw docstring

analyzer-envclj

(analyzer-env ns-sym)

An empty analyzer environment scoped to ns-sym.

An empty analyzer environment scoped to `ns-sym`.
sourceraw docstring

build-optsclj

(build-opts repl-opts options)

Initialise the repl options the way cljs.repl/repl* would internally. We evaluate outside of that loop, so we have to do this ourselves.

Initialise the repl options the way `cljs.repl/repl*` would internally. We
evaluate outside of that loop, so we have to do this ourselves.
sourceraw docstring

cljs-replclj

(cljs-repl repl-env & {:as options})

Starts a ClojureScript REPL over top an nREPL session. Accepts all options usually accepted by e.g. cljs.repl/repl.

Starts a ClojureScript REPL over top an nREPL session.  Accepts
all options usually accepted by e.g. cljs.repl/repl.
sourceraw docstring

current-nsclj

(current-ns)

The current ClojureScript namespace (a symbol).

The current ClojureScript namespace (a symbol).
sourceraw docstring

default-caughtclj

The default :caught handler (cljs.repl/repl-caught).

The default `:caught` handler (`cljs.repl/repl-caught`).
sourceraw docstring

default-compiler-envclj

(default-compiler-env opts)

A fresh ClojureScript compiler environment for opts.

A fresh ClojureScript compiler environment for `opts`.
sourceraw docstring

delegating-repl-envclj

(delegating-repl-env repl-env)

Wrap repl-env in a delegating env with a no-op -tear-down.

Wrap `repl-env` in a delegating env with a no-op `-tear-down`.
sourceraw docstring

describe-cljsclj

(describe-cljs {:keys [session]})

A describe-fn (see nREPL's wrap-describe) that contributes Piggieback's per-session ClojureScript status to the describe response's :aux map.

Lets tooling detect whether the session is currently evaluating ClojureScript (and against which repl-env), instead of having to infer it out of band.

A describe-fn (see nREPL's `wrap-describe`) that contributes Piggieback's
per-session ClojureScript status to the `describe` response's `:aux` map.

Lets tooling detect whether the session is currently evaluating ClojureScript
(and against which repl-env), instead of having to infer it out of band.
sourceraw docstring

do-evalclj

(do-eval {:keys [session transport code file ns] :as msg})
source

ensure-close-teardown!clj

(ensure-close-teardown! session)

Augment the session's :close metadata (once) so that closing the session also tears down any active ClojureScript repl-env.

nREPL's session middleware handles the close op itself and never delegates it to Piggieback, so we can't intercept it as an op. Instead we compose our teardown into the :close fn that nrepl.middleware.session/close-session invokes. Without this, closing a session (or a client exiting) without first sending :cljs/quit leaks the JavaScript runtime, e.g. a Node subprocess.

Augment the session's `:close` metadata (once) so that closing the session
also tears down any active ClojureScript repl-env.

nREPL's session middleware handles the `close` op itself and never delegates
it to Piggieback, so we can't intercept it as an op. Instead we compose our
teardown into the `:close` fn that `nrepl.middleware.session/close-session`
invokes. Without this, closing a session (or a client exiting) without first
sending `:cljs/quit` leaks the JavaScript runtime, e.g. a Node subprocess.
sourceraw docstring

eval-bindingsclj

(eval-bindings compiler-env repl-env)

Binding map of the ClojureScript analyzer/compiler dynamic vars needed for a single evaluation. compiler-env and repl-env come from the session.

Binding map of the ClojureScript analyzer/compiler dynamic vars needed for a
single evaluation. `compiler-env` and `repl-env` come from the session.
sourceraw docstring

eval-cljsclj

(eval-cljs repl-env env form file opts)
source

eval-formclj

(eval-form repl-env env form file opts print-fn)

Evaluate a single ClojureScript form in repl-env/env. opts are the repl options; print-fn is the name of nREPL's requested print function, used to pick a result-wrapping strategy.

Evaluate a single ClojureScript `form` in `repl-env`/`env`. `opts` are the
repl options; `print-fn` is the name of nREPL's requested print function, used
to pick a result-wrapping strategy.
sourceraw docstring

GetReplEnvcljprotocol

get-repl-envclj

(get-repl-env this)
source

load-sourceclj

(load-source repl-env source filename)

Load ClojureScript source (a string of one or more forms) as if it were the file at filename, evaluating each form in repl-env.

Unlike cljs.repl/load-file, this loads the source handed to it rather than reading the file from disk, so unsaved editor buffers load correctly. The current analyzer namespace is restored afterwards, matching the behaviour of cljs.repl/load-file.

Load ClojureScript `source` (a string of one or more forms) as if it were the
file at `filename`, evaluating each form in `repl-env`.

Unlike `cljs.repl/load-file`, this loads the source handed to it rather than
reading the file from disk, so unsaved editor buffers load correctly. The
current analyzer namespace is restored afterwards, matching the behaviour of
`cljs.repl/load-file`.
sourceraw docstring

ns-varclj

The ClojureScript analyzer's current-namespace var. Exposed so the handlers can use it as a key in binding maps and in the session atom without naming a compiler internal directly.

The ClojureScript analyzer's current-namespace var. Exposed so the handlers
can use it as a key in `binding` maps and in the session atom without naming a
compiler internal directly.
sourceraw docstring

read-formclj

(read-form form-str)

Read a single ClojureScript form from form-str, with the cljs data readers and the current namespace's alias map in place. Returns nil for blank input.

Read a single ClojureScript form from `form-str`, with the cljs data readers
and the current namespace's alias map in place. Returns nil for blank input.
sourceraw docstring

repl-caughtclj

(repl-caught session transport nrepl-msg err repl-env repl-options)
source

repl-optionsclj

(repl-options repl-env)

The repl-env's own repl options (cljs.repl/-repl-options).

The repl-env's own repl options (`cljs.repl/-repl-options`).
sourceraw docstring

set-current-ns!clj

(set-current-ns! ns-sym)

Set the current ClojureScript namespace. Must run on a thread where ns-var is bound.

Set the current ClojureScript namespace. Must run on a thread where
`ns-var` is bound.
sourceraw docstring

setup-replclj

(setup-repl repl-env compiler-env options init-ns code)

Drive cljs.repl/repl* through a single setup form (the cljs.user namespace require), starting from analyzer namespace init-ns.

This is the one place we drive the full repl* loop rather than evaluating forms ourselves; everything else goes through eval-form. The setup form always switches into cljs.user, and the compiler env is the one we passed in, so the caller can read both back directly after this returns - no callback or :print side-channel needed.

Drive `cljs.repl/repl*` through a single setup form (the `cljs.user`
namespace require), starting from analyzer namespace `init-ns`.

This is the one place we drive the full `repl*` loop rather than evaluating
forms ourselves; everything else goes through `eval-form`. The setup form
always switches into `cljs.user`, and the compiler env is the one we passed in,
so the caller can read both back directly after this returns - no callback or
`:print` side-channel needed.
sourceraw docstring

special-fnsclj

(special-fns repl-options)

The REPL special functions, merging the cljs defaults with any provided by the repl options.

The REPL special functions, merging the cljs defaults with any provided by
the repl options.
sourceraw docstring

tear-down!clj

(tear-down! repl-env)

Tear down the (unwrapped) repl env.

Tear down the (unwrapped) repl env.
sourceraw docstring

warning-handlersclj

(warning-handlers)
source

warningsclj

(warnings)
source

wrap-cljs-replclj

(wrap-cljs-repl handler)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close