@kairotic/data 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edn.mjs +3 -3
- package/dist/fetch.mjs +2 -2
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
- package/src/edn.cljs +6 -6
- package/src/fetch.cljs +8 -8
package/dist/edn.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Generated by packages/build.mjs from src/edn.cljs
|
|
2
2
|
export default {
|
|
3
3
|
"class": "edn",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"author": "bonuoq",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
|
-
"doc": "Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). depth n opens it n levels down; bang sends the picked part again (the whole value if none); clear empties it.",
|
|
8
|
-
"source": ";; edn · any value as a tree to open, read and pick from\n;; Part of @kairotic/data. Written against the Kairotic API (api/…).\n;; After Portal (djblue/portal): what arrives is shown as a tree whose collections open and close, each\n;; value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part\n;; of the value (left) and its path (right), the path a fetch box takes as [:get …]. Dragging scrolls.\n;; What happens in the view (open, pick, scroll) is a message to the box itself, like any gesture, so\n;; the same value sent again changes nothing.\n(let [row-h 14 top-y 22 foot-h 16 cw 5.6 ; a line, where lines start, the footer, a character (size 9)\n max-children 200 max-rows 3000\n coll-kind (fn [v] (cond (map? v) :map (vector? v) :vector (set? v) :set (sequential? v) :list :else nil))\n opener {:map \"{\" :vector \"[\" :set \"#{\" :list \"(\"}\n plural (fn [n one many] (str n \" \" (if (= 1 n) one many)))\n size-text (fn [v] (case (coll-kind v)\n :map (plural (count v) \"key\" \"keys\")\n (:vector :list) (plural (count v) \"item\" \"items\")\n :set (plural (count v) \"element\" \"elements\")\n nil))\n ;; the colour of a value, by its kind (the palette of the patch, light or dark)\n ink-of (fn [v] (cond (string? v) :ink (number? v) :kairos (keyword? v) :accent\n (or (nil? v) (boolean? v)) :soft (coll-kind v) :soft :else :ink))\n ;; one level down: the parts of a collection, in a steady order, at most max-children of them\n entries (fn [c]\n (let [es (case (coll-kind c)\n :map (for [[k v] (sort-by (fn [[k _]] (pr-str k)) c)] {:k k :label (pr-str k) :key? true :v v})\n :set (for [v (sort-by pr-str c)] {:k v :label \"\" :v v})\n (map-indexed (fn [i v] {:k i :label (str i) :v v}) c))\n shown (vec (take max-children es))]\n (if (> (count c) max-children)\n (conj shown {:more (- (count c) max-children)})\n shown)))\n ;; a part of the value by its path: get-in, also through lists and sets\n part (fn [root path]\n (reduce (fn [c k] (case (coll-kind c)\n (:map :set) (get c k)\n (:vector :list) (if (number? k) (nth (seq c) k nil) nil)\n nil))\n root path))\n ;; the lines of the tree as it is open: [{:path :depth :label :key? :v :open? :more}]\n rows-of (fn [{:keys [root open]}]\n (if-not (coll-kind root)\n []\n (loop [todo (into () (reverse (map (fn [e] (assoc e :path [(:k e)] :depth 0)) (entries root))))\n out (transient [])]\n (if (or (empty? todo) (>= (count out) max-rows))\n (persistent! out)\n (let [r (first todo) more (rest todo)\n open? (and (coll-kind (:v r)) (contains? open (:path r)) (not (:more r)))\n kids (when open? (map (fn [e] (assoc e :path (conj (:path r) (:k e)) :depth (inc (:depth r))))\n (entries (:v r))))]\n (recur (if open? (into more (reverse kids)) more)\n (conj! out (assoc r :open? open?))))))))\n visible (fn [h] (max 1 (js/Math.floor (/ (- h top-y foot-h) row-h))))\n size-of (fn [args] (api/padded (filter number? args) [320 300]))\n ;; every collection down to depth n, open (at most max-rows of them)\n open-to (fn [root n]\n (loop [todo (list [[] root 0]) acc #{}]\n (if (or (empty? todo) (> (count acc) max-rows))\n acc\n (let [[p v d] (first todo)\n kids (when (and (coll-kind v) (< d n))\n (for [e (entries v) :when (and (not (:more e)) (coll-kind (:v e)))] [(conj p (:k e)) (:v e) (inc d)]))]\n (recur (into (rest todo) kids) (if (and (seq p) (coll-kind v) (<= d n)) (conj acc p) acc))))))\n shown-of (fn [st] {:top (:top st 0) :sel (:sel st) :open (count (:open st))})\n with-top (fn [st top h] (let [n (count (rows-of st))] (assoc st :top (max 0 (min (js/Math.round top) (- n (visible h)))))))]\n {;; ── about ──\n :class \"edn\"\n :license \"MPL-2.0\"\n :doc \"Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). depth n opens it n levels down; bang sends the picked part again (the whole value if none); clear empties it.\"\n :usage \"edn [width height]\"\n :io [1 2]\n :size (fn [box] (size-of (:args box)))\n\n ;; ── logic ──\n :receive (fn [{:keys [value state args]}]\n (let [st (or state {:open #{} :top 0})\n [_ h] (size-of args)\n msg? (fn [k] (and (vector? value) (= k (first value))))\n view (fn [st2] {:state st2 :show (shown-of st2)})]\n (cond\n ;; what happens in the view\n (msg? :edn-open)\n (let [[_ p on] value]\n (view (with-top (update st :open (if on conj disj) p) (:top st 0) h)))\n (msg? :edn-top) (view (with-top st (second value) h))\n (msg? :edn-pick)\n (let [p (second value)]\n (if (or (= p (:sel st)) (not (contains? st :root)))\n {:state st}\n {:state (assoc st :sel p) :show (shown-of (assoc st :sel p))\n :out [[1 p] [0 (part (:root st) p)]]}))\n ;; messages\n (and (msg? :depth) (number? (second value)))\n (view (with-top (assoc st :open (open-to (:root st) (max 0 (dec (second value))))) 0 h))\n (#{:bang \"bang\"} value)\n (if (contains? st :root)\n (let [p (or (:sel st) [])] {:out [[1 p] [0 (part (:root st) p)]]})\n {})\n (#{:clear \"clear\"} value) (view {:open #{} :top 0})\n ;; a value: the same again changes nothing; another keeps what was open and picked\n (and (contains? st :root) (= value (:root st))) {:state st}\n :else\n (let [st2 (assoc st :root value)]\n (view (with-top st2 (:top st 0) h))))))\n\n ;; a line pressed (on its arrow: open or close it; elsewhere: pick it), or a drag that scrolls\n :gesture (fn [{:keys [up hit dy start state h]}]\n (let [st (or state {}) rows (rows-of st) n (count rows) vis (visible h)\n t0 (:top start (:top st 0))]\n (cond\n (>= (js/Math.abs dy) 3)\n [:edn-top (if (= hit :bar)\n (+ t0 (* dy (/ n (* vis row-h))))\n (- t0 (/ dy row-h)))]\n (not up) nil\n ;; a line is its index; its arrow, -1 - its index\n (and (number? hit) (neg? hit))\n (when-let [r (get rows (- -1 hit))] (when (coll-kind (:v r)) [:edn-open (:path r) (not (:open? r))]))\n (number? hit) (when-let [r (get rows hit)] (when-not (:more r) [:edn-pick (:path r)]))\n :else nil)))\n\n ;; ── view ──\n :draw (fn [{:keys [state w h]}]\n (let [st (or state {}) root (:root st) rows (rows-of st) n (count rows)\n vis (visible h) top (max 0 (min (:top st 0) (- n vis))) bar? (> n vis)\n right (- w (if bar? 14 6))\n chars (fn [x] (max 0 (js/Math.floor (/ (- right x) cw))))\n cut (fn [s x] (let [m (chars x)] (if (> (count s) m) (str (subs s 0 (max 0 (dec m))) \"…\") s)))\n line (fn [j r i]\n (let [y (+ top-y (* j row-h)) base (+ y 10)\n x (+ 8 (* 12 (:depth r))) v (:v r) kind (coll-kind v)\n lbl (:label r) vx (+ x 12 (if (seq lbl) (* cw (inc (count lbl))) 0))\n sel? (= (:sel st) (:path r))]\n (if (:more r)\n [[:text {:x (+ x 12) :y base :size 9 :fill :soft} (str \"… \" (:more r) \" more\")]]\n (concat\n [[:rect {:x 2 :y y :w (- right 2) :h row-h :fill (if sel? :accent :bg) :opacity (if sel? 0.14 0) :hit i}]]\n (when kind\n [[:rect {:x (- x 2) :y y :w 12 :h row-h :fill :bg :opacity 0 :hit (- -1 i)}]\n [:text {:x x :y base :size 9 :fill :soft} (if (:open? r) \"▾\" \"▸\")]])\n (when (seq lbl)\n [[:text {:x (+ x 12) :y base :size 9 :fill (if (:key? r) :accent :soft)} (cut lbl (+ x 12))]])\n [[:text {:x vx :y base :size 9 :fill (ink-of v)}\n (cut (cond (and kind (:open? r)) (str (opener kind) \" \" (size-text v))\n kind (pr-str v)\n :else (pr-str v))\n vx)]]))))]\n (concat\n [[:rect {:x 1 :y 1 :w (- w 2) :h (- h 2) :r 4 :stroke :grid :fill :bg}]\n [:text {:x 8 :y 15 :size 9 :fill :soft}\n (cond (not (contains? st :root)) \"edn · send it a value\"\n (coll-kind root) (str (name (coll-kind root)) \" · \" (size-text root))\n :else (str (cond (string? root) \"string\" (number? root) \"number\" (keyword? root) \"keyword\"\n (nil? root) \"nil\" (boolean? root) \"boolean\" :else \"value\")))]\n [:line {:x1 1 :y1 19 :x2 (- w 1) :y2 19 :stroke :grid}]]\n ;; a value that is not a collection: itself, on one line\n (when (and (contains? st :root) (not (coll-kind root)))\n [[:text {:x 8 :y (+ top-y 10) :size 9 :fill (ink-of root)} (cut (pr-str root) 8)]])\n (mapcat (fn [j] (line j (nth rows (+ top j)) (+ top j))) (range (min vis (- n top))))\n (when bar?\n (let [track (* vis row-h) th (max 14 (* track (/ vis n))) ty (+ top-y (* (- track th) (/ top (max 1 (- n vis)))))]\n [[:rect {:x (- w 10) :y top-y :w 6 :h track :r 3 :fill :grid :hit :bar}]\n [:rect {:x (- w 10) :y ty :w 6 :h th :r 3 :fill :soft :hit :bar}]]))\n [[:line {:x1 1 :y1 (- h foot-h) :x2 (- w 1) :y2 (- h foot-h) :stroke :grid}]\n [:text {:x 8 :y (- h 5) :size 8 :fill :soft}\n (cut (cond (:sel st) (str \"→ \" (pr-str (:sel st)))\n (seq rows) (str n (if (= 1 n) \" line\" \" lines\") (when bar? (str \" · \" (inc top) \"–\" (min n (+ top vis)))) \" · pick a line\")\n :else \"\")\n 8)]])))\n\n ;; ── help ──\n :help {:inlets [\"any value: a map, a vector, a set, a list, or a single value; depth n · bang · clear\"]\n :outlets [\"the part picked\" \"its path, for [:get …] of a fetch box\"]\n :messages [[\"depth 2\" \"opens it two levels down\"]\n [\"bang\" \"sends the part picked again (the whole value if none)\"]\n [\"clear\" \"empties it\"]]\n :try \"Send it a fetch's answer and open the branches: pick a line and its path comes out on the right.\"}})\n"
|
|
7
|
+
"doc": "Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). :depth n opens it n levels down; bang sends the picked part again (the whole value if none); :clear empties it.",
|
|
8
|
+
"source": ";; edn · any value as a tree to open, read and pick from\n;; Part of @kairotic/data. Written against the Kairotic API (api/…).\n;; After Portal (djblue/portal): what arrives is shown as a tree whose collections open and close, each\n;; value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part\n;; of the value (left) and its path (right), the path a fetch box takes as [:get …]. Dragging scrolls.\n;; What happens in the view (open, pick, scroll) is a message to the box itself, like any gesture, so\n;; the same value sent again changes nothing.\n(let [row-h 14 top-y 22 foot-h 16 cw 5.6 ; a line, where lines start, the footer, a character (size 9)\n max-children 200 max-rows 3000\n coll-kind (fn [v] (cond (map? v) :map (vector? v) :vector (set? v) :set (sequential? v) :list :else nil))\n opener {:map \"{\" :vector \"[\" :set \"#{\" :list \"(\"}\n plural (fn [n one many] (str n \" \" (if (= 1 n) one many)))\n size-text (fn [v] (case (coll-kind v)\n :map (plural (count v) \"key\" \"keys\")\n (:vector :list) (plural (count v) \"item\" \"items\")\n :set (plural (count v) \"element\" \"elements\")\n nil))\n ;; the colour of a value, by its kind (the palette of the patch, light or dark)\n ink-of (fn [v] (cond (string? v) :ink (number? v) :kairos (keyword? v) :accent\n (or (nil? v) (boolean? v)) :soft (coll-kind v) :soft :else :ink))\n ;; one level down: the parts of a collection, in a steady order, at most max-children of them\n entries (fn [c]\n (let [es (case (coll-kind c)\n :map (for [[k v] (sort-by (fn [[k _]] (pr-str k)) c)] {:k k :label (pr-str k) :key? true :v v})\n :set (for [v (sort-by pr-str c)] {:k v :label \"\" :v v})\n (map-indexed (fn [i v] {:k i :label (str i) :v v}) c))\n shown (vec (take max-children es))]\n (if (> (count c) max-children)\n (conj shown {:more (- (count c) max-children)})\n shown)))\n ;; a part of the value by its path: get-in, also through lists and sets\n part (fn [root path]\n (reduce (fn [c k] (case (coll-kind c)\n (:map :set) (get c k)\n (:vector :list) (if (number? k) (nth (seq c) k nil) nil)\n nil))\n root path))\n ;; the lines of the tree as it is open: [{:path :depth :label :key? :v :open? :more}]\n rows-of (fn [{:keys [root open]}]\n (if-not (coll-kind root)\n []\n (loop [todo (into () (reverse (map (fn [e] (assoc e :path [(:k e)] :depth 0)) (entries root))))\n out (transient [])]\n (if (or (empty? todo) (>= (count out) max-rows))\n (persistent! out)\n (let [r (first todo) more (rest todo)\n open? (and (coll-kind (:v r)) (contains? open (:path r)) (not (:more r)))\n kids (when open? (map (fn [e] (assoc e :path (conj (:path r) (:k e)) :depth (inc (:depth r))))\n (entries (:v r))))]\n (recur (if open? (into more (reverse kids)) more)\n (conj! out (assoc r :open? open?))))))))\n visible (fn [h] (max 1 (js/Math.floor (/ (- h top-y foot-h) row-h))))\n size-of (fn [args] (api/padded (filter number? args) [320 300]))\n ;; every collection down to depth n, open (at most max-rows of them)\n open-to (fn [root n]\n (loop [todo (list [[] root 0]) acc #{}]\n (if (or (empty? todo) (> (count acc) max-rows))\n acc\n (let [[p v d] (first todo)\n kids (when (and (coll-kind v) (< d n))\n (for [e (entries v) :when (and (not (:more e)) (coll-kind (:v e)))] [(conj p (:k e)) (:v e) (inc d)]))]\n (recur (into (rest todo) kids) (if (and (seq p) (coll-kind v) (<= d n)) (conj acc p) acc))))))\n shown-of (fn [st] {:top (:top st 0) :sel (:sel st) :open (count (:open st))})\n with-top (fn [st top h] (let [n (count (rows-of st))] (assoc st :top (max 0 (min (js/Math.round top) (- n (visible h)))))))]\n {;; ── about ──\n :class \"edn\"\n :license \"MPL-2.0\"\n :doc \"Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). :depth n opens it n levels down; bang sends the picked part again (the whole value if none); :clear empties it.\"\n :usage \"edn [width height]\"\n :io [1 2]\n :size (fn [box] (size-of (:args box)))\n\n ;; ── logic ──\n :receive (fn [{:keys [value state args]}]\n (let [st (or state {:open #{} :top 0})\n [_ h] (size-of args)\n msg? (fn [k] (and (vector? value) (= k (first value))))\n view (fn [st2] {:state st2 :show (shown-of st2)})]\n (cond\n ;; what happens in the view\n (msg? :edn-open)\n (let [[_ p on] value]\n (view (with-top (update st :open (if on conj disj) p) (:top st 0) h)))\n (msg? :edn-top) (view (with-top st (second value) h))\n (msg? :edn-pick)\n (let [p (second value)]\n (if (or (= p (:sel st)) (not (contains? st :root)))\n {:state st}\n {:state (assoc st :sel p) :show (shown-of (assoc st :sel p))\n :out [[1 p] [0 (part (:root st) p)]]}))\n ;; messages\n (and (msg? :depth) (number? (second value)))\n (view (with-top (assoc st :open (open-to (:root st) (max 0 (dec (second value))))) 0 h))\n (#{:bang} value)\n (if (contains? st :root)\n (let [p (or (:sel st) [])] {:out [[1 p] [0 (part (:root st) p)]]})\n {})\n (#{:clear} value) (view {:open #{} :top 0})\n ;; a value: the same again changes nothing; another keeps what was open and picked\n (and (contains? st :root) (= value (:root st))) {:state st}\n :else\n (let [st2 (assoc st :root value)]\n (view (with-top st2 (:top st 0) h))))))\n\n ;; a line pressed (on its arrow: open or close it; elsewhere: pick it), or a drag that scrolls\n :gesture (fn [{:keys [up hit dy start state h]}]\n (let [st (or state {}) rows (rows-of st) n (count rows) vis (visible h)\n t0 (:top start (:top st 0))]\n (cond\n (>= (js/Math.abs dy) 3)\n [:edn-top (if (= hit :bar)\n (+ t0 (* dy (/ n (* vis row-h))))\n (- t0 (/ dy row-h)))]\n (not up) nil\n ;; a line is its index; its arrow, -1 - its index\n (and (number? hit) (neg? hit))\n (when-let [r (get rows (- -1 hit))] (when (coll-kind (:v r)) [:edn-open (:path r) (not (:open? r))]))\n (number? hit) (when-let [r (get rows hit)] (when-not (:more r) [:edn-pick (:path r)]))\n :else nil)))\n\n ;; ── view ──\n :draw (fn [{:keys [state w h]}]\n (let [st (or state {}) root (:root st) rows (rows-of st) n (count rows)\n vis (visible h) top (max 0 (min (:top st 0) (- n vis))) bar? (> n vis)\n right (- w (if bar? 14 6))\n chars (fn [x] (max 0 (js/Math.floor (/ (- right x) cw))))\n cut (fn [s x] (let [m (chars x)] (if (> (count s) m) (str (subs s 0 (max 0 (dec m))) \"…\") s)))\n line (fn [j r i]\n (let [y (+ top-y (* j row-h)) base (+ y 10)\n x (+ 8 (* 12 (:depth r))) v (:v r) kind (coll-kind v)\n lbl (:label r) vx (+ x 12 (if (seq lbl) (* cw (inc (count lbl))) 0))\n sel? (= (:sel st) (:path r))]\n (if (:more r)\n [[:text {:x (+ x 12) :y base :size 9 :fill :soft} (str \"… \" (:more r) \" more\")]]\n (concat\n [[:rect {:x 2 :y y :w (- right 2) :h row-h :fill (if sel? :accent :bg) :opacity (if sel? 0.14 0) :hit i}]]\n (when kind\n [[:rect {:x (- x 2) :y y :w 12 :h row-h :fill :bg :opacity 0 :hit (- -1 i)}]\n [:text {:x x :y base :size 9 :fill :soft} (if (:open? r) \"▾\" \"▸\")]])\n (when (seq lbl)\n [[:text {:x (+ x 12) :y base :size 9 :fill (if (:key? r) :accent :soft)} (cut lbl (+ x 12))]])\n [[:text {:x vx :y base :size 9 :fill (ink-of v)}\n (cut (cond (and kind (:open? r)) (str (opener kind) \" \" (size-text v))\n kind (pr-str v)\n :else (pr-str v))\n vx)]]))))]\n (concat\n [[:rect {:x 1 :y 1 :w (- w 2) :h (- h 2) :r 4 :stroke :grid :fill :bg}]\n [:text {:x 8 :y 15 :size 9 :fill :soft}\n (cond (not (contains? st :root)) \"edn · send it a value\"\n (coll-kind root) (str (name (coll-kind root)) \" · \" (size-text root))\n :else (str (cond (string? root) \"string\" (number? root) \"number\" (keyword? root) \"keyword\"\n (nil? root) \"nil\" (boolean? root) \"boolean\" :else \"value\")))]\n [:line {:x1 1 :y1 19 :x2 (- w 1) :y2 19 :stroke :grid}]]\n ;; a value that is not a collection: itself, on one line\n (when (and (contains? st :root) (not (coll-kind root)))\n [[:text {:x 8 :y (+ top-y 10) :size 9 :fill (ink-of root)} (cut (pr-str root) 8)]])\n (mapcat (fn [j] (line j (nth rows (+ top j)) (+ top j))) (range (min vis (- n top))))\n (when bar?\n (let [track (* vis row-h) th (max 14 (* track (/ vis n))) ty (+ top-y (* (- track th) (/ top (max 1 (- n vis)))))]\n [[:rect {:x (- w 10) :y top-y :w 6 :h track :r 3 :fill :grid :hit :bar}]\n [:rect {:x (- w 10) :y ty :w 6 :h th :r 3 :fill :soft :hit :bar}]]))\n [[:line {:x1 1 :y1 (- h foot-h) :x2 (- w 1) :y2 (- h foot-h) :stroke :grid}]\n [:text {:x 8 :y (- h 5) :size 8 :fill :soft}\n (cut (cond (:sel st) (str \"→ \" (pr-str (:sel st)))\n (seq rows) (str n (if (= 1 n) \" line\" \" lines\") (when bar? (str \" · \" (inc top) \"–\" (min n (+ top vis)))) \" · pick a line\")\n :else \"\")\n 8)]])))\n\n ;; ── help ──\n :help {:inlets [\"any value: a map, a vector, a set, a list, or a single value; :depth n · bang · :clear\"]\n :outlets [\"the part picked\" \"its path, for [:get …] of a fetch box\"]\n :messages [[\":depth 2\" \"opens it two levels down\"]\n [\"bang\" \"sends the part picked again (the whole value if none)\"]\n [\":clear\" \"empties it\"]]\n :try \"Send it a fetch's answer and open the branches: pick a line and its path comes out on the right.\"}})\n"
|
|
9
9
|
};
|
package/dist/fetch.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Generated by packages/build.mjs from src/fetch.cljs
|
|
2
2
|
export default {
|
|
3
3
|
"class": "fetch",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"author": "bonuoq",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
7
|
"doc": "Brings in what is at a URL: JSON (read as EDN: keys that can be keywords become keywords), text or EDN. A URL (https://…, or github:owner/repo@ref/path through jsDelivr) asks for it; what arrives goes out on the left and is kept as the data of the box, in the history, so everyone in a room has the same and going back does not fetch again (a URL it already holds is sent again, not fetched: refresh fetches it again). With live it is only held in this tab, for answers that change. On the right: :loading, :ready or [:error \"…\"].",
|
|
8
|
-
"source": ";; fetch · what is at a URL (JSON, text or EDN), brought in as a task\n;; Part of @kairotic/data. Written against the Kairotic API (api/…).\n;; Its logic never touches the network: a URL asks for the task :get, the engine runs it (api/http-get)\n;; and what it finds comes back to this box on inlet :task. By default the box keeps it as its data\n;; ([:keep …]): one gesture of the history, the same for everyone in a room, and going back in the\n;; history does not fetch it again. With `live` it is only held in this tab, for answers that change.\n(let [formats #{:json :text :edn}\n fmt-of (fn [args] (if (formats (:as args)) (:as args) :json))\n ;; what the box holds: kept in the work, or (live) only here\n sane (fn [d] (if (and (map? d) (string? (:url d))) (select-keys d [:url :value :date]) {}))\n ;; kept in the work (its data) or, live or before it could be kept (inside a sub-patch, too long, played\n ;; by someone else in a jam), only here (its state)\n held-of (fn [args data state] (if (and (not (:live args)) (contains? data :value)) data (:got state)))\n kept? (fn [args data] (and (not (:live args)) (contains? data :value)))\n summary (fn [v] (cond (map? v) (str \"{} \" (count v) (if (= 1 (count v)) \" key\" \" keys\"))\n (sequential? v) (str \"[] \" (count v) (if (= 1 (count v)) \" item\" \" items\"))\n (string? v) (str \"\\\"\\\" \" (count v) \" characters\")\n (nil? v) \"nil\"\n :else (pr-str v)))\n url-in (fn [value]\n (cond (api/url-of value) (api/url-of value)\n (and (sequential? value) (#{:fetch :url
|
|
8
|
+
"source": ";; fetch · what is at a URL (JSON, text or EDN), brought in as a task\n;; Part of @kairotic/data. Written against the Kairotic API (api/…).\n;; Its logic never touches the network: a URL asks for the task :get, the engine runs it (api/http-get)\n;; and what it finds comes back to this box on inlet :task. By default the box keeps it as its data\n;; ([:keep …]): one gesture of the history, the same for everyone in a room, and going back in the\n;; history does not fetch it again. With `live` it is only held in this tab, for answers that change.\n(let [formats #{:json :text :edn}\n fmt-of (fn [args] (if (formats (:as args)) (:as args) :json))\n ;; what the box holds: kept in the work, or (live) only here\n sane (fn [d] (if (and (map? d) (string? (:url d))) (select-keys d [:url :value :date]) {}))\n ;; kept in the work (its data) or, live or before it could be kept (inside a sub-patch, too long, played\n ;; by someone else in a jam), only here (its state)\n held-of (fn [args data state] (if (and (not (:live args)) (contains? data :value)) data (:got state)))\n kept? (fn [args data] (and (not (:live args)) (contains? data :value)))\n summary (fn [v] (cond (map? v) (str \"{} \" (count v) (if (= 1 (count v)) \" key\" \" keys\"))\n (sequential? v) (str \"[] \" (count v) (if (= 1 (count v)) \" item\" \" items\"))\n (string? v) (str \"\\\"\\\" \" (count v) \" characters\")\n (nil? v) \"nil\"\n :else (pr-str v)))\n url-in (fn [value]\n (cond (api/url-of value) (api/url-of value)\n (and (sequential? value) (#{:fetch :url} (first value))) (api/url-of (second value))\n :else nil))\n path-in (fn [value] (let [p (rest value)] (if (and (= 1 (count p)) (sequential? (first p))) (vec (first p)) (vec p))))]\n {;; ── about ──\n :class \"fetch\"\n :license \"MPL-2.0\"\n :doc \"Brings in what is at a URL: JSON (read as EDN: keys that can be keywords become keywords), text or EDN. A URL (https://…, or github:owner/repo@ref/path through jsDelivr) asks for it; what arrives goes out on the left and is kept as the data of the box, in the history, so everyone in a room has the same and going back does not fetch again (a URL it already holds is sent again, not fetched: refresh fetches it again). With live it is only held in this tab, for answers that change. On the right: :loading, :ready or [:error \\\"…\\\"].\"\n :usage \"fetch [json|text|edn] [live]\"\n :io [1 2]\n :size [230 42]\n\n ;; ── arguments ──\n :args [[:as nil] [:live false]]\n\n ;; ── data: what it keeps, in the history ──\n :model {:empty {}\n :step (fn [d [op x]] (case op :set (sane x) :clear {} d))\n :load sane\n :code (fn [id d] (when (contains? d :value) [(str \"(keep! \" id \" \" (pr-str d) \")\")]))}\n\n ;; ── tasks: outside its pure logic ──\n :tasks {:get (fn [{:keys [url as]} _]\n (.then (api/http-get url {:as as})\n (fn [v] {:body v :date (.toISOString (js/Date.))})))}\n\n ;; ── logic ──\n :receive (fn [{:keys [inlet value state data args]}]\n (let [st (or state {})\n held (held-of args data st)\n ask (fn [u] (let [req {:url u :as (fmt-of args) :n (inc (:n st 0))}]\n {:state (assoc st :waiting req :n (:n req))\n :show {:status :loading :url u}\n :out [[1 :loading]]\n :effects [[:get req]]}))]\n (cond\n ;; what the task found\n (= inlet :task)\n (cond\n (not= (:arg value) (:waiting st)) {} ; the answer to an older request: dropped\n (:error value)\n {:state (dissoc st :waiting)\n :show {:status :error :url (:url (:arg value)) :error (:error value)}\n :out [[1 [:error (:error value)]]]}\n :else\n (let [got {:url (:url (:arg value)) :value (:body (:value value)) :date (:date (:value value))}\n same? (and (kept? args data) (= (:url data) (:url got)) (= (:value data) (:value got)))]\n {:state (-> st (dissoc :waiting) (assoc :got got))\n :show {:status :ready :url (:url got) :summary (summary (:value got))}\n :out [[1 :ready] [0 (:value got)]]\n :effects (if (or (:live args) same?) [] [[:keep got]])}))\n\n ;; a URL: fetched, unless it is the one it already keeps (sent again, then)\n (url-in value)\n (let [u (url-in value)]\n (cond (= u (:url (:waiting st))) {}\n (and (kept? args data) (= u (:url held))) {:out [[1 :ready] [0 (:value held)]]}\n :else (ask u)))\n (#{:refresh} value)\n (if-let [u (or (:url held) (:url (:waiting st)))] (ask u) {})\n\n (#{:bang} value) (if held {:out [[1 :ready] [0 (:value held)]]} {})\n (and (sequential? value) (#{:get} (first value)))\n (if held\n (let [p (path-in value) x (get-in (:value held) p ::none)]\n (if (= x ::none)\n {:out [[1 [:error (str \"nothing at \" (pr-str p))]]]}\n {:out [[0 x]]}))\n {})\n (#{:clear} value)\n {:state {:n (:n st 0)} :show {:status :idle}\n :effects (if (kept? args data) [[:keep nil]] [])}\n :else {})))\n\n :derive (fn [{:keys [shown data state args]}]\n (let [held (held-of args data state)\n status (or (:status shown) (if held :held :idle))\n short (fn [s n] (if (> (count s) n) (str (subs s 0 (dec n)) \"…\") s))]\n {:color (case status (:ready :held) :accent :loading :soft :error :kairos :grid)\n :label (short (case status\n :loading \"loading…\"\n :error (str \"✕ \" (:error shown))\n (:ready :held) (str (cond (kept? args data) \"kept · \" (:live args) \"live · \" :else \"here · \")\n (summary (:value held)))\n (str \"send a URL\" (when (:live args) \" · live\")))\n 38)\n :url (short (str (or (:url shown) (:url held) \"\")) 46)}))\n\n ;; ── view ──\n :view [[:rect {:x 1 :y 1 :w 228 :h 40 :r 4 :stroke :grid :fill :bg}]\n [:circle {:cx 12 :cy 14 :r 4 :fill :$color}]\n [:text {:x 22 :y 17 :size 10 :fill :ink} :$label]\n [:text {:x 8 :y 33 :size 8 :fill :soft} :$url]]\n\n ;; ── help ──\n :help {:inlets [\"a URL (msg https://… · a string · [:fetch url]); refresh; bang; [:get key …]; clear\"]\n :outlets [\"what it found (or the part a [:get …] asks for)\" \":loading, :ready or [:error \\\"…\\\"]\"]\n :messages [[\"a URL\" \"brings it in (if it already keeps that URL, sends it again)\"]\n [\":refresh\" \"fetches its URL again\"]\n [\"bang\" \"sends what it holds\"]\n [\":get :items 0 :name · [:get [:items 0 :name]]\" \"sends one part of it\"]\n [\":clear\" \"forgets it\"]]\n :try \"Click the message with the URL: the answer comes out on the left, into an edn box. Go back in the history: it is still there, without fetching.\"}})\n"
|
|
9
9
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by packages/build.mjs
|
|
2
2
|
export default {
|
|
3
3
|
"package": "@kairotic/data",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"api": 1,
|
|
6
6
|
"author": "bonuoq",
|
|
7
7
|
"license": "MPL-2.0",
|
|
@@ -9,14 +9,14 @@ export default {
|
|
|
9
9
|
{
|
|
10
10
|
"class": "edn",
|
|
11
11
|
"license": "MPL-2.0",
|
|
12
|
-
"doc": "Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). depth n opens it n levels down; bang sends the picked part again (the whole value if none); clear empties it.",
|
|
13
|
-
"source": ";; edn · any value as a tree to open, read and pick from\n;; Part of @kairotic/data. Written against the Kairotic API (api/…).\n;; After Portal (djblue/portal): what arrives is shown as a tree whose collections open and close, each\n;; value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part\n;; of the value (left) and its path (right), the path a fetch box takes as [:get …]. Dragging scrolls.\n;; What happens in the view (open, pick, scroll) is a message to the box itself, like any gesture, so\n;; the same value sent again changes nothing.\n(let [row-h 14 top-y 22 foot-h 16 cw 5.6 ; a line, where lines start, the footer, a character (size 9)\n max-children 200 max-rows 3000\n coll-kind (fn [v] (cond (map? v) :map (vector? v) :vector (set? v) :set (sequential? v) :list :else nil))\n opener {:map \"{\" :vector \"[\" :set \"#{\" :list \"(\"}\n plural (fn [n one many] (str n \" \" (if (= 1 n) one many)))\n size-text (fn [v] (case (coll-kind v)\n :map (plural (count v) \"key\" \"keys\")\n (:vector :list) (plural (count v) \"item\" \"items\")\n :set (plural (count v) \"element\" \"elements\")\n nil))\n ;; the colour of a value, by its kind (the palette of the patch, light or dark)\n ink-of (fn [v] (cond (string? v) :ink (number? v) :kairos (keyword? v) :accent\n (or (nil? v) (boolean? v)) :soft (coll-kind v) :soft :else :ink))\n ;; one level down: the parts of a collection, in a steady order, at most max-children of them\n entries (fn [c]\n (let [es (case (coll-kind c)\n :map (for [[k v] (sort-by (fn [[k _]] (pr-str k)) c)] {:k k :label (pr-str k) :key? true :v v})\n :set (for [v (sort-by pr-str c)] {:k v :label \"\" :v v})\n (map-indexed (fn [i v] {:k i :label (str i) :v v}) c))\n shown (vec (take max-children es))]\n (if (> (count c) max-children)\n (conj shown {:more (- (count c) max-children)})\n shown)))\n ;; a part of the value by its path: get-in, also through lists and sets\n part (fn [root path]\n (reduce (fn [c k] (case (coll-kind c)\n (:map :set) (get c k)\n (:vector :list) (if (number? k) (nth (seq c) k nil) nil)\n nil))\n root path))\n ;; the lines of the tree as it is open: [{:path :depth :label :key? :v :open? :more}]\n rows-of (fn [{:keys [root open]}]\n (if-not (coll-kind root)\n []\n (loop [todo (into () (reverse (map (fn [e] (assoc e :path [(:k e)] :depth 0)) (entries root))))\n out (transient [])]\n (if (or (empty? todo) (>= (count out) max-rows))\n (persistent! out)\n (let [r (first todo) more (rest todo)\n open? (and (coll-kind (:v r)) (contains? open (:path r)) (not (:more r)))\n kids (when open? (map (fn [e] (assoc e :path (conj (:path r) (:k e)) :depth (inc (:depth r))))\n (entries (:v r))))]\n (recur (if open? (into more (reverse kids)) more)\n (conj! out (assoc r :open? open?))))))))\n visible (fn [h] (max 1 (js/Math.floor (/ (- h top-y foot-h) row-h))))\n size-of (fn [args] (api/padded (filter number? args) [320 300]))\n ;; every collection down to depth n, open (at most max-rows of them)\n open-to (fn [root n]\n (loop [todo (list [[] root 0]) acc #{}]\n (if (or (empty? todo) (> (count acc) max-rows))\n acc\n (let [[p v d] (first todo)\n kids (when (and (coll-kind v) (< d n))\n (for [e (entries v) :when (and (not (:more e)) (coll-kind (:v e)))] [(conj p (:k e)) (:v e) (inc d)]))]\n (recur (into (rest todo) kids) (if (and (seq p) (coll-kind v) (<= d n)) (conj acc p) acc))))))\n shown-of (fn [st] {:top (:top st 0) :sel (:sel st) :open (count (:open st))})\n with-top (fn [st top h] (let [n (count (rows-of st))] (assoc st :top (max 0 (min (js/Math.round top) (- n (visible h)))))))]\n {;; ── about ──\n :class \"edn\"\n :license \"MPL-2.0\"\n :doc \"Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). depth n opens it n levels down; bang sends the picked part again (the whole value if none); clear empties it.\"\n :usage \"edn [width height]\"\n :io [1 2]\n :size (fn [box] (size-of (:args box)))\n\n ;; ── logic ──\n :receive (fn [{:keys [value state args]}]\n (let [st (or state {:open #{} :top 0})\n [_ h] (size-of args)\n msg? (fn [k] (and (vector? value) (= k (first value))))\n view (fn [st2] {:state st2 :show (shown-of st2)})]\n (cond\n ;; what happens in the view\n (msg? :edn-open)\n (let [[_ p on] value]\n (view (with-top (update st :open (if on conj disj) p) (:top st 0) h)))\n (msg? :edn-top) (view (with-top st (second value) h))\n (msg? :edn-pick)\n (let [p (second value)]\n (if (or (= p (:sel st)) (not (contains? st :root)))\n {:state st}\n {:state (assoc st :sel p) :show (shown-of (assoc st :sel p))\n :out [[1 p] [0 (part (:root st) p)]]}))\n ;; messages\n (and (msg? :depth) (number? (second value)))\n (view (with-top (assoc st :open (open-to (:root st) (max 0 (dec (second value))))) 0 h))\n (#{:bang \"bang\"} value)\n (if (contains? st :root)\n (let [p (or (:sel st) [])] {:out [[1 p] [0 (part (:root st) p)]]})\n {})\n (#{:clear \"clear\"} value) (view {:open #{} :top 0})\n ;; a value: the same again changes nothing; another keeps what was open and picked\n (and (contains? st :root) (= value (:root st))) {:state st}\n :else\n (let [st2 (assoc st :root value)]\n (view (with-top st2 (:top st 0) h))))))\n\n ;; a line pressed (on its arrow: open or close it; elsewhere: pick it), or a drag that scrolls\n :gesture (fn [{:keys [up hit dy start state h]}]\n (let [st (or state {}) rows (rows-of st) n (count rows) vis (visible h)\n t0 (:top start (:top st 0))]\n (cond\n (>= (js/Math.abs dy) 3)\n [:edn-top (if (= hit :bar)\n (+ t0 (* dy (/ n (* vis row-h))))\n (- t0 (/ dy row-h)))]\n (not up) nil\n ;; a line is its index; its arrow, -1 - its index\n (and (number? hit) (neg? hit))\n (when-let [r (get rows (- -1 hit))] (when (coll-kind (:v r)) [:edn-open (:path r) (not (:open? r))]))\n (number? hit) (when-let [r (get rows hit)] (when-not (:more r) [:edn-pick (:path r)]))\n :else nil)))\n\n ;; ── view ──\n :draw (fn [{:keys [state w h]}]\n (let [st (or state {}) root (:root st) rows (rows-of st) n (count rows)\n vis (visible h) top (max 0 (min (:top st 0) (- n vis))) bar? (> n vis)\n right (- w (if bar? 14 6))\n chars (fn [x] (max 0 (js/Math.floor (/ (- right x) cw))))\n cut (fn [s x] (let [m (chars x)] (if (> (count s) m) (str (subs s 0 (max 0 (dec m))) \"…\") s)))\n line (fn [j r i]\n (let [y (+ top-y (* j row-h)) base (+ y 10)\n x (+ 8 (* 12 (:depth r))) v (:v r) kind (coll-kind v)\n lbl (:label r) vx (+ x 12 (if (seq lbl) (* cw (inc (count lbl))) 0))\n sel? (= (:sel st) (:path r))]\n (if (:more r)\n [[:text {:x (+ x 12) :y base :size 9 :fill :soft} (str \"… \" (:more r) \" more\")]]\n (concat\n [[:rect {:x 2 :y y :w (- right 2) :h row-h :fill (if sel? :accent :bg) :opacity (if sel? 0.14 0) :hit i}]]\n (when kind\n [[:rect {:x (- x 2) :y y :w 12 :h row-h :fill :bg :opacity 0 :hit (- -1 i)}]\n [:text {:x x :y base :size 9 :fill :soft} (if (:open? r) \"▾\" \"▸\")]])\n (when (seq lbl)\n [[:text {:x (+ x 12) :y base :size 9 :fill (if (:key? r) :accent :soft)} (cut lbl (+ x 12))]])\n [[:text {:x vx :y base :size 9 :fill (ink-of v)}\n (cut (cond (and kind (:open? r)) (str (opener kind) \" \" (size-text v))\n kind (pr-str v)\n :else (pr-str v))\n vx)]]))))]\n (concat\n [[:rect {:x 1 :y 1 :w (- w 2) :h (- h 2) :r 4 :stroke :grid :fill :bg}]\n [:text {:x 8 :y 15 :size 9 :fill :soft}\n (cond (not (contains? st :root)) \"edn · send it a value\"\n (coll-kind root) (str (name (coll-kind root)) \" · \" (size-text root))\n :else (str (cond (string? root) \"string\" (number? root) \"number\" (keyword? root) \"keyword\"\n (nil? root) \"nil\" (boolean? root) \"boolean\" :else \"value\")))]\n [:line {:x1 1 :y1 19 :x2 (- w 1) :y2 19 :stroke :grid}]]\n ;; a value that is not a collection: itself, on one line\n (when (and (contains? st :root) (not (coll-kind root)))\n [[:text {:x 8 :y (+ top-y 10) :size 9 :fill (ink-of root)} (cut (pr-str root) 8)]])\n (mapcat (fn [j] (line j (nth rows (+ top j)) (+ top j))) (range (min vis (- n top))))\n (when bar?\n (let [track (* vis row-h) th (max 14 (* track (/ vis n))) ty (+ top-y (* (- track th) (/ top (max 1 (- n vis)))))]\n [[:rect {:x (- w 10) :y top-y :w 6 :h track :r 3 :fill :grid :hit :bar}]\n [:rect {:x (- w 10) :y ty :w 6 :h th :r 3 :fill :soft :hit :bar}]]))\n [[:line {:x1 1 :y1 (- h foot-h) :x2 (- w 1) :y2 (- h foot-h) :stroke :grid}]\n [:text {:x 8 :y (- h 5) :size 8 :fill :soft}\n (cut (cond (:sel st) (str \"→ \" (pr-str (:sel st)))\n (seq rows) (str n (if (= 1 n) \" line\" \" lines\") (when bar? (str \" · \" (inc top) \"–\" (min n (+ top vis)))) \" · pick a line\")\n :else \"\")\n 8)]])))\n\n ;; ── help ──\n :help {:inlets [\"any value: a map, a vector, a set, a list, or a single value; depth n · bang · clear\"]\n :outlets [\"the part picked\" \"its path, for [:get …] of a fetch box\"]\n :messages [[\"depth 2\" \"opens it two levels down\"]\n [\"bang\" \"sends the part picked again (the whole value if none)\"]\n [\"clear\" \"empties it\"]]\n :try \"Send it a fetch's answer and open the branches: pick a line and its path comes out on the right.\"}})\n"
|
|
12
|
+
"doc": "Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). :depth n opens it n levels down; bang sends the picked part again (the whole value if none); :clear empties it.",
|
|
13
|
+
"source": ";; edn · any value as a tree to open, read and pick from\n;; Part of @kairotic/data. Written against the Kairotic API (api/…).\n;; After Portal (djblue/portal): what arrives is shown as a tree whose collections open and close, each\n;; value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part\n;; of the value (left) and its path (right), the path a fetch box takes as [:get …]. Dragging scrolls.\n;; What happens in the view (open, pick, scroll) is a message to the box itself, like any gesture, so\n;; the same value sent again changes nothing.\n(let [row-h 14 top-y 22 foot-h 16 cw 5.6 ; a line, where lines start, the footer, a character (size 9)\n max-children 200 max-rows 3000\n coll-kind (fn [v] (cond (map? v) :map (vector? v) :vector (set? v) :set (sequential? v) :list :else nil))\n opener {:map \"{\" :vector \"[\" :set \"#{\" :list \"(\"}\n plural (fn [n one many] (str n \" \" (if (= 1 n) one many)))\n size-text (fn [v] (case (coll-kind v)\n :map (plural (count v) \"key\" \"keys\")\n (:vector :list) (plural (count v) \"item\" \"items\")\n :set (plural (count v) \"element\" \"elements\")\n nil))\n ;; the colour of a value, by its kind (the palette of the patch, light or dark)\n ink-of (fn [v] (cond (string? v) :ink (number? v) :kairos (keyword? v) :accent\n (or (nil? v) (boolean? v)) :soft (coll-kind v) :soft :else :ink))\n ;; one level down: the parts of a collection, in a steady order, at most max-children of them\n entries (fn [c]\n (let [es (case (coll-kind c)\n :map (for [[k v] (sort-by (fn [[k _]] (pr-str k)) c)] {:k k :label (pr-str k) :key? true :v v})\n :set (for [v (sort-by pr-str c)] {:k v :label \"\" :v v})\n (map-indexed (fn [i v] {:k i :label (str i) :v v}) c))\n shown (vec (take max-children es))]\n (if (> (count c) max-children)\n (conj shown {:more (- (count c) max-children)})\n shown)))\n ;; a part of the value by its path: get-in, also through lists and sets\n part (fn [root path]\n (reduce (fn [c k] (case (coll-kind c)\n (:map :set) (get c k)\n (:vector :list) (if (number? k) (nth (seq c) k nil) nil)\n nil))\n root path))\n ;; the lines of the tree as it is open: [{:path :depth :label :key? :v :open? :more}]\n rows-of (fn [{:keys [root open]}]\n (if-not (coll-kind root)\n []\n (loop [todo (into () (reverse (map (fn [e] (assoc e :path [(:k e)] :depth 0)) (entries root))))\n out (transient [])]\n (if (or (empty? todo) (>= (count out) max-rows))\n (persistent! out)\n (let [r (first todo) more (rest todo)\n open? (and (coll-kind (:v r)) (contains? open (:path r)) (not (:more r)))\n kids (when open? (map (fn [e] (assoc e :path (conj (:path r) (:k e)) :depth (inc (:depth r))))\n (entries (:v r))))]\n (recur (if open? (into more (reverse kids)) more)\n (conj! out (assoc r :open? open?))))))))\n visible (fn [h] (max 1 (js/Math.floor (/ (- h top-y foot-h) row-h))))\n size-of (fn [args] (api/padded (filter number? args) [320 300]))\n ;; every collection down to depth n, open (at most max-rows of them)\n open-to (fn [root n]\n (loop [todo (list [[] root 0]) acc #{}]\n (if (or (empty? todo) (> (count acc) max-rows))\n acc\n (let [[p v d] (first todo)\n kids (when (and (coll-kind v) (< d n))\n (for [e (entries v) :when (and (not (:more e)) (coll-kind (:v e)))] [(conj p (:k e)) (:v e) (inc d)]))]\n (recur (into (rest todo) kids) (if (and (seq p) (coll-kind v) (<= d n)) (conj acc p) acc))))))\n shown-of (fn [st] {:top (:top st 0) :sel (:sel st) :open (count (:open st))})\n with-top (fn [st top h] (let [n (count (rows-of st))] (assoc st :top (max 0 (min (js/Math.round top) (- n (visible h)))))))]\n {;; ── about ──\n :class \"edn\"\n :license \"MPL-2.0\"\n :doc \"Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). :depth n opens it n levels down; bang sends the picked part again (the whole value if none); :clear empties it.\"\n :usage \"edn [width height]\"\n :io [1 2]\n :size (fn [box] (size-of (:args box)))\n\n ;; ── logic ──\n :receive (fn [{:keys [value state args]}]\n (let [st (or state {:open #{} :top 0})\n [_ h] (size-of args)\n msg? (fn [k] (and (vector? value) (= k (first value))))\n view (fn [st2] {:state st2 :show (shown-of st2)})]\n (cond\n ;; what happens in the view\n (msg? :edn-open)\n (let [[_ p on] value]\n (view (with-top (update st :open (if on conj disj) p) (:top st 0) h)))\n (msg? :edn-top) (view (with-top st (second value) h))\n (msg? :edn-pick)\n (let [p (second value)]\n (if (or (= p (:sel st)) (not (contains? st :root)))\n {:state st}\n {:state (assoc st :sel p) :show (shown-of (assoc st :sel p))\n :out [[1 p] [0 (part (:root st) p)]]}))\n ;; messages\n (and (msg? :depth) (number? (second value)))\n (view (with-top (assoc st :open (open-to (:root st) (max 0 (dec (second value))))) 0 h))\n (#{:bang} value)\n (if (contains? st :root)\n (let [p (or (:sel st) [])] {:out [[1 p] [0 (part (:root st) p)]]})\n {})\n (#{:clear} value) (view {:open #{} :top 0})\n ;; a value: the same again changes nothing; another keeps what was open and picked\n (and (contains? st :root) (= value (:root st))) {:state st}\n :else\n (let [st2 (assoc st :root value)]\n (view (with-top st2 (:top st 0) h))))))\n\n ;; a line pressed (on its arrow: open or close it; elsewhere: pick it), or a drag that scrolls\n :gesture (fn [{:keys [up hit dy start state h]}]\n (let [st (or state {}) rows (rows-of st) n (count rows) vis (visible h)\n t0 (:top start (:top st 0))]\n (cond\n (>= (js/Math.abs dy) 3)\n [:edn-top (if (= hit :bar)\n (+ t0 (* dy (/ n (* vis row-h))))\n (- t0 (/ dy row-h)))]\n (not up) nil\n ;; a line is its index; its arrow, -1 - its index\n (and (number? hit) (neg? hit))\n (when-let [r (get rows (- -1 hit))] (when (coll-kind (:v r)) [:edn-open (:path r) (not (:open? r))]))\n (number? hit) (when-let [r (get rows hit)] (when-not (:more r) [:edn-pick (:path r)]))\n :else nil)))\n\n ;; ── view ──\n :draw (fn [{:keys [state w h]}]\n (let [st (or state {}) root (:root st) rows (rows-of st) n (count rows)\n vis (visible h) top (max 0 (min (:top st 0) (- n vis))) bar? (> n vis)\n right (- w (if bar? 14 6))\n chars (fn [x] (max 0 (js/Math.floor (/ (- right x) cw))))\n cut (fn [s x] (let [m (chars x)] (if (> (count s) m) (str (subs s 0 (max 0 (dec m))) \"…\") s)))\n line (fn [j r i]\n (let [y (+ top-y (* j row-h)) base (+ y 10)\n x (+ 8 (* 12 (:depth r))) v (:v r) kind (coll-kind v)\n lbl (:label r) vx (+ x 12 (if (seq lbl) (* cw (inc (count lbl))) 0))\n sel? (= (:sel st) (:path r))]\n (if (:more r)\n [[:text {:x (+ x 12) :y base :size 9 :fill :soft} (str \"… \" (:more r) \" more\")]]\n (concat\n [[:rect {:x 2 :y y :w (- right 2) :h row-h :fill (if sel? :accent :bg) :opacity (if sel? 0.14 0) :hit i}]]\n (when kind\n [[:rect {:x (- x 2) :y y :w 12 :h row-h :fill :bg :opacity 0 :hit (- -1 i)}]\n [:text {:x x :y base :size 9 :fill :soft} (if (:open? r) \"▾\" \"▸\")]])\n (when (seq lbl)\n [[:text {:x (+ x 12) :y base :size 9 :fill (if (:key? r) :accent :soft)} (cut lbl (+ x 12))]])\n [[:text {:x vx :y base :size 9 :fill (ink-of v)}\n (cut (cond (and kind (:open? r)) (str (opener kind) \" \" (size-text v))\n kind (pr-str v)\n :else (pr-str v))\n vx)]]))))]\n (concat\n [[:rect {:x 1 :y 1 :w (- w 2) :h (- h 2) :r 4 :stroke :grid :fill :bg}]\n [:text {:x 8 :y 15 :size 9 :fill :soft}\n (cond (not (contains? st :root)) \"edn · send it a value\"\n (coll-kind root) (str (name (coll-kind root)) \" · \" (size-text root))\n :else (str (cond (string? root) \"string\" (number? root) \"number\" (keyword? root) \"keyword\"\n (nil? root) \"nil\" (boolean? root) \"boolean\" :else \"value\")))]\n [:line {:x1 1 :y1 19 :x2 (- w 1) :y2 19 :stroke :grid}]]\n ;; a value that is not a collection: itself, on one line\n (when (and (contains? st :root) (not (coll-kind root)))\n [[:text {:x 8 :y (+ top-y 10) :size 9 :fill (ink-of root)} (cut (pr-str root) 8)]])\n (mapcat (fn [j] (line j (nth rows (+ top j)) (+ top j))) (range (min vis (- n top))))\n (when bar?\n (let [track (* vis row-h) th (max 14 (* track (/ vis n))) ty (+ top-y (* (- track th) (/ top (max 1 (- n vis)))))]\n [[:rect {:x (- w 10) :y top-y :w 6 :h track :r 3 :fill :grid :hit :bar}]\n [:rect {:x (- w 10) :y ty :w 6 :h th :r 3 :fill :soft :hit :bar}]]))\n [[:line {:x1 1 :y1 (- h foot-h) :x2 (- w 1) :y2 (- h foot-h) :stroke :grid}]\n [:text {:x 8 :y (- h 5) :size 8 :fill :soft}\n (cut (cond (:sel st) (str \"→ \" (pr-str (:sel st)))\n (seq rows) (str n (if (= 1 n) \" line\" \" lines\") (when bar? (str \" · \" (inc top) \"–\" (min n (+ top vis)))) \" · pick a line\")\n :else \"\")\n 8)]])))\n\n ;; ── help ──\n :help {:inlets [\"any value: a map, a vector, a set, a list, or a single value; :depth n · bang · :clear\"]\n :outlets [\"the part picked\" \"its path, for [:get …] of a fetch box\"]\n :messages [[\":depth 2\" \"opens it two levels down\"]\n [\"bang\" \"sends the part picked again (the whole value if none)\"]\n [\":clear\" \"empties it\"]]\n :try \"Send it a fetch's answer and open the branches: pick a line and its path comes out on the right.\"}})\n"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"class": "fetch",
|
|
17
17
|
"license": "MPL-2.0",
|
|
18
18
|
"doc": "Brings in what is at a URL: JSON (read as EDN: keys that can be keywords become keywords), text or EDN. A URL (https://…, or github:owner/repo@ref/path through jsDelivr) asks for it; what arrives goes out on the left and is kept as the data of the box, in the history, so everyone in a room has the same and going back does not fetch again (a URL it already holds is sent again, not fetched: refresh fetches it again). With live it is only held in this tab, for answers that change. On the right: :loading, :ready or [:error \"…\"].",
|
|
19
|
-
"source": ";; fetch · what is at a URL (JSON, text or EDN), brought in as a task\n;; Part of @kairotic/data. Written against the Kairotic API (api/…).\n;; Its logic never touches the network: a URL asks for the task :get, the engine runs it (api/http-get)\n;; and what it finds comes back to this box on inlet :task. By default the box keeps it as its data\n;; ([:keep …]): one gesture of the history, the same for everyone in a room, and going back in the\n;; history does not fetch it again. With `live` it is only held in this tab, for answers that change.\n(let [formats #{:json :text :edn}\n fmt-of (fn [args] (if (formats (:as args)) (:as args) :json))\n ;; what the box holds: kept in the work, or (live) only here\n sane (fn [d] (if (and (map? d) (string? (:url d))) (select-keys d [:url :value :date]) {}))\n ;; kept in the work (its data) or, live or before it could be kept (inside a sub-patch, too long, played\n ;; by someone else in a jam), only here (its state)\n held-of (fn [args data state] (if (and (not (:live args)) (contains? data :value)) data (:got state)))\n kept? (fn [args data] (and (not (:live args)) (contains? data :value)))\n summary (fn [v] (cond (map? v) (str \"{} \" (count v) (if (= 1 (count v)) \" key\" \" keys\"))\n (sequential? v) (str \"[] \" (count v) (if (= 1 (count v)) \" item\" \" items\"))\n (string? v) (str \"\\\"\\\" \" (count v) \" characters\")\n (nil? v) \"nil\"\n :else (pr-str v)))\n url-in (fn [value]\n (cond (api/url-of value) (api/url-of value)\n (and (sequential? value) (#{:fetch :url
|
|
19
|
+
"source": ";; fetch · what is at a URL (JSON, text or EDN), brought in as a task\n;; Part of @kairotic/data. Written against the Kairotic API (api/…).\n;; Its logic never touches the network: a URL asks for the task :get, the engine runs it (api/http-get)\n;; and what it finds comes back to this box on inlet :task. By default the box keeps it as its data\n;; ([:keep …]): one gesture of the history, the same for everyone in a room, and going back in the\n;; history does not fetch it again. With `live` it is only held in this tab, for answers that change.\n(let [formats #{:json :text :edn}\n fmt-of (fn [args] (if (formats (:as args)) (:as args) :json))\n ;; what the box holds: kept in the work, or (live) only here\n sane (fn [d] (if (and (map? d) (string? (:url d))) (select-keys d [:url :value :date]) {}))\n ;; kept in the work (its data) or, live or before it could be kept (inside a sub-patch, too long, played\n ;; by someone else in a jam), only here (its state)\n held-of (fn [args data state] (if (and (not (:live args)) (contains? data :value)) data (:got state)))\n kept? (fn [args data] (and (not (:live args)) (contains? data :value)))\n summary (fn [v] (cond (map? v) (str \"{} \" (count v) (if (= 1 (count v)) \" key\" \" keys\"))\n (sequential? v) (str \"[] \" (count v) (if (= 1 (count v)) \" item\" \" items\"))\n (string? v) (str \"\\\"\\\" \" (count v) \" characters\")\n (nil? v) \"nil\"\n :else (pr-str v)))\n url-in (fn [value]\n (cond (api/url-of value) (api/url-of value)\n (and (sequential? value) (#{:fetch :url} (first value))) (api/url-of (second value))\n :else nil))\n path-in (fn [value] (let [p (rest value)] (if (and (= 1 (count p)) (sequential? (first p))) (vec (first p)) (vec p))))]\n {;; ── about ──\n :class \"fetch\"\n :license \"MPL-2.0\"\n :doc \"Brings in what is at a URL: JSON (read as EDN: keys that can be keywords become keywords), text or EDN. A URL (https://…, or github:owner/repo@ref/path through jsDelivr) asks for it; what arrives goes out on the left and is kept as the data of the box, in the history, so everyone in a room has the same and going back does not fetch again (a URL it already holds is sent again, not fetched: refresh fetches it again). With live it is only held in this tab, for answers that change. On the right: :loading, :ready or [:error \\\"…\\\"].\"\n :usage \"fetch [json|text|edn] [live]\"\n :io [1 2]\n :size [230 42]\n\n ;; ── arguments ──\n :args [[:as nil] [:live false]]\n\n ;; ── data: what it keeps, in the history ──\n :model {:empty {}\n :step (fn [d [op x]] (case op :set (sane x) :clear {} d))\n :load sane\n :code (fn [id d] (when (contains? d :value) [(str \"(keep! \" id \" \" (pr-str d) \")\")]))}\n\n ;; ── tasks: outside its pure logic ──\n :tasks {:get (fn [{:keys [url as]} _]\n (.then (api/http-get url {:as as})\n (fn [v] {:body v :date (.toISOString (js/Date.))})))}\n\n ;; ── logic ──\n :receive (fn [{:keys [inlet value state data args]}]\n (let [st (or state {})\n held (held-of args data st)\n ask (fn [u] (let [req {:url u :as (fmt-of args) :n (inc (:n st 0))}]\n {:state (assoc st :waiting req :n (:n req))\n :show {:status :loading :url u}\n :out [[1 :loading]]\n :effects [[:get req]]}))]\n (cond\n ;; what the task found\n (= inlet :task)\n (cond\n (not= (:arg value) (:waiting st)) {} ; the answer to an older request: dropped\n (:error value)\n {:state (dissoc st :waiting)\n :show {:status :error :url (:url (:arg value)) :error (:error value)}\n :out [[1 [:error (:error value)]]]}\n :else\n (let [got {:url (:url (:arg value)) :value (:body (:value value)) :date (:date (:value value))}\n same? (and (kept? args data) (= (:url data) (:url got)) (= (:value data) (:value got)))]\n {:state (-> st (dissoc :waiting) (assoc :got got))\n :show {:status :ready :url (:url got) :summary (summary (:value got))}\n :out [[1 :ready] [0 (:value got)]]\n :effects (if (or (:live args) same?) [] [[:keep got]])}))\n\n ;; a URL: fetched, unless it is the one it already keeps (sent again, then)\n (url-in value)\n (let [u (url-in value)]\n (cond (= u (:url (:waiting st))) {}\n (and (kept? args data) (= u (:url held))) {:out [[1 :ready] [0 (:value held)]]}\n :else (ask u)))\n (#{:refresh} value)\n (if-let [u (or (:url held) (:url (:waiting st)))] (ask u) {})\n\n (#{:bang} value) (if held {:out [[1 :ready] [0 (:value held)]]} {})\n (and (sequential? value) (#{:get} (first value)))\n (if held\n (let [p (path-in value) x (get-in (:value held) p ::none)]\n (if (= x ::none)\n {:out [[1 [:error (str \"nothing at \" (pr-str p))]]]}\n {:out [[0 x]]}))\n {})\n (#{:clear} value)\n {:state {:n (:n st 0)} :show {:status :idle}\n :effects (if (kept? args data) [[:keep nil]] [])}\n :else {})))\n\n :derive (fn [{:keys [shown data state args]}]\n (let [held (held-of args data state)\n status (or (:status shown) (if held :held :idle))\n short (fn [s n] (if (> (count s) n) (str (subs s 0 (dec n)) \"…\") s))]\n {:color (case status (:ready :held) :accent :loading :soft :error :kairos :grid)\n :label (short (case status\n :loading \"loading…\"\n :error (str \"✕ \" (:error shown))\n (:ready :held) (str (cond (kept? args data) \"kept · \" (:live args) \"live · \" :else \"here · \")\n (summary (:value held)))\n (str \"send a URL\" (when (:live args) \" · live\")))\n 38)\n :url (short (str (or (:url shown) (:url held) \"\")) 46)}))\n\n ;; ── view ──\n :view [[:rect {:x 1 :y 1 :w 228 :h 40 :r 4 :stroke :grid :fill :bg}]\n [:circle {:cx 12 :cy 14 :r 4 :fill :$color}]\n [:text {:x 22 :y 17 :size 10 :fill :ink} :$label]\n [:text {:x 8 :y 33 :size 8 :fill :soft} :$url]]\n\n ;; ── help ──\n :help {:inlets [\"a URL (msg https://… · a string · [:fetch url]); refresh; bang; [:get key …]; clear\"]\n :outlets [\"what it found (or the part a [:get …] asks for)\" \":loading, :ready or [:error \\\"…\\\"]\"]\n :messages [[\"a URL\" \"brings it in (if it already keeps that URL, sends it again)\"]\n [\":refresh\" \"fetches its URL again\"]\n [\"bang\" \"sends what it holds\"]\n [\":get :items 0 :name · [:get [:items 0 :name]]\" \"sends one part of it\"]\n [\":clear\" \"forgets it\"]]\n :try \"Click the message with the URL: the answer comes out on the left, into an edn box. Go back in the history: it is still there, without fetching.\"}})\n"
|
|
20
20
|
}
|
|
21
21
|
]
|
|
22
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kairotic/data",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Kairotic data components: fetch (what is at a URL, brought in as a task and kept in the work) and edn (any value as a tree to open, read and pick from, after Portal)",
|
|
5
5
|
"author": "bonuoq",
|
|
6
6
|
"license": "MPL-2.0",
|
package/src/edn.cljs
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
{;; ── about ──
|
|
66
66
|
:class "edn"
|
|
67
67
|
:license "MPL-2.0"
|
|
68
|
-
:doc "Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). depth n opens it n levels down; bang sends the picked part again (the whole value if none); clear empties it."
|
|
68
|
+
:doc "Shows any value as a tree, like Portal: maps, vectors, sets and lists open and close (▸ ▾), each value coloured by its kind, a closed collection previewed on its line. Picking a line sends that part of the value (left) and its path (right): the path a fetch box takes as [:get …]. Dragging scrolls (or the bar on the right). :depth n opens it n levels down; bang sends the picked part again (the whole value if none); :clear empties it."
|
|
69
69
|
:usage "edn [width height]"
|
|
70
70
|
:io [1 2]
|
|
71
71
|
:size (fn [box] (size-of (:args box)))
|
|
@@ -91,11 +91,11 @@
|
|
|
91
91
|
;; messages
|
|
92
92
|
(and (msg? :depth) (number? (second value)))
|
|
93
93
|
(view (with-top (assoc st :open (open-to (:root st) (max 0 (dec (second value))))) 0 h))
|
|
94
|
-
(#{:bang
|
|
94
|
+
(#{:bang} value)
|
|
95
95
|
(if (contains? st :root)
|
|
96
96
|
(let [p (or (:sel st) [])] {:out [[1 p] [0 (part (:root st) p)]]})
|
|
97
97
|
{})
|
|
98
|
-
(#{:clear
|
|
98
|
+
(#{:clear} value) (view {:open #{} :top 0})
|
|
99
99
|
;; a value: the same again changes nothing; another keeps what was open and picked
|
|
100
100
|
(and (contains? st :root) (= value (:root st))) {:state st}
|
|
101
101
|
:else
|
|
@@ -168,9 +168,9 @@
|
|
|
168
168
|
8)]])))
|
|
169
169
|
|
|
170
170
|
;; ── help ──
|
|
171
|
-
:help {:inlets ["any value: a map, a vector, a set, a list, or a single value; depth n · bang · clear"]
|
|
171
|
+
:help {:inlets ["any value: a map, a vector, a set, a list, or a single value; :depth n · bang · :clear"]
|
|
172
172
|
:outlets ["the part picked" "its path, for [:get …] of a fetch box"]
|
|
173
|
-
:messages [["depth 2" "opens it two levels down"]
|
|
173
|
+
:messages [[":depth 2" "opens it two levels down"]
|
|
174
174
|
["bang" "sends the part picked again (the whole value if none)"]
|
|
175
|
-
["clear" "empties it"]]
|
|
175
|
+
[":clear" "empties it"]]
|
|
176
176
|
:try "Send it a fetch's answer and open the branches: pick a line and its path comes out on the right."}})
|
package/src/fetch.cljs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
:else (pr-str v)))
|
|
20
20
|
url-in (fn [value]
|
|
21
21
|
(cond (api/url-of value) (api/url-of value)
|
|
22
|
-
(and (sequential? value) (#{:fetch :url
|
|
22
|
+
(and (sequential? value) (#{:fetch :url} (first value))) (api/url-of (second value))
|
|
23
23
|
:else nil))
|
|
24
24
|
path-in (fn [value] (let [p (rest value)] (if (and (= 1 (count p)) (sequential? (first p))) (vec (first p)) (vec p))))]
|
|
25
25
|
{;; ── about ──
|
|
@@ -76,18 +76,18 @@
|
|
|
76
76
|
(cond (= u (:url (:waiting st))) {}
|
|
77
77
|
(and (kept? args data) (= u (:url held))) {:out [[1 :ready] [0 (:value held)]]}
|
|
78
78
|
:else (ask u)))
|
|
79
|
-
(#{:refresh
|
|
79
|
+
(#{:refresh} value)
|
|
80
80
|
(if-let [u (or (:url held) (:url (:waiting st)))] (ask u) {})
|
|
81
81
|
|
|
82
|
-
(#{:bang
|
|
83
|
-
(and (sequential? value) (#{:get
|
|
82
|
+
(#{:bang} value) (if held {:out [[1 :ready] [0 (:value held)]]} {})
|
|
83
|
+
(and (sequential? value) (#{:get} (first value)))
|
|
84
84
|
(if held
|
|
85
85
|
(let [p (path-in value) x (get-in (:value held) p ::none)]
|
|
86
86
|
(if (= x ::none)
|
|
87
87
|
{:out [[1 [:error (str "nothing at " (pr-str p))]]]}
|
|
88
88
|
{:out [[0 x]]}))
|
|
89
89
|
{})
|
|
90
|
-
(#{:clear
|
|
90
|
+
(#{:clear} value)
|
|
91
91
|
{:state {:n (:n st 0)} :show {:status :idle}
|
|
92
92
|
:effects (if (kept? args data) [[:keep nil]] [])}
|
|
93
93
|
:else {})))
|
|
@@ -116,8 +116,8 @@
|
|
|
116
116
|
:help {:inlets ["a URL (msg https://… · a string · [:fetch url]); refresh; bang; [:get key …]; clear"]
|
|
117
117
|
:outlets ["what it found (or the part a [:get …] asks for)" ":loading, :ready or [:error \"…\"]"]
|
|
118
118
|
:messages [["a URL" "brings it in (if it already keeps that URL, sends it again)"]
|
|
119
|
-
["refresh" "fetches its URL again"]
|
|
119
|
+
[":refresh" "fetches its URL again"]
|
|
120
120
|
["bang" "sends what it holds"]
|
|
121
|
-
["get items 0 name · [:get [:items 0 :name]]" "sends one part of it"]
|
|
122
|
-
["clear" "forgets it"]]
|
|
121
|
+
[":get :items 0 :name · [:get [:items 0 :name]]" "sends one part of it"]
|
|
122
|
+
[":clear" "forgets it"]]
|
|
123
123
|
:try "Click the message with the URL: the answer comes out on the left, into an edn box. Go back in the history: it is still there, without fetching."}})
|