Explorar el Código

Upgrade cljs + shadow

- Upgraded shadow to keep goog compiler versions the same
- Converted some safe-parse-int's to parse-long
- Converted some safe-parse-float's to parse-double
- Simplified impl of safe-parse-* fns
Gabriel Horner hace 3 años
padre
commit
fec0b755a8

+ 4 - 1
.clj-kondo/config.edn

@@ -2,7 +2,10 @@
  {:unresolved-symbol {:exclude [goog.DEBUG
                                 goog.string.unescapeEntities
                                 ;; TODO:lint: Fix when fixing all type hints
-                                object]}
+                                object
+                                ;; TODO: Remove parse-* when https://github.com/clj-kondo/clj-kondo/issues/1694 is done
+                                parse-long
+                                parse-double]}
   ;; TODO:lint: Remove node-path excludes once we have a cleaner api
   :unresolved-var {:exclude [frontend.util/node-path.basename
                              frontend.util/node-path.dirname

+ 3 - 3
deps.edn

@@ -22,7 +22,7 @@
   hiccups/hiccups                       {:mvn/version "0.3.0"}
   tongue/tongue                         {:mvn/version "0.2.9"}
   org.clojure/core.async                {:mvn/version "1.3.610"}
-  thheller/shadow-cljs                  {:mvn/version "2.17.5"}
+  thheller/shadow-cljs                  {:mvn/version "2.19.0"}
   expound/expound                       {:mvn/version "0.8.6"}
   com.lambdaisland/glogi                {:mvn/version "1.1.144"}
   binaryage/devtools                    {:mvn/version "1.0.5"}
@@ -33,14 +33,14 @@
   org.clojars.mmb90/cljs-cache          {:mvn/version "0.1.4"}}
 
  :aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/" "src/electron/"]
-                  :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.10.891"}
+                  :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.11.54"}
                                 org.clojure/tools.namespace      {:mvn/version "0.2.11"}
                                 cider/cider-nrepl                {:mvn/version "0.26.0"}
                                 org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}}
                   :main-opts   ["-m" "shadow.cljs.devtools.cli"]}
 
            :test {:extra-paths ["src/test/"]
-                  :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.10.891"}
+                  :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.11.54"}
                                 org.clojure/test.check           {:mvn/version "1.1.1"}
                                 pjstadig/humane-test-output      {:mvn/version "0.11.0"}
                                 org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}}

+ 1 - 1
src/main/frontend/components/plugins.cljs

@@ -733,7 +733,7 @@
         updates (state/all-available-coming-updates)]
 
     [:div.cp__plugins-waiting-updates
-     [:h1.mb-4.text-2xl.p-1 (util/format "Found %s updates" (util/safe-parse-int (count updates)))]
+     [:h1.mb-4.text-2xl.p-1 (util/format "Found %s updates" (count updates))]
 
      (if (seq updates)
        ;; lists

+ 2 - 2
src/main/frontend/db/query_dsl.cljs

@@ -67,7 +67,7 @@
           (date/journal-title->int input)))
 
       :else
