|
2 | 2 | (:refer-clojure :exclude [read])
|
3 | 3 | (:require #?(:clj [portal.sync :as a]
|
4 | 4 | :cljr [portal.sync :as a]
|
5 |
| - :cljs [portal.async :as a]) |
| 5 | + :cljs [portal.async :as a] |
| 6 | + :lpy [portal.sync :as a]) |
6 | 7 | #?(:joyride [portal.runtime.datafy :refer [datafy nav]]
|
7 | 8 | :org.babashka/nbb [portal.runtime.datafy :refer [datafy nav]]
|
| 9 | + :lpy [portal.runtime.datafy :refer [datafy nav]] |
8 | 10 | :default [clojure.datafy :refer [datafy nav]])
|
9 | 11 | #?(:joyride [cljs.pprint :as pprint]
|
10 | 12 | :default [clojure.pprint :as pprint])
|
|
15 | 17 |
|
16 | 18 | #?(:joyride nil
|
17 | 19 | :org.babashka/nbb nil
|
| 20 | + :lpy nil |
18 | 21 | :default
|
19 | 22 | (defmethod pprint/simple-dispatch tagged-type [value]
|
20 | 23 | (if (not= (:tag value) "remote")
|
|
74 | 77 | (defn- hashable? [value]
|
75 | 78 | (try
|
76 | 79 | (and (hash value) true)
|
77 |
| - (catch #?(:clj Exception :cljr Exception :cljs :default) _ |
| 80 | + (catch #?(:clj Exception :cljr Exception :cljs :default :lpy Exception) _ |
78 | 81 | false)))
|
79 | 82 |
|
80 | 83 | #?(:bb (def clojure.lang.Range (type (range 1.0))))
|
|
96 | 99 | (try (with-meta value {}) true
|
97 | 100 | (catch :default _e false)))
|
98 | 101 |
|
99 |
| - :cljs (implements? IMeta value))) |
| 102 | + :cljs (implements? IMeta value) |
| 103 | + |
| 104 | + :lpy |
| 105 | + (try (with-meta value {}) true |
| 106 | + (catch Exception _e false)))) |
| 107 | + |
| 108 | +#?(:lpy (defn- sorted? [_] false)) |
100 | 109 |
|
101 | 110 | (defn- hash+ [x]
|
102 | 111 | (cond
|
|
138 | 147 | :cljr (instance? clojure.lang.Atom o)
|
139 | 148 | :joyride (= Atom (type o))
|
140 | 149 | :org.babashka/nbb (= Atom (type o))
|
141 |
| - :cljs (satisfies? cljs.core/IAtom o))) |
| 150 | + :cljs (satisfies? cljs.core/IAtom o) |
| 151 | + :lpy (instance? basilisp.lang.atom/Atom o))) |
142 | 152 |
|
143 | 153 | (defn- notify [session-id a]
|
144 | 154 | (when-let [request @request]
|
|
212 | 222 |
|
213 | 223 | (defn- to-object [buffer value tag rep]
|
214 | 224 | (if-not *session*
|
215 |
| - (cson/-to-json |
| 225 | + (cson/to-json* |
216 | 226 | (with-meta
|
217 | 227 | (cson/tagged-value "remote" (pr-str value))
|
218 | 228 | (meta value))
|
|
235 | 245 | :clj
|
236 | 246 | (extend-type java.util.Collection
|
237 | 247 | cson/ToJson
|
238 |
| - (-to-json [value buffer] |
| 248 | + (to-json* [value buffer] |
239 | 249 | (if-let [id (value->id? value)]
|
240 |
| - (cson/-to-json (cson/tagged-value "ref" id) buffer) |
| 250 | + (cson/to-json* (cson/tagged-value "ref" id) buffer) |
241 | 251 | (cson/tagged-coll
|
242 | 252 | buffer
|
243 | 253 | (cond
|
|
251 | 261 | :clj
|
252 | 262 | (extend-type java.util.Map
|
253 | 263 | cson/ToJson
|
254 |
| - (-to-json [value buffer] |
| 264 | + (to-json* [value buffer] |
255 | 265 | (if-let [id (value->id? value)]
|
256 |
| - (cson/-to-json (cson/tagged-value "ref" id) buffer) |
| 266 | + (cson/to-json* (cson/tagged-value "ref" id) buffer) |
257 | 267 | (cson/tagged-map
|
258 | 268 | buffer
|
259 | 269 | "{"
|
|
264 | 274 |
|
265 | 275 | (extend-type #?(:clj Object
|
266 | 276 | :cljr Object
|
267 |
| - :cljs default) |
| 277 | + :cljs default |
| 278 | + :lpy python/object) |
268 | 279 | cson/ToJson
|
269 |
| - (-to-json [value buffer] |
| 280 | + (to-json* [value buffer] |
270 | 281 | (to-object buffer value :object nil)))
|
271 | 282 |
|
272 | 283 | (defn- has? [m k]
|
273 | 284 | (try
|
274 | 285 | (k m)
|
275 |
| - (catch #?(:clj Exception :cljr Exception :cljs :default) _e))) |
| 286 | + (catch #?(:clj Exception :cljr Exception :lpy Exception :cljs :default) _e nil))) |
276 | 287 |
|
277 | 288 | (defn- no-cache [value]
|
278 | 289 | (or (not (coll? value))
|
|
341 | 352 |
|
342 | 353 | #_{:clj-kondo/ignore [:unused-private-var]}
|
343 | 354 | (defn- runtime []
|
344 |
| - #?(:portal :portal :bb :bb :clj :clj :joyride :joyride :org.babashka/nbb :nbb :cljs :cljs :cljr :cljr)) |
| 355 | + #?(:portal :portal :bb :bb :clj :clj :joyride :joyride :org.babashka/nbb :nbb :cljs :cljs :cljr :cljr :lpy :py)) |
345 | 356 |
|
346 | 357 | (defn- error->data [e]
|
347 | 358 | #?(:clj (assoc (Throwable->map e) :runtime (runtime))
|
348 | 359 | :cljr (assoc (Throwable->map e) :runtime (runtime))
|
349 |
| - :cljs e)) |
| 360 | + :default e)) |
350 | 361 |
|
351 | 362 | (defn update-value [new-value]
|
352 | 363 | (try
|
353 | 364 | (realize-value! new-value)
|
354 | 365 | (swap! tap-list conj new-value)
|
355 |
| - (catch #?(:clj Exception :cljr Exception :cljs :default) e |
| 366 | + (catch #?(:clj Exception :cljr Exception :lpy Exception :cljs :default) e |
356 | 367 | (swap! tap-list conj
|
357 | 368 | (error->data
|
358 |
| - (ex-info "Failed to receive value." {:value-type (type new-value)} e)))))) |
| 369 | + #?(:lpy |
| 370 | + (ex-info "Failed to receive value." {:value-type (type new-value)}) |
| 371 | + :default |
| 372 | + (ex-info "Failed to receive value." {:value-type (type new-value)} e))))))) |
359 | 373 |
|
360 | 374 | (def ^:private runtime-keymap (atom ^::no-cache {}))
|
361 | 375 |
|
|
372 | 386 | #?(:bb "bb"
|
373 | 387 | :clj "jvm"
|
374 | 388 | :cljr "clr"
|
| 389 | + :lpy "py" |
375 | 390 | :joyride "joyride"
|
376 | 391 | :org.babashka/nbb "nbb"
|
377 | 392 | :cljs (cond
|
|
431 | 446 | (cond-> out
|
432 | 447 | (predicate v)
|
433 | 448 | (assoc name result))
|
434 |
| - (catch #?(:clj Exception :cljr Exception :cljs :default) _ex out)) |
| 449 | + (catch #?(:cljs :default :default Exception) _ex out)) |
435 | 450 | (assoc out name result)))))
|
436 | 451 | {}
|
437 | 452 | @registry)
|
|
453 | 468 | (a/try
|
454 | 469 | (a/let [return (binding [*session* session] (apply f args))]
|
455 | 470 | (done (assoc (source-info f) :return return)))
|
456 |
| - (catch #?(:clj Exception :cljr Exception :cljs js/Error) e |
| 471 | + (catch #?(:clj Exception :cljr Exception :cljs js/Error :default Exception) e |
457 | 472 | (done (assoc
|
458 | 473 | (source-info f)
|
459 | 474 | :error
|
|
462 | 477 | {::function f
|
463 | 478 | ::args args
|
464 | 479 | ::found? (some? f)
|
465 |
| - ::data (ex-data e)} |
466 |
| - e) |
| 480 | + ::data (ex-data e)}) |
467 | 481 | datafy
|
468 | 482 | (assoc :runtime (runtime)))))))))
|
469 | 483 |
|
|
0 commit comments