Initial commit; does not yet work.

This commit is contained in:
Simon Brooke 2020-02-25 09:45:17 +00:00
commit bca0f8492d
600 changed files with 171999 additions and 0 deletions

View file

@ -0,0 +1,88 @@
(ns devtools.formatters.budgeting
(:require-macros [devtools.oops :refer [oget oset ocall]])
(:require [devtools.formatters.templating :refer [render-markup]]
[devtools.formatters.state :refer [get-depth-budget set-depth-budget]]
[devtools.formatters.helpers :refer [pref]]
[devtools.formatters.markup :refer [<header-expander>]]))
; This functionality provides a workaround to issue #22 (https://github.com/binaryage/cljs-devtools/issues/22).
; The idea is to track hierarchy depth for json-ml(s) we are generating.
; If we are about to cross the depth limit hardcoded in WebKit,
; instead we render simple expandable placeholders which resume full rendering in their bodies (when expanded by user).
; Note that this technique has some quirks, it may break styling in some pathological cases.
; we need to reserve some depth levels for our expander symbol markup
(def header-expander-depth-cost 2)
; -- tracking over-budget values -------------------------------------------------------------------------------------------
; note: phantomjs does not have WeakSet, so we have to emulate it when testing
(def over-budget-values (if (exists? js/WeakSet) (js/WeakSet.) (volatile! #{})))
(defn add-over-budget-value! [value]
(if (volatile? over-budget-values)
(vreset! over-budget-values (conj @over-budget-values value))
(ocall over-budget-values "add" value)))
(defn delete-over-budget-value! [value]
(if (volatile? over-budget-values)
(vreset! over-budget-values (disj @over-budget-values value))
(ocall over-budget-values "delete" value)))
(defn has-over-budget-value? [value]
(if (volatile? over-budget-values)
(contains? @over-budget-values value)
(ocall over-budget-values "has" value)))
; -- depth budget accounting ------------------------------------------------------------------------------------------------
(defn object-reference? [json-ml]
(= (first json-ml) "object"))
(defn determine-depth [json-ml]
(if (array? json-ml)
(inc (apply max (map determine-depth json-ml)))
0))
(defn has-any-object-reference? [json-ml]
(if (array? json-ml)
(if (object-reference? json-ml)
true
(some has-any-object-reference? json-ml))))
(defn transfer-remaining-depth-budget! [object-reference depth-budget]
{:pre [(not (neg? depth-budget))]}
(let [data (second object-reference)
_ (assert (object? data))
config (oget data "config")]
(oset data ["config"] (set-depth-budget config depth-budget))))
(defn distribute-budget! [json-ml depth-budget]
{:pre [(not (neg? depth-budget))]}
(if (array? json-ml)
(let [new-depth-budget (dec depth-budget)]
(if (object-reference? json-ml)
(transfer-remaining-depth-budget! json-ml new-depth-budget)
(doseq [item json-ml]
(distribute-budget! item new-depth-budget)))))
json-ml)
; -- api --------------------------------------------------------------------------------------------------------------------
(defn was-over-budget?! [value]
(when (has-over-budget-value? value)
(delete-over-budget-value! value)
true))
(defn alter-json-ml-to-fit-in-remaining-budget! [value json-ml]
(if-let [initial-hierarchy-depth-budget (pref :initial-hierarchy-depth-budget)] ; this is hardcoded in InjectedScriptSource.js in WebKit, look for maxCustomPreviewRecursionDepth
(let [remaining-depth-budget (or (get-depth-budget) (dec initial-hierarchy-depth-budget))
depth (determine-depth json-ml)
final? (not (has-any-object-reference? json-ml))
needed-depth (if final? depth (+ depth header-expander-depth-cost))]
(if (>= remaining-depth-budget needed-depth)
(distribute-budget! json-ml remaining-depth-budget)
(let [expander-ml (render-markup (<header-expander> value))]
(add-over-budget-value! value) ; we need to record over-budget values to for later was-over-budget?! check, see has-body* in formatters.core
expander-ml)))
json-ml))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,182 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('devtools.formatters.budgeting');
goog.require('cljs.core');
goog.require('devtools.formatters.templating');
goog.require('devtools.formatters.state');
goog.require('devtools.formatters.helpers');
goog.require('devtools.formatters.markup');
devtools.formatters.budgeting.header_expander_depth_cost = (2);
devtools.formatters.budgeting.over_budget_values = (((typeof WeakSet !== 'undefined'))?(new WeakSet()):cljs.core.volatile_BANG_.call(null,cljs.core.PersistentHashSet.EMPTY));
devtools.formatters.budgeting.add_over_budget_value_BANG_ = (function devtools$formatters$budgeting$add_over_budget_value_BANG_(value){
if(cljs.core.volatile_QMARK_.call(null,devtools.formatters.budgeting.over_budget_values)){
return cljs.core.vreset_BANG_.call(null,devtools.formatters.budgeting.over_budget_values,cljs.core.conj.call(null,cljs.core.deref.call(null,devtools.formatters.budgeting.over_budget_values),value));
} else {
var o__25265__auto__ = devtools.formatters.budgeting.over_budget_values;
return (o__25265__auto__["add"]).call(o__25265__auto__,value);
}
});
devtools.formatters.budgeting.delete_over_budget_value_BANG_ = (function devtools$formatters$budgeting$delete_over_budget_value_BANG_(value){
if(cljs.core.volatile_QMARK_.call(null,devtools.formatters.budgeting.over_budget_values)){
return cljs.core.vreset_BANG_.call(null,devtools.formatters.budgeting.over_budget_values,cljs.core.disj.call(null,cljs.core.deref.call(null,devtools.formatters.budgeting.over_budget_values),value));
} else {
var o__25265__auto__ = devtools.formatters.budgeting.over_budget_values;
return (o__25265__auto__["delete"]).call(o__25265__auto__,value);
}
});
devtools.formatters.budgeting.has_over_budget_value_QMARK_ = (function devtools$formatters$budgeting$has_over_budget_value_QMARK_(value){
if(cljs.core.volatile_QMARK_.call(null,devtools.formatters.budgeting.over_budget_values)){
return cljs.core.contains_QMARK_.call(null,cljs.core.deref.call(null,devtools.formatters.budgeting.over_budget_values),value);
} else {
var o__25265__auto__ = devtools.formatters.budgeting.over_budget_values;
return (o__25265__auto__["has"]).call(o__25265__auto__,value);
}
});
devtools.formatters.budgeting.object_reference_QMARK_ = (function devtools$formatters$budgeting$object_reference_QMARK_(json_ml){
return cljs.core._EQ_.call(null,cljs.core.first.call(null,json_ml),"object");
});
devtools.formatters.budgeting.determine_depth = (function devtools$formatters$budgeting$determine_depth(json_ml){
if(cljs.core.array_QMARK_.call(null,json_ml)){
return (cljs.core.apply.call(null,cljs.core.max,cljs.core.map.call(null,devtools.formatters.budgeting.determine_depth,json_ml)) + (1));
} else {
return (0);
}
});
devtools.formatters.budgeting.has_any_object_reference_QMARK_ = (function devtools$formatters$budgeting$has_any_object_reference_QMARK_(json_ml){
if(cljs.core.array_QMARK_.call(null,json_ml)){
if(devtools.formatters.budgeting.object_reference_QMARK_.call(null,json_ml)){
return true;
} else {
return cljs.core.some.call(null,devtools.formatters.budgeting.has_any_object_reference_QMARK_,json_ml);
}
} else {
return null;
}
});
devtools.formatters.budgeting.transfer_remaining_depth_budget_BANG_ = (function devtools$formatters$budgeting$transfer_remaining_depth_budget_BANG_(object_reference,depth_budget){
if((!((depth_budget < (0))))){
} else {
throw (new Error("Assert failed: (not (neg? depth-budget))"));
}
var data = cljs.core.second.call(null,object_reference);
var _ = ((cljs.core.object_QMARK_.call(null,data))?null:(function(){throw (new Error("Assert failed: (object? data)"))})());
var config = (data["config"]);
var G__28088 = data;
var target__25270__auto__ = G__28088;
if(cljs.core.truth_(target__25270__auto__)){
} else {
throw (new Error(["Assert failed: ",["unable to locate object path ",null," in ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__28088)].join(''),"\n","target__25270__auto__"].join('')));
}
(target__25270__auto__["config"] = devtools.formatters.state.set_depth_budget.call(null,config,depth_budget));
return G__28088;
});
devtools.formatters.budgeting.distribute_budget_BANG_ = (function devtools$formatters$budgeting$distribute_budget_BANG_(json_ml,depth_budget){
if((!((depth_budget < (0))))){
} else {
throw (new Error("Assert failed: (not (neg? depth-budget))"));
}
if(cljs.core.array_QMARK_.call(null,json_ml)){
var new_depth_budget_28093 = (depth_budget - (1));
if(devtools.formatters.budgeting.object_reference_QMARK_.call(null,json_ml)){
devtools.formatters.budgeting.transfer_remaining_depth_budget_BANG_.call(null,json_ml,new_depth_budget_28093);
} else {
var seq__28089_28094 = cljs.core.seq.call(null,json_ml);
var chunk__28090_28095 = null;
var count__28091_28096 = (0);
var i__28092_28097 = (0);
while(true){
if((i__28092_28097 < count__28091_28096)){
var item_28098 = cljs.core._nth.call(null,chunk__28090_28095,i__28092_28097);
devtools.formatters.budgeting.distribute_budget_BANG_.call(null,item_28098,new_depth_budget_28093);
var G__28099 = seq__28089_28094;
var G__28100 = chunk__28090_28095;
var G__28101 = count__28091_28096;
var G__28102 = (i__28092_28097 + (1));
seq__28089_28094 = G__28099;
chunk__28090_28095 = G__28100;
count__28091_28096 = G__28101;
i__28092_28097 = G__28102;
continue;
} else {
var temp__5720__auto___28103 = cljs.core.seq.call(null,seq__28089_28094);
if(temp__5720__auto___28103){
var seq__28089_28104__$1 = temp__5720__auto___28103;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__28089_28104__$1)){
var c__4550__auto___28105 = cljs.core.chunk_first.call(null,seq__28089_28104__$1);
var G__28106 = cljs.core.chunk_rest.call(null,seq__28089_28104__$1);
var G__28107 = c__4550__auto___28105;
var G__28108 = cljs.core.count.call(null,c__4550__auto___28105);
var G__28109 = (0);
seq__28089_28094 = G__28106;
chunk__28090_28095 = G__28107;
count__28091_28096 = G__28108;
i__28092_28097 = G__28109;
continue;
} else {
var item_28110 = cljs.core.first.call(null,seq__28089_28104__$1);
devtools.formatters.budgeting.distribute_budget_BANG_.call(null,item_28110,new_depth_budget_28093);
var G__28111 = cljs.core.next.call(null,seq__28089_28104__$1);
var G__28112 = null;
var G__28113 = (0);
var G__28114 = (0);
seq__28089_28094 = G__28111;
chunk__28090_28095 = G__28112;
count__28091_28096 = G__28113;
i__28092_28097 = G__28114;
continue;
}
} else {
}
}
break;
}
}
} else {
}
return json_ml;
});
devtools.formatters.budgeting.was_over_budget_QMARK__BANG_ = (function devtools$formatters$budgeting$was_over_budget_QMARK__BANG_(value){
if(cljs.core.truth_(devtools.formatters.budgeting.has_over_budget_value_QMARK_.call(null,value))){
devtools.formatters.budgeting.delete_over_budget_value_BANG_.call(null,value);
return true;
} else {
return null;
}
});
devtools.formatters.budgeting.alter_json_ml_to_fit_in_remaining_budget_BANG_ = (function devtools$formatters$budgeting$alter_json_ml_to_fit_in_remaining_budget_BANG_(value,json_ml){
var temp__5718__auto__ = devtools.formatters.helpers.pref.call(null,new cljs.core.Keyword(null,"initial-hierarchy-depth-budget","initial-hierarchy-depth-budget",-482715807));
if(cljs.core.truth_(temp__5718__auto__)){
var initial_hierarchy_depth_budget = temp__5718__auto__;
var remaining_depth_budget = (function (){var or__4131__auto__ = devtools.formatters.state.get_depth_budget.call(null);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (initial_hierarchy_depth_budget - (1));
}
})();
var depth = devtools.formatters.budgeting.determine_depth.call(null,json_ml);
var final_QMARK_ = cljs.core.not.call(null,devtools.formatters.budgeting.has_any_object_reference_QMARK_.call(null,json_ml));
var needed_depth = ((final_QMARK_)?depth:(depth + devtools.formatters.budgeting.header_expander_depth_cost));
if((remaining_depth_budget >= needed_depth)){
return devtools.formatters.budgeting.distribute_budget_BANG_.call(null,json_ml,remaining_depth_budget);
} else {
var expander_ml = devtools.formatters.templating.render_markup.call(null,devtools.formatters.markup._LT_header_expander_GT_.call(null,value));
devtools.formatters.budgeting.add_over_budget_value_BANG_.call(null,value);
return expander_ml;
}
} else {
return json_ml;
}
});
//# sourceMappingURL=budgeting.js.map?rel=1582560150454

View file

@ -0,0 +1 @@
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/resources\/public\/js\/compiled\/out\/devtools\/formatters\/budgeting.js","sources":["budgeting.cljs?rel=1582560150455"],"lineCount":182,"mappings":";AAAA;;;;;;AAcA,2DAAA,3DAAKA;AAKL,AAAKC,mDAAmB,EAAI,QAAAC,0BAAqB,KAAAA,WAAc,mCAAA,nCAACC;AAEhE,4DAAA,5DAAMC,gIAAwBC;AAA9B,AACE,GAAI,AAACC,oCAAUL;AACb,OAACM,iCAAQN,iDAAmB,yBAAA,AAAAO,zBAACC,mDAAMR,kDAAmBI;;AACtD,IAAAK,mBAAOT;AAAP,AAAA,OAAA,CAAAS,iBAAA,aAAAA,iBAAgCL;;;AAEpC,+DAAA,\/DAAMM,sIAA2BN;AAAjC,AACE,GAAI,AAACC,oCAAUL;AACb,OAACM,iCAAQN,iDAAmB,yBAAA,AAAAO,zBAACI,mDAAMX,kDAAmBI;;AACtD,IAAAK,mBAAOT;AAAP,AAAA,OAAA,CAAAS,iBAAA,gBAAAA,iBAAmCL;;;AAEvC,6DAAA,7DAAMQ,kIAAwBR;AAA9B,AACE,GAAI,AAACC,oCAAUL;AACb,2CAAA,AAAAO,pCAACM,8DAAWb,kDAAmBI;;AAC\/B,IAAAK,mBAAOT;AAAP,AAAA,OAAA,CAAAS,iBAAA,aAAAA,iBAAgCL;;;AAIpC,wDAAA,xDAAMU,wHAAmBC;AAAzB,AACE,mEAAA,5DAACC,yBAAE,AAACC,0BAAMF;;AAEZ,gDAAA,hDAAMG,wGAAiBH;AAAvB,AACE,GAAI,AAACI,iCAAOJ;AACV,kIAAA,1HAAK,AAACK,0BAAMC,cAAI,AAACC,wBAAIJ,8CAAgBH;;AADvC;;;AAIF,gEAAA,hEAAMQ,wIAA2BR;AAAjC,AACE,GAAI,AAACI,iCAAOJ;AACV,GAAI,AAACD,gEAAkBC;AAAvB;;AAEE,OAACS,yBAAKD,8DAA0BR;;;AAHpC;;;AAKF,sEAAA,tEAAMW,oJAAkCC,iBAAiBC;AAAzD,AAAA,GACS,GAAK,gBAAA,fAAMA;AADpB;AAAA,AAAA,MAAA,KAAAH,MAAA;;;AAEE,IAAMI,OAAK,AAACC,2BAAOH;IACbI,IAAE,2CAAA,KAAA,AAAA,kBAAA,KAAAN,MAAA,3EAAQ,AAACO,kCAAQH;IACnBI,SAAO,MAAA,LAAMJ;AAFnB,AAGE,IAAAK,WAAML;IAANM,wBAAAD;AAAA,AAAA,oBAAAC;AAAA;AAAA,AAAA,MAAA,KAAAV,MAAA,CAAA,kBAAA,CAAA,gCAAA,KAAA,mDAAAS,oBAAA,KAAA;;;AAAA,CAAAC,sBAAA,YAAsB,AAACC,qDAAiBH,OAAOL;;AAA\/CM;;AAEJ,wDAAA,xDAAMG,wHAAoBtB,QAAQa;AAAlC,AAAA,GACS,GAAK,gBAAA,fAAMA;AADpB;AAAA,AAAA,MAAA,KAAAH,MAAA;;;AAEE,GAAI,AAACN,iCAAOJ;AACV,IAAMuB,yBAAiB,gBAAA,fAAKV;AAA5B,AACE,GAAI,AAACd,gEAAkBC;AACrB,AAACW,8EAAiCX,QAAQuB;;AAC1C,IAAAC,mBAAA,AAAAC,wBAAazB;IAAb0B,qBAAA;IAAAC,qBAAA;IAAAC,iBAAA;;AAAA,AAAA,GAAA,AAAA,CAAAA,iBAAAD;AAAA,iBAAA,AAAAE,yBAAAH,mBAAAE,zDAAQS;AAAR,AAAA,AACE,AAACf,gEAAmBe,WAAKd;;AAD3B;AAAA,eAAAC;eAAAE;eAAAC;eAAA,CAAAC,iBAAA;;;;;;;AAAA,IAAAE,2BAAA,AAAAL,wBAAAD;AAAA,AAAA,GAAAM;AAAA,AAAA,IAAAN,uBAAAM;AAAA,AAAA,GAAA,AAAAC,uCAAAP;AAAA,IAAAQ,wBAAA,AAAAC,gCAAAT;AAAA,AAAA,eAAA,AAAAU,+BAAAV;eAAAQ;eAAA,AAAAG,0BAAAH;eAAA;;;;;;;AAAA,iBAAA,AAAA9B,0BAAAsB,vCAAQa;AAAR,AAAA,AACE,AAACf,gEAAmBe,WAAKd;;AAD3B;AAAA,eAAA,AAAAa,yBAAAZ;eAAA;eAAA;eAAA;;;;;;;;AAAA;;;;;;AAJN;;AAMAxB;;AAIF,6DAAA,7DAAMsC,kIAAmBjD;AAAzB,AACE,oBAAM,AAACQ,qEAAuBR;AAA9B,AACE,AAACM,uEAA0BN;;AAD7B;;AAAA;;;AAIF,+EAAA,\/EAAMkD,sKAA2ClD,MAAMW;AAAvD,AACE,IAAAwC,qBAAwC,2CAAA,3CAACE;AAAzC,AAAA,oBAAAF;AAAA,qCAAAA,jCAASC;AAAT,AACE,IAAME,yBAAuB,iBAAAC,mBAAI,AAACC;AAAL,AAAA,oBAAAD;AAAAA;;AAAuB,yCAAA,jCAAKH;;;IACnDK,QAAM,AAAC3C,wDAAgBH;IACvB+C,eAAO,AAACC,wBAAI,AAACxC,wEAA0BR;IACvCiD,eAAa,EAAIF,cAAOD,MAAM,CAAGA,QAAM9D;AAH7C,AAIE,GAAI,CAAI2D,0BAAuBM;AAC7B,OAAC3B,gEAAmBtB,QAAQ2C;;AAC5B,IAAMO,cAAY,AAACC,uDAAc,AAACC,6DAAkB\/D;AAApD,AACE,AAACD,oEAAuBC;;AACxB6D;;;AACNlD","names":["devtools.formatters.budgeting\/header-expander-depth-cost","devtools.formatters.budgeting\/over-budget-values","js\/WeakSet","cljs.core\/volatile!","devtools.formatters.budgeting\/add-over-budget-value!","value","cljs.core\/volatile?","cljs.core\/vreset!","cljs.core\/deref","cljs.core\/conj","o__25265__auto__","devtools.formatters.budgeting\/delete-over-budget-value!","cljs.core\/disj","devtools.formatters.budgeting\/has-over-budget-value?","cljs.core\/contains?","devtools.formatters.budgeting\/object-reference?","json-ml","cljs.core\/=","cljs.core\/first","devtools.formatters.budgeting\/determine-depth","cljs.core\/array?","cljs.core\/apply","cljs.core\/max","cljs.core\/map","devtools.formatters.budgeting\/has-any-object-reference?","cljs.core\/some","js\/Error","devtools.formatters.budgeting\/transfer-remaining-depth-budget!","object-reference","depth-budget","data","cljs.core\/second","_","cljs.core\/object?","config","G__28088","target__25270__auto__","devtools.formatters.state\/set-depth-budget","devtools.formatters.budgeting\/distribute-budget!","new-depth-budget","seq__28089","cljs.core\/seq","chunk__28090","count__28091","i__28092","cljs.core\/-nth","temp__5720__auto__","cljs.core\/chunked-seq?","c__4550__auto__","cljs.core\/chunk-first","cljs.core\/chunk-rest","cljs.core\/count","cljs.core\/next","item","devtools.formatters.budgeting\/was-over-budget?!","devtools.formatters.budgeting\/alter-json-ml-to-fit-in-remaining-budget!","temp__5718__auto__","initial-hierarchy-depth-budget","devtools.formatters.helpers\/pref","remaining-depth-budget","or__4131__auto__","devtools.formatters.state\/get-depth-budget","depth","final?","cljs.core\/not","needed-depth","expander-ml","devtools.formatters.templating\/render-markup","devtools.formatters.markup\/<header-expander>"]}

View file

@ -0,0 +1,85 @@
(ns devtools.formatters.core
(:require-macros [devtools.oops :refer [safe-call]])
(:require [devtools.prefs :refer [pref]]
[devtools.format :refer [IDevtoolsFormat]]
[devtools.protocols :refer [IFormat]]
[devtools.reporter :as reporter]
[devtools.formatters.templating :refer [surrogate? render-markup get-surrogate-body]]
[devtools.formatters.helpers :refer [cljs-value?]]
[devtools.formatters.state :refer [prevent-recursion? *current-state* get-default-state update-current-state!
reset-depth-limits]]
[devtools.formatters.markup :refer [<header> <surrogate-header> <surrogate-body>]]
[devtools.formatters.budgeting :refer [was-over-budget?! alter-json-ml-to-fit-in-remaining-budget!]]))
; -- RAW API ----------------------------------------------------------------------------------------------------------------
(defn want-value?* [value]
(and (not (prevent-recursion?))
(or (cljs-value? value) (surrogate? value))))
(defn header* [value]
(let [json-ml (cond
(surrogate? value) (render-markup (<surrogate-header> value))
(safe-call satisfies? false IDevtoolsFormat value) (devtools.format/-header value)
(safe-call satisfies? false IFormat value) (devtools.protocols/-header value)
:else (render-markup (<header> value)))]
(alter-json-ml-to-fit-in-remaining-budget! value json-ml))) ; see issue #22
(defn has-body* [value]
; note: body is emulated using surrogate references
(if (was-over-budget?! value) ; see issue #22
false ; see alter-json-ml-to-fit-in-remaining-budget!, in case we didn't fit into budget, a header-expander placeholder with body was added in place
(boolean
(cond
(surrogate? value) (some? (get-surrogate-body value))
(safe-call satisfies? false IDevtoolsFormat value) (devtools.format/-has-body value)
(safe-call satisfies? false IFormat value) (devtools.protocols/-has-body value)
:else false))))
(defn body* [value]
(update-current-state! reset-depth-limits)
(cond
(surrogate? value) (render-markup (<surrogate-body> value))
(safe-call satisfies? false IDevtoolsFormat value) (devtools.format/-body value)
(safe-call satisfies? false IFormat value) (devtools.protocols/-body value)))
; ---------------------------------------------------------------------------------------------------------------------------
; config-aware RAW API, see state management documentation state.cljs
(defn config-wrapper [raw-fn]
(fn [value config]
(binding [*current-state* (or config (get-default-state))]
(raw-fn value))))
(def want-value? (config-wrapper want-value?*))
(def header (config-wrapper header*))
(def has-body (config-wrapper has-body*))
(def body (config-wrapper body*))
; -- API CALLS --------------------------------------------------------------------------------------------------------------
(defn wrap-with-exception-guard [f]
(fn [& args]
(try
(apply f args)
(catch :default e
(reporter/report-internal-error! e "an exception was raised during value formatting")
nil))))
(defn build-api-call [raw-fn pre-handler-key post-handler-key]
"Wraps raw API call in a function which calls pre-handler and post-handler.
pre-handler gets a chance to pre-process value before it is passed to cljs-devtools
post-handler gets a chance to post-process value returned by cljs-devtools."
(let [handler (fn [value config]
(let [pre-handler (or (pref pre-handler-key) identity)
post-handler (or (pref post-handler-key) identity)
preprocessed-value (pre-handler value)
result (if (want-value? preprocessed-value config)
(raw-fn preprocessed-value config))]
(post-handler result)))]
(wrap-with-exception-guard handler)))
(def header-api-call (build-api-call header :header-pre-handler :header-post-handler))
(def has-body-api-call (build-api-call has-body :has-body-pre-handler :has-body-post-handler))
(def body-api-call (build-api-call body :body-pre-handler :body-post-handler))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,220 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('devtools.formatters.core');
goog.require('cljs.core');
goog.require('devtools.prefs');
goog.require('devtools.format');
goog.require('devtools.protocols');
goog.require('devtools.reporter');
goog.require('devtools.formatters.templating');
goog.require('devtools.formatters.helpers');
goog.require('devtools.formatters.state');
goog.require('devtools.formatters.markup');
goog.require('devtools.formatters.budgeting');
devtools.formatters.core.want_value_QMARK__STAR_ = (function devtools$formatters$core$want_value_QMARK__STAR_(value){
var and__4120__auto__ = cljs.core.not.call(null,devtools.formatters.state.prevent_recursion_QMARK_.call(null));
if(and__4120__auto__){
var or__4131__auto__ = devtools.formatters.helpers.cljs_value_QMARK_.call(null,value);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return devtools.formatters.templating.surrogate_QMARK_.call(null,value);
}
} else {
return and__4120__auto__;
}
});
devtools.formatters.core.header_STAR_ = (function devtools$formatters$core$header_STAR_(value){
var json_ml = ((devtools.formatters.templating.surrogate_QMARK_.call(null,value))?devtools.formatters.templating.render_markup.call(null,devtools.formatters.markup._LT_surrogate_header_GT_.call(null,value)):(cljs.core.truth_((function (){try{if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$format$IDevtoolsFormat$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,value);
}
}catch (e28117){var _e__25272__auto__ = e28117;
return false;
}})())?devtools.format._header.call(null,value):(cljs.core.truth_((function (){try{if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$protocols$IFormat$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,value);
}
}catch (e28119){var _e__25272__auto__ = e28119;
return false;
}})())?devtools.protocols._header.call(null,value):devtools.formatters.templating.render_markup.call(null,devtools.formatters.markup._LT_header_GT_.call(null,value))
)));
return devtools.formatters.budgeting.alter_json_ml_to_fit_in_remaining_budget_BANG_.call(null,value,json_ml);
});
devtools.formatters.core.has_body_STAR_ = (function devtools$formatters$core$has_body_STAR_(value){
if(cljs.core.truth_(devtools.formatters.budgeting.was_over_budget_QMARK__BANG_.call(null,value))){
return false;
} else {
return cljs.core.boolean$.call(null,((devtools.formatters.templating.surrogate_QMARK_.call(null,value))?(!((devtools.formatters.templating.get_surrogate_body.call(null,value) == null))):(cljs.core.truth_((function (){try{if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$format$IDevtoolsFormat$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,value);
}
}catch (e28121){var _e__25272__auto__ = e28121;
return false;
}})())?devtools.format._has_body.call(null,value):(cljs.core.truth_((function (){try{if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$protocols$IFormat$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,value);
}
}catch (e28123){var _e__25272__auto__ = e28123;
return false;
}})())?devtools.protocols._has_body.call(null,value):false
))));
}
});
devtools.formatters.core.body_STAR_ = (function devtools$formatters$core$body_STAR_(value){
devtools.formatters.state.update_current_state_BANG_.call(null,devtools.formatters.state.reset_depth_limits);
if(devtools.formatters.templating.surrogate_QMARK_.call(null,value)){
return devtools.formatters.templating.render_markup.call(null,devtools.formatters.markup._LT_surrogate_body_GT_.call(null,value));
} else {
if(cljs.core.truth_((function (){try{if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$format$IDevtoolsFormat$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,value);
}
}catch (e28125){var _e__25272__auto__ = e28125;
return false;
}})())){
return devtools.format._body.call(null,value);
} else {
if(cljs.core.truth_((function (){try{if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$protocols$IFormat$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,value);
}
}catch (e28127){var _e__25272__auto__ = e28127;
return false;
}})())){
return devtools.protocols._body.call(null,value);
} else {
return null;
}
}
}
});
devtools.formatters.core.config_wrapper = (function devtools$formatters$core$config_wrapper(raw_fn){
return (function (value,config){
var _STAR_current_state_STAR__orig_val__28129 = devtools.formatters.state._STAR_current_state_STAR_;
var _STAR_current_state_STAR__temp_val__28130 = (function (){var or__4131__auto__ = config;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return devtools.formatters.state.get_default_state.call(null);
}
})();
devtools.formatters.state._STAR_current_state_STAR_ = _STAR_current_state_STAR__temp_val__28130;
try{return raw_fn.call(null,value);
}finally {devtools.formatters.state._STAR_current_state_STAR_ = _STAR_current_state_STAR__orig_val__28129;
}});
});
devtools.formatters.core.want_value_QMARK_ = devtools.formatters.core.config_wrapper.call(null,devtools.formatters.core.want_value_QMARK__STAR_);
devtools.formatters.core.header = devtools.formatters.core.config_wrapper.call(null,devtools.formatters.core.header_STAR_);
devtools.formatters.core.has_body = devtools.formatters.core.config_wrapper.call(null,devtools.formatters.core.has_body_STAR_);
devtools.formatters.core.body = devtools.formatters.core.config_wrapper.call(null,devtools.formatters.core.body_STAR_);
devtools.formatters.core.wrap_with_exception_guard = (function devtools$formatters$core$wrap_with_exception_guard(f){
return (function() {
var G__28132__delegate = function (args){
try{return cljs.core.apply.call(null,f,args);
}catch (e28131){var e = e28131;
devtools.reporter.report_internal_error_BANG_.call(null,e,"an exception was raised during value formatting");
return null;
}};
var G__28132 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__28133__i = 0, G__28133__a = new Array(arguments.length - 0);
while (G__28133__i < G__28133__a.length) {G__28133__a[G__28133__i] = arguments[G__28133__i + 0]; ++G__28133__i;}
args = new cljs.core.IndexedSeq(G__28133__a,0,null);
}
return G__28132__delegate.call(this,args);};
G__28132.cljs$lang$maxFixedArity = 0;
G__28132.cljs$lang$applyTo = (function (arglist__28134){
var args = cljs.core.seq(arglist__28134);
return G__28132__delegate(args);
});
G__28132.cljs$core$IFn$_invoke$arity$variadic = G__28132__delegate;
return G__28132;
})()
;
});
devtools.formatters.core.build_api_call = (function devtools$formatters$core$build_api_call(raw_fn,pre_handler_key,post_handler_key){
var handler = (function (value,config){
var pre_handler = (function (){var or__4131__auto__ = devtools.prefs.pref.call(null,pre_handler_key);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.core.identity;
}
})();
var post_handler = (function (){var or__4131__auto__ = devtools.prefs.pref.call(null,post_handler_key);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.core.identity;
}
})();
var preprocessed_value = pre_handler.call(null,value);
var result = (cljs.core.truth_(devtools.formatters.core.want_value_QMARK_.call(null,preprocessed_value,config))?raw_fn.call(null,preprocessed_value,config):null);
return post_handler.call(null,result);
});
return devtools.formatters.core.wrap_with_exception_guard.call(null,handler);
});
devtools.formatters.core.header_api_call = devtools.formatters.core.build_api_call.call(null,devtools.formatters.core.header,new cljs.core.Keyword(null,"header-pre-handler","header-pre-handler",-1997722262),new cljs.core.Keyword(null,"header-post-handler","header-post-handler",514828618));
devtools.formatters.core.has_body_api_call = devtools.formatters.core.build_api_call.call(null,devtools.formatters.core.has_body,new cljs.core.Keyword(null,"has-body-pre-handler","has-body-pre-handler",1787020038),new cljs.core.Keyword(null,"has-body-post-handler","has-body-post-handler",-863451271));
devtools.formatters.core.body_api_call = devtools.formatters.core.build_api_call.call(null,devtools.formatters.core.body,new cljs.core.Keyword(null,"body-pre-handler","body-pre-handler",1211926529),new cljs.core.Keyword(null,"body-post-handler","body-post-handler",-1040905424));
//# sourceMappingURL=core.js.map?rel=1582560150477

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,118 @@
(ns devtools.formatters.helpers
(:require-macros [devtools.oops :refer [oget safe-call]])
(:require [devtools.prefs :as prefs]
[devtools.munging :as munging]
[devtools.format :refer [IDevtoolsFormat]]
[devtools.protocols :refer [ITemplate IGroup ISurrogate IFormat]]))
(defn pref [v]
(if (keyword? v)
(recur (prefs/pref v))
v))
(defn get-prototype [o]
(.-prototype o))
(defn get-constructor [o]
(.-constructor o))
; ---------------------------------------------------------------------------------------------------------------------------
(defn is-prototype? [o]
(identical? (get-prototype (get-constructor o)) o))
(defn is-js-symbol? [o]
(= (goog/typeOf o) "symbol"))
(defn cljs-function? [value]
(and (not (pref :disable-cljs-fn-formatting)) ; TODO: this should be deprecated
(not (var? value)) ; HACK: vars have IFn protocol and would act as functions TODO: implement custom rendering for vars
(munging/cljs-fn? value)))
(defn has-formatting-protocol? [value]
(or (safe-call satisfies? false IPrintWithWriter value)
(safe-call satisfies? false IDevtoolsFormat value) ; legacy
(safe-call satisfies? false IFormat value)))
; IRC #clojurescript @ freenode.net on 2015-01-27:
; [13:40:09] darwin_: Hi, what is the best way to test if I'm handled ClojureScript data value or plain javascript object?
; [14:04:34] dnolen: there is a very low level thing you can check
; [14:04:36] dnolen: https://github.com/clojure/clojurescript/blob/c2550c4fdc94178a7957497e2bfde54e5600c457/src/clj/cljs/core.clj#L901
; [14:05:00] dnolen: this property is unlikely to change - still it's probably not something anything anyone should use w/o a really good reason
(defn cljs-type? [f]
(and (goog/isObject f) ; see http://stackoverflow.com/a/22482737/84283
(not (is-prototype? f))
(.-cljs$lang$type f)))
(defn cljs-instance? [value]
(and (goog/isObject value) ; see http://stackoverflow.com/a/22482737/84283
(cljs-type? (get-constructor value))))
(defn cljs-land-value? [value]
(or (cljs-instance? value)
(has-formatting-protocol? value))) ; some raw js types can be extend-protocol to support cljs printing, see issue #21
(defn cljs-value? [value]
(and
(or (cljs-land-value? value)
(cljs-function? value))
(not (is-prototype? value))
(not (is-js-symbol? value))))
(defn bool? [value]
(or (true? value) (false? value)))
(defn instance-of-a-well-known-type? [value]
(let [well-known-types (pref :well-known-types)
constructor-fn (get-constructor value)
[ns name] (munging/parse-constructor-info constructor-fn)
fully-qualified-type-name (str ns "/" name)]
(contains? well-known-types fully-qualified-type-name)))
(defn should-render-instance? [value]
(and (cljs-instance? value)
(not (instance-of-a-well-known-type? value))))
(defn directly-printable? [value]
(or (string? value)
(number? value)
(bool? value)))
; ---------------------------------------------------------------------------------------------------------------------------
(defn abbreviated? [template]
(some #(= (pref :more-marker) %) template))
(defn abbreviate-long-string [string marker prefix-limit postfix-limit]
(let [prefix (.slice string 0 prefix-limit)
postfix (.slice string (- (.-length string) postfix-limit))]
(str prefix marker postfix)))
(defn get-more-marker [more-count]
(str (pref :plus-symbol) more-count (pref :more-symbol)))
(defn wrap-arity [arity]
(let [args-open-symbol (pref :args-open-symbol)
args-close-symbol (pref :args-close-symbol)]
(str args-open-symbol arity args-close-symbol)))
(defn fetch-field-value [obj field]
[field (oget obj (munge field))])
(defn fetch-fields-values [obj fields]
(map (partial fetch-field-value obj) fields))
(defn expandable? [obj]
(if (satisfies? ISeqable obj)
(if-let [min-count (pref (if (instance-of-a-well-known-type? obj)
:min-expandable-sequable-count-for-well-known-types
:min-expandable-sequable-count))]
(if-not (empty? obj)
(let [actual-count (bounded-count min-count obj)]
(>= actual-count min-count))))))
(defn should-render? [pref-key value default-check]
(if-let [render-pref (pref pref-key)]
(cond
(true? render-pref) (default-check value)
(fn? render-pref) (render-pref value))))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,228 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('devtools.formatters.helpers');
goog.require('cljs.core');
goog.require('devtools.prefs');
goog.require('devtools.munging');
goog.require('devtools.format');
goog.require('devtools.protocols');
devtools.formatters.helpers.pref = (function devtools$formatters$helpers$pref(v){
while(true){
if((v instanceof cljs.core.Keyword)){
var G__26258 = devtools.prefs.pref.call(null,v);
v = G__26258;
continue;
} else {
return v;
}
break;
}
});
devtools.formatters.helpers.get_prototype = (function devtools$formatters$helpers$get_prototype(o){
return o.prototype;
});
devtools.formatters.helpers.get_constructor = (function devtools$formatters$helpers$get_constructor(o){
return o.constructor;
});
devtools.formatters.helpers.is_prototype_QMARK_ = (function devtools$formatters$helpers$is_prototype_QMARK_(o){
return (devtools.formatters.helpers.get_prototype.call(null,devtools.formatters.helpers.get_constructor.call(null,o)) === o);
});
devtools.formatters.helpers.is_js_symbol_QMARK_ = (function devtools$formatters$helpers$is_js_symbol_QMARK_(o){
return cljs.core._EQ_.call(null,goog.typeOf(o),"symbol");
});
devtools.formatters.helpers.cljs_function_QMARK_ = (function devtools$formatters$helpers$cljs_function_QMARK_(value){
var and__4120__auto__ = cljs.core.not.call(null,devtools.formatters.helpers.pref.call(null,new cljs.core.Keyword(null,"disable-cljs-fn-formatting","disable-cljs-fn-formatting",1903786837)));
if(and__4120__auto__){
var and__4120__auto____$1 = (!(cljs.core.var_QMARK_.call(null,value)));
if(and__4120__auto____$1){
return devtools.munging.cljs_fn_QMARK_.call(null,value);
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
});
devtools.formatters.helpers.has_formatting_protocol_QMARK_ = (function devtools$formatters$helpers$has_formatting_protocol_QMARK_(value){
var or__4131__auto__ = (function (){try{if((!((value == null)))){
if((((value.cljs$lang$protocol_mask$partition0$ & (2147483648))) || ((cljs.core.PROTOCOL_SENTINEL === value.cljs$core$IPrintWithWriter$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition0$)){
return cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IPrintWithWriter,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IPrintWithWriter,value);
}
}catch (e26261){var _e__25272__auto__ = e26261;
return false;
}})();
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
var or__4131__auto____$1 = (function (){try{if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$format$IDevtoolsFormat$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,value);
}
}catch (e26265){var _e__25272__auto__ = e26265;
return false;
}})();
if(cljs.core.truth_(or__4131__auto____$1)){
return or__4131__auto____$1;
} else {
try{if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$protocols$IFormat$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,value);
}
}catch (e26267){var _e__25272__auto__ = e26267;
return false;
}}
}
});
devtools.formatters.helpers.cljs_type_QMARK_ = (function devtools$formatters$helpers$cljs_type_QMARK_(f){
var and__4120__auto__ = goog.isObject(f);
if(cljs.core.truth_(and__4120__auto__)){
var and__4120__auto____$1 = (!(devtools.formatters.helpers.is_prototype_QMARK_.call(null,f)));
if(and__4120__auto____$1){
return f.cljs$lang$type;
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
});
devtools.formatters.helpers.cljs_instance_QMARK_ = (function devtools$formatters$helpers$cljs_instance_QMARK_(value){
var and__4120__auto__ = goog.isObject(value);
if(cljs.core.truth_(and__4120__auto__)){
return devtools.formatters.helpers.cljs_type_QMARK_.call(null,devtools.formatters.helpers.get_constructor.call(null,value));
} else {
return and__4120__auto__;
}
});
devtools.formatters.helpers.cljs_land_value_QMARK_ = (function devtools$formatters$helpers$cljs_land_value_QMARK_(value){
var or__4131__auto__ = devtools.formatters.helpers.cljs_instance_QMARK_.call(null,value);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return devtools.formatters.helpers.has_formatting_protocol_QMARK_.call(null,value);
}
});
devtools.formatters.helpers.cljs_value_QMARK_ = (function devtools$formatters$helpers$cljs_value_QMARK_(value){
var and__4120__auto__ = (function (){var or__4131__auto__ = devtools.formatters.helpers.cljs_land_value_QMARK_.call(null,value);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return devtools.formatters.helpers.cljs_function_QMARK_.call(null,value);
}
})();
if(cljs.core.truth_(and__4120__auto__)){
return (((!(devtools.formatters.helpers.is_prototype_QMARK_.call(null,value)))) && ((!(devtools.formatters.helpers.is_js_symbol_QMARK_.call(null,value)))));
} else {
return and__4120__auto__;
}
});
devtools.formatters.helpers.bool_QMARK_ = (function devtools$formatters$helpers$bool_QMARK_(value){
return ((value === true) || (value === false));
});
devtools.formatters.helpers.instance_of_a_well_known_type_QMARK_ = (function devtools$formatters$helpers$instance_of_a_well_known_type_QMARK_(value){
var well_known_types = devtools.formatters.helpers.pref.call(null,new cljs.core.Keyword(null,"well-known-types","well-known-types",70638649));
var constructor_fn = devtools.formatters.helpers.get_constructor.call(null,value);
var vec__26269 = devtools.munging.parse_constructor_info.call(null,constructor_fn);
var ns = cljs.core.nth.call(null,vec__26269,(0),null);
var name = cljs.core.nth.call(null,vec__26269,(1),null);
var fully_qualified_type_name = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(ns),"/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(name)].join('');
return cljs.core.contains_QMARK_.call(null,well_known_types,fully_qualified_type_name);
});
devtools.formatters.helpers.should_render_instance_QMARK_ = (function devtools$formatters$helpers$should_render_instance_QMARK_(value){
var and__4120__auto__ = devtools.formatters.helpers.cljs_instance_QMARK_.call(null,value);
if(cljs.core.truth_(and__4120__auto__)){
return (!(devtools.formatters.helpers.instance_of_a_well_known_type_QMARK_.call(null,value)));
} else {
return and__4120__auto__;
}
});
devtools.formatters.helpers.directly_printable_QMARK_ = (function devtools$formatters$helpers$directly_printable_QMARK_(value){
return ((typeof value === 'string') || (typeof value === 'number') || (devtools.formatters.helpers.bool_QMARK_.call(null,value)));
});
devtools.formatters.helpers.abbreviated_QMARK_ = (function devtools$formatters$helpers$abbreviated_QMARK_(template){
return cljs.core.some.call(null,(function (p1__26272_SHARP_){
return cljs.core._EQ_.call(null,devtools.formatters.helpers.pref.call(null,new cljs.core.Keyword(null,"more-marker","more-marker",-14717935)),p1__26272_SHARP_);
}),template);
});
devtools.formatters.helpers.abbreviate_long_string = (function devtools$formatters$helpers$abbreviate_long_string(string,marker,prefix_limit,postfix_limit){
var prefix = string.slice((0),prefix_limit);
var postfix = string.slice((string.length - postfix_limit));
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(prefix),cljs.core.str.cljs$core$IFn$_invoke$arity$1(marker),cljs.core.str.cljs$core$IFn$_invoke$arity$1(postfix)].join('');
});
devtools.formatters.helpers.get_more_marker = (function devtools$formatters$helpers$get_more_marker(more_count){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(devtools.formatters.helpers.pref.call(null,new cljs.core.Keyword(null,"plus-symbol","plus-symbol",-1984915189))),cljs.core.str.cljs$core$IFn$_invoke$arity$1(more_count),cljs.core.str.cljs$core$IFn$_invoke$arity$1(devtools.formatters.helpers.pref.call(null,new cljs.core.Keyword(null,"more-symbol","more-symbol",-2139760242)))].join('');
});
devtools.formatters.helpers.wrap_arity = (function devtools$formatters$helpers$wrap_arity(arity){
var args_open_symbol = devtools.formatters.helpers.pref.call(null,new cljs.core.Keyword(null,"args-open-symbol","args-open-symbol",-1336957557));
var args_close_symbol = devtools.formatters.helpers.pref.call(null,new cljs.core.Keyword(null,"args-close-symbol","args-close-symbol",777697973));
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(args_open_symbol),cljs.core.str.cljs$core$IFn$_invoke$arity$1(arity),cljs.core.str.cljs$core$IFn$_invoke$arity$1(args_close_symbol)].join('');
});
devtools.formatters.helpers.fetch_field_value = (function devtools$formatters$helpers$fetch_field_value(obj,field){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [field,(obj[cljs.core.munge.call(null,field)])], null);
});
devtools.formatters.helpers.fetch_fields_values = (function devtools$formatters$helpers$fetch_fields_values(obj,fields){
return cljs.core.map.call(null,cljs.core.partial.call(null,devtools.formatters.helpers.fetch_field_value,obj),fields);
});
devtools.formatters.helpers.expandable_QMARK_ = (function devtools$formatters$helpers$expandable_QMARK_(obj){
if((((!((obj == null))))?(((((obj.cljs$lang$protocol_mask$partition0$ & (8388608))) || ((cljs.core.PROTOCOL_SENTINEL === obj.cljs$core$ISeqable$))))?true:(((!obj.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISeqable,obj):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISeqable,obj))){
var temp__5718__auto__ = devtools.formatters.helpers.pref.call(null,((devtools.formatters.helpers.instance_of_a_well_known_type_QMARK_.call(null,obj))?new cljs.core.Keyword(null,"min-expandable-sequable-count-for-well-known-types","min-expandable-sequable-count-for-well-known-types",-1879576081):new cljs.core.Keyword(null,"min-expandable-sequable-count","min-expandable-sequable-count",63566227)));
if(cljs.core.truth_(temp__5718__auto__)){
var min_count = temp__5718__auto__;
if((!(cljs.core.empty_QMARK_.call(null,obj)))){
var actual_count = cljs.core.bounded_count.call(null,min_count,obj);
return (actual_count >= min_count);
} else {
return null;
}
} else {
return null;
}
} else {
return null;
}
});
devtools.formatters.helpers.should_render_QMARK_ = (function devtools$formatters$helpers$should_render_QMARK_(pref_key,value,default_check){
var temp__5718__auto__ = devtools.formatters.helpers.pref.call(null,pref_key);
if(cljs.core.truth_(temp__5718__auto__)){
var render_pref = temp__5718__auto__;
if(render_pref === true){
return default_check.call(null,value);
} else {
if(cljs.core.fn_QMARK_.call(null,render_pref)){
return render_pref.call(null,value);
} else {
return null;
}
}
} else {
return null;
}
});
//# sourceMappingURL=helpers.js.map?rel=1582560149104

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,451 @@
(ns devtools.formatters.markup
(:require-macros [devtools.formatters.markup :refer [emit-markup-db]])
(:require [devtools.formatters.helpers :refer [bool? cljs-function? cljs-type? cljs-instance?
should-render-instance? expandable? abbreviated?
abbreviate-long-string get-constructor pref should-render?
get-more-marker wrap-arity fetch-fields-values]]
[devtools.formatters.printing :refer [managed-print-via-writer managed-print-via-protocol]]
[devtools.formatters.state :refer [set-prevent-recursion set-managed-print-level reset-depth-limits]]
[devtools.formatters.templating :refer [get-surrogate-body
get-surrogate-target
get-surrogate-start-index
get-surrogate-header]]
[devtools.munging :as munging]))
; reusable hiccup-like templates
(declare get-markup-db)
; -- cljs printing ---------------------------------------------------------------------------------------------------------
(defn print-with [method value tag & [max-level]]
(let [job-fn #(method value tag (get-markup-db))]
(if (some? max-level)
(binding [*print-level* (inc max-level)] ; when printing do at most print-level deep recursion
(job-fn))
(job-fn))))
(defn print-via-writer [value tag & [max-level]]
(print-with managed-print-via-writer value tag max-level))
(defn print-via-protocol [value tag & [max-level]]
(print-with managed-print-via-protocol value tag max-level))
; -- references -------------------------------------------------------------------------------------------------------------
(defn <expandable> [& children]
(let [inner-markup (concat [:expandable-inner-tag] children)]
[:expandable-tag :expandable-symbol inner-markup]))
(defn <raw-surrogate> [& args]
(concat ["surrogate"] args))
(defn <surrogate> [& [object header body start-index]]
(let [header (if (some? body) (<expandable> header) header)]
(<raw-surrogate> object header body start-index)))
(defn <reference> [& args]
(concat ["reference"] args))
(defn <reference-surrogate> [& args]
(<reference> (apply <surrogate> args)))
(defn <circular-reference> [& children]
(<reference-surrogate> nil [:circular-reference-tag :circular-ref-icon] (concat [:circular-reference-body-tag] children)))
(defn <native-reference> [object]
(let [reference (<reference> object #(set-prevent-recursion % true))]
[:native-reference-wrapper-tag :native-reference-background [:native-reference-tag reference]]))
(defn <header-expander> [object]
(<reference> (<raw-surrogate> object :header-expander-symbol :target) reset-depth-limits))
; -- simple markup ----------------------------------------------------------------------------------------------------------
(defn <cljs-land> [& children]
(concat [:cljs-land-tag] children))
(defn <nil> []
; this code is duplicated in templating.cljs, see make-reference
[:nil-tag :nil-label])
(defn <bool> [bool]
[:bool-tag (str bool)])
(defn <keyword> [keyword]
[:keyword-tag (str keyword)])
(defn <symbol> [symbol]
[:symbol-tag (str symbol)])
(defn <number> [number]
(if (integer? number)
[:integer-tag number]
[:float-tag number]))
; -- string markup ----------------------------------------------------------------------------------------------------------
(defn <string> [string]
(let [dq (pref :dq)
re-nl (js/RegExp. "\n" "g")
nl-marker (pref :new-line-string-replacer)
inline-string (.replace string re-nl nl-marker)
max-inline-string-size (+ (pref :string-prefix-limit) (pref :string-postfix-limit))
quote-string (fn [s] (str dq s dq))
should-abbreviate? (> (count inline-string) max-inline-string-size)]
(if should-abbreviate?
(let [abbreviated-string (abbreviate-long-string inline-string
(pref :string-abbreviation-marker)
(pref :string-prefix-limit)
(pref :string-postfix-limit))
abbreviated-string-markup [:string-tag (quote-string abbreviated-string)]
string-with-nl-markers (.replace string re-nl (str nl-marker "\n"))
details-markup [:expanded-string-tag string-with-nl-markers]]
(<reference-surrogate> string abbreviated-string-markup details-markup))
[:string-tag (quote-string inline-string)])))
; -- generic preview markup -------------------------------------------------------------------------------------------------
(defn <preview> [value]
(print-via-writer value :header-tag (pref :max-print-level)))
; -- body-related templates -------------------------------------------------------------------------------------------------
(defn <body> [markup]
[:body-tag markup])
(defn <aligned-body> [markups-lists]
(let [prepend-li-tag (fn [line]
(if line
(concat [:aligned-li-tag] line)))
aligned-lines (keep prepend-li-tag markups-lists)]
(<body> (concat [:standard-ol-no-margin-tag] aligned-lines))))
(defn <standard-body> [markups-lists & [no-margin?]]
(let [ol-tag (if no-margin? :standard-ol-no-margin-tag :standard-ol-tag)
li-tag (if no-margin? :standard-li-no-margin-tag :standard-li-tag)
prepend-li-tag (fn [line]
(if line
(concat [li-tag] line)))
lines-markups (keep prepend-li-tag markups-lists)]
(concat [ol-tag] lines-markups)))
(defn <standard-body-reference> [o]
(<standard-body> [[(<reference> o)]]))
; -- generic details markup -------------------------------------------------------------------------------------------------
(defn <index> [value]
[:index-tag value :line-index-separator])
(defn- body-line [index value]
(let [index-markup (<index> index)
value-markup (print-via-writer value :item-tag (pref :body-line-max-print-level))]
[index-markup value-markup]))
; TODO: this fn is screaming for rewrite
(defn- prepare-body-lines [data starting-index]
(loop [work data
index starting-index
lines []]
(if (empty? work)
lines
(recur (rest work) (inc index) (conj lines (body-line index (first work)))))))
(defn- body-lines [value starting-index]
(let [seq (seq value)
max-number-body-items (pref :max-number-body-items)
chunk (take max-number-body-items seq)
rest (drop max-number-body-items seq)
lines (prepare-body-lines chunk starting-index)
continue? (not (empty? (take 1 rest)))]
(if-not continue?
lines
(let [more-label-markup [:body-items-more-tag :body-items-more-label]
start-index (+ starting-index max-number-body-items)
more-markup (<reference-surrogate> rest more-label-markup :target start-index)]
(conj lines [more-markup])))))
(defn <details> [value starting-index]
(let [has-continuation? (pos? starting-index)
body-markup (<standard-body> (body-lines value starting-index) has-continuation?)]
(if has-continuation?
body-markup
(<body> body-markup))))
; -- generic list template --------------------------------------------------------------------------------------------------
(defn <list-details> [items _opts]
(<aligned-body> (map list items)))
(defn <list> [items max-count & [opts]]
(let [items-markups (take max-count items)
more-count (- (count items) max-count)
more? (pos? more-count)
separator (or (:separator opts) :list-separator)
more-symbol (if more?
(if-let [more-symbol (:more-symbol opts)]
(if (fn? more-symbol)
(more-symbol more-count)
more-symbol)
(get-more-marker more-count)))
preview-markup (concat [(or (:tag opts) :list-tag)
(or (:open-symbol opts) :list-open-symbol)]
(interpose separator items-markups)
(if more? [separator more-symbol])
[(or (:close-symbol opts) :list-close-symbol)])]
(if more?
(let [details-markup (:details opts)
default-details-fn (partial <list-details> items opts)]
(<reference-surrogate> nil preview-markup (or details-markup default-details-fn)))
preview-markup)))
; -- mete-related markup ----------------------------------------------------------------------------------------------------
(defn <meta> [metadata]
(let [body-fn (fn [] [:meta-body-tag (<preview> metadata)])
header [:meta-header-tag "meta"]]
[:meta-reference-tag (<reference-surrogate> metadata header body-fn)])) ; body must be lazy, see #35
(defn <meta-wrapper> [metadata & children]
(concat [:meta-wrapper-tag] children [(<meta> metadata)]))
; -- function markup --------------------------------------------------------------------------------------------------------
(defn <function-details> [fn-obj ns _name arities prefix]
{:pre [(fn? fn-obj)]}
(let [arities (map wrap-arity arities)
make-arity-markup-list (fn [arity]
[[:fn-multi-arity-args-indent-tag prefix]
[:fn-args-tag arity]])
arities-markupts-lists (if (> (count arities) 1) (map make-arity-markup-list arities))
ns-markups-list (if-not (empty? ns) [:ns-icon [:fn-ns-name-tag ns]])
native-markups-list [:native-icon (<native-reference> fn-obj)]]
(<aligned-body> (concat arities-markupts-lists [ns-markups-list native-markups-list]))))
(defn <arities> [arities]
(let [multi-arity? (> (count arities) 1)]
[:fn-args-tag (wrap-arity (if multi-arity?
(pref :multi-arity-symbol)
(first arities)))]))
(defn <function> [fn-obj]
{:pre [(fn? fn-obj)]}
(let [[ns name] (munging/parse-fn-info fn-obj)
lambda? (empty? name)
spacer-symbol (pref :spacer)
rest-symbol (pref :rest-symbol)
multi-arity-symbol (pref :multi-arity-symbol)
arities (munging/extract-arities fn-obj true spacer-symbol multi-arity-symbol rest-symbol)
arities-markup (<arities> arities)
name-markup (if-not lambda? [:fn-name-tag name])
icon-markup (if lambda? :lambda-icon :fn-icon)
prefix-markup [:fn-prefix-tag icon-markup name-markup]
preview-markup [:fn-header-tag prefix-markup arities-markup]
details-fn (partial <function-details> fn-obj ns name arities prefix-markup)]
(<reference-surrogate> fn-obj preview-markup details-fn)))
; -- type markup ------------------------------------------------------------------------------------------------------------
(defn <type-basis-item> [basis-item]
[:type-basis-item-tag (name basis-item)])
(defn <type-basis> [basis]
(let [item-markups (map <type-basis-item> basis)
children-markups (interpose :type-basis-item-separator item-markups)]
(concat [:type-basis-tag] children-markups)))
(defn <type-details> [constructor-fn ns _name basis]
(let [ns-markup (if-not (empty? ns) [:ns-icon [:fn-ns-name-tag ns]])
basis-markup (if (empty? basis)
[:empty-basis-symbol]
[:basis-icon (<type-basis> basis)])
native-markup [:native-icon (<native-reference> constructor-fn)]]
(<aligned-body> [basis-markup ns-markup native-markup])))
(defn <type> [constructor-fn & [header-tag]]
(let [[ns name basis] (munging/parse-constructor-info constructor-fn)
name-markup [:type-name-tag name]
preview-markup [(or header-tag :type-header-tag) :type-symbol name-markup]
details-markup-fn (partial <type-details> constructor-fn ns name basis)]
[:type-wrapper-tag
:type-header-background
[:type-ref-tag (<reference-surrogate> constructor-fn preview-markup details-markup-fn)]]))
(defn <standalone-type> [constructor-fn & [header-tag]]
[:standalone-type-tag (<type> constructor-fn header-tag)])
; -- protocols markup -------------------------------------------------------------------------------------------------------
(defn <protocol-method-arity> [arity-fn]
(<reference> arity-fn))
(defn <protocol-method-arities-details> [fns]
(<aligned-body> (map <protocol-method-arity> fns)))
(defn <protocol-method-arities> [fns & [max-fns]]
(let [max-fns (or max-fns (pref :max-protocol-method-arities-list))
more? (> (count fns) max-fns)
aritites-markups (map <protocol-method-arity> (take max-fns fns))
preview-markup (concat [:protocol-method-arities-header-tag :protocol-method-arities-header-open-symbol]
(interpose :protocol-method-arities-list-header-separator aritites-markups)
(if more? [:protocol-method-arities-more-symbol])
[:protocol-method-arities-header-close-symbol])]
(if more?
(let [details-markup-fn (partial <protocol-method-arities-details> fns)]
(<reference-surrogate> nil preview-markup details-markup-fn))
preview-markup)))
(defn <protocol-method> [name arities]
[:protocol-method-tag
:method-icon
[:protocol-method-name-tag name]
(<protocol-method-arities> arities)])
(defn <protocol-details> [obj ns _name selector _fast?]
(let [protocol-obj (munging/get-protocol-object selector)
ns-markups-list (if-not (empty? ns) [:ns-icon [:protocol-ns-name-tag ns]])
native-markups-list (if (some? protocol-obj) [:native-icon (<native-reference> protocol-obj)])
methods (munging/collect-protocol-methods obj selector)
methods-markups (map (fn [[name arities]] (<protocol-method> name arities)) methods)
methods-markups-lists (map list methods-markups)]
(<aligned-body> (concat methods-markups-lists [ns-markups-list native-markups-list]))))
(defn <protocol> [obj protocol & [tag]]
(let [{:keys [ns name selector fast?]} protocol
preview-markup [(or tag :protocol-name-tag) name]
prefix-markup [(if fast? :fast-protocol-tag :slow-protocol-tag) :protocol-background]]
(if (some? obj)
(let [details-markup-fn (partial <protocol-details> obj ns name selector fast?)]
(conj prefix-markup (<reference-surrogate> obj preview-markup details-markup-fn)))
(conj prefix-markup preview-markup))))
(defn <more-protocols> [more-count]
(let [fake-protocol {:name (get-more-marker more-count)}]
(<protocol> nil fake-protocol :protocol-more-tag)))
(defn <protocols-list> [obj protocols & [max-protocols]]
(let [max-protocols (or max-protocols (pref :max-list-protocols))
protocols-markups (map (partial <protocol> obj) protocols)]
(<list> protocols-markups max-protocols {:tag :protocols-header-tag
:open-symbol :protocols-list-open-symbol
:close-symbol :protocols-list-close-symbol
:separator :header-protocol-separator
:more-symbol <more-protocols>})))
; -- instance fields markup -------------------------------------------------------------------------------------------------
(defn <field> [name value]
[:header-field-tag
[:header-field-name-tag (str name)]
:header-field-value-spacer
[:header-field-value-tag (<reference> (<surrogate> value) #(set-managed-print-level % 1))]
:header-field-separator])
(defn <fields-details-row> [field]
(let [[name value] field]
[:body-field-tr-tag
[:body-field-td1-tag
:body-field-symbol
[:body-field-name-tag (str name)]]
[:body-field-td2-tag
:body-field-value-spacer]
[:body-field-td3-tag
[:body-field-value-tag (<reference-surrogate> value)]]]))
(defn <fields> [fields & [max-fields]]
(if (zero? (count fields))
[:fields-header-tag :fields-header-no-fields-symbol]
(let [max-fields (or max-fields (pref :max-instance-header-fields))
more? (> (count fields) max-fields)
fields-markups (map (fn [[name value]] (<field> name value)) (take max-fields fields))]
(concat [:fields-header-tag
:fields-header-open-symbol]
fields-markups
[(if more? :more-fields-symbol)
:fields-header-close-symbol]))))
(defn <fields-details> [fields obj]
(let [protocols (munging/scan-protocols obj)
has-protocols? (not (empty? protocols))
fields-markup (if-not (zero? (count fields))
[:fields-icon (concat [:instance-body-fields-table-tag] (map <fields-details-row> fields))])
protocols-list-markup (if has-protocols? [:protocols-icon (<protocols-list> obj protocols)])
native-markup [:native-icon (<native-reference> obj)]]
(<aligned-body> [fields-markup protocols-list-markup native-markup])))
; -- type/record instance markup --------------------------------------------------------------------------------------------
(defn <instance> [value]
(let [constructor-fn (get-constructor value)
[_ns _name basis] (munging/parse-constructor-info constructor-fn)
custom-printing? (implements? IPrintWithWriter value)
type-markup (<type> constructor-fn :instance-type-header-tag)
fields (fetch-fields-values value basis)
fields-markup (<fields> fields (if custom-printing? 0))
fields-details-markup-fn #(<fields-details> fields value)
fields-preview-markup [:instance-value-tag (<reference-surrogate> value fields-markup fields-details-markup-fn)]
custom-printing-markup (if custom-printing?
[:instance-custom-printing-wrapper-tag
:instance-custom-printing-background
(print-via-protocol value :instance-custom-printing-tag)])]
[:instance-header-tag
:instance-header-background
fields-preview-markup
custom-printing-markup
type-markup]))
; ---------------------------------------------------------------------------------------------------------------------------
(defn <header> [value]
(<cljs-land> (<preview> value)))
(defn <surrogate-header> [surrogate]
(or (get-surrogate-header surrogate)
(<preview> (get-surrogate-target surrogate))))
(defn <surrogate-target> [surrogate]
(let [target (get-surrogate-target surrogate)]
(if (seqable? target)
(let [starting-index (get-surrogate-start-index surrogate)]
(<details> target starting-index))
(<standard-body-reference> target))))
(defn <surrogate-body> [surrogate]
(if-let [body (get-surrogate-body surrogate)]
(if (= :target body)
(<surrogate-target> surrogate)
body)))
; ---------------------------------------------------------------------------------------------------------------------------
(defn <atomic> [value]
(cond
(should-render? :render-nils value nil?) (<nil>)
(should-render? :render-bools value bool?) (<bool> value)
(should-render? :render-strings value string?) (<string> value)
(should-render? :render-numbers value number?) (<number> value)
(should-render? :render-keywords value keyword?) (<keyword> value)
(should-render? :render-symbols value symbol?) (<symbol> value)
(should-render? :render-instances value should-render-instance?) (<instance> value)
(should-render? :render-types value cljs-type?) (<standalone-type> value)
(should-render? :render-functions value cljs-function?) (<function> value)))
; ---------------------------------------------------------------------------------------------------------------------------
(def ^:dynamic *markup-db*)
; emit-markup-db macro will generate a map of all markup <functions> in this namespace:
;
; {:atomic <atomic>
; :reference <reference>
; :native-reference <native-reference>
; ...}
;
; we generate it only on first call and cache it in *markup-db*
; emitting markup db statically into def would prevent dead-code elimination
;
(defn get-markup-db []
(if (nil? *markup-db*)
(set! *markup-db* (emit-markup-db)))
*markup-db*)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,145 @@
(ns devtools.formatters.printing
(:require-macros [devtools.oops :refer [safe-call]])
(:require [devtools.prefs :refer [pref]]
[devtools.format :refer [IDevtoolsFormat]]
[devtools.protocols :refer [ITemplate IGroup ISurrogate IFormat]]
[devtools.formatters.state :refer [push-object-to-current-history! *current-state* get-current-state
is-circular? get-managed-print-level set-managed-print-level
update-current-state!]]
[devtools.formatters.helpers :refer [cljs-value? expandable? abbreviated? directly-printable? should-render?]]))
; -- helpers ----------------------------------------------------------------------------------------------------------------
(defn markup? [value]
(::markup (meta value)))
(defn mark-as-markup [value]
(with-meta value {::markup true}))
(defn build-markup [markup-db fn-key & args]
(let [f (get markup-db fn-key)]
(assert f (str "missing markup method in markup-db: " fn-key))
(mark-as-markup (apply f args))))
(defn wrap-value-as-reference-if-needed [markup-db value]
(if (or (directly-printable? value) (markup? value))
value
(build-markup markup-db :reference-surrogate value)))
; -- TemplateWriter ---------------------------------------------------------------------------------------------------------
(deftype TemplateWriter [^:mutable group markup-db]
Object
(merge [_ a] (set! group (concat group a)))
(get-group [_] group)
IWriter
(-write [_ o] (set! group (concat group [(wrap-value-as-reference-if-needed markup-db o)]))) ; issue #21
(-flush [_] nil))
(defn make-template-writer [markup-db]
(TemplateWriter. [] markup-db))
; -- post-processing --------------------------------------------------------------------------------------------------------
(defn already-reference? [group]
(if-let [tag (first (first group))]
(= tag "reference")))
(defn wrap-group-in-reference-if-needed [group obj markup-db]
(if (and (not (already-reference? group))
(or (expandable? obj) (abbreviated? group)))
(let [expandable-markup (apply build-markup markup-db :expandable group)
surrogate-markup (build-markup markup-db :raw-surrogate obj expandable-markup :target)
reference-markup (build-markup markup-db :reference surrogate-markup)]
[reference-markup])
group))
(defn wrap-group-in-circular-warning-if-needed [group markup-db circular?]
(if circular?
[(apply build-markup markup-db :circular-reference group)]
group))
(defn wrap-group-in-meta-if-needed [group value markup-db]
(if (should-render? :render-metas value #(some? (meta %)))
[(apply (partial (:meta-wrapper markup-db) (meta value)) group)]
group))
; default printer implementation can do this:
; :else (write-all writer "#<" (str obj) ">")
; we want to wrap stringified obj in a reference for further inspection
;
; this behaviour changed in https://github.com/clojure/clojurescript/commit/34c3b8985ed8197d90f441c46d168c4024a20eb8
; newly functions and :else branch print "#object [" ... "]"
;
; in some situations obj can still be a clojurescript value (e.g. deftypes)
; we have to implement a special flag to prevent infinite recursion
; see https://github.com/binaryage/cljs-devtools/issues/2
; https://github.com/binaryage/cljs-devtools/issues/8
(defn detect-edge-case-and-patch-it [group obj markup-db]
(cond
(or
(and (= (count group) 5) (= (nth group 0) "#object[") (= (nth group 4) "\"]")) ; function case
(and (= (count group) 5) (= (nth group 0) "#object[") (= (nth group 4) "]")) ; :else -constructor case
(and (= (count group) 3) (= (nth group 0) "#object[") (= (nth group 2) "]"))) ; :else -cljs$lang$ctorStr case
[(build-markup markup-db :native-reference obj)]
(and (= (count group) 3) (= (nth group 0) "#<") (= (str obj) (nth group 1)) (= (nth group 2) ">")) ; old code prior r1.7.28
[(nth group 0) (build-markup :native-reference obj) (nth group 2)]
:else group))
(defn post-process-printed-output [output-group obj markup-db circular?]
(-> output-group
(detect-edge-case-and-patch-it obj markup-db) ; an ugly hack
(wrap-group-in-reference-if-needed obj markup-db)
(wrap-group-in-circular-warning-if-needed markup-db circular?)
(wrap-group-in-meta-if-needed obj markup-db)))
; -- alternative printer ----------------------------------------------------------------------------------------------------
(defn alt-printer-job [obj writer opts]
(let [{:keys [markup-db]} opts]
(if (or (safe-call satisfies? false IDevtoolsFormat obj)
(safe-call satisfies? false IFormat obj)) ; we have to wrap value in reference if detected IFormat
(-write writer (build-markup markup-db :reference obj))
(if-let [atomic-markup (build-markup markup-db :atomic obj)]
(-write writer atomic-markup)
(let [default-impl (:fallback-impl opts)
; we want to limit print-level, at max-print-level level use maximal abbreviation e.g. [...] or {...}
inner-opts (if (= *print-level* 1) (assoc opts :print-length 0) opts)]
(default-impl obj writer inner-opts))))))
(defn alt-printer-impl [obj writer opts]
(binding [*current-state* (get-current-state)]
(let [{:keys [markup-db]} opts
circular? (is-circular? obj)
inner-writer (make-template-writer (:markup-db opts))]
(push-object-to-current-history! obj)
(alt-printer-job obj inner-writer opts)
(.merge writer (post-process-printed-output (.get-group inner-writer) obj markup-db circular?)))))
; -- common code for managed printing ---------------------------------------------------------------------------------------
(defn managed-print [tag markup-db printer]
(let [writer (make-template-writer markup-db)
opts {:alt-impl alt-printer-impl
:markup-db markup-db
:print-length (pref :max-header-elements)
:more-marker (pref :more-marker)}
job-fn #(printer writer opts)]
(if-let [managed-print-level (get-managed-print-level)]
(binding [*print-level* managed-print-level]
(update-current-state! #(set-managed-print-level % nil)) ; reset managed-print-level so it does not propagate further down in expaded data
(job-fn))
(job-fn))
(concat [(pref tag)] (.get-group writer))))
; -- public printing API ----------------------------------------------------------------------------------------------------
(defn managed-print-via-writer [value tag markup-db]
(managed-print tag markup-db (fn [writer opts]
(pr-seq-writer [value] writer opts)))) ; note we use pr-seq-writer becasue pr-writer is private for some reason
(defn managed-print-via-protocol [value tag markup-db]
(managed-print tag markup-db (fn [writer opts]
(-pr-writer value writer opts))))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,299 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('devtools.formatters.printing');
goog.require('cljs.core');
goog.require('devtools.prefs');
goog.require('devtools.format');
goog.require('devtools.protocols');
goog.require('devtools.formatters.state');
goog.require('devtools.formatters.helpers');
devtools.formatters.printing.markup_QMARK_ = (function devtools$formatters$printing$markup_QMARK_(value){
return new cljs.core.Keyword("devtools.formatters.printing","markup","devtools.formatters.printing/markup",-1990109186).cljs$core$IFn$_invoke$arity$1(cljs.core.meta.call(null,value));
});
devtools.formatters.printing.mark_as_markup = (function devtools$formatters$printing$mark_as_markup(value){
return cljs.core.with_meta.call(null,value,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("devtools.formatters.printing","markup","devtools.formatters.printing/markup",-1990109186),true], null));
});
devtools.formatters.printing.build_markup = (function devtools$formatters$printing$build_markup(var_args){
var args__4736__auto__ = [];
var len__4730__auto___26287 = arguments.length;
var i__4731__auto___26288 = (0);
while(true){
if((i__4731__auto___26288 < len__4730__auto___26287)){
args__4736__auto__.push((arguments[i__4731__auto___26288]));
var G__26289 = (i__4731__auto___26288 + (1));
i__4731__auto___26288 = G__26289;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((2) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((2)),(0),null)):null);
return devtools.formatters.printing.build_markup.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4737__auto__);
});
devtools.formatters.printing.build_markup.cljs$core$IFn$_invoke$arity$variadic = (function (markup_db,fn_key,args){
var f = cljs.core.get.call(null,markup_db,fn_key);
if(cljs.core.truth_(f)){
} else {
throw (new Error(["Assert failed: ",["missing markup method in markup-db: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(fn_key)].join(''),"\n","f"].join('')));
}
return devtools.formatters.printing.mark_as_markup.call(null,cljs.core.apply.call(null,f,args));
});
devtools.formatters.printing.build_markup.cljs$lang$maxFixedArity = (2);
/** @this {Function} */
devtools.formatters.printing.build_markup.cljs$lang$applyTo = (function (seq26284){
var G__26285 = cljs.core.first.call(null,seq26284);
var seq26284__$1 = cljs.core.next.call(null,seq26284);
var G__26286 = cljs.core.first.call(null,seq26284__$1);
var seq26284__$2 = cljs.core.next.call(null,seq26284__$1);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__26285,G__26286,seq26284__$2);
});
devtools.formatters.printing.wrap_value_as_reference_if_needed = (function devtools$formatters$printing$wrap_value_as_reference_if_needed(markup_db,value){
if(cljs.core.truth_((function (){var or__4131__auto__ = devtools.formatters.helpers.directly_printable_QMARK_.call(null,value);
if(or__4131__auto__){
return or__4131__auto__;
} else {
return devtools.formatters.printing.markup_QMARK_.call(null,value);
}
})())){
return value;
} else {
return devtools.formatters.printing.build_markup.call(null,markup_db,new cljs.core.Keyword(null,"reference-surrogate","reference-surrogate",274031791),value);
}
});
/**
* @constructor
* @implements {cljs.core.IWriter}
* @implements {devtools.formatters.printing.Object}
*/
devtools.formatters.printing.TemplateWriter = (function (group,markup_db){
this.group = group;
this.markup_db = markup_db;
this.cljs$lang$protocol_mask$partition0$ = 1073741824;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
devtools.formatters.printing.TemplateWriter.prototype.merge = (function (a){
var self__ = this;
var _ = this;
return self__.group = cljs.core.concat.call(null,self__.group,a);
});
devtools.formatters.printing.TemplateWriter.prototype.get_group = (function (){
var self__ = this;
var _ = this;
return self__.group;
});
devtools.formatters.printing.TemplateWriter.prototype.cljs$core$IWriter$_write$arity$2 = (function (_,o){
var self__ = this;
var ___$1 = this;
return self__.group = cljs.core.concat.call(null,self__.group,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [devtools.formatters.printing.wrap_value_as_reference_if_needed.call(null,self__.markup_db,o)], null));
});
devtools.formatters.printing.TemplateWriter.prototype.cljs$core$IWriter$_flush$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return null;
});
devtools.formatters.printing.TemplateWriter.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"group","group",-2071839637,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"markup-db","markup-db",-1841597035,null)], null);
});
devtools.formatters.printing.TemplateWriter.cljs$lang$type = true;
devtools.formatters.printing.TemplateWriter.cljs$lang$ctorStr = "devtools.formatters.printing/TemplateWriter";
devtools.formatters.printing.TemplateWriter.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"devtools.formatters.printing/TemplateWriter");
});
/**
* Positional factory function for devtools.formatters.printing/TemplateWriter.
*/
devtools.formatters.printing.__GT_TemplateWriter = (function devtools$formatters$printing$__GT_TemplateWriter(group,markup_db){
return (new devtools.formatters.printing.TemplateWriter(group,markup_db));
});
devtools.formatters.printing.make_template_writer = (function devtools$formatters$printing$make_template_writer(markup_db){
return (new devtools.formatters.printing.TemplateWriter(cljs.core.PersistentVector.EMPTY,markup_db));
});
devtools.formatters.printing.already_reference_QMARK_ = (function devtools$formatters$printing$already_reference_QMARK_(group){
var temp__5718__auto__ = cljs.core.first.call(null,cljs.core.first.call(null,group));
if(cljs.core.truth_(temp__5718__auto__)){
var tag = temp__5718__auto__;
return cljs.core._EQ_.call(null,tag,"reference");
} else {
return null;
}
});
devtools.formatters.printing.wrap_group_in_reference_if_needed = (function devtools$formatters$printing$wrap_group_in_reference_if_needed(group,obj,markup_db){
if(cljs.core.truth_((function (){var and__4120__auto__ = cljs.core.not.call(null,devtools.formatters.printing.already_reference_QMARK_.call(null,group));
if(and__4120__auto__){
var or__4131__auto__ = devtools.formatters.helpers.expandable_QMARK_.call(null,obj);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return devtools.formatters.helpers.abbreviated_QMARK_.call(null,group);
}
} else {
return and__4120__auto__;
}
})())){
var expandable_markup = cljs.core.apply.call(null,devtools.formatters.printing.build_markup,markup_db,new cljs.core.Keyword(null,"expandable","expandable",-704609097),group);
var surrogate_markup = devtools.formatters.printing.build_markup.call(null,markup_db,new cljs.core.Keyword(null,"raw-surrogate","raw-surrogate",904931181),obj,expandable_markup,new cljs.core.Keyword(null,"target","target",253001721));
var reference_markup = devtools.formatters.printing.build_markup.call(null,markup_db,new cljs.core.Keyword(null,"reference","reference",-1711695023),surrogate_markup);
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [reference_markup], null);
} else {
return group;
}
});
devtools.formatters.printing.wrap_group_in_circular_warning_if_needed = (function devtools$formatters$printing$wrap_group_in_circular_warning_if_needed(group,markup_db,circular_QMARK_){
if(cljs.core.truth_(circular_QMARK_)){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.apply.call(null,devtools.formatters.printing.build_markup,markup_db,new cljs.core.Keyword(null,"circular-reference","circular-reference",970308727),group)], null);
} else {
return group;
}
});
devtools.formatters.printing.wrap_group_in_meta_if_needed = (function devtools$formatters$printing$wrap_group_in_meta_if_needed(group,value,markup_db){
if(cljs.core.truth_(devtools.formatters.helpers.should_render_QMARK_.call(null,new cljs.core.Keyword(null,"render-metas","render-metas",1141294116),value,(function (p1__26290_SHARP_){
return (!((cljs.core.meta.call(null,p1__26290_SHARP_) == null)));
})))){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.apply.call(null,cljs.core.partial.call(null,new cljs.core.Keyword(null,"meta-wrapper","meta-wrapper",-1989845587).cljs$core$IFn$_invoke$arity$1(markup_db),cljs.core.meta.call(null,value)),group)], null);
} else {
return group;
}
});
devtools.formatters.printing.detect_edge_case_and_patch_it = (function devtools$formatters$printing$detect_edge_case_and_patch_it(group,obj,markup_db){
if(((((cljs.core._EQ_.call(null,cljs.core.count.call(null,group),(5))) && (cljs.core._EQ_.call(null,cljs.core.nth.call(null,group,(0)),"#object[")) && (cljs.core._EQ_.call(null,cljs.core.nth.call(null,group,(4)),"\"]")))) || (((cljs.core._EQ_.call(null,cljs.core.count.call(null,group),(5))) && (cljs.core._EQ_.call(null,cljs.core.nth.call(null,group,(0)),"#object[")) && (cljs.core._EQ_.call(null,cljs.core.nth.call(null,group,(4)),"]")))) || (((cljs.core._EQ_.call(null,cljs.core.count.call(null,group),(3))) && (cljs.core._EQ_.call(null,cljs.core.nth.call(null,group,(0)),"#object[")) && (cljs.core._EQ_.call(null,cljs.core.nth.call(null,group,(2)),"]")))))){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [devtools.formatters.printing.build_markup.call(null,markup_db,new cljs.core.Keyword(null,"native-reference","native-reference",-2013708658),obj)], null);
} else {
if(((cljs.core._EQ_.call(null,cljs.core.count.call(null,group),(3))) && (cljs.core._EQ_.call(null,cljs.core.nth.call(null,group,(0)),"#<")) && (cljs.core._EQ_.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(obj),cljs.core.nth.call(null,group,(1)))) && (cljs.core._EQ_.call(null,cljs.core.nth.call(null,group,(2)),">")))){
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.nth.call(null,group,(0)),devtools.formatters.printing.build_markup.call(null,new cljs.core.Keyword(null,"native-reference","native-reference",-2013708658),obj),cljs.core.nth.call(null,group,(2))], null);
} else {
return group;
}
}
});
devtools.formatters.printing.post_process_printed_output = (function devtools$formatters$printing$post_process_printed_output(output_group,obj,markup_db,circular_QMARK_){
return devtools.formatters.printing.wrap_group_in_meta_if_needed.call(null,devtools.formatters.printing.wrap_group_in_circular_warning_if_needed.call(null,devtools.formatters.printing.wrap_group_in_reference_if_needed.call(null,devtools.formatters.printing.detect_edge_case_and_patch_it.call(null,output_group,obj,markup_db),obj,markup_db),markup_db,circular_QMARK_),obj,markup_db);
});
devtools.formatters.printing.alt_printer_job = (function devtools$formatters$printing$alt_printer_job(obj,writer,opts){
var map__26291 = opts;
var map__26291__$1 = (((((!((map__26291 == null))))?(((((map__26291.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__26291.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__26291):map__26291);
var markup_db = cljs.core.get.call(null,map__26291__$1,new cljs.core.Keyword(null,"markup-db","markup-db",812838734));
if(cljs.core.truth_((function (){var or__4131__auto__ = (function (){try{if((!((obj == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === obj.devtools$format$IDevtoolsFormat$)))){
return true;
} else {
if((!obj.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,obj);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.format.IDevtoolsFormat,obj);
}
}catch (e26295){var _e__25272__auto__ = e26295;
return false;
}})();
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
try{if((!((obj == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === obj.devtools$protocols$IFormat$)))){
return true;
} else {
if((!obj.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,obj);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IFormat,obj);
}
}catch (e26297){var _e__25272__auto__ = e26297;
return false;
}}
})())){
return cljs.core._write.call(null,writer,devtools.formatters.printing.build_markup.call(null,markup_db,new cljs.core.Keyword(null,"reference","reference",-1711695023),obj));
} else {
var temp__5718__auto__ = devtools.formatters.printing.build_markup.call(null,markup_db,new cljs.core.Keyword(null,"atomic","atomic",-120459460),obj);
if(cljs.core.truth_(temp__5718__auto__)){
var atomic_markup = temp__5718__auto__;
return cljs.core._write.call(null,writer,atomic_markup);
} else {
var default_impl = new cljs.core.Keyword(null,"fallback-impl","fallback-impl",-1501286995).cljs$core$IFn$_invoke$arity$1(opts);
var inner_opts = ((cljs.core._EQ_.call(null,cljs.core._STAR_print_level_STAR_,(1)))?cljs.core.assoc.call(null,opts,new cljs.core.Keyword(null,"print-length","print-length",1931866356),(0)):opts);
return default_impl.call(null,obj,writer,inner_opts);
}
}
});
devtools.formatters.printing.alt_printer_impl = (function devtools$formatters$printing$alt_printer_impl(obj,writer,opts){
var _STAR_current_state_STAR__orig_val__26299 = devtools.formatters.state._STAR_current_state_STAR_;
var _STAR_current_state_STAR__temp_val__26300 = devtools.formatters.state.get_current_state.call(null);
devtools.formatters.state._STAR_current_state_STAR_ = _STAR_current_state_STAR__temp_val__26300;
try{var map__26301 = opts;
var map__26301__$1 = (((((!((map__26301 == null))))?(((((map__26301.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__26301.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__26301):map__26301);
var markup_db = cljs.core.get.call(null,map__26301__$1,new cljs.core.Keyword(null,"markup-db","markup-db",812838734));
var circular_QMARK_ = devtools.formatters.state.is_circular_QMARK_.call(null,obj);
var inner_writer = devtools.formatters.printing.make_template_writer.call(null,new cljs.core.Keyword(null,"markup-db","markup-db",812838734).cljs$core$IFn$_invoke$arity$1(opts));
devtools.formatters.state.push_object_to_current_history_BANG_.call(null,obj);
devtools.formatters.printing.alt_printer_job.call(null,obj,inner_writer,opts);
return writer.merge(devtools.formatters.printing.post_process_printed_output.call(null,inner_writer.get_group(),obj,markup_db,circular_QMARK_));
}finally {devtools.formatters.state._STAR_current_state_STAR_ = _STAR_current_state_STAR__orig_val__26299;
}});
devtools.formatters.printing.managed_print = (function devtools$formatters$printing$managed_print(tag,markup_db,printer){
var writer = devtools.formatters.printing.make_template_writer.call(null,markup_db);
var opts = new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"alt-impl","alt-impl",670969595),devtools.formatters.printing.alt_printer_impl,new cljs.core.Keyword(null,"markup-db","markup-db",812838734),markup_db,new cljs.core.Keyword(null,"print-length","print-length",1931866356),devtools.prefs.pref.call(null,new cljs.core.Keyword(null,"max-header-elements","max-header-elements",713629864)),new cljs.core.Keyword(null,"more-marker","more-marker",-14717935),devtools.prefs.pref.call(null,new cljs.core.Keyword(null,"more-marker","more-marker",-14717935))], null);
var job_fn = ((function (writer,opts){
return (function (){
return printer.call(null,writer,opts);
});})(writer,opts))
;
var temp__5718__auto___26306 = devtools.formatters.state.get_managed_print_level.call(null);
if(cljs.core.truth_(temp__5718__auto___26306)){
var managed_print_level_26307 = temp__5718__auto___26306;
var _STAR_print_level_STAR__orig_val__26304_26308 = cljs.core._STAR_print_level_STAR_;
var _STAR_print_level_STAR__temp_val__26305_26309 = managed_print_level_26307;
cljs.core._STAR_print_level_STAR_ = _STAR_print_level_STAR__temp_val__26305_26309;
try{devtools.formatters.state.update_current_state_BANG_.call(null,((function (_STAR_print_level_STAR__orig_val__26304_26308,_STAR_print_level_STAR__temp_val__26305_26309,managed_print_level_26307,temp__5718__auto___26306,writer,opts,job_fn){
return (function (p1__26303_SHARP_){
return devtools.formatters.state.set_managed_print_level.call(null,p1__26303_SHARP_,null);
});})(_STAR_print_level_STAR__orig_val__26304_26308,_STAR_print_level_STAR__temp_val__26305_26309,managed_print_level_26307,temp__5718__auto___26306,writer,opts,job_fn))
);
job_fn.call(null);
}finally {cljs.core._STAR_print_level_STAR_ = _STAR_print_level_STAR__orig_val__26304_26308;
}} else {
job_fn.call(null);
}
return cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [devtools.prefs.pref.call(null,tag)], null),writer.get_group());
});
devtools.formatters.printing.managed_print_via_writer = (function devtools$formatters$printing$managed_print_via_writer(value,tag,markup_db){
return devtools.formatters.printing.managed_print.call(null,tag,markup_db,(function (writer,opts){
return cljs.core.pr_seq_writer.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [value], null),writer,opts);
}));
});
devtools.formatters.printing.managed_print_via_protocol = (function devtools$formatters$printing$managed_print_via_protocol(value,tag,markup_db){
return devtools.formatters.printing.managed_print.call(null,tag,markup_db,(function (writer,opts){
return cljs.core._pr_writer.call(null,value,writer,opts);
}));
});
//# sourceMappingURL=printing.js.map?rel=1582560149156

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,73 @@
(ns devtools.formatters.state)
; - state management --------------------------------------------------------------------------------------------------------
;
; we have to maintain some state:
; a) to prevent infinite recursion in some pathological cases (https://github.com/binaryage/cljs-devtools/issues/2)
; b) to keep track of printed objects to visually signal circular data structures
;
; We dynamically bind *current-config* to the config passed from "outside" when entering calls to our API methods.
; Initially the state is empty, but we accumulate there a history of seen values when rendering individual values
; in depth-first traversal order. See alt-printer-impl where we re-bind *current-config* for each traversal level.
; But there is a catch. For larger data structures our printing methods usually do not print everything at once.
; We can include so called "object references" which are just placeholders which can be expanded later
; by DevTools UI (when user clicks a disclosure triangle).
; For proper continuation in rendering of those references we have to carry our existing state over.
; We use "config" feature of custom formatters system to pass current state to future API calls.
(def ^:dynamic *current-state* nil)
(defn valid-current-state? []
(some? *current-state*))
(defn get-default-state []
{})
(defn get-current-state []
{:pre [(valid-current-state?)]}
*current-state*)
(defn update-current-state! [f & args]
{:pre [(valid-current-state?)]}
(set! *current-state* (apply f *current-state* args)))
; -- high level API ---------------------------------------------------------------------------------------------------------
(defn push-object-to-current-history! [object]
(update-current-state! update :history conj object))
(defn get-current-history []
(:history (get-current-state)))
(defn is-circular? [object]
(let [history (get-current-history)]
(some #(identical? % object) history)))
(defn ^bool prevent-recursion? []
(boolean (:prevent-recursion (get-current-state))))
(defn set-prevent-recursion [state val]
(if (some? val)
(assoc state :prevent-recursion val)
(dissoc state :prevent-recursion)))
(defn get-managed-print-level []
(:managed-print-level (get-current-state)))
(defn set-managed-print-level [state val]
(if (some? val)
(assoc state :managed-print-level val)
(dissoc state :managed-print-level)))
(defn get-depth-budget []
(:depth-budget (get-current-state)))
(defn set-depth-budget [state val]
(if (some? val)
(assoc state :depth-budget val)
(dissoc state :depth-budget)))
(defn reset-depth-limits [state]
(-> state
(set-depth-budget nil)
(set-managed-print-level nil)))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,106 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('devtools.formatters.state');
goog.require('cljs.core');
devtools.formatters.state._STAR_current_state_STAR_ = null;
devtools.formatters.state.valid_current_state_QMARK_ = (function devtools$formatters$state$valid_current_state_QMARK_(){
return (!((devtools.formatters.state._STAR_current_state_STAR_ == null)));
});
devtools.formatters.state.get_default_state = (function devtools$formatters$state$get_default_state(){
return cljs.core.PersistentArrayMap.EMPTY;
});
devtools.formatters.state.get_current_state = (function devtools$formatters$state$get_current_state(){
if(devtools.formatters.state.valid_current_state_QMARK_.call(null)){
} else {
throw (new Error("Assert failed: (valid-current-state?)"));
}
return devtools.formatters.state._STAR_current_state_STAR_;
});
devtools.formatters.state.update_current_state_BANG_ = (function devtools$formatters$state$update_current_state_BANG_(var_args){
var args__4736__auto__ = [];
var len__4730__auto___26278 = arguments.length;
var i__4731__auto___26279 = (0);
while(true){
if((i__4731__auto___26279 < len__4730__auto___26278)){
args__4736__auto__.push((arguments[i__4731__auto___26279]));
var G__26280 = (i__4731__auto___26279 + (1));
i__4731__auto___26279 = G__26280;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
return devtools.formatters.state.update_current_state_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
});
devtools.formatters.state.update_current_state_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
if(devtools.formatters.state.valid_current_state_QMARK_.call(null)){
} else {
throw (new Error("Assert failed: (valid-current-state?)"));
}
return devtools.formatters.state._STAR_current_state_STAR_ = cljs.core.apply.call(null,f,devtools.formatters.state._STAR_current_state_STAR_,args);
});
devtools.formatters.state.update_current_state_BANG_.cljs$lang$maxFixedArity = (1);
/** @this {Function} */
devtools.formatters.state.update_current_state_BANG_.cljs$lang$applyTo = (function (seq26276){
var G__26277 = cljs.core.first.call(null,seq26276);
var seq26276__$1 = cljs.core.next.call(null,seq26276);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__26277,seq26276__$1);
});
devtools.formatters.state.push_object_to_current_history_BANG_ = (function devtools$formatters$state$push_object_to_current_history_BANG_(object){
return devtools.formatters.state.update_current_state_BANG_.call(null,cljs.core.update,new cljs.core.Keyword(null,"history","history",-247395220),cljs.core.conj,object);
});
devtools.formatters.state.get_current_history = (function devtools$formatters$state$get_current_history(){
return new cljs.core.Keyword(null,"history","history",-247395220).cljs$core$IFn$_invoke$arity$1(devtools.formatters.state.get_current_state.call(null));
});
devtools.formatters.state.is_circular_QMARK_ = (function devtools$formatters$state$is_circular_QMARK_(object){
var history = devtools.formatters.state.get_current_history.call(null);
return cljs.core.some.call(null,((function (history){
return (function (p1__26281_SHARP_){
return (p1__26281_SHARP_ === object);
});})(history))
,history);
});
devtools.formatters.state.prevent_recursion_QMARK_ = (function devtools$formatters$state$prevent_recursion_QMARK_(){
return cljs.core.boolean$.call(null,new cljs.core.Keyword(null,"prevent-recursion","prevent-recursion",-1498371606).cljs$core$IFn$_invoke$arity$1(devtools.formatters.state.get_current_state.call(null)));
});
devtools.formatters.state.set_prevent_recursion = (function devtools$formatters$state$set_prevent_recursion(state,val){
if((!((val == null)))){
return cljs.core.assoc.call(null,state,new cljs.core.Keyword(null,"prevent-recursion","prevent-recursion",-1498371606),val);
} else {
return cljs.core.dissoc.call(null,state,new cljs.core.Keyword(null,"prevent-recursion","prevent-recursion",-1498371606));
}
});
devtools.formatters.state.get_managed_print_level = (function devtools$formatters$state$get_managed_print_level(){
return new cljs.core.Keyword(null,"managed-print-level","managed-print-level",-844058473).cljs$core$IFn$_invoke$arity$1(devtools.formatters.state.get_current_state.call(null));
});
devtools.formatters.state.set_managed_print_level = (function devtools$formatters$state$set_managed_print_level(state,val){
if((!((val == null)))){
return cljs.core.assoc.call(null,state,new cljs.core.Keyword(null,"managed-print-level","managed-print-level",-844058473),val);
} else {
return cljs.core.dissoc.call(null,state,new cljs.core.Keyword(null,"managed-print-level","managed-print-level",-844058473));
}
});
devtools.formatters.state.get_depth_budget = (function devtools$formatters$state$get_depth_budget(){
return new cljs.core.Keyword(null,"depth-budget","depth-budget",-335905888).cljs$core$IFn$_invoke$arity$1(devtools.formatters.state.get_current_state.call(null));
});
devtools.formatters.state.set_depth_budget = (function devtools$formatters$state$set_depth_budget(state,val){
if((!((val == null)))){
return cljs.core.assoc.call(null,state,new cljs.core.Keyword(null,"depth-budget","depth-budget",-335905888),val);
} else {
return cljs.core.dissoc.call(null,state,new cljs.core.Keyword(null,"depth-budget","depth-budget",-335905888));
}
});
devtools.formatters.state.reset_depth_limits = (function devtools$formatters$state$reset_depth_limits(state){
return devtools.formatters.state.set_managed_print_level.call(null,devtools.formatters.state.set_depth_budget.call(null,state,null),null);
});
//# sourceMappingURL=state.js.map?rel=1582560149121

View file

@ -0,0 +1 @@
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/resources\/public\/js\/compiled\/out\/devtools\/formatters\/state.js","sources":["state.cljs?rel=1582560149121"],"lineCount":106,"mappings":";AAAA;;AAiBA,sDAAA,tDAAeA;AAEf,uDAAA,vDAAMC;AAAN,AACE,UAAA,wDAAA,vDAAOD;;AAET,8CAAA,9CAAME;AAAN,AAAA;;AAGA,8CAAA,9CAAME;AAAN,AAAA,GACS,AAACH;AADV;AAAA,AAAA,MAAA,KAAAE,MAAA;;;AAEEH;;AAEF,AAAA,uDAAA,+DAAAK,tHAAMM;AAAN,AAAA,IAAAL,qBAAA;AAAA,AAAA,IAAAC,0BAAA,AAAA;AAAA,AAAA,IAAAC,wBAAA;;AAAA,AAAA,GAAA,CAAAA,wBAAAD;AAAA,AAAA,AAAAD,wBAAA,CAAA,UAAAE;;AAAA,eAAA,CAAAA,wBAAA;;;;AAAA;;;;AAAA,IAAAC,uBAAA,EAAA,CAAA,MAAA,AAAAH,4BAAA,AAAA,KAAAI,qBAAA,AAAAJ,yBAAA,KAAA,IAAA,OAAA;AAAA,AAAA,OAAAK,0FAAA,CAAA,UAAA,MAAAF;;;AAAA,AAAA,AAAA,4FAAA,5FAAME,uGAAuBM,EAAIC;AAAjC,AAAA,GACS,AAACjB;AADV;AAAA,AAAA,MAAA,KAAAE,MAAA;;;AAEE,OAAMH,sDAAgB,AAACmB,0BAAMF,EAAEjB,oDAAgBkB;;;AAFjD,AAAA,+EAAA,\/EAAMP;;AAAN;AAAA,AAAA,yEAAA,WAAAC,pFAAMD;AAAN,AAAA,IAAAE,WAAA,AAAAC,0BAAAF;IAAAA,eAAA,AAAAG,yBAAAH;AAAA,AAAA,IAAAI,qBAAA;AAAA,AAAA,OAAAA,wDAAAH,SAAAD;;;AAAA,AAMA,iEAAA,jEAAMQ,0IAAiCC;AAAvC,AACE,uFAAA,hFAACV,+DAAsBW,4EAAgBC,eAAKF;;AAE9C,gDAAA,hDAAMG;AAAN,AACE,OAAA,yFAAU,AAACpB;;AAEb,+CAAA,\/CAAMqB,sGAAcJ;AAApB,AACE,IAAMK,UAAQ,AAACF;AAAf,AACE,gCAAA,zBAACI;kBAADD;AAAA,AAAO,QAAAA,qBAAcN;;CAAQK;;AAEjC,qDAAA,rDAAYG;AAAZ,AACE,OAACC,6BAAQ,AAAA,8GAAoB,AAAC1B;;AAEhC,kDAAA,lDAAM2B,4GAAuBC,MAAMC;AAAnC,AACE,GAAI,GAAA,QAAA,PAAOA;AACT,uCAAA,hCAACC,0BAAMF,sFAAyBC;;AAChC,wCAAA,jCAACE,2BAAOH;;;AAEZ,oDAAA,pDAAMI;AAAN,AACE,OAAA,iHAAsB,AAAChC;;AAEzB,oDAAA,pDAAMiC,gHAAyBL,MAAMC;AAArC,AACE,GAAI,GAAA,QAAA,PAAOA;AACT,uCAAA,hCAACC,0BAAMF,yFAA2BC;;AAClC,wCAAA,jCAACE,2BAAOH;;;AAEZ,6CAAA,7CAAMM;AAAN,AACE,OAAA,mGAAe,AAAClC;;AAElB,6CAAA,7CAAMmC,kGAAkBP,MAAMC;AAA9B,AACE,GAAI,GAAA,QAAA,PAAOA;AACT,uCAAA,hCAACC,0BAAMF,2EAAoBC;;AAC3B,wCAAA,jCAACE,2BAAOH;;;AAEZ,+CAAA,\/CAAMQ,sGAAoBR;AAA1B,wHACMA,rDACA,2DAAA,3DAACO,nEACD,oIAAA,7HAACF","names":["devtools.formatters.state\/*current-state*","devtools.formatters.state\/valid-current-state?","devtools.formatters.state\/get-default-state","js\/Error","devtools.formatters.state\/get-current-state","var_args","args__4736__auto__","len__4730__auto__","i__4731__auto__","argseq__4737__auto__","cljs.core\/IndexedSeq","devtools.formatters.state\/update-current-state!","seq26276","G__26277","cljs.core\/first","cljs.core\/next","self__4717__auto__","f","args","cljs.core\/apply","devtools.formatters.state\/push-object-to-current-history!","object","cljs.core\/update","cljs.core\/conj","devtools.formatters.state\/get-current-history","devtools.formatters.state\/is-circular?","history","p1__26281#","cljs.core\/some","devtools.formatters.state\/prevent-recursion?","cljs.core\/boolean","devtools.formatters.state\/set-prevent-recursion","state","val","cljs.core\/assoc","cljs.core\/dissoc","devtools.formatters.state\/get-managed-print-level","devtools.formatters.state\/set-managed-print-level","devtools.formatters.state\/get-depth-budget","devtools.formatters.state\/set-depth-budget","devtools.formatters.state\/reset-depth-limits"]}

View file

@ -0,0 +1,209 @@
(ns devtools.formatters.templating
(:require-macros [devtools.oops :refer [oget oset ocall oapply safe-call unchecked-aget]])
(:require [clojure.walk :refer [prewalk]]
[devtools.util :refer [pprint-str]]
[devtools.protocols :refer [ITemplate IGroup ISurrogate IFormat]]
[devtools.formatters.helpers :refer [pref cljs-value?]]
[devtools.formatters.state :refer [get-current-state prevent-recursion?]]
[clojure.string :as string]))
; -- object marking support -------------------------------------------------------------------------------------------------
(defn mark-as-group! [value]
(specify! value IGroup)
value)
(defn group? [value]
(satisfies? IGroup value))
(defn mark-as-template! [value]
(specify! value ITemplate)
value)
(defn template? [value]
(satisfies? ITemplate value))
(defn mark-as-surrogate! [value]
(specify! value ISurrogate)
value)
(defn surrogate? [value]
(satisfies? ISurrogate value))
(defn reference? [value]
(and (group? value)
(= (unchecked-aget value 0) "object")))
; ---------------------------------------------------------------------------------------------------------------------------
(defn make-group [& items]
(let [group (mark-as-group! #js [])]
(doseq [item items]
(if (some? item)
(if (coll? item)
(.apply (unchecked-aget group "push") group (mark-as-group! (into-array item))) ; convenience helper to splat cljs collections
(.push group (pref item)))))
group))
(defn make-template
[tag style & children]
(let [tag (pref tag)
style (pref style)
template (mark-as-template! #js [tag (if (empty? style)
#js {}
#js {"style" style})])]
(doseq [child children]
(if (some? child)
(if (coll? child)
(.apply (unchecked-aget template "push") template (mark-as-template! (into-array (keep pref child)))) ; convenience helper to splat cljs collections
(if-let [child-value (pref child)]
(.push template child-value)))))
template))
(defn concat-templates! [template & templates]
(mark-as-template! (.apply (oget template "concat") template (into-array (map into-array (keep pref templates))))))
(defn extend-template! [template & args]
(concat-templates! template args))
(defn make-surrogate
; passing :target as body means that targt object body should be rendered using standard templates
; see <surrogate-body> in markup.cljs
([object] (make-surrogate object nil))
([object header] (make-surrogate object header nil))
([object header body] (make-surrogate object header body 0))
([object header body start-index]
(mark-as-surrogate! (js-obj
"target" object
"header" header
"body" body
"startIndex" (or start-index 0)))))
(defn get-surrogate-target [surrogate]
{:pre [(surrogate? surrogate)]}
(oget surrogate "target"))
(defn get-surrogate-header [surrogate]
{:pre [(surrogate? surrogate)]}
(oget surrogate "header"))
(defn get-surrogate-body [surrogate]
{:pre [(surrogate? surrogate)]}
(oget surrogate "body"))
(defn get-surrogate-start-index [surrogate]
{:pre [(surrogate? surrogate)]}
(oget surrogate "startIndex"))
(defn make-reference [object & [state-override-fn]]
{:pre [(or (nil? state-override-fn) (fn? state-override-fn))]}
(if (nil? object)
; this code is duplicated in markup.cljs <nil>
(make-template :span :nil-style :nil-label)
(let [sub-state (if (some? state-override-fn)
(state-override-fn (get-current-state))
(get-current-state))]
(make-group "object" #js {"object" object
"config" sub-state}))))
; -- JSON ML support --------------------------------------------------------------------------------------------------------
; a renderer from hiccup-like data markup to json-ml
;
; [[tag style] child1 child2 ...] -> #js [tag #js {"style" ...} child1 child2 ...]
;
(declare render-json-ml*)
(def ^:dynamic *current-render-stack* [])
(def ^:dynamic *current-render-path* [])
(defn print-preview [markup]
(binding [*print-level* 1]
(pr-str markup)))
(defn add-stack-separators [stack]
(interpose "-------------" stack))
(defn replace-fns-with-markers [stack]
(let [f (fn [v]
(if (fn? v)
"##fn##"
v))]
(prewalk f stack)))
(defn pprint-render-calls [stack]
(map pprint-str stack))
(defn pprint-render-stack [stack]
(string/join "\n" (-> stack
reverse
replace-fns-with-markers
pprint-render-calls
add-stack-separators)))
(defn pprint-render-path [path]
(pprint-str path))
(defn assert-markup-error [msg]
(assert false (str msg "\n"
"Render path: " (pprint-render-path *current-render-path*) "\n"
"Render stack:\n"
(pprint-render-stack *current-render-stack*))))
(defn surrogate-markup? [markup]
(and (sequential? markup) (= (first markup) "surrogate")))
(defn render-special [name args]
(case name
"surrogate" (let [obj (first args)
converted-args (map render-json-ml* (rest args))]
(apply make-surrogate (concat [obj] converted-args)))
"reference" (let [obj (first args)
converted-obj (if (surrogate-markup? obj) (render-json-ml* obj) obj)]
(apply make-reference (concat [converted-obj] (rest args))))
(assert-markup-error (str "no matching special tag name: '" name "'"))))
(defn emptyish? [v]
(if (or (seqable? v) (array? v) (string? v))
(empty? v)
false))
(defn render-subtree [tag children]
(let [[html-tag style] tag]
(apply make-template html-tag style (map render-json-ml* (remove emptyish? (map pref children))))))
(defn render-json-ml* [markup]
(if-not (sequential? markup)
markup
(binding [*current-render-path* (conj *current-render-path* (first markup))]
(let [tag (pref (first markup))]
(cond
(string? tag) (render-special tag (rest markup))
(sequential? tag) (render-subtree tag (rest markup))
:else (assert-markup-error (str "invalid json-ml markup at " (print-preview markup) ":")))))))
(defn render-json-ml [markup]
(binding [*current-render-stack* (conj *current-render-stack* markup)
*current-render-path* (conj *current-render-path* "<render-json-ml>")]
(render-json-ml* markup)))
; -- template rendering -----------------------------------------------------------------------------------------------------
(defn ^:dynamic assert-failed-markup-rendering [initial-value value]
(assert false (str "result of markup rendering must be a template,\n"
"resolved to " (pprint-str value)
"initial value: " (pprint-str initial-value))))
(defn render-markup* [initial-value value]
(cond
(fn? value) (recur initial-value (value))
(keyword? value) (recur initial-value (pref value))
(sequential? value) (recur initial-value (render-json-ml value))
(template? value) value
(surrogate? value) value
(reference? value) value
:else (assert-failed-markup-rendering initial-value value)))
(defn render-markup [value]
(render-markup* value value))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,655 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('devtools.formatters.templating');
goog.require('cljs.core');
goog.require('clojure.walk');
goog.require('devtools.util');
goog.require('devtools.protocols');
goog.require('devtools.formatters.helpers');
goog.require('devtools.formatters.state');
goog.require('clojure.string');
devtools.formatters.templating.mark_as_group_BANG_ = (function devtools$formatters$templating$mark_as_group_BANG_(value){
var x27759_27760 = value;
x27759_27760.devtools$protocols$IGroup$ = cljs.core.PROTOCOL_SENTINEL;
return value;
});
devtools.formatters.templating.group_QMARK_ = (function devtools$formatters$templating$group_QMARK_(value){
if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$protocols$IGroup$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IGroup,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.IGroup,value);
}
});
devtools.formatters.templating.mark_as_template_BANG_ = (function devtools$formatters$templating$mark_as_template_BANG_(value){
var x27762_27763 = value;
x27762_27763.devtools$protocols$ITemplate$ = cljs.core.PROTOCOL_SENTINEL;
return value;
});
devtools.formatters.templating.template_QMARK_ = (function devtools$formatters$templating$template_QMARK_(value){
if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$protocols$ITemplate$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.ITemplate,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.ITemplate,value);
}
});
devtools.formatters.templating.mark_as_surrogate_BANG_ = (function devtools$formatters$templating$mark_as_surrogate_BANG_(value){
var x27765_27766 = value;
x27765_27766.devtools$protocols$ISurrogate$ = cljs.core.PROTOCOL_SENTINEL;
return value;
});
devtools.formatters.templating.surrogate_QMARK_ = (function devtools$formatters$templating$surrogate_QMARK_(value){
if((!((value == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === value.devtools$protocols$ISurrogate$)))){
return true;
} else {
if((!value.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.ISurrogate,value);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,devtools.protocols.ISurrogate,value);
}
});
devtools.formatters.templating.reference_QMARK_ = (function devtools$formatters$templating$reference_QMARK_(value){
return ((devtools.formatters.templating.group_QMARK_.call(null,value)) && (cljs.core._EQ_.call(null,(value[(0)]),"object")));
});
devtools.formatters.templating.make_group = (function devtools$formatters$templating$make_group(var_args){
var args__4736__auto__ = [];
var len__4730__auto___27773 = arguments.length;
var i__4731__auto___27774 = (0);
while(true){
if((i__4731__auto___27774 < len__4730__auto___27773)){
args__4736__auto__.push((arguments[i__4731__auto___27774]));
var G__27775 = (i__4731__auto___27774 + (1));
i__4731__auto___27774 = G__27775;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((0) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((0)),(0),null)):null);
return devtools.formatters.templating.make_group.cljs$core$IFn$_invoke$arity$variadic(argseq__4737__auto__);
});
devtools.formatters.templating.make_group.cljs$core$IFn$_invoke$arity$variadic = (function (items){
var group = devtools.formatters.templating.mark_as_group_BANG_.call(null,[]);
var seq__27769_27776 = cljs.core.seq.call(null,items);
var chunk__27770_27777 = null;
var count__27771_27778 = (0);
var i__27772_27779 = (0);
while(true){
if((i__27772_27779 < count__27771_27778)){
var item_27780 = cljs.core._nth.call(null,chunk__27770_27777,i__27772_27779);
if((!((item_27780 == null)))){
if(cljs.core.coll_QMARK_.call(null,item_27780)){
(group["push"]).apply(group,devtools.formatters.templating.mark_as_group_BANG_.call(null,cljs.core.into_array.call(null,item_27780)));
} else {
group.push(devtools.formatters.helpers.pref.call(null,item_27780));
}
} else {
}
var G__27781 = seq__27769_27776;
var G__27782 = chunk__27770_27777;
var G__27783 = count__27771_27778;
var G__27784 = (i__27772_27779 + (1));
seq__27769_27776 = G__27781;
chunk__27770_27777 = G__27782;
count__27771_27778 = G__27783;
i__27772_27779 = G__27784;
continue;
} else {
var temp__5720__auto___27785 = cljs.core.seq.call(null,seq__27769_27776);
if(temp__5720__auto___27785){
var seq__27769_27786__$1 = temp__5720__auto___27785;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__27769_27786__$1)){
var c__4550__auto___27787 = cljs.core.chunk_first.call(null,seq__27769_27786__$1);
var G__27788 = cljs.core.chunk_rest.call(null,seq__27769_27786__$1);
var G__27789 = c__4550__auto___27787;
var G__27790 = cljs.core.count.call(null,c__4550__auto___27787);
var G__27791 = (0);
seq__27769_27776 = G__27788;
chunk__27770_27777 = G__27789;
count__27771_27778 = G__27790;
i__27772_27779 = G__27791;
continue;
} else {
var item_27792 = cljs.core.first.call(null,seq__27769_27786__$1);
if((!((item_27792 == null)))){
if(cljs.core.coll_QMARK_.call(null,item_27792)){
(group["push"]).apply(group,devtools.formatters.templating.mark_as_group_BANG_.call(null,cljs.core.into_array.call(null,item_27792)));
} else {
group.push(devtools.formatters.helpers.pref.call(null,item_27792));
}
} else {
}
var G__27793 = cljs.core.next.call(null,seq__27769_27786__$1);
var G__27794 = null;
var G__27795 = (0);
var G__27796 = (0);
seq__27769_27776 = G__27793;
chunk__27770_27777 = G__27794;
count__27771_27778 = G__27795;
i__27772_27779 = G__27796;
continue;
}
} else {
}
}
break;
}
return group;
});
devtools.formatters.templating.make_group.cljs$lang$maxFixedArity = (0);
/** @this {Function} */
devtools.formatters.templating.make_group.cljs$lang$applyTo = (function (seq27768){
var self__4718__auto__ = this;
return self__4718__auto__.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq27768));
});
devtools.formatters.templating.make_template = (function devtools$formatters$templating$make_template(var_args){
var args__4736__auto__ = [];
var len__4730__auto___27804 = arguments.length;
var i__4731__auto___27805 = (0);
while(true){
if((i__4731__auto___27805 < len__4730__auto___27804)){
args__4736__auto__.push((arguments[i__4731__auto___27805]));
var G__27806 = (i__4731__auto___27805 + (1));
i__4731__auto___27805 = G__27806;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((2) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((2)),(0),null)):null);
return devtools.formatters.templating.make_template.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4737__auto__);
});
devtools.formatters.templating.make_template.cljs$core$IFn$_invoke$arity$variadic = (function (tag,style,children){
var tag__$1 = devtools.formatters.helpers.pref.call(null,tag);
var style__$1 = devtools.formatters.helpers.pref.call(null,style);
var template = devtools.formatters.templating.mark_as_template_BANG_.call(null,[tag__$1,((cljs.core.empty_QMARK_.call(null,style__$1))?({}):({"style": style__$1}))]);
var seq__27800_27807 = cljs.core.seq.call(null,children);
var chunk__27801_27808 = null;
var count__27802_27809 = (0);
var i__27803_27810 = (0);
while(true){
if((i__27803_27810 < count__27802_27809)){
var child_27811 = cljs.core._nth.call(null,chunk__27801_27808,i__27803_27810);
if((!((child_27811 == null)))){
if(cljs.core.coll_QMARK_.call(null,child_27811)){
(template["push"]).apply(template,devtools.formatters.templating.mark_as_template_BANG_.call(null,cljs.core.into_array.call(null,cljs.core.keep.call(null,devtools.formatters.helpers.pref,child_27811))));
} else {
var temp__5718__auto___27812 = devtools.formatters.helpers.pref.call(null,child_27811);
if(cljs.core.truth_(temp__5718__auto___27812)){
var child_value_27813 = temp__5718__auto___27812;
template.push(child_value_27813);
} else {
}
}
} else {
}
var G__27814 = seq__27800_27807;
var G__27815 = chunk__27801_27808;
var G__27816 = count__27802_27809;
var G__27817 = (i__27803_27810 + (1));
seq__27800_27807 = G__27814;
chunk__27801_27808 = G__27815;
count__27802_27809 = G__27816;
i__27803_27810 = G__27817;
continue;
} else {
var temp__5720__auto___27818 = cljs.core.seq.call(null,seq__27800_27807);
if(temp__5720__auto___27818){
var seq__27800_27819__$1 = temp__5720__auto___27818;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__27800_27819__$1)){
var c__4550__auto___27820 = cljs.core.chunk_first.call(null,seq__27800_27819__$1);
var G__27821 = cljs.core.chunk_rest.call(null,seq__27800_27819__$1);
var G__27822 = c__4550__auto___27820;
var G__27823 = cljs.core.count.call(null,c__4550__auto___27820);
var G__27824 = (0);
seq__27800_27807 = G__27821;
chunk__27801_27808 = G__27822;
count__27802_27809 = G__27823;
i__27803_27810 = G__27824;
continue;
} else {
var child_27825 = cljs.core.first.call(null,seq__27800_27819__$1);
if((!((child_27825 == null)))){
if(cljs.core.coll_QMARK_.call(null,child_27825)){
(template["push"]).apply(template,devtools.formatters.templating.mark_as_template_BANG_.call(null,cljs.core.into_array.call(null,cljs.core.keep.call(null,devtools.formatters.helpers.pref,child_27825))));
} else {
var temp__5718__auto___27826 = devtools.formatters.helpers.pref.call(null,child_27825);
if(cljs.core.truth_(temp__5718__auto___27826)){
var child_value_27827 = temp__5718__auto___27826;
template.push(child_value_27827);
} else {
}
}
} else {
}
var G__27828 = cljs.core.next.call(null,seq__27800_27819__$1);
var G__27829 = null;
var G__27830 = (0);
var G__27831 = (0);
seq__27800_27807 = G__27828;
chunk__27801_27808 = G__27829;
count__27802_27809 = G__27830;
i__27803_27810 = G__27831;
continue;
}
} else {
}
}
break;
}
return template;
});
devtools.formatters.templating.make_template.cljs$lang$maxFixedArity = (2);
/** @this {Function} */
devtools.formatters.templating.make_template.cljs$lang$applyTo = (function (seq27797){
var G__27798 = cljs.core.first.call(null,seq27797);
var seq27797__$1 = cljs.core.next.call(null,seq27797);
var G__27799 = cljs.core.first.call(null,seq27797__$1);
var seq27797__$2 = cljs.core.next.call(null,seq27797__$1);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__27798,G__27799,seq27797__$2);
});
devtools.formatters.templating.concat_templates_BANG_ = (function devtools$formatters$templating$concat_templates_BANG_(var_args){
var args__4736__auto__ = [];
var len__4730__auto___27834 = arguments.length;
var i__4731__auto___27835 = (0);
while(true){
if((i__4731__auto___27835 < len__4730__auto___27834)){
args__4736__auto__.push((arguments[i__4731__auto___27835]));
var G__27836 = (i__4731__auto___27835 + (1));
i__4731__auto___27835 = G__27836;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
return devtools.formatters.templating.concat_templates_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
});
devtools.formatters.templating.concat_templates_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (template,templates){
return devtools.formatters.templating.mark_as_template_BANG_.call(null,(template["concat"]).apply(template,cljs.core.into_array.call(null,cljs.core.map.call(null,cljs.core.into_array,cljs.core.keep.call(null,devtools.formatters.helpers.pref,templates)))));
});
devtools.formatters.templating.concat_templates_BANG_.cljs$lang$maxFixedArity = (1);
/** @this {Function} */
devtools.formatters.templating.concat_templates_BANG_.cljs$lang$applyTo = (function (seq27832){
var G__27833 = cljs.core.first.call(null,seq27832);
var seq27832__$1 = cljs.core.next.call(null,seq27832);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__27833,seq27832__$1);
});
devtools.formatters.templating.extend_template_BANG_ = (function devtools$formatters$templating$extend_template_BANG_(var_args){
var args__4736__auto__ = [];
var len__4730__auto___27839 = arguments.length;
var i__4731__auto___27840 = (0);
while(true){
if((i__4731__auto___27840 < len__4730__auto___27839)){
args__4736__auto__.push((arguments[i__4731__auto___27840]));
var G__27841 = (i__4731__auto___27840 + (1));
i__4731__auto___27840 = G__27841;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
return devtools.formatters.templating.extend_template_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
});
devtools.formatters.templating.extend_template_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (template,args){
return devtools.formatters.templating.concat_templates_BANG_.call(null,template,args);
});
devtools.formatters.templating.extend_template_BANG_.cljs$lang$maxFixedArity = (1);
/** @this {Function} */
devtools.formatters.templating.extend_template_BANG_.cljs$lang$applyTo = (function (seq27837){
var G__27838 = cljs.core.first.call(null,seq27837);
var seq27837__$1 = cljs.core.next.call(null,seq27837);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__27838,seq27837__$1);
});
devtools.formatters.templating.make_surrogate = (function devtools$formatters$templating$make_surrogate(var_args){
var G__27843 = arguments.length;
switch (G__27843) {
case 1:
return devtools.formatters.templating.make_surrogate.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return devtools.formatters.templating.make_surrogate.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return devtools.formatters.templating.make_surrogate.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return devtools.formatters.templating.make_surrogate.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
devtools.formatters.templating.make_surrogate.cljs$core$IFn$_invoke$arity$1 = (function (object){
return devtools.formatters.templating.make_surrogate.call(null,object,null);
});
devtools.formatters.templating.make_surrogate.cljs$core$IFn$_invoke$arity$2 = (function (object,header){
return devtools.formatters.templating.make_surrogate.call(null,object,header,null);
});
devtools.formatters.templating.make_surrogate.cljs$core$IFn$_invoke$arity$3 = (function (object,header,body){
return devtools.formatters.templating.make_surrogate.call(null,object,header,body,(0));
});
devtools.formatters.templating.make_surrogate.cljs$core$IFn$_invoke$arity$4 = (function (object,header,body,start_index){
return devtools.formatters.templating.mark_as_surrogate_BANG_.call(null,(function (){var obj27845 = ({"target":object,"header":header,"body":body,"startIndex":(function (){var or__4131__auto__ = start_index;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (0);
}
})()});
return obj27845;
})());
});
devtools.formatters.templating.make_surrogate.cljs$lang$maxFixedArity = 4;
devtools.formatters.templating.get_surrogate_target = (function devtools$formatters$templating$get_surrogate_target(surrogate){
if(devtools.formatters.templating.surrogate_QMARK_.call(null,surrogate)){
} else {
throw (new Error("Assert failed: (surrogate? surrogate)"));
}
return (surrogate["target"]);
});
devtools.formatters.templating.get_surrogate_header = (function devtools$formatters$templating$get_surrogate_header(surrogate){
if(devtools.formatters.templating.surrogate_QMARK_.call(null,surrogate)){
} else {
throw (new Error("Assert failed: (surrogate? surrogate)"));
}
return (surrogate["header"]);
});
devtools.formatters.templating.get_surrogate_body = (function devtools$formatters$templating$get_surrogate_body(surrogate){
if(devtools.formatters.templating.surrogate_QMARK_.call(null,surrogate)){
} else {
throw (new Error("Assert failed: (surrogate? surrogate)"));
}
return (surrogate["body"]);
});
devtools.formatters.templating.get_surrogate_start_index = (function devtools$formatters$templating$get_surrogate_start_index(surrogate){
if(devtools.formatters.templating.surrogate_QMARK_.call(null,surrogate)){
} else {
throw (new Error("Assert failed: (surrogate? surrogate)"));
}
return (surrogate["startIndex"]);
});
devtools.formatters.templating.make_reference = (function devtools$formatters$templating$make_reference(var_args){
var args__4736__auto__ = [];
var len__4730__auto___27853 = arguments.length;
var i__4731__auto___27854 = (0);
while(true){
if((i__4731__auto___27854 < len__4730__auto___27853)){
args__4736__auto__.push((arguments[i__4731__auto___27854]));
var G__27855 = (i__4731__auto___27854 + (1));
i__4731__auto___27854 = G__27855;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
return devtools.formatters.templating.make_reference.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
});
devtools.formatters.templating.make_reference.cljs$core$IFn$_invoke$arity$variadic = (function (object,p__27849){
var vec__27850 = p__27849;
var state_override_fn = cljs.core.nth.call(null,vec__27850,(0),null);
if((((state_override_fn == null)) || (cljs.core.fn_QMARK_.call(null,state_override_fn)))){
} else {
throw (new Error("Assert failed: (or (nil? state-override-fn) (fn? state-override-fn))"));
}
if((object == null)){
return devtools.formatters.templating.make_template.call(null,new cljs.core.Keyword(null,"span","span",1394872991),new cljs.core.Keyword(null,"nil-style","nil-style",-1505044832),new cljs.core.Keyword(null,"nil-label","nil-label",-587789203));
} else {
var sub_state = (((!((state_override_fn == null))))?state_override_fn.call(null,devtools.formatters.state.get_current_state.call(null)):devtools.formatters.state.get_current_state.call(null));
return devtools.formatters.templating.make_group.call(null,"object",({"object": object, "config": sub_state}));
}
});
devtools.formatters.templating.make_reference.cljs$lang$maxFixedArity = (1);
/** @this {Function} */
devtools.formatters.templating.make_reference.cljs$lang$applyTo = (function (seq27847){
var G__27848 = cljs.core.first.call(null,seq27847);
var seq27847__$1 = cljs.core.next.call(null,seq27847);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__27848,seq27847__$1);
});
devtools.formatters.templating._STAR_current_render_stack_STAR_ = cljs.core.PersistentVector.EMPTY;
devtools.formatters.templating._STAR_current_render_path_STAR_ = cljs.core.PersistentVector.EMPTY;
devtools.formatters.templating.print_preview = (function devtools$formatters$templating$print_preview(markup){
var _STAR_print_level_STAR__orig_val__27856 = cljs.core._STAR_print_level_STAR_;
var _STAR_print_level_STAR__temp_val__27857 = (1);
cljs.core._STAR_print_level_STAR_ = _STAR_print_level_STAR__temp_val__27857;
try{return cljs.core.pr_str.call(null,markup);
}finally {cljs.core._STAR_print_level_STAR_ = _STAR_print_level_STAR__orig_val__27856;
}});
devtools.formatters.templating.add_stack_separators = (function devtools$formatters$templating$add_stack_separators(stack){
return cljs.core.interpose.call(null,"-------------",stack);
});
devtools.formatters.templating.replace_fns_with_markers = (function devtools$formatters$templating$replace_fns_with_markers(stack){
var f = (function (v){
if(cljs.core.fn_QMARK_.call(null,v)){
return "##fn##";
} else {
return v;
}
});
return clojure.walk.prewalk.call(null,f,stack);
});
devtools.formatters.templating.pprint_render_calls = (function devtools$formatters$templating$pprint_render_calls(stack){
return cljs.core.map.call(null,devtools.util.pprint_str,stack);
});
devtools.formatters.templating.pprint_render_stack = (function devtools$formatters$templating$pprint_render_stack(stack){
return clojure.string.join.call(null,"\n",devtools.formatters.templating.add_stack_separators.call(null,devtools.formatters.templating.pprint_render_calls.call(null,devtools.formatters.templating.replace_fns_with_markers.call(null,cljs.core.reverse.call(null,stack)))));
});
devtools.formatters.templating.pprint_render_path = (function devtools$formatters$templating$pprint_render_path(path){
return devtools.util.pprint_str.call(null,path);
});
devtools.formatters.templating.assert_markup_error = (function devtools$formatters$templating$assert_markup_error(msg){
throw (new Error(["Assert failed: ",[cljs.core.str.cljs$core$IFn$_invoke$arity$1(msg),"\n","Render path: ",devtools.formatters.templating.pprint_render_path.call(null,devtools.formatters.templating._STAR_current_render_path_STAR_),"\n","Render stack:\n",cljs.core.str.cljs$core$IFn$_invoke$arity$1(devtools.formatters.templating.pprint_render_stack.call(null,devtools.formatters.templating._STAR_current_render_stack_STAR_))].join(''),"\n","false"].join('')));
});
devtools.formatters.templating.surrogate_markup_QMARK_ = (function devtools$formatters$templating$surrogate_markup_QMARK_(markup){
return ((cljs.core.sequential_QMARK_.call(null,markup)) && (cljs.core._EQ_.call(null,cljs.core.first.call(null,markup),"surrogate")));
});
devtools.formatters.templating.render_special = (function devtools$formatters$templating$render_special(name,args){
var G__27858 = name;
switch (G__27858) {
case "surrogate":
var obj = cljs.core.first.call(null,args);
var converted_args = cljs.core.map.call(null,devtools.formatters.templating.render_json_ml_STAR_,cljs.core.rest.call(null,args));
return cljs.core.apply.call(null,devtools.formatters.templating.make_surrogate,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [obj], null),converted_args));
break;
case "reference":
var obj = cljs.core.first.call(null,args);
var converted_obj = ((devtools.formatters.templating.surrogate_markup_QMARK_.call(null,obj))?devtools.formatters.templating.render_json_ml_STAR_.call(null,obj):obj);
return cljs.core.apply.call(null,devtools.formatters.templating.make_reference,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [converted_obj], null),cljs.core.rest.call(null,args)));
break;
default:
return devtools.formatters.templating.assert_markup_error.call(null,["no matching special tag name: '",cljs.core.str.cljs$core$IFn$_invoke$arity$1(name),"'"].join(''));
}
});
devtools.formatters.templating.emptyish_QMARK_ = (function devtools$formatters$templating$emptyish_QMARK_(v){
if(((cljs.core.seqable_QMARK_.call(null,v)) || (cljs.core.array_QMARK_.call(null,v)) || (typeof v === 'string'))){
return cljs.core.empty_QMARK_.call(null,v);
} else {
return false;
}
});
devtools.formatters.templating.render_subtree = (function devtools$formatters$templating$render_subtree(tag,children){
var vec__27860 = tag;
var html_tag = cljs.core.nth.call(null,vec__27860,(0),null);
var style = cljs.core.nth.call(null,vec__27860,(1),null);
return cljs.core.apply.call(null,devtools.formatters.templating.make_template,html_tag,style,cljs.core.map.call(null,devtools.formatters.templating.render_json_ml_STAR_,cljs.core.remove.call(null,devtools.formatters.templating.emptyish_QMARK_,cljs.core.map.call(null,devtools.formatters.helpers.pref,children))));
});
devtools.formatters.templating.render_json_ml_STAR_ = (function devtools$formatters$templating$render_json_ml_STAR_(markup){
if((!(cljs.core.sequential_QMARK_.call(null,markup)))){
return markup;
} else {
var _STAR_current_render_path_STAR__orig_val__27863 = devtools.formatters.templating._STAR_current_render_path_STAR_;
var _STAR_current_render_path_STAR__temp_val__27864 = cljs.core.conj.call(null,devtools.formatters.templating._STAR_current_render_path_STAR_,cljs.core.first.call(null,markup));
devtools.formatters.templating._STAR_current_render_path_STAR_ = _STAR_current_render_path_STAR__temp_val__27864;
try{var tag = devtools.formatters.helpers.pref.call(null,cljs.core.first.call(null,markup));
if(typeof tag === 'string'){
return devtools.formatters.templating.render_special.call(null,tag,cljs.core.rest.call(null,markup));
} else {
if(cljs.core.sequential_QMARK_.call(null,tag)){
return devtools.formatters.templating.render_subtree.call(null,tag,cljs.core.rest.call(null,markup));
} else {
return devtools.formatters.templating.assert_markup_error.call(null,["invalid json-ml markup at ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(devtools.formatters.templating.print_preview.call(null,markup)),":"].join(''));
}
}
}finally {devtools.formatters.templating._STAR_current_render_path_STAR_ = _STAR_current_render_path_STAR__orig_val__27863;
}}
});
devtools.formatters.templating.render_json_ml = (function devtools$formatters$templating$render_json_ml(markup){
var _STAR_current_render_stack_STAR__orig_val__27865 = devtools.formatters.templating._STAR_current_render_stack_STAR_;
var _STAR_current_render_path_STAR__orig_val__27866 = devtools.formatters.templating._STAR_current_render_path_STAR_;
var _STAR_current_render_stack_STAR__temp_val__27867 = cljs.core.conj.call(null,devtools.formatters.templating._STAR_current_render_stack_STAR_,markup);
var _STAR_current_render_path_STAR__temp_val__27868 = cljs.core.conj.call(null,devtools.formatters.templating._STAR_current_render_path_STAR_,"<render-json-ml>");
devtools.formatters.templating._STAR_current_render_stack_STAR_ = _STAR_current_render_stack_STAR__temp_val__27867;
devtools.formatters.templating._STAR_current_render_path_STAR_ = _STAR_current_render_path_STAR__temp_val__27868;
try{return devtools.formatters.templating.render_json_ml_STAR_.call(null,markup);
}finally {devtools.formatters.templating._STAR_current_render_path_STAR_ = _STAR_current_render_path_STAR__orig_val__27866;
devtools.formatters.templating._STAR_current_render_stack_STAR_ = _STAR_current_render_stack_STAR__orig_val__27865;
}});
devtools.formatters.templating.assert_failed_markup_rendering = (function devtools$formatters$templating$assert_failed_markup_rendering(initial_value,value){
throw (new Error(["Assert failed: ",["result of markup rendering must be a template,\n","resolved to ",devtools.util.pprint_str.call(null,value),"initial value: ",devtools.util.pprint_str.call(null,initial_value)].join(''),"\n","false"].join('')));
});
devtools.formatters.templating.render_markup_STAR_ = (function devtools$formatters$templating$render_markup_STAR_(initial_value,value){
while(true){
if(cljs.core.fn_QMARK_.call(null,value)){
var G__27869 = initial_value;
var G__27870 = value.call(null);
initial_value = G__27869;
value = G__27870;
continue;
} else {
if((value instanceof cljs.core.Keyword)){
var G__27871 = initial_value;
var G__27872 = devtools.formatters.helpers.pref.call(null,value);
initial_value = G__27871;
value = G__27872;
continue;
} else {
if(cljs.core.sequential_QMARK_.call(null,value)){
var G__27873 = initial_value;
var G__27874 = devtools.formatters.templating.render_json_ml.call(null,value);
initial_value = G__27873;
value = G__27874;
continue;
} else {
if(devtools.formatters.templating.template_QMARK_.call(null,value)){
return value;
} else {
if(devtools.formatters.templating.surrogate_QMARK_.call(null,value)){
return value;
} else {
if(devtools.formatters.templating.reference_QMARK_.call(null,value)){
return value;
} else {
return devtools.formatters.templating.assert_failed_markup_rendering.call(null,initial_value,value);
}
}
}
}
}
}
break;
}
});
devtools.formatters.templating.render_markup = (function devtools$formatters$templating$render_markup(value){
return devtools.formatters.templating.render_markup_STAR_.call(null,value,value);
});
//# sourceMappingURL=templating.js.map?rel=1582560150274

File diff suppressed because one or more lines are too long