-      (let [duration (util/parse-int (subs input 0 (dec (count input))))
+      (let [duration (parse-long (subs input 0 (dec (count input))))
             kind (last input)
             tf (case kind
                  "y" t/years
@@ -99,7 +99,7 @@
           (date/journal-title->long input)))
 
       :else
-      (let [duration (util/parse-int (subs input 0 (dec (count input))))
+      (let [duration (parse-long (subs input 0 (dec (count input))))
             kind (last input)
             tf (case kind
                  "y" t/years

+ 2 - 2
src/main/frontend/db/query_react.cljs

@@ -33,12 +33,12 @@
     (and (keyword? input)
          (util/safe-re-find #"^\d+d(-before)?$" (name input)))
     (let [input (name input)
-          days (util/parse-int (subs input 0 (dec (count input))))]
+          days (parse-long (subs input 0 (dec (count input))))]
       (date->int (t/minus (t/today) (t/days days))))
     (and (keyword? input)
          (util/safe-re-find #"^\d+d(-after)?$" (name input)))
     (let [input (name input)
-          days (util/parse-int (subs input 0 (dec (count input))))]
+          days (parse-long (subs input 0 (dec (count input))))]
       (date->int (t/plus (t/today) (t/days days))))
 
     (and (string? input) (text/page-ref? input))

+ 1 - 2
src/main/frontend/db/utils.cljs

@@ -4,7 +4,6 @@
             [frontend.state :as state]
             [clojure.string :as string]
             [datascript.transit :as dt]
-            [frontend.util :as util]
             [frontend.date :as date]
             [frontend.db.conn :as conn]
             [frontend.config :as config]
@@ -46,7 +45,7 @@
 
 (defn date->int
   [date]
-  (util/parse-int
+  (parse-long
    (string/replace (date/ymd date) "/" "")))
 
 (defn entity

+ 2 - 2
src/main/frontend/extensions/video/youtube.cljs

@@ -123,9 +123,9 @@ Remember: You can paste a raw YouTube url as embedded video on mobile."
         reg-number #"^\d+$"
         timestamp (str timestamp)
         total-seconds (-> (re-matches reg-number timestamp)
-                          util/safe-parse-int)
+                          parse-long)
         [_ hours minutes seconds] (re-matches reg timestamp)
-        [hours minutes seconds] (map util/safe-parse-int [hours minutes seconds])]
+        [hours minutes seconds] (map parse-long [hours minutes seconds])]
     (cond
       total-seconds
       total-seconds

+ 8 - 26
src/main/frontend/util.cljc

@@ -217,39 +217,21 @@
     (str "0" n)
     (str n)))
 
-(defn parse-int
-  [x]
-  #?(:cljs (if (string? x)
-             (js/parseInt x)
-             x)
-     :clj (if (string? x)
-            (Integer/parseInt x)
-            x)))
-
-(defn safe-parse-int
-  [x]
-  #?(:cljs (let [result (parse-int x)]
-             (if (js/isNaN result)
-               nil
-               result))
-     :clj ((try
-             (parse-int x)
-             (catch Exception _
-               nil)))))
-#?(:cljs
-   (defn parse-float
+#?(:cljs
+   (defn safe-parse-int
+     "Use if arg could be an int or string. If arg is only a string, use `parse-long`."
      [x]
      (if (string? x)
-       (js/parseFloat x)
+       (parse-long x)
        x)))
 
 #?(:cljs
    (defn safe-parse-float
+     "Use if arg could be a float or string. If arg is only a string, use `parse-double`"
      [x]
-     (let [result (parse-float x)]
-       (if (js/isNaN result)
-         nil
-         result))))
+     (if (string? x)
+       (parse-double x)
+       x)))
 
 #?(:cljs
    (defn debounce

+ 2 - 3
src/main/frontend/util/list.cljs

@@ -1,8 +1,7 @@
 (ns frontend.util.list
   (:require [frontend.util.thingatpt :as thingatpt]
             [frontend.util.cursor :as cursor]
-            [clojure.string :as string]
-            [frontend.util :as util]))
+            [clojure.string :as string]))
 
 (defn get-prev-item [& [input]]
   (when-not (cursor/textarea-cursor-first-row? input)
@@ -56,7 +55,7 @@
              (map (fn [line] (if (newline? line) "" line)))
              (string/join "\n"))
         (let [[_ num-str] (re-find #"^(\d+){1}\." line)
-              num (if num-str (util/safe-parse-int num-str) nil)
+              num (if num-str (parse-long num-str) nil)
               double-newlines?' (or double-newlines?
                                      (and (newline? line) (seq others) (newline? (first others))))
               [idx' result'] (if (and (not double-newlines?') num)

+ 1 - 1
src/main/logseq/graph_parser/date_time_util.cljs

@@ -37,7 +37,7 @@
   (when journal-title
     (let [journal-title (gp-util/capitalize-all journal-title)]
       (journal-title-> journal-title
-                       #(gp-util/parse-int (tf/unparse (tf/formatter "yyyyMMdd") %))
+                       #(parse-long (tf/unparse (tf/formatter "yyyyMMdd") %))
                        formatters))))
 
 (defn format

+ 1 - 1
src/main/logseq/graph_parser/text.cljs

@@ -350,7 +350,7 @@
        false
 
        (and (not= k "alias") (gp-util/safe-re-find #"^\d+$" v))
-       (gp-util/safe-parse-int v)
+       (parse-long v)
 
        (gp-util/wrapped-by-quotes? v) ; wrapped in ""
        v

+ 0 - 15
src/main/logseq/graph_parser/util.cljs

@@ -67,21 +67,6 @@
   [v]
   (and (string? v) (>= (count v) 2) (= "\"" (first v) (last v))))
 
-(defn parse-int
-  "Copy of frontend.util/parse-int. Too basic to couple to main app"
-  [x]
-  (if (string? x)
-    (js/parseInt x)
-    x))
-
-(defn safe-parse-int
-  "Copy of frontend.util/safe-parse-int. Too basic to couple to main app"
-  [x]
-  (let [result (parse-int x)]
-    (if (js/isNaN result)
-      nil
-      result)))
-
 (defn url?
   [s]
   (and (string? s)