<commit_before>(ns shadow.cljs.live-reload
  (:require [cljs.reader :as reader]
            [goog.net.jsloader :as loader]))


(defonce scripts-to-load (atom []))

(def debug)

(defn debug
  ([a1]
    (when (aget js/window "console" "debug")
      (.debug js/console a1)))
  ([a1 a2]
    (when (aget js/window "console" "debug")
      (.debug js/console a1 a2)))
  ([a1 a2 a3]
    (when (aget js/window "console" "debug")
      (.debug js/console a1 a2 a3)))
  )

(defn handle-changes [{:keys [public-path before-load after-load] :as config} {:keys [js] :as changes}]
  (let [js-to-reload (->> js
                          ;; only reload things we actually require'd somewhere
                          (filter (fn [{:keys [provides]}]
                                    (some #(js/goog.isProvided_ (str %)) provides)))
                          (into []))]

    (when (seq js-to-reload)
      (when before-load
        (let [fn (js/goog.getObjectByName before-load)]
          (debug "Executing :before-load" before-load)
          (fn)
          ))

      (doseq [{:keys [name provides]} js-to-reload]
        (debug "LOAD JS: " name (->> provides (map str) (into-array))))

      (swap! scripts-to-load into (->> js-to-reload
                                       (map :js-name)
                                       (map #(str public-path "/src/" % "?r=" (rand)))
                                       ))

      (let [after-load-fn (fn []
                            (when after-load
                              (let [fn (js/goog.getObjectByName after-load)]
                                (debug "Executing :after-load " after-load)
                                (fn))))
<commit_msg>work arround REPL bootstrap replacing goog.isProvided_<commit_after>(ns shadow.cljs.live-reload
  (:require [cljs.reader :as reader]
            [goog.net.jsloader :as loader]))


(defonce scripts-to-load (atom []))

(def debug)

(defn debug
  ([a1]
    (when (aget js/window "console" "debug")
      (.debug js/console a1)))
  ([a1 a2]
    (when (aget js/window "console" "debug")
      (.debug js/console a1 a2)))
  ([a1 a2 a3]
    (when (aget js/window "console" "debug")
      (.debug js/console a1 a2 a3)))
  )

(def loaded? js/goog.isProvided_)

(defn handle-changes [{:keys [public-path before-load after-load] :as config} {:keys [js] :as changes}]
  (let [js-to-reload (->> js
                          ;; only reload things we actually require'd somewhere
                          (filter (fn [{:keys [provides]}]
                                    (some #(loaded? (str %)) provides)))
                          (into []))]

    (when (seq js-to-reload)
      (when before-load
        (let [fn (js/goog.getObjectByName before-load)]
          (debug "Executing :before-load" before-load)
          (fn)
          ))

      (doseq [{:keys [name provides]} js-to-reload]
        (debug "LOAD JS: " name (->> provides (map str) (into-array))))

      (swap! scripts-to-load into (->> js-to-reload
                                       (map :js-name)
                                       (map #(str public-path "/src/" % "?r=" (rand)))
                                       ))

      (let [after-load-fn (fn []
                            (when after-load
                              (let [fn (js/goog.getObjectByName after-load)]
                                (debug "Executing :after-load " after-load)
                                (fn))))

{'fraction_non_alphanumeric': 0.14835164835164835, 'fraction_numerical': 0.006940427993059572, 'mean_word_length': 1.4795698924731182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3208435', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1036, 'n_words': 274}