0.8.0
deftypes and more!
My main goal of this release was to add support for ClojureScript types. It turned out that rendering type fields, protocols and their details is somewhat complex. So I decided to rewrite rendering subsystem to use hiccup-like templates instead of rendering raw JSON-ML templates by hand. And when I was at it, I decided to do other major changes and refactoring. Please refer to upgrading section below and report any unexpected breaking issues.
deftypes, defrecords and protocols
Please consider this code:
In the console you can see that logged items have azure wrapping with white type name on the right.
The first log statement logs just the MyType
type (a javascript constructor function). We can drill down and see its details in the expanded body:
You can see basis of three fields p1
, p2
and p3
, namespace in which the type was defined and have possibility to drill down to underlying javascript object.
Let's inspect the second logged value, it was an instance of MyType
:
The header displays abbreviated field values, more details can be seen in expanded body. For example protocols are presented there as well. We can inspect some. Let's look at MyProtocol
:
Neat! It gives us a list of defined methods, their arities and a possibility to drill down into individual anonymous functions.
Let's look at the third logged value, which was an instance of MyRecord
:
Because records implement ISequable
protocol, we get offered an extra disclosure triangle in front of the type to inspect sequable representation. Also note that yellow part in header. That part was printed because records implement IPrintWithWriter
.
We can still drill down into type details (records are "rich" types with bunch of implemented protocols):
As you can see, our record implements 14 protocols. Note that yellow-ish protocols are implemented using fast-path dispatch.
And as the last example, let's look at MyMinimalType
instance which has no fields:
The empty set symbol should hint at no fields. We can drill down into raw javascript representation to inspect guts of the underlying javascript object. Please note the white background when we get back in javascript lands.
Experimental :async feature
I'm a heavy user of core.async
, this new :async
feature allows display of long chains of async stack traces in Chrome DevTools Sources Panel.
Read more details in the FAQ.
Upgrading
If you have installed cljs-devtools without custom configuration you have nothing to do. Easy!
Have you used :preloads
as described in the previous release? If you did some config overrides, please change :tooling-config
key to :external-config
(:external-config
still works, but it will be deprecated in the future). This change is for Figwheel compatibility.
Full documentation for using preloads has been add to the installation docs.
Also I decided to change keyword names for individual features:
:custom-formatters
-> :formatters
:sanity-hints
-> :hints
Old keys still work, but will be deprecated in the future.
If you have used devtools.format.IDevtoolsFormat
protocol for writing your own custom rendering, please use devtools.protocols.IFormat
instead.
In case you used some functions from devtools.format
namespace while implementing custom rendering, please look at the deprecated versions of those functions and consider using new hiccup-like APIs from markup.cljs. After composing markup template data, you want to use render-markup
function to render final JSON-ML. Look for inspiration in this commit.
Notable commits:
86dbbbb add experimental :async feature
ccb9f8d wrap IPrintWithWriter products as references if needed (#21)
8dbb865 use devtools.protocols.IFormat instead of IDevtoolsFormat
e5e963e rename template
to make-template
2b09ecd rename surrogate
to make-surrogate
e230645 treat js objects with selected cljs protocols as coming from cljs land
55b4d0b read configuration from :external-config, deprecate :tooling-config
952d6c6 initial types/instances support
5583bf8 move defaults-pref to devtools.defaults
01908f4 rename custom-formatters to formatters
3820bfe rename sanity-hints to hints
ca5296f rename prefs.clj to defaults.clj
b630d01 provide complete list of :well-known-types
2598c2c implement proper-demunge which is js-reserved? aware
b7b0ce2 introduce proper-arg-demunge, which is aware of leading underscore
82d2055 dance around issue #22
95b9578 introduce :min-expandable-sequable-count-for-well-known-types
3a92c64 do not offer expanding of empty sequables
806dd24 allow control of rendering atomic templates via prefs
62e412f reimplement some old apis in devtools.format and mark them as deprecated
All new work: v0.7.2...v0.8.0