1
0
Эх сурвалжийг харах

Move gp-util and gp-config to the common dep

Tienson Qin 1 жил өмнө
parent
commit
b7d9098e80
88 өөрчлөгдсөн 463 нэмэгдсэн , 472 устгасан
  1. 85 3
      deps/common/src/logseq/common/config.cljs
  2. 1 1
      deps/common/src/logseq/common/log.cljs
  3. 4 4
      deps/common/src/logseq/common/util.cljs
  4. 5 5
      deps/common/test/logseq/common/util_test.cljs
  5. 1 2
      deps/db/deps.edn
  6. 3 1
      deps/db/nbb.edn
  7. 9 9
      deps/db/src/logseq/db.cljs
  8. 3 3
      deps/db/src/logseq/db/frontend/property.cljs
  9. 1 1
      deps/db/src/logseq/db/frontend/property/type.cljs
  10. 1 1
      deps/db/src/logseq/db/frontend/property/util.cljs
  11. 7 2
      deps/db/src/logseq/db/sqlite/util.cljs
  12. 3 3
      deps/db/test/logseq/db/sqlite/db_test.cljs
  13. 10 10
      deps/graph-parser/src/logseq/graph_parser.cljs
  14. 15 15
      deps/graph-parser/src/logseq/graph_parser/block.cljs
  15. 5 5
      deps/graph-parser/src/logseq/graph_parser/cli.cljs
  16. 0 85
      deps/graph-parser/src/logseq/graph_parser/config.cljs
  17. 5 5
      deps/graph-parser/src/logseq/graph_parser/date_time_util.cljs
  18. 25 25
      deps/graph-parser/src/logseq/graph_parser/extract.cljc
  19. 10 10
      deps/graph-parser/src/logseq/graph_parser/mldoc.cljc
  20. 4 4
      deps/graph-parser/src/logseq/graph_parser/property.cljs
  21. 3 3
      deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs
  22. 3 3
      deps/graph-parser/src/logseq/graph_parser/text.cljs
  23. 4 4
      deps/graph-parser/src/logseq/graph_parser/whiteboard.cljs
  24. 1 1
      deps/graph-parser/test/logseq/graph_parser/cli_test.cljs
  25. 3 5
      deps/graph-parser/test/logseq/graph_parser/util/file_name_test.cljs
  26. 2 2
      src/main/electron/listener.cljs
  27. 6 6
      src/main/frontend/commands.cljs
  28. 21 21
      src/main/frontend/components/block.cljs
  29. 3 3
      src/main/frontend/components/cmdk.cljs
  30. 2 2
      src/main/frontend/components/content.cljs
  31. 3 3
      src/main/frontend/components/conversion.cljs
  32. 8 8
      src/main/frontend/components/editor.cljs
  33. 9 9
      src/main/frontend/components/file.cljs
  34. 2 2
      src/main/frontend/components/file_sync.cljs
  35. 3 3
      src/main/frontend/components/page.cljs
  36. 2 2
      src/main/frontend/components/query/builder.cljs
  37. 3 3
      src/main/frontend/components/query/result.cljs
  38. 6 6
      src/main/frontend/config.cljs
  39. 2 2
      src/main/frontend/db/conn.cljs
  40. 3 3
      src/main/frontend/db/model.cljs
  41. 2 2
      src/main/frontend/db/query_dsl.cljs
  42. 2 2
      src/main/frontend/db/utils.cljs
  43. 2 2
      src/main/frontend/diff.cljs
  44. 7 7
      src/main/frontend/extensions/pdf/assets.cljs
  45. 2 2
      src/main/frontend/external/roam.cljs
  46. 2 2
      src/main/frontend/format.cljs
  47. 2 2
      src/main/frontend/format/mldoc.cljs
  48. 4 4
      src/main/frontend/fs.cljs
  49. 4 4
      src/main/frontend/fs/nfs.cljs
  50. 4 4
      src/main/frontend/fs/sync.cljs
  51. 3 3
      src/main/frontend/fs/watcher_handler.cljs
  52. 7 7
      src/main/frontend/handler/assets.cljs
  53. 8 8
      src/main/frontend/handler/common/file.cljs
  54. 5 5
      src/main/frontend/handler/common/page.cljs
  55. 6 6
      src/main/frontend/handler/conversion.cljs
  56. 9 9
      src/main/frontend/handler/db_based/property.cljs
  57. 3 3
      src/main/frontend/handler/db_based/property/util.cljs
  58. 3 3
      src/main/frontend/handler/draw.cljs
  59. 3 3
      src/main/frontend/handler/editor.cljs
  60. 2 2
      src/main/frontend/handler/events.cljs
  61. 2 2
      src/main/frontend/handler/export/common.cljs
  62. 8 8
      src/main/frontend/handler/file.cljs
  63. 3 3
      src/main/frontend/handler/file_based/property.cljs
  64. 5 5
      src/main/frontend/handler/graph.cljs
  65. 2 2
      src/main/frontend/handler/import.cljs
  66. 8 8
      src/main/frontend/handler/page.cljs
  67. 7 7
      src/main/frontend/handler/paste.cljs
  68. 2 2
      src/main/frontend/handler/property/util.cljs
  69. 2 2
      src/main/frontend/handler/repo.cljs
  70. 2 2
      src/main/frontend/handler/shell.cljs
  71. 4 4
      src/main/frontend/handler/web/nfs.cljs
  72. 2 2
      src/main/frontend/handler/whiteboard.cljs
  73. 2 2
      src/main/frontend/mobile/deeplink.cljs
  74. 6 6
      src/main/frontend/mobile/intent.cljs
  75. 2 2
      src/main/frontend/modules/outliner/core.cljs
  76. 2 2
      src/main/frontend/modules/outliner/datascript.cljs
  77. 2 2
      src/main/frontend/search.cljs
  78. 2 2
      src/main/frontend/state.cljs
  79. 5 5
      src/main/frontend/util.cljc
  80. 2 2
      src/main/frontend/util/fs.cljs
  81. 2 2
      src/main/frontend/worker/date.cljs
  82. 3 2
      src/main/frontend/worker/file.cljs
  83. 3 3
      src/main/frontend/worker/file/property_util.cljs
  84. 4 4
      src/main/frontend/worker/file/util.cljs
  85. 4 3
      src/main/frontend/worker/search.cljs
  86. 5 17
      src/main/frontend/worker/util.cljs
  87. 2 2
      src/test/frontend/db/name_sanity_test.cljs
  88. 4 4
      src/test/frontend/handler/repo_conversion_test.cljs

+ 85 - 3
deps/common/src/logseq/common/config.cljs

@@ -1,6 +1,7 @@
 (ns logseq.common.config
-  "This ns provides common fns related to user config"
-  (:require [clojure.string :as string]))
+  "App config that is shared between the app"
+  (:require [clojure.string :as string]
+            [goog.object :as gobj]))
 
 (defn- hidden?
   [path patterns]
@@ -22,4 +23,85 @@
     (remove (fn [file]
               (let [path (get-path-fn file)]
                 (hidden? path patterns))) files)
-    files))
+    files))
+
+(def app-name
+  "Copy of frontend.config/app-name. Too small to couple to main app"
+  "logseq")
+
+(defonce asset-protocol "assets://")
+(defonce capacitor-protocol "capacitor://")
+(defonce capacitor-prefix "_capacitor_file_")
+(defonce capacitor-protocol-with-prefix (str capacitor-protocol "localhost/" capacitor-prefix))
+(defonce capacitor-x-protocol-with-prefix (str (gobj/getValueByKeys js/globalThis "location" "href") capacitor-prefix))
+
+(defonce local-assets-dir "assets")
+
+(defn local-asset?
+  [s]
+  (and (string? s)
+       (re-find (re-pattern (str "^[./]*" local-assets-dir)) s)))
+
+(defn local-protocol-asset?
+  [s]
+  (when (string? s)
+    (or (string/starts-with? s asset-protocol)
+        (string/starts-with? s capacitor-protocol)
+        (string/starts-with? s capacitor-x-protocol-with-prefix))))
+
+(defn remove-asset-protocol
+  [s]
+  (if (local-protocol-asset? s)
+    (-> s
+        (string/replace-first asset-protocol "file://")
+        (string/replace-first capacitor-protocol-with-prefix "file://")
+        (string/replace-first capacitor-x-protocol-with-prefix "file://"))
+    s))
+
+(defonce default-draw-directory "draws")
+;; TODO read configurable value?
+(defonce default-whiteboards-directory "whiteboards")
+
+(defn draw?
+  [path]
+  (string/starts-with? path default-draw-directory))
+
+(defn whiteboard?
+  [path]
+  (and path
+       (string/includes? path (str default-whiteboards-directory "/"))
+       (string/ends-with? path ".edn")))
+
+;; TODO: rename
+(defonce mldoc-support-formats
+  #{:org :markdown :md})
+
+(defn mldoc-support?
+  [format]
+  (contains? mldoc-support-formats (keyword format)))
+
+(defn text-formats
+  []
+  #{:json :org :md :yml :dat :asciidoc :rst :txt :markdown :adoc :html :js :ts :edn :clj :ml :rb :ex :erl :java :php :c :css
+    :excalidraw :tldr :sh})
+
+(defn img-formats
+  []
+  #{:gif :svg :jpeg :ico :png :jpg :bmp :webp})
+
+(defn get-date-formatter
+  [config]
+  (or
+   (:journal/page-title-format config)
+   ;; for compatibility
+   (:date-formatter config)
+   "MMM do, yyyy"))
+
+(defn get-block-pattern
+  [format]
+  (let [format' (keyword format)]
+    (case format'
+      :org
+      "*"
+
+      "-")))

+ 1 - 1
deps/graph-parser/src/logseq/graph_parser/log.cljs → deps/common/src/logseq/common/log.cljs

@@ -1,4 +1,4 @@
-(ns logseq.graph-parser.log
+(ns logseq.common.log
   "Minimal, logging ns that shims lambdaisland.glogi fns for nbb. Could port
   glogi to nbb later if this shim gets too big")
 

+ 4 - 4
deps/graph-parser/src/logseq/graph_parser/util.cljs → deps/common/src/logseq/common/util.cljs

@@ -1,11 +1,11 @@
-(ns logseq.graph-parser.util
-  "Util fns shared between graph-parser and rest of app. Util fns only rely on
+(ns logseq.common.util
+  "Util fns shared between the app. Util fns only rely on
   clojure standard libraries."
   (:require [cljs.reader :as reader]
             [clojure.edn :as edn]
             [clojure.string :as string]
             [clojure.walk :as walk]
-            [logseq.graph-parser.log :as log]))
+            [logseq.common.log :as log]))
 
 (defn safe-decode-uri-component
   [uri]
@@ -249,7 +249,7 @@
     (or (safe-decode-uri-component title) title)))
 
 ;; Register sanitization / parsing fns in:
-;; logseq.graph-parser.util (parsing only)
+;; logseq.common.util (parsing only)
 ;; frontend.util.fs         (sanitization only)
 ;; frontend.handler.conversion (both)
 (defn title-parsing

+ 5 - 5
deps/graph-parser/test/logseq/graph_parser/util_test.cljs → deps/common/test/logseq/common/util_test.cljs

@@ -1,10 +1,10 @@
-(ns logseq.graph-parser.util-test
+(ns logseq.common.util-test
   (:require [clojure.test :refer [deftest are]]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 (deftest valid-edn-keyword?
   (are [x y]
-       (= (gp-util/valid-edn-keyword? x) y)
+       (= (common-util/valid-edn-keyword? x) y)
 
        ":foo-bar"  true
        ":foo!"     true
@@ -15,7 +15,7 @@
 
 (deftest extract-file-extension?
   (are [x y]
-       (= (gp-util/path->file-ext x) y)
+       (= (common-util/path->file-ext x) y)
        "foo.bar" "bar"
        "foo"     nil
        "foo.bar.baz" "baz"
@@ -31,7 +31,7 @@
 
 (deftest url?
   (are [x y]
-       (= (gp-util/url? x) y)
+       (= (common-util/url? x) y)
        "http://logseq.com" true
        "prop:: value" false
        "a:" false))

+ 1 - 2
deps/db/deps.edn

@@ -3,8 +3,7 @@
  {datascript/datascript {:git/url "https://github.com/logseq/datascript" ;; fork
                          :sha     "21fc7880c7042fb1d9086135d162ea7a91681f89"}
   com.cognitect/transit-cljs   {:mvn/version "0.8.280"}
-  cljs-bean/cljs-bean          {:mvn/version "1.5.0"}
-  logseq/graph-parser          {:local/root "../../deps/graph-parser"}}
+  logseq/common                {:local/root "../common"}}
 
  :aliases
  {:clj-kondo

+ 3 - 1
deps/db/nbb.edn

@@ -1,6 +1,8 @@
 {:paths ["src"]
  :deps
- {metosin/malli
+ {logseq/common
+  {:local/root "../common"}
+  metosin/malli
   {:mvn/version "0.10.0"}
   io.github.nextjournal/nbb-test-runner
   {:git/sha "60ed57aa04bca8d604f5ba6b28848bd887109347"}}}

+ 9 - 9
deps/db/src/logseq/db.cljs

@@ -9,8 +9,8 @@
             [logseq.db.frontend.property.util :as db-property-util]
             [logseq.db.sqlite.util :as sqlite-util]
             [clojure.string :as string]
-            [logseq.graph-parser.util :as gp-util]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.util :as common-util]
+            [logseq.common.config :as common-config]
             [logseq.db.frontend.content :as db-content]
             [clojure.set :as set]))
 
@@ -99,7 +99,7 @@
   ([blocks parent]
    (sort-by-left blocks parent {:check? true}))
   ([blocks parent {:keys [_check?]}]
-   (let [blocks (gp-util/distinct-by :db/id blocks)
+   (let [blocks (common-util/distinct-by :db/id blocks)
          left->blocks (reduce (fn [acc b] (assoc acc (:db/id (:block/left b)) b)) {} blocks)]
      (loop [block parent
             result []]
@@ -141,12 +141,12 @@
   [db page]
   (cond
     (string? page)
-    (let [page (d/entity db [:block/name (gp-util/page-name-sanity-lc page)])]
+    (let [page (d/entity db [:block/name (common-util/page-name-sanity-lc page)])]
       (or
        (contains? (set (:block/type page)) "whiteboard")
        (when-let [file (:block/file page)]
          (when-let [path (:file/path (d/entity db (:db/id file)))]
-           (gp-config/whiteboard? path)))))
+           (common-config/whiteboard? path)))))
 
     (seq page)
     (contains? (set (:block/type page)) "whiteboard")
@@ -159,7 +159,7 @@
   [db page {:keys [pull-keys]
             :or {pull-keys '[*]}}]
   (when page
-    (let [page (gp-util/page-name-sanity-lc page)
+    (let [page (common-util/page-name-sanity-lc page)
           page-id (:db/id (d/entity db [:block/name page]))]
       (when page-id
         (let [datoms (d/datoms db :avet :block/page page-id)
@@ -200,7 +200,7 @@
   (when page
     (if (string? page)
       (and (string/starts-with? page "$$$")
-           (gp-util/uuid-string? (gp-util/safe-subs page 3)))
+           (common-util/uuid-string? (common-util/safe-subs page 3)))
       (contains? (set (:block/type page)) "hidden"))))
 
 (defn get-pages
@@ -219,7 +219,7 @@
   `page-id` could be either a string or a db/id."
   [db page-id]
   (let [page-id (if (string? page-id)
-                  [:block/name (gp-util/page-name-sanity-lc page-id)]
+                  [:block/name (common-util/page-name-sanity-lc page-id)]
                   page-id)
         page (d/entity db page-id)]
     (nil? (:block/_left page))))
@@ -233,7 +233,7 @@
         orphaned-pages (->>
                         (map
                          (fn [page]
-                           (let [name (gp-util/page-name-sanity-lc page)]
+                           (let [name (common-util/page-name-sanity-lc page)]
                              (when-let [page (d/entity db [:block/name name])]
                                (and
                                 (empty-ref-f page)

+ 3 - 3
deps/db/src/logseq/db/frontend/property.cljs

@@ -3,7 +3,7 @@
   (:require [clojure.set :as set]
             [logseq.db.sqlite.util :as sqlite-util]
             [datascript.core :as d]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 ;; FIXME: no support for built-in-extended-properties
 (def ^:large-vars/data-var built-in-properties
@@ -113,7 +113,7 @@
                           (name key)
                           key)]
       (if (sqlite-util/db-based-graph? repo)
-        (when-let [property (d/entity db [:block/name (gp-util/page-name-sanity-lc property-name)])]
+        (when-let [property (d/entity db [:block/name (common-util/page-name-sanity-lc property-name)])]
           (get coll (:block/uuid property)))
         (get coll key)))))
 
@@ -129,7 +129,7 @@
   "Get a property's id (name or uuid) given its name. For file and db graphs"
   [repo db property-name]
   (if (sqlite-util/db-based-graph? repo)
-    (:block/uuid (d/entity db [:block/name (gp-util/page-name-sanity-lc (name property-name))]))
+    (:block/uuid (d/entity db [:block/name (common-util/page-name-sanity-lc (name property-name))]))
     property-name))
 
 (defn shape-block?

+ 1 - 1
deps/db/src/logseq/db/frontend/property/type.cljs

@@ -49,7 +49,7 @@
 
 (defn url?
   "Test if it is a `protocol://`-style URL.
-   Originally from gp-util/url? but does not need to be the same"
+   Originally from common-util/url? but does not need to be the same"
   [s]
   (and (string? s)
        (try

+ 1 - 1
deps/db/src/logseq/db/frontend/property/util.cljs

@@ -48,7 +48,7 @@
 
 (defn new-property-tx
   "Provide attributes for a new built-in property given name, schema and uuid.
-   TODO: Merge this with sqlite-util/build-new-property once gp-util/page-name-sanity-lc
+   TODO: Merge this with sqlite-util/build-new-property once common-util/page-name-sanity-lc
    is available to deps/db"
   [prop-name prop-schema prop-uuid]
   {:block/uuid prop-uuid

+ 7 - 2
deps/db/src/logseq/db/sqlite/util.cljs

@@ -4,7 +4,7 @@
             [cljs-time.core :as t]
             [clojure.string :as string]
             [logseq.db.frontend.schema :as db-schema]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 (defonce db-version-prefix "logseq_db_")
 (defonce file-version-prefix "logseq_local_")
@@ -13,6 +13,11 @@
   [graph-name]
   (string/starts-with? graph-name db-version-prefix))
 
+(defn local-file-based-graph?
+  [s]
+  (and (string? s)
+       (string/starts-with? s file-version-prefix)))
+
 (defn get-schema
   "Returns schema for given repo"
   [repo]
@@ -35,7 +40,7 @@
                 (assoc :block/created-at updated-at))]
     block))
 
-(def sanitize-page-name gp-util/page-name-sanity-lc)
+(def sanitize-page-name common-util/page-name-sanity-lc)
 
 (defn build-new-property
   "Build a standard new property so that it is is consistent across contexts"

+ 3 - 3
deps/db/test/logseq/db/sqlite/db_test.cljs

@@ -24,7 +24,7 @@
 (deftest get-initial-data
   (testing "Fetches a defined block"
     (create-graph-dir "tmp/graphs" "test-db")
-    
+
     (let [conn* (sqlite-db/open-db! "tmp/graphs" "test-db")
           blocks [{:block/uuid (random-uuid)
                    :file/path "logseq/config.edn"
@@ -55,7 +55,7 @@
                   {:db/id 100002
                    :block/content "test"
                    :block/uuid block-uuid
-                   :block/page {:db/id 100001}
+                   :block/page 100001
                    :block/created-at created-at
                    :block/updated-at created-at}]
           _ (d/transact! conn* blocks)
@@ -67,4 +67,4 @@
                          :where [?b :block/created-at]]
                        @conn)
                   (map first)))
-          "Datascript db matches data inserted into sqlite"))))
+          "Datascript db matches data inserted into sqlite"))))

+ 10 - 10
deps/graph-parser/src/logseq/graph_parser.cljs

@@ -3,9 +3,9 @@
   the given database connection"
   (:require [datascript.core :as d]
             [logseq.graph-parser.extract :as extract]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.date-time-util :as date-time-util]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [logseq.db.frontend.schema :as db-schema]
             [clojure.string :as string]
             [clojure.set :as set]))
@@ -36,7 +36,7 @@
   "Copy of db/get-page-blocks-no-cache. Too basic to couple to main app"
   [db page {:keys [pull-keys]
             :or {pull-keys '[*]}}]
-  (let [sanitized-page (gp-util/page-name-sanity-lc page)
+  (let [sanitized-page (common-util/page-name-sanity-lc page)
         page-id (:db/id (d/entity db [:block/name sanitized-page]))]
     (when page-id
       (let [datoms (d/datoms db :avet :block/page page-id)
@@ -84,10 +84,10 @@ Options available:
                             delete-blocks-fn (constantly [])
                             skip-db-transact? false}
                        :as options}]
-   (let [format (gp-util/get-format file)
+   (let [format (common-util/get-format file)
          file-content [{:file/path file}]
          {:keys [tx ast]}
-         (let [extract-options' (merge {:block-pattern (gp-config/get-block-pattern format)
+         (let [extract-options' (merge {:block-pattern (common-config/get-block-pattern format)
                                         :date-formatter "MMM do, yyyy"
                                         :uri-encoded? false
                                         :filename-format :legacy}
@@ -97,10 +97,10 @@ Options available:
                 :or   {pages []
                        blocks []
                        ast []}}
-               (cond (contains? gp-config/mldoc-support-formats format)
+               (cond (contains? common-config/mldoc-support-formats format)
                  (extract/extract file content extract-options')
 
-                 (gp-config/whiteboard? file)
+                 (common-config/whiteboard? file)
                  (extract/extract-whiteboard-edn file content extract-options')
 
                  :else nil)
@@ -123,7 +123,7 @@ Options available:
                                 new?
                                 ;; TODO: use file system timestamp?
                                 (assoc :file/created-at (date-time-util/time-ms)))])
-         tx' (gp-util/fast-remove-nils tx)
+         tx' (common-util/fast-remove-nils tx)
          result (if skip-db-transact?
                   tx'
                   (d/transact! conn tx' (select-keys options [:new-graph? :from-disk?])))]
@@ -136,8 +136,8 @@ Options available:
   [files]
   (let [support-files (filter
                        (fn [file]
-                         (let [format (gp-util/get-format (:file/path file))]
-                           (contains? (set/union #{:edn :css} gp-config/mldoc-support-formats) format)))
+                         (let [format (common-util/get-format (:file/path file))]
+                           (contains? (set/union #{:edn :css} common-config/mldoc-support-formats) format)))
                        files)
         support-files (sort-by :file/path support-files)
         {journals true non-journals false} (group-by (fn [file] (string/includes? (:file/path file) "journals/")) support-files)

+ 15 - 15
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -4,13 +4,13 @@
             [clojure.string :as string]
             [clojure.walk :as walk]
             [datascript.core :as d]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [logseq.graph-parser.date-time-util :as date-time-util]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.property :as gp-property]
             [logseq.graph-parser.text :as text]
             [logseq.graph-parser.utf8 :as utf8]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [logseq.graph-parser.util.page-ref :as page-ref]))
 
@@ -45,8 +45,8 @@
                   (and
                    (= url-type "Page_ref")
                    (and (string? value)
-                        (not (or (gp-config/local-asset? value)
-                                 (gp-config/draw? value))))
+                        (not (or (common-config/local-asset? value)
+                                 (common-config/draw? value))))
                    value)
 
                   (and
@@ -56,7 +56,7 @@
 
                   (and (= url-type "Search")
                        (= format :org)
-                       (not (gp-config/local-asset? value))
+                       (not (common-config/local-asset? value))
                        value)
 
                   (and
@@ -250,7 +250,7 @@
                    (map (fn [[k v]]
                           (let [{:keys [date repetition]} v
                                 {:keys [year month day]} date
-                                day (js/parseInt (str year (gp-util/zero-pad month) (gp-util/zero-pad day)))]
+                                day (js/parseInt (str year (common-util/zero-pad month) (common-util/zero-pad day)))]
                             (cond->
                              (case k
                                :scheduled
@@ -265,11 +265,11 @@
   "Convert journal file name to user' custom date format"
   [original-page-name date-formatter]
   (when original-page-name
-    (let [page-name (gp-util/page-name-sanity-lc original-page-name)
+    (let [page-name (common-util/page-name-sanity-lc original-page-name)
           day (date-time-util/journal-title->int page-name (date-time-util/safe-journal-title-formatters date-formatter))]
      (if day
        (let [original-page-name (date-time-util/int->journal-title day date-formatter)]
-         [original-page-name (gp-util/page-name-sanity-lc original-page-name) day])
+         [original-page-name (common-util/page-name-sanity-lc original-page-name) day])
        [original-page-name page-name day]))))
 
 (def convert-page-if-journal (memoize convert-page-if-journal-impl))
@@ -289,7 +289,7 @@
    & {:keys [from-page]}]
   (cond
     (and original-page-name (string? original-page-name))
-    (let [original-page-name (gp-util/remove-boundary-slashes original-page-name)
+    (let [original-page-name (common-util/remove-boundary-slashes original-page-name)
           [original-page-name page-name journal-day] (convert-page-if-journal original-page-name date-formatter)
           namespace? (and (not (boolean (text/get-nested-page-name original-page-name)))
                           (text/namespace-page? original-page-name))
@@ -305,9 +305,9 @@
                          (d/squuid))]
            {:block/uuid new-uuid}))
        (when namespace?
-         (let [namespace (first (gp-util/split-last "/" original-page-name))]
+         (let [namespace (first (common-util/split-last "/" original-page-name))]
            (when-not (string/blank? namespace)
-             {:block/namespace {:block/name (gp-util/page-name-sanity-lc namespace)}})))
+             {:block/namespace {:block/name (common-util/page-name-sanity-lc namespace)}})))
        (when (and with-timestamp? (not page-entity)) ;; Only assign timestamp on creating new entity
          (let [current-ms (date-time-util/time-ms)]
            {:block/created-at current-ms
@@ -343,7 +343,7 @@
            (swap! *refs conj page))
          (when-let [tag (get-tag form)]
            (let [tag (text/page-ref-un-brackets! tag)]
-             (when (gp-util/tag-valid? tag)
+             (when (common-util/tag-valid? tag)
                (swap! *refs conj tag)
                (swap! *structured-tags conj tag))))
          form))
@@ -358,7 +358,7 @@
                                                               (when (string? p)
                                                                 (let [p (or (text/get-nested-page-name p) p)]
                                                                   (when (text/namespace-page? p)
-                                                                    (gp-util/split-namespace-pages p))))))
+                                                                    (common-util/split-namespace-pages p))))))
                                                           col)
                                                   (remove string/blank?)
                                                   (distinct))
@@ -394,7 +394,7 @@
   [blocks]
   (map (fn [block]
          (if (map? block)
-           (block-keywordize (gp-util/remove-nils-non-nested block))
+           (block-keywordize (common-util/remove-nils-non-nested block))
            block))
        blocks))
 
@@ -476,7 +476,7 @@
                                 (remove string/blank?)
                                 (map (fn [ref]
                                        (if (string? ref)
-                                         {:block/name (gp-util/page-name-sanity-lc ref)}
+                                         {:block/name (common-util/page-name-sanity-lc ref)}
                                          ref)))
                                 (remove vector?)
                                 (remove nil?)

+ 5 - 5
deps/graph-parser/src/logseq/graph_parser/cli.cljs

@@ -6,8 +6,8 @@
             [logseq.common.graph :as common-graph]
             [logseq.common.config :as common-config]
             [logseq.graph-parser :as graph-parser]
-            [logseq.graph-parser.config :as gp-config]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.config :as common-config]
+            [logseq.common.util :as common-util]
             [logseq.db :as ldb]))
 
 (defn- slurp
@@ -37,14 +37,14 @@
 (defn- read-config
   "Reads repo-specific config from logseq/config.edn"
   [dir]
-  (let [config-file (str dir "/" gp-config/app-name "/config.edn")]
+  (let [config-file (str dir "/" common-config/app-name "/config.edn")]
     (if (fs/existsSync config-file)
       (-> config-file fs/readFileSync str edn/read-string)
       {})))
 
 (defn- parse-files
   [conn files {:keys [config] :as options}]
-  (let [extract-options (merge {:date-formatter (gp-config/get-date-formatter config)
+  (let [extract-options (merge {:date-formatter (common-config/get-date-formatter config)
                                 :user-config config
                                 :filename-format (or (:file/name-format config) :legacy)
                                 :extracted-block-ids (atom #{})}
@@ -55,7 +55,7 @@
              (let [parse-file-options
                    (merge {:extract-options
                            (assoc extract-options
-                                  :block-pattern (gp-config/get-block-pattern (gp-util/get-format path)))}
+                                  :block-pattern (common-config/get-block-pattern (common-util/get-format path)))}
                           (:parse-file-options options))]
                (graph-parser/parse-file conn path content parse-file-options))]
          {:file path :ast ast}))

+ 0 - 85
deps/graph-parser/src/logseq/graph_parser/config.cljs

@@ -1,85 +0,0 @@
-(ns logseq.graph-parser.config
-  "App config that is shared between graph-parser and rest of app"
-  (:require [clojure.string :as string]
-            [goog.object :as gobj]))
-
-(def app-name
-  "Copy of frontend.config/app-name. Too small to couple to main app"
-  "logseq")
-
-(defonce asset-protocol "assets://")
-(defonce capacitor-protocol "capacitor://")
-(defonce capacitor-prefix "_capacitor_file_")
-(defonce capacitor-protocol-with-prefix (str capacitor-protocol "localhost/" capacitor-prefix))
-(defonce capacitor-x-protocol-with-prefix (str (gobj/getValueByKeys js/globalThis "location" "href") capacitor-prefix))
-
-(defonce local-assets-dir "assets")
-
-(defn local-asset?
-  [s]
-  (and (string? s)
-       (re-find (re-pattern (str "^[./]*" local-assets-dir)) s)))
-
-(defn local-protocol-asset?
-  [s]
-  (when (string? s)
-    (or (string/starts-with? s asset-protocol)
-        (string/starts-with? s capacitor-protocol)
-        (string/starts-with? s capacitor-x-protocol-with-prefix))))
-
-(defn remove-asset-protocol
-  [s]
-  (if (local-protocol-asset? s)
-    (-> s
-        (string/replace-first asset-protocol "file://")
-        (string/replace-first capacitor-protocol-with-prefix "file://")
-        (string/replace-first capacitor-x-protocol-with-prefix "file://"))
-    s))
-
-(defonce default-draw-directory "draws")
-;; TODO read configurable value?
-(defonce default-whiteboards-directory "whiteboards")
-
-(defn draw?
-  [path]
-  (string/starts-with? path default-draw-directory))
-
-(defn whiteboard?
-  [path]
-  (and path
-       (string/includes? path (str default-whiteboards-directory "/"))
-       (string/ends-with? path ".edn")))
-
-;; TODO: rename
-(defonce mldoc-support-formats
-  #{:org :markdown :md})
-
-(defn mldoc-support?
-  [format]
-  (contains? mldoc-support-formats (keyword format)))
-
-(defn text-formats
-  []
-  #{:json :org :md :yml :dat :asciidoc :rst :txt :markdown :adoc :html :js :ts :edn :clj :ml :rb :ex :erl :java :php :c :css
-    :excalidraw :tldr :sh})
-
-(defn img-formats
-  []
-  #{:gif :svg :jpeg :ico :png :jpg :bmp :webp})
-
-(defn get-date-formatter
-  [config]
-  (or
-   (:journal/page-title-format config)
-   ;; for compatibility
-   (:date-formatter config)
-   "MMM do, yyyy"))
-
-(defn get-block-pattern
-  [format]
-  (let [format' (keyword format)]
-    (case format'
-      :org
-      "*"
-
-      "-")))

+ 5 - 5
deps/graph-parser/src/logseq/graph_parser/date_time_util.cljs

@@ -4,7 +4,7 @@
             [cljs-time.core :as t]
             [cljs-time.format :as tf]
             [clojure.string :as string]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 (defn time-ms
   "Copy of util/time-ms. Too basic to couple this to main app"
@@ -24,7 +24,7 @@
     (when-let [time (->> (map
                           (fn [formatter]
                             (try
-                              (tf/parse (tf/formatter formatter) (gp-util/capitalize-all journal-title))
+                              (tf/parse (tf/formatter formatter) (common-util/capitalize-all journal-title))
                               (catch :default _e
                                 nil)))
                           formatters)
@@ -35,7 +35,7 @@
 (defn journal-title->int
   [journal-title formatters]
   (when journal-title
-    (let [journal-title (gp-util/capitalize-all journal-title)]
+    (let [journal-title (common-util/capitalize-all journal-title)]
       (journal-title-> journal-title
                        #(parse-long (tf/unparse (tf/formatter "yyyyMMdd") %))
                        formatters))))
@@ -69,8 +69,8 @@
   ([date]
    (let [{:keys [year month day]} date]
      {:year year
-      :month (gp-util/zero-pad month)
-      :day (gp-util/zero-pad day)})))
+      :month (common-util/zero-pad month)
+      :day (common-util/zero-pad day)})))
 
 (defn ymd
   ([]

+ 25 - 25
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -9,22 +9,22 @@
             [clojure.walk :as walk]
             [datascript.core :as d]
             [logseq.graph-parser.text :as text]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.block :as gp-block]
             [logseq.graph-parser.property :as gp-property]
-            [logseq.graph-parser.config :as gp-config]
-            #?(:org.babashka/nbb [logseq.graph-parser.log :as log]
+            [logseq.common.config :as common-config]
+            #?(:org.babashka/nbb [logseq.common.log :as log]
                :default [lambdaisland.glogi :as log])
             [logseq.graph-parser.whiteboard :as gp-whiteboard]))
 
 (defn- filepath->page-name
   [filepath]
   (when-let [file-name (last (string/split filepath #"/"))]
-    (let [result (first (gp-util/split-last "." file-name))
-          ext (string/lower-case (gp-util/get-file-ext filepath))]
-      (if (or (gp-config/mldoc-support? ext) (= "edn" ext))
-        (gp-util/safe-decode-uri-component (string/replace result "." "/"))
+    (let [result (first (common-util/split-last "." file-name))
+          ext (string/lower-case (common-util/get-file-ext filepath))]
+      (if (or (common-config/mldoc-support? ext) (= "edn" ext))
+        (common-util/safe-decode-uri-component (string/replace result "." "/"))
         result))))
 
 (defn- get-page-name
@@ -54,9 +54,9 @@
                                (and first-block
                                     (string? title)
                                     title))
-            file-name (when-let [result (gp-util/path->file-body file)]
-                        (if (gp-config/mldoc-support? (gp-util/get-file-ext file))
-                          (gp-util/title-parsing result filename-format)
+            file-name (when-let [result (common-util/path->file-body file)]
+                        (if (common-config/mldoc-support? (common-util/get-file-ext file))
+                          (common-util/title-parsing result filename-format)
                           result))]
         (or property-name
             file-name
@@ -67,12 +67,12 @@
   (let [alias (:alias properties)
         alias' (if (coll? alias) alias [(str alias)])
         aliases (and alias'
-                     (seq (remove #(or (= page-name (gp-util/page-name-sanity-lc %))
+                     (seq (remove #(or (= page-name (common-util/page-name-sanity-lc %))
                                        (string/blank? %)) ;; disable blank alias
                                   alias')))
         aliases' (keep
                    (fn [alias]
-                     (let [page-name (gp-util/page-name-sanity-lc alias)
+                     (let [page-name (common-util/page-name-sanity-lc alias)
                            aliases (distinct
                                     (conj
                                      (remove #{alias} aliases)
@@ -80,7 +80,7 @@
                            aliases (when (seq aliases)
                                      (map
                                        (fn [alias]
-                                         {:block/name (gp-util/page-name-sanity-lc alias)})
+                                         {:block/name (common-util/page-name-sanity-lc alias)})
                                        aliases))]
                        (if (seq aliases)
                          {:block/name page-name
@@ -97,7 +97,7 @@
                  (assoc :block/tags (let [tags (:tags properties)
                                           tags (if (coll? tags) tags [(str tags)])
                                           tags (remove string/blank? tags)]
-                                      (map (fn [tag] {:block/name (gp-util/page-name-sanity-lc tag)
+                                      (map (fn [tag] {:block/name (common-util/page-name-sanity-lc tag)
                                                       :block/original-name tag})
                                         tags))))]
     (update result :block/properties #(apply dissoc % gp-property/editable-linkable-built-in-properties))))
@@ -111,11 +111,11 @@
         invalid-properties (set (->> (map (comp name first) *invalid-properties)
                                      (concat invalid-properties)))
         page-m (->
-                (gp-util/remove-nils-non-nested
+                (common-util/remove-nils-non-nested
                  (assoc
                   (gp-block/page-name->map page false db true date-formatter
                                            :from-page from-page)
-                  :block/file {:file/path (gp-util/path-normalize file)}))
+                  :block/file {:file/path (common-util/path-normalize file)}))
                 (extract-page-alias-and-tags page page-name properties))]
     (cond->
       page-m
@@ -193,7 +193,7 @@
           page-map (build-page-map properties invalid-properties properties-text-values file page page-name (assoc options' :from-page page))
           namespace-pages (let [page (:block/original-name page-map)]
                             (when (text/namespace-page? page)
-                              (->> (gp-util/split-namespace-pages page)
+                              (->> (common-util/split-namespace-pages page)
                                    (map (fn [page]
                                           (-> (gp-block/page-name->map page true db true date-formatter)
                                               (assoc :block/format format)))))))
@@ -204,7 +204,7 @@
                      ;; remove block references
                      (remove vector?)
                      (remove nil?))
-          pages (gp-util/distinct-by :block/name pages)
+          pages (common-util/distinct-by :block/name pages)
           pages (remove nil? pages)
           pages (map (fn [page] (assoc page :block/uuid (d/squuid))) pages)
           blocks (->> (remove nil? blocks)
@@ -218,7 +218,7 @@
   [file-path content {:keys [user-config verbose] :or {verbose true} :as options}]
   (if (string/blank? content)
     []
-    (let [format (gp-util/get-format file-path)
+    (let [format (common-util/get-format file-path)
           _ (when verbose (println "Parsing start: " file-path))
           ast (gp-mldoc/->edn content (gp-mldoc/default-config format
                                         ;; {:parse_outline_only? true}
@@ -252,24 +252,24 @@
    - blocks will be adapted to tldraw shapes. All blocks's parent is the given page."
   [file content {:keys [verbose] :or {verbose true}}]
   (let [_ (when verbose (println "Parsing start: " file))
-        {:keys [pages blocks]} (gp-util/safe-read-string content)
+        {:keys [pages blocks]} (common-util/safe-read-string content)
         blocks (map
                 (fn [block]
                   (-> block
-                      (gp-util/dissoc-in [:block/parent :block/name])
-                      (gp-util/dissoc-in [:block/left :block/name])))
+                      (common-util/dissoc-in [:block/parent :block/name])
+                      (common-util/dissoc-in [:block/left :block/name])))
                 blocks)
         serialized-page (first pages)
         ;; whiteboard edn file should normally have valid :block/original-name, :block/name, :block/uuid
         page-name (-> (or (:block/name serialized-page)
                           (filepath->page-name file))
-                      (gp-util/page-name-sanity-lc))
+                      (common-util/page-name-sanity-lc))
         original-name (or (:block/original-name serialized-page)
                           page-name)
         page-block (merge {:block/name page-name
                            :block/original-name original-name
                            :block/type "whiteboard"
-                           :block/file {:file/path (gp-util/path-normalize file)}}
+                           :block/file {:file/path (common-util/path-normalize file)}}
                           serialized-page)
         page-block (gp-whiteboard/migrate-page-block page-block)
         blocks (->> blocks
@@ -281,7 +281,7 @@
 
 (defn- with-block-uuid
   [pages]
-  (->> (gp-util/distinct-by :block/name pages)
+  (->> (common-util/distinct-by :block/name pages)
        (map (fn [page]
               (if (:block/uuid page)
                 page

+ 10 - 10
deps/graph-parser/src/logseq/graph_parser/mldoc.cljc

@@ -6,14 +6,14 @@
                                         :unresolved-symbol {:level :off}}}})
   (:require #?(:org.babashka/nbb ["mldoc$default" :refer [Mldoc]]
                :default ["mldoc" :refer [Mldoc]])
-            #?(:org.babashka/nbb [logseq.graph-parser.log :as log]
+            #?(:org.babashka/nbb [logseq.common.log :as log]
                :default [lambdaisland.glogi :as log])
             [goog.object :as gobj]
             [cljs-bean.core :as bean]
             [logseq.graph-parser.utf8 :as utf8]
             [clojure.string :as string]
-            [logseq.graph-parser.util :as gp-util]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.util :as common-util]
+            [logseq.common.config :as common-config]
             [logseq.graph-parser.schema.mldoc :as mldoc-schema]))
 
 (defonce parseJson (gobj/get Mldoc "parseJson"))
@@ -46,7 +46,7 @@
 (defn get-references
   [text config]
   (when-not (string/blank? text)
-    (gp-util/json->clj (getReferences text config))))
+    (common-util/json->clj (getReferences text config))))
 
 (defn ast-export-markdown
   [ast config references]
@@ -96,9 +96,9 @@
                     ;; Check if the indentation area only contains white spaces
                     ;; Level = ast level + 1, 1-based indentation level
                     ;; For markdown in Logseq, the indentation area for the non-first line of multi-line block is (ast level - 1) * "\t" + 2 * "(space)"
-                    (if (string/blank? (gp-util/safe-subs line 0 level))
+                    (if (string/blank? (common-util/safe-subs line 0 level))
                       ;; If valid, then remove the indentation area spaces. Keep the rest of the line (might contain leading spaces)
-                      (gp-util/safe-subs line level)
+                      (common-util/safe-subs line level)
                       ;; Otherwise, trim these invalid spaces
                       (string/triml line)))
                (if remove-first-line? lines r))
@@ -145,7 +145,7 @@
         []
         (-> content
             (parse-json config)
-            (gp-util/json->clj)
+            (common-util/json->clj)
             (update-src-full-content content)
             (collect-page-properties config)))
       (catch :default e
@@ -160,7 +160,7 @@
       {}
       (-> text
           (inline-parse-json config)
-          (gp-util/json->clj)))
+          (common-util/json->clj)))
     (catch :default _e
       [])))
 
@@ -175,10 +175,10 @@
           (and (contains? #{"Page_ref"} ref-type)
                (or
                 ;; 2. excalidraw link
-                (gp-config/draw? ref-value)
+                (common-config/draw? ref-value)
 
                 ;; 3. local asset link
-                (boolean (gp-config/local-asset? ref-value))))))))
+                (boolean (common-config/local-asset? ref-value))))))))
 
 (defn link?
   [format link]

+ 4 - 4
deps/graph-parser/src/logseq/graph_parser/property.cljs

@@ -1,6 +1,6 @@
 (ns logseq.graph-parser.property
   "Core vars and util fns for properties and file based graphs"
-  (:require [logseq.graph-parser.util :as gp-util]
+  (:require [logseq.common.util :as common-util]
             [clojure.string :as string]
             [clojure.set :as set]
             [goog.string :as gstring]
@@ -29,7 +29,7 @@
 (defn valid-property-name?
   [s]
   {:pre [(string? s)]}
-  (and (gp-util/valid-edn-keyword? s)
+  (and (common-util/valid-edn-keyword? s)
        (not (re-find #"[\"|^|(|)|{|}]+" s))
        ;; Disallow tags as property names
        (not (re-find #"^:#" s))))
@@ -145,7 +145,7 @@
         (let [before (subvec lines 0 start-idx)
               middle (->> (subvec lines (inc start-idx) end-idx)
                           (map (fn [text]
-                                 (let [[k v] (gp-util/split-first ":" (subs text 1))]
+                                 (let [[k v] (common-util/split-first ":" (subs text 1))]
                                    (if (and k v)
                                      (let [k (string/replace k "_" "-")
                                            compare-k (keyword (string/lower-case k))
@@ -157,4 +157,4 @@
               lines (concat before middle after)]
           (string/join "\n" lines))
         content))
-    content))
+    content))

+ 3 - 3
deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs

@@ -4,7 +4,7 @@
             ["child_process" :as child-process]
             [cljs.test :refer [is testing]]
             [clojure.string :as string]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [datascript.core :as d]))
 
 ;; Helper fns for test setup
@@ -82,9 +82,9 @@
   (testing "Query based stats"
     (is (= (->> files
                 ;; logseq files aren't saved under :block/file
-                (remove #(string/includes? % (str graph-dir "/" gp-config/app-name "/")))
+                (remove #(string/includes? % (str graph-dir "/" common-config/app-name "/")))
                 ;; edn files being listed in docs by parse-graph aren't graph files
-                (remove #(and (not (gp-config/whiteboard? %)) (string/ends-with? % ".edn")))
+                (remove #(and (not (common-config/whiteboard? %)) (string/ends-with? % ".edn")))
                 set)
            (->> (d/q '[:find (pull ?b [* {:block/file [:file/path]}])
                        :where [?b :block/name] [?b :block/file]]

+ 3 - 3
deps/graph-parser/src/logseq/graph_parser/text.cljs

@@ -6,7 +6,7 @@
             [clojure.set :as set]
             [logseq.graph-parser.property :as gp-property]
             [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.page-ref :as page-ref]))
 
 (defn get-file-basename
@@ -82,7 +82,7 @@
        (string/includes? page-name "/")
        (not (string/starts-with? page-name "../"))
        (not (string/starts-with? page-name "./"))
-       (not (gp-util/url? page-name))))
+       (not (common-util/url? page-name))))
 
 (defn parse-non-string-property-value
   "Return parsed non-string property value or nil if none is found"
@@ -174,7 +174,7 @@
                  (name k))
       v'
 
-      (gp-util/wrapped-by-quotes? v')
+      (common-util/wrapped-by-quotes? v')
       v'
 
       ;; parse property value as needed

+ 4 - 4
deps/graph-parser/src/logseq/graph_parser/whiteboard.cljs

@@ -1,6 +1,6 @@
 (ns logseq.graph-parser.whiteboard
   "Whiteboard related parser utilities"
-  (:require [logseq.graph-parser.util :as gp-util]
+  (:require [logseq.common.util :as common-util]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [logseq.graph-parser.util.page-ref :as page-ref]))
 
@@ -45,13 +45,13 @@
 (defn- get-shape-refs [shape]
   (let [portal-refs (when (= "logseq-portal" (:type shape))
                       [(if (= (:blockType shape) "P")
-                         {:block/name (gp-util/page-name-sanity-lc (:pageId shape))}
+                         {:block/name (common-util/page-name-sanity-lc (:pageId shape))}
                          {:block/uuid (uuid (:pageId shape))})])
         shape-link-refs (->> (:refs shape)
                              (filter (complement empty?))
                              (map (fn [ref] (if (parse-uuid ref)
                                               {:block/uuid (parse-uuid ref)}
-                                              {:block/name (gp-util/page-name-sanity-lc ref)}))))]
+                                              {:block/name (common-util/page-name-sanity-lc ref)}))))]
     (concat portal-refs shape-link-refs)))
 
 (defn- with-whiteboard-block-refs
@@ -77,7 +77,7 @@
   [block page-name]
   (let [shape? (shape-block? block)
         shape (block->shape block)
-        default-page-ref {:block/name (gp-util/page-name-sanity-lc page-name)}]
+        default-page-ref {:block/name (common-util/page-name-sanity-lc page-name)}]
     (merge (when shape?
              (merge
               {:block/uuid (uuid (:id shape))}

+ 1 - 1
deps/graph-parser/test/logseq/graph_parser/cli_test.cljs

@@ -39,7 +39,7 @@
                             ;; edn files don't have ast
                             (string/ends-with? (:file %) ".edn")
                             ;; logseq files don't have ast
-                            ;; could also used gp-config but API isn't public yet
+                            ;; could also used common-config but API isn't public yet
                             (string/includes? (:file %) (str graph-dir "/logseq/")))
                           asts))
           "Parsed files shouldn't have empty asts"))))

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 3 - 5
deps/graph-parser/test/logseq/graph_parser/util/file_name_test.cljs


+ 2 - 2
src/main/electron/listener.cljs

@@ -17,7 +17,7 @@
             [frontend.state :as state]
             [frontend.ui :as ui]
             [logseq.common.path :as path]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [promesa.core :as p]
             [frontend.handler.property.util :as pu]))
 
@@ -34,7 +34,7 @@
   (safe-api-call "file-watcher"
                  (fn [data]
                    (let [{:keys [type payload]} (bean/->clj data)
-                         path (gp-util/path-normalize (:path payload))
+                         path (common-util/path-normalize (:path payload))
                          dir (:dir payload)
                          payload (assoc payload :path (path/relative-path dir path))]
                      (watcher-handler/handle-changed! type payload)

+ 6 - 6
src/main/frontend/commands.cljs

@@ -19,9 +19,9 @@
             [frontend.handler.property.file :as property-file]
             [goog.dom :as gdom]
             [goog.object :as gobj]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [logseq.graph-parser.property :as gp-property]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [logseq.graph-parser.util.page-ref :as page-ref]
             [promesa.core :as p]))
@@ -299,7 +299,7 @@
                       [:codemirror/focus]] "Insert a calculator"]
        ["Draw" (fn []
                  (let [file (draw/file-name)
-                       path (str gp-config/default-draw-directory "/" file)
+                       path (str common-config/default-draw-directory "/" file)
                        text (page-ref/->page-ref path)]
                    (p/let [_ (draw/create-draw-with-default-content path)]
                      (println "draw file created, " path))
@@ -364,7 +364,7 @@
           current-pos (cursor/pos input)
           current-pos (or
                        (when (and end-pattern (string? end-pattern))
-                         (when-let [i (string/index-of (gp-util/safe-subs edit-content current-pos) end-pattern)]
+                         (when-let [i (string/index-of (common-util/safe-subs edit-content current-pos) end-pattern)]
                            (+ current-pos i)))
                        current-pos)
           orig-prefix (subs edit-content 0 current-pos)
@@ -372,7 +372,7 @@
           postfix (if postfix-fn (postfix-fn postfix) postfix)
           space? (let [space? (when (and last-pattern orig-prefix)
                                 (let [s (when-let [last-index (string/last-index-of orig-prefix last-pattern)]
-                                          (gp-util/safe-subs orig-prefix 0 last-index))]
+                                          (common-util/safe-subs orig-prefix 0 last-index))]
                                   (not
                                    (or
                                     (and (= :page-ref command)
@@ -394,7 +394,7 @@
                      space?))
           prefix (cond
                    (and backward-truncate-number (integer? backward-truncate-number))
-                   (str (gp-util/safe-subs orig-prefix 0 (- (count orig-prefix) backward-truncate-number))
+                   (str (common-util/safe-subs orig-prefix 0 (- (count orig-prefix) backward-truncate-number))
                         (when-not (zero? backward-truncate-number)
                           value))
 

+ 21 - 21
src/main/frontend/components/block.cljs

@@ -71,10 +71,10 @@
             [goog.object :as gobj]
             [lambdaisland.glogi :as log]
             [logseq.graph-parser.block :as gp-block]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.text :as text]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [logseq.graph-parser.util.page-ref :as page-ref]
             [logseq.shui.core :as shui]
@@ -185,12 +185,12 @@
   (rum/local false ::loading?)
   {:will-mount  (fn [state]
                   (let [src (first (:rum/args state))]
-                    (if (and (gp-config/local-protocol-asset? src)
+                    (if (and (common-config/local-protocol-asset? src)
                              (file-sync/current-graph-sync-on?))
                       (let [*exist? (::exist? state)
                             ;; special handling for asset:// protocol
                             ;; Capacitor uses a special URL for assets loading
-                            asset-path (gp-config/remove-asset-protocol src)
+                            asset-path (common-config/remove-asset-protocol src)
                             asset-path (fs/asset-path-normalize asset-path)]
                         (if (string/blank? asset-path)
                           (reset! *exist? false)
@@ -226,7 +226,7 @@
         asset-file? (::asset-file? state)
         sync-enabled? (boolean (file-sync/current-graph-sync-on?))
         ext (keyword (util/get-file-ext src))
-        img? (contains? (gp-config/img-formats) ext)
+        img? (contains? (common-config/img-formats) ext)
         audio? (contains? config/audio-formats ext)
         type (cond img? "image"
                    audio? "audio"
@@ -367,7 +367,7 @@
 
 (rum/defc audio-cp [src]
   ;; Change protocol to allow media fragment uris to play
-  [:audio {:src (string/replace-first src gp-config/asset-protocol "file://")
+  [:audio {:src (string/replace-first src common-config/asset-protocol "file://")
            :controls true
            :on-touch-start #(util/stop %)}])
 
@@ -406,11 +406,11 @@
           (asset-loader @src
                         #(audio-cp @src))
 
-          (contains? (gp-config/img-formats) ext)
+          (contains? (common-config/img-formats) ext)
           (asset-loader @src
                         #(resizable-image config title @src metadata full_text true))
 
-          (contains? (gp-config/text-formats) ext)
+          (contains? (common-config/text-formats) ext)
           [:a.asset-ref.is-plaintext {:href (rfe/href :file {:path path})
                                       :on-click (fn [_event]
                                                   (p/let [result (fs/read-file repo-dir path)]
@@ -436,12 +436,12 @@
 (defn image-link [config url href label metadata full_text]
   (let [metadata (if (string/blank? metadata)
                    nil
-                   (gp-util/safe-read-string metadata))
+                   (common-util/safe-read-string metadata))
         title (second (first label))
         repo (state/get-current-repo)]
     (ui/catch-error
      [:span.warning full_text]
-     (if (and (gp-config/local-asset? href)
+     (if (and (common-config/local-asset? href)
               (or (config/local-file-based-graph? repo)
                   (config/db-based-graph? repo)))
        (asset-link config title href metadata full_text)
@@ -699,7 +699,7 @@
    - `:preview?`: Is this component under preview mode? (If true, `page-preview-trigger` won't be registered to this `page-cp`)"
   [{:keys [html-export? redirect-page-name label children contents-page? preview? disable-preview?] :as config} page]
   (when-let [page-name-in-block (:block/name page)]
-    (let [page-name-in-block (gp-util/remove-boundary-slashes page-name-in-block)
+    (let [page-name-in-block (common-util/remove-boundary-slashes page-name-in-block)
           page-name (util/page-name-sanity-lc page-name-in-block)
           page-entity (db/entity [:block/name page-name])
           whiteboard-page? (model/whiteboard-page? page-name)
@@ -722,7 +722,7 @@
   [config title path]
   (let [repo (state/get-current-repo)
         real-path-url (cond
-                        (gp-util/url? path)
+                        (common-util/url? path)
                         path
 
                         (path/absolute? path)
@@ -862,7 +862,7 @@
   [label]
   (when (and (= 1 (count label))
              (string? (last (first label))))
-    (gp-util/safe-decode-uri-component (last (first label)))))
+    (common-util/safe-decode-uri-component (last (first label)))))
 
 (defn- get-page
   [label]
@@ -1011,7 +1011,7 @@
 (defn- show-link?
   [config metadata s full-text]
   (let [media-formats (set (map name config/media-formats))
-        metadata-show (:show (gp-util/safe-read-string metadata))
+        metadata-show (:show (common-util/safe-read-string metadata))
         format (get-in config [:block :block/format])]
     (or
      (and
@@ -1020,7 +1020,7 @@
        (and
         (nil? metadata-show)
         (or
-         (gp-config/local-asset? s)
+         (common-config/local-asset? s)
          (text-util/media-link? media-formats s)))
        (true? (boolean metadata-show))))
 
@@ -1044,7 +1044,7 @@
 
 (rum/defc audio-link
   [config url href _label metadata full_text]
-  (if (and (gp-config/local-asset? href)
+  (if (and (common-config/local-asset? href)
            (config/local-file-based-graph? (state/get-current-repo)))
     (asset-link config nil href metadata full_text)
     (let [href (cond
@@ -1215,7 +1215,7 @@
                   show-brackets? (state/show-brackets?)]
               (if (and page
                        (when-let [ext (util/get-file-ext href)]
-                         (gp-config/mldoc-support? ext)))
+                         (common-config/mldoc-support? ext)))
                 [:span.page-reference
                  (when show-brackets? [:span.text-gray-500 page-ref/left-brackets])
                  (page-cp config page)
@@ -1350,7 +1350,7 @@
 (defn- macro-video-cp
   [_config arguments]
   (if-let [url (first arguments)]
-    (if (gp-util/url? url)
+    (if (common-util/url? url)
       (let [results (text-util/get-matched-video url)
             src (match results
                   [_ _ _ (:or "youtube.com" "youtu.be" "y2u.be") _ id _]
@@ -1572,7 +1572,7 @@
 
 (defn hiccup->html
   [s]
-  (let [result (gp-util/safe-read-string s)
+  (let [result (common-util/safe-read-string s)
         result' (if (seq result) result
                     [:div.warning {:title "Invalid hiccup"}
                      s])]
@@ -2061,8 +2061,8 @@
         date
         date
 
-        (and (string? v) (gp-util/wrapped-by-quotes? v))
-        (gp-util/unquote-string v)
+        (and (string? v) (common-util/wrapped-by-quotes? v))
+        (common-util/unquote-string v)
 
         (and property-separated-by-commas? (coll? v))
         (let [v (->> (remove string/blank? v)

+ 3 - 3
src/main/frontend/components/cmdk.cljs

@@ -23,7 +23,7 @@
    [rum.core :as rum]
    [frontend.mixins :as mixins]
    [logseq.graph-parser.util.block-ref :as block-ref]
-   [logseq.graph-parser.util :as gp-util]
+   [logseq.common.util :as common-util]
    [logseq.shui.button.v2 :as button]
    [frontend.modules.shortcut.utils :as shortcut-utils]
    [frontend.config :as config]
@@ -341,7 +341,7 @@
   [input]
   (or (when (string/starts-with? input "/")
         (subs input 1))
-      (last (gp-util/split-last "/" input))))
+      (last (common-util/split-last "/" input))))
 
 (defmethod load-results :filters [group state]
   (let [!results (::results state)
@@ -513,7 +513,7 @@
   [input]
   (cond
     (string/includes? input "/")
-    (first (gp-util/split-last "/" input))
+    (first (common-util/split-last "/" input))
     (string/starts-with? input "/")
     ""
     :else

+ 2 - 2
src/main/frontend/components/content.cljs

@@ -20,7 +20,7 @@
             [frontend.ui :as ui]
             [frontend.util :as util]
             [frontend.modules.shortcut.core :as shortcut]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [frontend.util.url :as url-util]
             [goog.dom :as gdom]
@@ -472,5 +472,5 @@
     [:div
      (hiccup-content id option)]
     ;; TODO: remove this
-    (let [format (gp-util/normalize-format format)]
+    (let [format (common-util/normalize-format format)]
       (non-hiccup-content id content on-click on-hide config format))))

+ 3 - 3
src/main/frontend/components/conversion.cljs

@@ -3,7 +3,7 @@
             [cljs.core.async.interop :refer [p->c]]
             [promesa.core :as p]
             [electron.ipc :as ipc]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.util :as util]
             [frontend.state :as state]
             [frontend.ui :as ui]
@@ -161,8 +161,8 @@
             [:tbody
              (for [{:keys [page file status target old-title changed-title]} rename-items]
                (let [path           (:file/path file)
-                     src-file-name  (gp-util/path->file-name path)
-                     tgt-file-name  (str target "." (gp-util/path->file-ext path))
+                     src-file-name  (common-util/path->file-name path)
+                     tgt-file-name  (str target "." (common-util/path->file-ext path))
                      rm-item-fn     #(swap! *pages dissoc path)
                      rename-fn      #(file-page-handler/rename-file! file target rm-item-fn)
                      rename-but     [:a {:on-click rename-fn

+ 8 - 8
src/main/frontend/components/editor.cljs

@@ -26,7 +26,7 @@
             [goog.dom :as gdom]
             [goog.string :as gstring]
             [logseq.graph-parser.property :as gp-property]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [promesa.core :as p]
             [react-draggable]
             [rum.core :as rum]
@@ -105,8 +105,8 @@
   (if embed?
     (fn [chosen-item _e]
       (let [value (.-value input)
-            value' (str (gp-util/safe-subs value 0 q)
-                        (gp-util/safe-subs value (+ (count q) 4 pos)))]
+            value' (str (common-util/safe-subs value 0 q)
+                        (common-util/safe-subs value (+ (count q) 4 pos)))]
         (state/set-edit-content! (.-id input) value')
         (state/clear-editor-action!)
         (let [page-name (util/page-name-sanity-lc chosen-item)
@@ -192,9 +192,9 @@
                 q (or
                    (editor-handler/get-selected-text)
                    (when (= action :page-search-hashtag)
-                     (gp-util/safe-subs edit-content pos current-pos))
+                     (common-util/safe-subs edit-content pos current-pos))
                    (when (> (count edit-content) current-pos)
-                     (gp-util/safe-subs edit-content pos current-pos))
+                     (common-util/safe-subs edit-content pos current-pos))
                    "")]
             (page-search-aux id format embed? db-tag? q current-pos input pos)))))))
 
@@ -211,8 +211,8 @@
     (fn [chosen-item]
       (let [pos (state/get-editor-last-pos)
             value (.-value input)
-            value' (str (gp-util/safe-subs value 0 q)
-                        (gp-util/safe-subs value (+ (count q) 4 pos)))]
+            value' (str (common-util/safe-subs value 0 q)
+                        (common-util/safe-subs value (+ (count q) 4 pos)))]
         (state/set-edit-content! (.-id input) value')
         (state/clear-editor-action!)
         (let [current-block (state/get-edit-block)
@@ -376,7 +376,7 @@
             current-pos  (cursor/pos input)
             edit-content (or (state/sub-edit-content) "")
             q            (or (editor-handler/get-selected-text)
-                             (gp-util/safe-subs edit-content pos current-pos)
+                             (common-util/safe-subs edit-content pos current-pos)
                              "")
             matched      (seq (fuzzy-search modes q))
             matched      (or matched (if (string/blank? q) modes [q]))]

+ 9 - 9
src/main/frontend/components/file.cljs

@@ -16,8 +16,8 @@
             [frontend.util :as util]
             [goog.object :as gobj]
             [goog.string :as gstring]
-            [logseq.graph-parser.config :as gp-config]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.config :as common-config]
+            [logseq.common.util :as common-util]
             [promesa.core :as p]
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]
@@ -47,8 +47,8 @@
           (let [file-id file]
             [:tr {:key file-id}
              [:td
-              (let [href (if (gp-config/draw? file)
-                           (rfe/href :draw nil {:file (string/replace file (str gp-config/default-draw-directory "/") "")})
+              (let [href (if (common-config/draw? file)
+                           (rfe/href :draw nil {:file (string/replace file (str common-config/default-draw-directory "/") "")})
                            (rfe/href :file {:path file-id}))]
                 [:a {:href href}
                  file])]
@@ -87,7 +87,7 @@
                                     ;; assume local file, relative path
                                     :else
                                     [repo-dir path])]
-                   (when (and format (contains? (gp-config/text-formats) format))
+                   (when (and format (contains? (common-config/text-formats) format))
                      (p/let [content (if (and (config/db-based-graph? repo)
                                               ;; not global
                                               (not (string/starts-with? path "/")))
@@ -145,11 +145,11 @@
 
      (cond
        ;; image type
-       (and format (contains? (gp-config/img-formats) format))
+       (and format (contains? (common-config/img-formats) format))
        [:img {:src (path/path-join "file://" path)}]
 
        (and format
-            (contains? (gp-config/text-formats) format)
+            (contains? (common-config/text-formats) format)
             content)
        (let [content' (string/trim content)
              mode (util/get-file-ext path)]
@@ -162,7 +162,7 @@
 
        ;; wait for content load
        (and format
-            (contains? (gp-config/text-formats) format))
+            (contains? (common-config/text-formats) format))
        (ui/loading)
 
        :else
@@ -171,5 +171,5 @@
 (rum/defcs file
   [state]
   (let [path (get-path state)
-        format (gp-util/get-format path)]
+        format (common-util/get-format path)]
     (rum/with-key (file-inner path format) path)))

+ 2 - 2
src/main/frontend/components/file_sync.cljs

@@ -30,7 +30,7 @@
             [cljs-time.core :as t]
             [cljs-time.coerce :as tc]
             [goog.functions :refer [debounce]]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 (declare maybe-onboarding-show)
 (declare open-icloud-graph-clone-picker)
@@ -79,7 +79,7 @@
 
      [:div.folder-tip.flex.flex-col.items-center
       [:h3
-       [:span (ui/icon "folder") [:label.pl-0.5 (gp-util/safe-decode-uri-component graph-name)]]]
+       [:span (ui/icon "folder") [:label.pl-0.5 (common-util/safe-decode-uri-component graph-name)]]]
       [:h4.px-6 (config/get-string-repo-dir repo)]
 
       (when (not (string/blank? selected-path))

+ 3 - 3
src/main/frontend/components/page.cljs

@@ -43,7 +43,7 @@
             [frontend.util.text :as text-util]
             [goog.object :as gobj]
             [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.page-ref :as page-ref]
             [logseq.db.frontend.property :as db-property]
             [medley.core :as medley]
@@ -266,8 +266,8 @@
                        (reset! *edit? true)
                        (.focus (rum/deref input-ref)))
         blur-fn (fn [e]
-                  (when (gp-util/wrapped-by-quotes? @*title-value)
-                    (swap! *title-value gp-util/unquote-string)
+                  (when (common-util/wrapped-by-quotes? @*title-value)
+                    (swap! *title-value common-util/unquote-string)
                     (gobj/set (rum/deref input-ref) "value" @*title-value))
                   (cond
                     (or (= old-name @*title-value) (and whiteboard-page? (string/blank? @*title-value)))

+ 2 - 2
src/main/frontend/components/query/builder.cljs

@@ -16,7 +16,7 @@
             [logseq.db.frontend.default :as db-default]
             [rum.core :as rum]
             [clojure.string :as string]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.page-ref :as page-ref]
             [promesa.core :as p]))
 
@@ -445,7 +445,7 @@
   (rum/local nil ::find)
   {:init (fn [state]
            (let [q-str (first (:rum/args state))
-                 query (gp-util/safe-read-string
+                 query (common-util/safe-read-string
                         query-dsl/custom-readers
                         (query-dsl/pre-transform-query q-str))
                  query' (cond

+ 3 - 3
src/main/frontend/components/query/result.cljs

@@ -5,7 +5,7 @@
             [frontend.db :as db]
             [frontend.db.query-dsl :as query-dsl]
             [frontend.state :as state]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.util :as util]
             [clojure.string :as string]
             [promesa.core :as p]
@@ -23,7 +23,7 @@
                      (cond
                        (:dsl-query? config)
                        (let [q (:query query)
-                             form (gp-util/safe-read-string q)]
+                             form (common-util/safe-read-string q)]
                          (cond
                            ;; Searches like 'foo' or 'foo bar' come back as symbols
                            ;; and are meant to go directly to full text search
@@ -81,4 +81,4 @@
     (when-let [query-result (:query-result config)]
       (reset! query-result result))
     (when query-atom
-      (util/safe-with-meta result (meta @query-atom)))))
+      (util/safe-with-meta result (meta @query-atom)))))

+ 6 - 6
src/main/frontend/config.cljs

@@ -6,8 +6,8 @@
             [frontend.state :as state]
             [frontend.util :as util]
             [logseq.common.path :as path]
-            [logseq.graph-parser.config :as gp-config]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.config :as common-config]
+            [logseq.common.util :as common-util]
             [shadow.resource :as rc]
             [goog.crypt.Md5]
             [goog.crypt :as crypt]))
@@ -138,14 +138,14 @@
 (def video-formats
   #{:mp4 :webm :mov :flv :avi :mkv})
 
-(def media-formats (set/union (gp-config/img-formats) audio-formats))
+(def media-formats (set/union (common-config/img-formats) audio-formats))
 
 (defn extname-of-supported?
   ([input] (extname-of-supported?
             input
             [image-formats doc-formats audio-formats
              video-formats markup-formats
-             (gp-config/text-formats)]))
+             (common-config/text-formats)]))
   ([input formats]
    (when-let [input (some->
                      (cond-> input
@@ -195,7 +195,7 @@
 
 (defn get-block-pattern
   [format]
-  (gp-config/get-block-pattern (or format (state/get-preferred-format))))
+  (common-config/get-block-pattern (or format (state/get-preferred-format))))
 
 (defn get-hr
   [format]
@@ -460,7 +460,7 @@
                  "Local"))
          (->> (string/split repo-dir "Documents/")
               last
-              gp-util/safe-decode-uri-component
+              common-util/safe-decode-uri-component
               (str "/" (string/capitalize app-name) "/")))
     (get-repo-dir (get-local-repo repo-dir))))
 

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

@@ -9,7 +9,7 @@
             [logseq.graph-parser.text :as text]
             [logseq.db :as ldb]
             [logseq.db.frontend.schema :as db-schema]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [datascript.core :as d]
             [logseq.db.sqlite.util :as sqlite-util]))
 
@@ -40,7 +40,7 @@
                      (text/get-file-basename repo-name)
 
                      (mobile-util/native-platform?)
-                     (gp-util/safe-decode-uri-component (text/get-file-basename repo-name))
+                     (common-util/safe-decode-uri-component (text/get-file-basename repo-name))
 
                      :else
                      repo-name)]

+ 3 - 3
src/main/frontend/db/model.cljs

@@ -16,7 +16,7 @@
             [logseq.db.frontend.rules :as rules]
             [logseq.graph-parser.text :as text]
             [logseq.graph-parser.util.db :as db-util]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [cljs-time.core :as t]
             [cljs-time.format :as tf]
             ;; add map ops to datascript Entity
@@ -302,7 +302,7 @@ independent of format as format specific heading characters are stripped"
        (:block/format page)
        (when-let [file (:block/file page)]
          (when-let [path (:file/path (db-utils/entity (:db/id file)))]
-           (gp-util/get-format path)))))
+           (common-util/get-format path)))))
     (state/get-preferred-format)
     :markdown)))
 
@@ -420,7 +420,7 @@ independent of format as format specific heading characters are stripped"
        :level - the level of the block, 1 for root, 2 for children of root, etc."
   [page-name]
   {:pre [(string? page-name)]}
-  (let [sanitized-page (gp-util/page-name-sanity-lc page-name)
+  (let [sanitized-page (common-util/page-name-sanity-lc page-name)
         page-id (:db/id (db-utils/entity [:block/name sanitized-page]))
         root (db-utils/entity page-id)]
     (loop [result []

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

@@ -17,7 +17,7 @@
             [frontend.template :as template]
             [logseq.graph-parser.text :as text]
             [logseq.graph-parser.util.page-ref :as page-ref]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.util.text :as text-util]
             [frontend.util :as util]
             [frontend.config :as config]))
@@ -455,7 +455,7 @@ Some bindings in this fn:
 (defonce tag-placeholder "~~~tag-placeholder~~~")
 (defn pre-transform
   [s]
-  (if (gp-util/wrapped-by-quotes? s)
+  (if (common-util/wrapped-by-quotes? s)
     s
     (let [quoted-page-ref (fn [matches]
                             (let [match' (string/replace (second matches) "#" tag-placeholder)]

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

@@ -5,7 +5,7 @@
             [datascript.transit :as dt]
             [frontend.db.conn :as conn]
             [frontend.config :as config]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.db.frontend.content :as db-content]))
 
 ;; transit serialization
@@ -92,7 +92,7 @@
 
 (defn- actual-transact!
   [repo-url tx-data tx-meta]
-  (let [tx-data (gp-util/fast-remove-nils tx-data)]
+  (let [tx-data (common-util/fast-remove-nils tx-data)]
     (when (seq tx-data)
       (conn/transact! repo-url tx-data tx-meta))))
 

+ 2 - 2
src/main/frontend/diff.cljs

@@ -5,7 +5,7 @@
             [lambdaisland.glogi :as log]
             [cljs-bean.core :as bean]
             [frontend.util :as util]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.util.text :as text-util]))
 
 (defn diff
@@ -55,7 +55,7 @@
           (+ pos 2)
 
           (contains? inline-special-chars (util/nth-safe markup pos))
-          (let [matched (->> (take-while inline-special-chars (gp-util/safe-subs markup pos))
+          (let [matched (->> (take-while inline-special-chars (common-util/safe-subs markup pos))
                              (apply str))
                 matched? (and current-line (string/includes? current-line (string/reverse matched)))]
             (if matched?

+ 7 - 7
src/main/frontend/extensions/pdf/assets.cljs

@@ -19,7 +19,7 @@
             [frontend.extensions.pdf.utils :as pdf-utils]
             [frontend.extensions.pdf.windows :as pdf-windows]
             [logseq.common.path :as path]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [medley.core :as medley]
             [promesa.core :as p]
@@ -48,7 +48,7 @@
 (defn resolve-area-image-file
   [img-stamp current {:keys [page id] :as _hl}]
   (when-let [key (:key current)]
-    (-> (str gp-config/local-assets-dir "/" key "/")
+    (-> (str common-config/local-assets-dir "/" key "/")
         (str (util/format "%s_%s_%s.png" page id img-stamp)))))
 
 (defn load-hls-data$
@@ -72,7 +72,7 @@
 (defn resolve-hls-data-by-key$
   [target-key]
   ;; TODO: fuzzy match
-  (when-let [hls-file (and target-key (str gp-config/local-assets-dir "/" target-key ".edn"))]
+  (when-let [hls-file (and target-key (str common-config/local-assets-dir "/" target-key ".edn"))]
     (load-hls-data$ {:hls-file hls-file})))
 
 (defn area-highlight?
@@ -111,7 +111,7 @@
                                   fstamp     (get-in new-hl [:content :image])
                                   old-fstamp (and old-hl (get-in old-hl [:content :image]))
                                   fname      (str (:page new-hl) "_" (:id new-hl))
-                                  fdir       (str gp-config/local-assets-dir "/" key)
+                                  fdir       (str common-config/local-assets-dir "/" key)
                                   _          (fs/mkdir-if-not-exists (path/path-join repo-dir fdir))
                                   new-fpath  (str fdir "/" fname "_" fstamp ".png")
                                   old-fpath  (and old-fstamp (str fdir "/" fname "_" old-fstamp ".png"))
@@ -142,7 +142,7 @@
           repo-dir (config/get-repo-dir repo-cur)
           fstamp   (get-in hl [:content :image])
           fname    (str (:page hl) "_" (:id hl))
-          fdir     (str gp-config/local-assets-dir "/" fkey)
+          fdir     (str common-config/local-assets-dir "/" fkey)
           fpath    (util/node-path.join repo-dir (str fdir "/" fname "_" fstamp ".png"))]
 
       (fs/unlink! repo-cur fpath {}))))
@@ -155,7 +155,7 @@
           file-path (:original-path pdf-current)
           format (state/get-preferred-format)
           repo-dir (config/get-repo-dir (state/get-current-repo))
-          asset-dir (util/node-path.join repo-dir gp-config/local-assets-dir)
+          asset-dir (util/node-path.join repo-dir common-config/local-assets-dir)
           url (if (string/includes? file-path asset-dir)
                 (str ".." (last (string/split file-path repo-dir)))
                 file-path)]
@@ -293,7 +293,7 @@
             :on-mouse-down util/stop
             :on-click      (fn [e]
                              (util/stop e)
-                             (-> (util/copy-image-to-clipboard (gp-config/remove-asset-protocol asset-path))
+                             (-> (util/copy-image-to-clipboard (common-config/remove-asset-protocol asset-path))
                                  (p/then #(notification/show! "Copied!" :success))))}
            (ui/icon "copy")])
 

+ 2 - 2
src/main/frontend/external/roam.cljs

@@ -7,7 +7,7 @@
             [clojure.string :as string]
             [goog.string :as gstring]
             [logseq.graph-parser.util.block-ref :as block-ref]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.text :as text]))
 
 (defonce all-refed-uids (atom #{}))
@@ -37,7 +37,7 @@
 (defn macro-transform
   [text]
   (string/replace text macro-pattern (fn [[original text]]
-                                       (let [[name arg] (gp-util/split-first ":" text)]
+                                       (let [[name arg] (common-util/split-first ":" text)]
                                          (if name
                                            (let [name (text/page-ref-un-brackets! name)]
                                              (gstring/format "{{%s %s}}" name arg))

+ 2 - 2
src/main/frontend/format.cljs

@@ -4,14 +4,14 @@ and edn. Can handle org-mode and markdown formats"
   (:require [frontend.format.mldoc :refer [->MldocMode] :as mldoc]
             [frontend.format.protocol :as protocol]
             [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [clojure.string :as string]))
 
 (defonce mldoc-record (->MldocMode))
 
 (defn get-format-record
   [format]
-  (case (gp-util/normalize-format format)
+  (case (common-util/normalize-format format)
     :org
     mldoc-record
     :markdown

+ 2 - 2
src/main/frontend/format/mldoc.cljs

@@ -8,7 +8,7 @@
             [lambdaisland.glogi :as log]
             ["mldoc" :as mldoc :refer [Mldoc]]
             [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.text :as text]
             [logseq.graph-parser.block :as gp-block]
             [clojure.walk :as walk]
@@ -44,7 +44,7 @@
   (try
     (if (string/blank? content)
       {}
-      (let [[headers blocks] (-> content (parse-opml) (gp-util/json->clj))]
+      (let [[headers blocks] (-> content (parse-opml) (common-util/json->clj))]
         [headers (gp-mldoc/collect-page-properties blocks config)]))
     (catch :default e
       (log/error :edn/convert-failed e)

+ 4 - 4
src/main/frontend/fs.cljs

@@ -15,7 +15,7 @@
             [logseq.common.path :as path]
             [clojure.string :as string]
             [frontend.state :as state]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [electron.ipc :as ipc]))
 
 (defonce nfs-backend (nfs/->Nfs))
@@ -83,7 +83,7 @@
     (js/console.error "BUG: (deprecation) path-only? is always true"))
   (p/let [result (protocol/readdir (get-fs dir) dir)
           result (bean/->clj result)]
-    (map gp-util/path-normalize result)))
+    (map common-util/path-normalize result)))
 
 (defn unlink!
   "Should move the path to logseq/recycle instead of deleting it."
@@ -103,7 +103,7 @@
 (defn write-file!
   [repo dir rpath content opts]
   (when content
-    (let [path (gp-util/path-normalize rpath)
+    (let [path (common-util/path-normalize rpath)
           fs-record (get-fs dir {:repo repo
                                  :rpath rpath})]
       (->
@@ -137,7 +137,7 @@
 (defn rename!
   "Rename files, incoming relative path, converted to absolute path"
   [repo old-path new-path]
-  (let [new-path (gp-util/path-normalize new-path)]
+  (let [new-path (common-util/path-normalize new-path)]
     (cond
       ; See https://github.com/isomorphic-git/lightning-fs/issues/41
       (= old-path new-path)

+ 4 - 4
src/main/frontend/fs/nfs.cljs

@@ -17,7 +17,7 @@
             [frontend.state :as state]
             [frontend.handler.notification :as notification]
             ["/frontend/utils" :as utils]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.common.path :as path]))
 
 ;; Cache the file handles in the memory so that
@@ -124,7 +124,7 @@
                            (not (contains? #{"md" "org" "excalidraw" "edn" "css"} ext))))))
          (map (fn [file]
                 (-> (.-webkitRelativePath file)
-                    gp-util/path-normalize))))))
+                    common-util/path-normalize))))))
 
 
 (defn- get-files-and-reload-all-handles
@@ -152,7 +152,7 @@
                        (p/let [content (.text file)]
                          {:name        (.-name file)
                           :path        (-> (.-webkitRelativePath file)
-                                           gp-util/path-normalize)
+                                           common-util/path-normalize)
                           :mtime       (.-lastModified file)
                           :size        (.-size file)
                           :type        (.-kind (.-handle file))
@@ -339,7 +339,7 @@
                                 ;; path content size mtime
                                 {:name        (.-name file)
                                  :path        (-> (.-webkitRelativePath file)
-                                                  gp-util/path-normalize)
+                                                  common-util/path-normalize)
                                  :mtime       (.-lastModified file)
                                  :size        (.-size file)
                                  :type        (.-kind (.-handle file))

+ 4 - 4
src/main/frontend/fs/sync.cljs

@@ -36,7 +36,7 @@
             [goog.string :as gstring]
             [lambdaisland.glogi :as log]
             [logseq.common.path :as path]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [medley.core :refer [dedupe-by]]
             [promesa.core :as p]
             [rum.core :as rum]))
@@ -729,7 +729,7 @@
 ;;; ### path-normalize
 (def path-normalize
 
-  gp-util/path-normalize)
+  common-util/path-normalize)
 
 
 ;;; ### APIs
@@ -1600,7 +1600,7 @@
                       (map (fn [rpath]
                              (p/let [base-file (path/path-join "logseq/version-files/base" rpath)
                                      current-change-file rpath
-                                     format (gp-util/get-format current-change-file)
+                                     format (common-util/get-format current-change-file)
                                      repo (state/get-current-repo)
                                      repo-dir (config/get-repo-dir repo)
                                      base-exists? (fs/file-exists? repo-dir base-file)]
@@ -1635,7 +1635,7 @@
                                   (p/let [incoming-file (path/path-join "logseq/version-files/incoming" rpath)
                                           base-file (path/path-join "logseq/version-files/base" rpath)
                                           current-change-file rpath
-                                          format (gp-util/get-format current-change-file)
+                                          format (common-util/get-format current-change-file)
                                           repo (state/get-current-repo)
                                           repo-dir (config/get-repo-dir repo)
                                           base-exists? (fs/file-exists? repo-dir base-file)]

+ 3 - 3
src/main/frontend/fs/watcher_handler.cljs

@@ -19,11 +19,11 @@
             [frontend.util :as util]
             [frontend.util.fs :as fs-util]
             [lambdaisland.glogi :as log]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [promesa.core :as p]))
 
-;; all IPC paths must be normalized! (via gp-util/path-normalize)
+;; all IPC paths must be normalized! (via common-util/path-normalize)
 
 (defn- set-missing-block-ids!
   "For every referred block in the content, fix their block ids in files if missing."
@@ -91,7 +91,7 @@
               (and (= "change" type)
                    (= dir repo-dir)
                    (not= (string/trim content) (string/trim db-content))
-                   (not (gp-config/local-asset? path)))
+                   (not (common-config/local-asset? path)))
               (when-not (and
                          (string/includes? path (str "/" (config/get-journals-directory) "/"))
                          (or

+ 7 - 7
src/main/frontend/handler/assets.cljs

@@ -4,10 +4,10 @@
             [frontend.util :as util]
             [frontend.config :as config]
             [frontend.mobile.util :as mobile-util]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [clojure.string :as string]
             [logseq.common.path :as path]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 (defn alias-enabled?
   []
@@ -49,7 +49,7 @@
     (and (string? full-path)
          (mobile-util/native-platform?))
     (string/replace-first
-     #"^(file://|assets://)" gp-config/capacitor-protocol-with-prefix)))
+     #"^(file://|assets://)" common-config/capacitor-protocol-with-prefix)))
 
 (defn resolve-asset-real-path-url
   [repo rpath]
@@ -57,8 +57,8 @@
                         (string/replace rpath #"^[.\/\\]+" ""))]
     (if config/publishing?
       (str "./" rpath)
-      (let [ret (let [rpath          (if-not (string/starts-with? rpath gp-config/local-assets-dir)
-                                       (path/path-join gp-config/local-assets-dir rpath)
+      (let [ret (let [rpath          (if-not (string/starts-with? rpath common-config/local-assets-dir)
+                                       (path/path-join common-config/local-assets-dir rpath)
                                        rpath)
                       encoded-chars? (boolean (re-find #"(?i)%[0-9a-f]{2}" rpath))
                       rpath          (if encoded-chars? (js/decodeURI rpath) rpath)
@@ -67,7 +67,7 @@
 
                   (if-let [[rpath' alias]
                            (and (alias-enabled?)
-                                (let [rpath' (string/replace rpath (re-pattern (str "^" gp-config/local-assets-dir "[\\/\\\\]+")) "")]
+                                (let [rpath' (string/replace rpath (re-pattern (str "^" common-config/local-assets-dir "[\\/\\\\]+")) "")]
                                   (and
                                    (string/starts-with? rpath' "@")
                                    (some->> (and (seq (get-alias-dirs))
@@ -94,7 +94,7 @@
       (path/absolute? path)
       (if (boolean (re-find #"(?i)%[0-9a-f]{2}" path)) ;; has encoded chars?
         ;; Incoming path might be already URL encoded. from PDF assets
-        (path/path-join "file://" (gp-util/safe-decode-uri-component path))
+        (path/path-join "file://" (common-util/safe-decode-uri-component path))
         (path/path-join "file://" path))
 
 

+ 8 - 8
src/main/frontend/handler/common/file.cljs

@@ -4,7 +4,7 @@
             [frontend.state :as state]
             [frontend.db :as db]
             [logseq.graph-parser :as graph-parser]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.fs.diff-merge :as diff-merge]
             [frontend.fs :as fs]
             [frontend.context.i18n :refer [t]]
@@ -23,17 +23,17 @@
 
 (defn- validate-existing-file
   "Handle the case when the file is already exists in db
-     Likely caused by renaming between caps and non-caps, then cause file system 
+     Likely caused by renaming between caps and non-caps, then cause file system
      bugs on some OS
-     e.g. on macOS, it doesn't fire the file change event when renaming between 
+     e.g. on macOS, it doesn't fire the file change event when renaming between
        caps and non-caps"
   [repo-url file-page file-path]
   (when-let [current-file (page-exists-in-another-file repo-url file-page file-path)]
     (when (not= file-path current-file)
       (cond
         ;; TODO: handle case sensitive file system
-        (= (gp-util/path-normalize (string/lower-case current-file))
-           (gp-util/path-normalize (string/lower-case file-path)))
+        (= (common-util/path-normalize (string/lower-case current-file))
+           (common-util/path-normalize (string/lower-case file-path)))
         ;; case renamed
         (when-let [file (db/pull [:file/path current-file])]
           (p/let [disk-content (fs/read-file "" current-file)]
@@ -70,7 +70,7 @@
 (defn- reset-file!*
   "Parse file considering diff-merge with local or remote file
    Decide how to treat the parsed file based on the file's triggering event
-   options - 
+   options -
      :fs/reset-event - the event that triggered the file update
      :fs/local-file-change - file changed on local disk
      :fs/remote-file-change - file changed on remote"
@@ -83,7 +83,7 @@
       (graph-parser/parse-file db-conn file-path content (assoc-in options [:extract-options :resolve-uuid-fn] diff-merge-uuids-2ways))
 
       ;; TODO Junyi: 3 ways to handle remote file change
-      ;; The file is on remote, so we should have 
+      ;; The file is on remote, so we should have
       ;;   1. a "common ancestor" file locally
       ;;     the worst case is that the file is not in db, so we should use the
       ;;     empty file as the common ancestor
@@ -105,7 +105,7 @@
                          :extract-options (merge
                                            {:user-config (state/get-config)
                                             :date-formatter (state/get-date-formatter)
-                                            :block-pattern (config/get-block-pattern (gp-util/get-format file-path))
+                                            :block-pattern (config/get-block-pattern (common-util/get-format file-path))
                                             :filename-format (state/get-filename-format repo-url)}
                                            ;; To avoid skipping the `:or` bounds for keyword destructuring
                                            (when (some? extracted-block-ids) {:extracted-block-ids extracted-block-ids})

+ 5 - 5
src/main/frontend/handler/common/page.cljs

@@ -20,7 +20,7 @@
             [frontend.util :as util]
             [logseq.db.frontend.schema :as db-schema]
             [logseq.graph-parser.block :as gp-block]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.text :as text]
             [lambdaisland.glogi :as log]
             [medley.core :as medley]
@@ -131,13 +131,13 @@
                         (text/page-ref-un-brackets!)
                         ;; remove `#` from tags
                         (string/replace #"^#+" ""))
-         title      (gp-util/remove-boundary-slashes title)
+         title      (common-util/remove-boundary-slashes title)
          page-name  (util/page-name-sanity-lc title)
          repo       (state/get-current-repo)
          with-uuid? (if (uuid? uuid) uuid true)] ;; FIXME: prettier validation
      (when (or (db/page-empty? repo page-name) rename?)
        (let [pages    (if split-namespace?
-                        (gp-util/split-namespace-pages title)
+                        (common-util/split-namespace-pages title)
                         [title])
              format   (or format (state/get-preferred-format))
              pages    (map (fn [page]
@@ -349,10 +349,10 @@
     (cond
       new-namespace?
       ;; update namespace
-      (let [namespace (first (gp-util/split-last "/" new-name))]
+      (let [namespace (first (common-util/split-last "/" new-name))]
         (when namespace
           (create! namespace {:redirect? false}) ;; create parent page if not exist, creation of namespace ref is handled in `create!`
-          (let [namespace-block (db/pull [:block/name (gp-util/page-name-sanity-lc namespace)])
+          (let [namespace-block (db/pull [:block/name (common-util/page-name-sanity-lc namespace)])
                 page-txs [{:db/id (:db/id page)
                            :block/namespace (:db/id namespace-block)}]]
             (db/transact! repo page-txs))))

+ 6 - 6
src/main/frontend/handler/conversion.cljs

@@ -2,7 +2,7 @@
 
 (ns frontend.handler.conversion
   "For conversion logic between old version and new version"
-  (:require [logseq.graph-parser.util :as gp-util]
+  (:require [logseq.common.util :as common-util]
             [frontend.util.fs :as fs-util]
             [frontend.handler.config :refer [set-config!]]
             [frontend.util :as util]))
@@ -23,7 +23,7 @@
      if no change of path happens"
   [format file-body prop-title]
   (let [page-title    (or prop-title
-                          (gp-util/title-parsing file-body format))
+                          (common-util/title-parsing file-body format))
         cur-file-body (fs-util/file-name-sanity page-title format)]
     (when-not (= file-body cur-file-body)
       {:status        :informal
@@ -37,8 +37,8 @@
      the file name for that page name under the current file naming rules,
      and the new title if no action applied, or `nil` if no break change happens"
   [old-format new-format file-body]
-  (let [new-title (gp-util/title-parsing file-body new-format) ;; Rename even the prop-title is provided.
-        old-title (gp-util/title-parsing file-body old-format)
+  (let [new-title (common-util/title-parsing file-body new-format) ;; Rename even the prop-title is provided.
+        old-title (common-util/title-parsing file-body old-format)
         target    (fs-util/file-name-sanity old-title new-format)]
     (when (not= new-title old-title)
       (if (not= target file-body)
@@ -53,7 +53,7 @@
          :changed-title new-title}))))
 
 ;; Register sanitization / parsing fns in:
-;; logseq.graph-parser.util (parsing only)
+;; logseq.common.util (parsing only)
 ;; frontend.util.fs         (sanitization only)
 ;; frontend.handler.conversion (both)
 ;;   - the special rule in `is-manual-title-prop?`
@@ -102,7 +102,7 @@
       :changed-title the new title} | nil"
   [page path old-format new-format]
   (let [prop-title (get-in page [:block/properties :title])
-        file-body  (gp-util/path->file-body path)
+        file-body  (common-util/path->file-body path)
         journal?   (:block/journal? page)
         manual-prop-title? (is-manual-title-prop? old-format file-body prop-title)]
     (cond

+ 9 - 9
src/main/frontend/handler/db_based/property.cljs

@@ -9,7 +9,7 @@
             [frontend.modules.outliner.core :as outliner-core]
             [frontend.util :as util]
             [frontend.state :as state]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.db.sqlite.util :as sqlite-util]
             [logseq.db.frontend.property.type :as db-property-type]
             [logseq.db.frontend.property.util :as db-property-util]
@@ -61,7 +61,7 @@
       (fail-parse-long v-str) :number
       (fail-parse-double v-str) :number
       (util/uuid-string? v-str) :page
-      (gp-util/url? v-str) :url
+      (common-util/url? v-str) :url
       (contains? #{"true" "false"} (string/lower-case v-str)) :checkbox
       :else :default)
     (catch :default _e
@@ -94,7 +94,7 @@
 
 (defn upsert-property!
   [repo k-name schema {:keys [property-uuid]}]
-  (let [property (db/entity [:block/name (gp-util/page-name-sanity-lc k-name)])
+  (let [property (db/entity [:block/name (common-util/page-name-sanity-lc k-name)])
         k-name (name k-name)
         property-uuid (or (:block/uuid property) property-uuid (db/new-block-id))]
     (when property
@@ -120,7 +120,7 @@
   [repo block-id k-name values _opts]
   (let [block (db/entity repo [:block/uuid block-id])
         k-name (name k-name)
-        property (db/pull repo '[*] [:block/name (gp-util/page-name-sanity-lc k-name)])
+        property (db/pull repo '[*] [:block/name (common-util/page-name-sanity-lc k-name)])
         values (remove nil? values)
         property-uuid (or (:block/uuid property) (db/new-block-id))
         property-schema (:block/schema property)
@@ -174,7 +174,7 @@
   [v]
   (when (and (string? v)
              (util/tag? (string/trim v)))
-    (let [tag-without-hash (gp-util/safe-subs (string/trim v) 1)
+    (let [tag-without-hash (common-util/safe-subs (string/trim v) 1)
           tag (or (page-ref/get-page-name tag-without-hash) tag-without-hash)]
       (when-not (string/blank? tag)
         (let [e (db/entity [:block/name (util/page-name-sanity-lc tag)])
@@ -194,7 +194,7 @@
   [repo block-id k-name v {:keys [old-value] :as opts}]
   (let [block (db/entity repo [:block/uuid block-id])
         k-name (name k-name)
-        property (db/pull repo '[*] [:block/name (gp-util/page-name-sanity-lc k-name)])
+        property (db/pull repo '[*] [:block/name (common-util/page-name-sanity-lc k-name)])
         property-uuid (or (:block/uuid property) (db/new-block-id))
         property-schema (:block/schema property)
         {:keys [type cardinality]} property-schema
@@ -305,7 +305,7 @@
           (let [tx-data (cond-> {:block/uuid property-uuid}
                           property-name (merge
                                          {:block/original-name property-name
-                                          :block/name (gp-util/page-name-sanity-lc property-name)})
+                                          :block/name (common-util/page-name-sanity-lc property-name)})
                           property-schema (assoc :block/schema
                                                  ;; a property must have a :type when making schema changes
                                                  (merge {:type :default}
@@ -322,7 +322,7 @@
   (when-let [class (db/entity repo [:block/uuid class-uuid])]
     (when (contains? (:block/type class) "class")
       (let [k-name (name k-name)
-            property (db/pull repo '[*] [:block/name (gp-util/page-name-sanity-lc k-name)])
+            property (db/pull repo '[*] [:block/name (common-util/page-name-sanity-lc k-name)])
             property-uuid (or (:block/uuid property) (db/new-block-id))
             property-type (get-in property [:block/schema :type])
             {:keys [properties] :as class-schema} (:block/schema class)
@@ -363,7 +363,7 @@
   "Notice that this works only for properties with cardinality equals to `one`."
   [repo block-ids k-name v]
   (let [k-name (name k-name)
-        property (db/entity repo [:block/name (gp-util/page-name-sanity-lc k-name)])
+        property (db/entity repo [:block/name (common-util/page-name-sanity-lc k-name)])
         property-uuid (or (:block/uuid property) (db/new-block-id))
         type (:type (:block/schema property))
         infer-schema (when-not type (infer-schema-from-input-string v))

+ 3 - 3
src/main/frontend/handler/db_based/property/util.cljs

@@ -3,7 +3,7 @@
   (:require [frontend.db.utils :as db-utils]
             [frontend.state :as state]
             [logseq.db.frontend.property :as db-property]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [clojure.set :as set]))
 
 (defn get-property-name
@@ -21,7 +21,7 @@
   "Get a user property's uuid given its unsanitized name"
   ([property-name] (get-user-property-uuid (state/get-current-repo) property-name))
   ([repo property-name]
-   (:block/uuid (db-utils/entity repo [:block/name (gp-util/page-name-sanity-lc (name property-name))]))))
+   (:block/uuid (db-utils/entity repo [:block/name (common-util/page-name-sanity-lc (name property-name))]))))
 
 (defonce *hidden-built-in-properties (atom #{}))
 
@@ -59,4 +59,4 @@
   "Returns property value if the given entity is type 'closed value' or nil"
   [ent]
   (when (contains? (:block/type ent) "closed value")
-    (get-in ent [:block/schema :value])))
+    (get-in ent [:block/schema :value])))

+ 3 - 3
src/main/frontend/handler/draw.cljs

@@ -8,7 +8,7 @@
             [frontend.handler.file :as file-handler]
             [frontend.state :as state]
             [frontend.util :as util]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [promesa.core :as p]))
 
 (defn create-draws-directory!
@@ -16,7 +16,7 @@
   (when repo
     (let [repo-dir (config/get-repo-dir repo)]
       (util/p-handle
-       (fs/mkdir! (str repo-dir (str "/" gp-config/default-draw-directory)))
+       (fs/mkdir! (str repo-dir (str "/" common-config/default-draw-directory)))
        (fn [_result] nil)
        (fn [_error] nil)))))
 
@@ -63,6 +63,6 @@
   [current-file]
   (when-let [repo (state/get-current-repo)]
     (p/let [exists? (fs/file-exists? (config/get-repo-dir repo)
-                                     (str gp-config/default-draw-directory current-file))]
+                                     (str common-config/default-draw-directory current-file))]
       (when-not exists?
         (save-excalidraw! current-file default-content)))))

+ 3 - 3
src/main/frontend/handler/editor.cljs

@@ -59,7 +59,7 @@
             [logseq.graph-parser.property :as gp-property]
             [logseq.graph-parser.text :as text]
             [logseq.graph-parser.utf8 :as utf8]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [logseq.graph-parser.util.page-ref :as page-ref]
             [promesa.core :as p]
@@ -1331,7 +1331,7 @@
                  elem (and input-id (gdom/getElement input-id))
                  db-content (:block/content db-block)
                  db-content-without-heading (and db-content
-                                                 (gp-util/safe-subs db-content (:block/level db-block)))
+                                                 (common-util/safe-subs db-content (:block/level db-block)))
                  value (if (= (:block/uuid current-block) (:block/uuid block))
                          (:block/content current-block)
                          (and elem (gobj/get elem "value")))]
@@ -3450,7 +3450,7 @@
                  (string/includes? content "#+END_QUERY"))
         (let [ast (mldoc/->edn (string/trim content) (or (:block/format entity) :markdown))
               q (mldoc/extract-first-query-from-ast ast)]
-          (some? (:query (gp-util/safe-read-string q))))))))
+          (some? (:query (common-util/safe-read-string q))))))))
 
 (defn collapsable?
   ([block-id]

+ 2 - 2
src/main/frontend/handler/events.cljs

@@ -70,7 +70,7 @@
             [frontend.util.persist-var :as persist-var]
             [goog.dom :as gdom]
             [logseq.db.frontend.schema :as db-schema]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [promesa.core :as p]
             [rum.core :as rum]
             [frontend.db.listener :as db-listener]
@@ -881,7 +881,7 @@
                         (for [[file error] parse-errors]
                           (let [data (ex-data error)]
                             (cond
-                             (and (gp-config/whiteboard? file)
+                             (and (common-config/whiteboard? file)
                                   (= :transact/upsert (:error data))
                                   (uuid? (last (:assertion data))))
                              (rum/with-key (file-id-conflict-item repo file data) file)

+ 2 - 2
src/main/frontend/handler/export/common.cljs

@@ -12,7 +12,7 @@
             [frontend.modules.outliner.tree :as outliner-tree]
             [frontend.state :as state]
             [frontend.util :as util :refer [concatv mapcatv removev]]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.handler.property.util :as pu]
             [malli.core :as m]
             [malli.util :as mu]))
@@ -210,7 +210,7 @@
                                                [?e2 :block/file ?e]
                                                [?e2 :block/name ?n]
                                                [?e2 :block/original-name ?n2]] db path)
-                                 :format (gp-util/get-format path)})))))
+                                 :format (common-util/get-format path)})))))
 
 ;;; utils (ends)
 

+ 8 - 8
src/main/frontend/handler/file.cljs

@@ -15,13 +15,13 @@
             [frontend.schema.handler.repo-config :as repo-config-schema]
             [frontend.state :as state]
             [frontend.util :as util]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [electron.ipc :as ipc]
             [lambdaisland.glogi :as log]
             [promesa.core :as p]
             [frontend.mobile.util :as mobile-util]
             [logseq.common.path :as path]
-            [logseq.graph-parser.config :as gp-config]))
+            [logseq.common.config :as common-config]))
 
 ;; TODO: extract all git ops using a channel
 
@@ -44,17 +44,17 @@
   [files formats]
   (filter
    (fn [file]
-     (let [format (gp-util/get-format file)]
+     (let [format (common-util/get-format file)]
        (contains? formats format)))
    files))
 
 (defn- only-text-formats
   [files]
-  (keep-formats files (gp-config/text-formats)))
+  (keep-formats files (common-config/text-formats)))
 
 (defn- only-image-formats
   [files]
-  (keep-formats files (gp-config/img-formats)))
+  (keep-formats files (common-config/img-formats)))
 
 (defn load-files-contents!
   [repo-url files ok-handler]
@@ -68,7 +68,7 @@
                                         (seq images)
                                         (merge (zipmap images (repeat (count images) ""))))
                         file-contents (for [[file content] file-contents]
-                                        {:file/path (gp-util/path-normalize file)
+                                        {:file/path (common-util/path-normalize file)
                                          :file/content content})]
                     (ok-handler file-contents))))
         (p/catch (fn [error]
@@ -148,7 +148,7 @@
                            re-render-root? false
                            from-disk? false
                            skip-compare? false}}]
-  (let [path (gp-util/path-normalize path)
+  (let [path (common-util/path-normalize path)
         config-file? (= path "logseq/config.edn")
         _ (when config-file?
             (detect-deprecations path content))
@@ -204,7 +204,7 @@
   [repo files {:keys [finish-handler]} file->content]
   (let [write-file-f (fn [[path content]]
                        (when path
-                         (let [path (gp-util/path-normalize path)
+                         (let [path (common-util/path-normalize path)
                                original-content (get file->content path)]
                           (-> (p/let [_ (or
                                          (util/electron?)

+ 3 - 3
src/main/frontend/handler/file_based/property.cljs

@@ -6,7 +6,7 @@
             [frontend.modules.outliner.core :as outliner-core]
             [frontend.modules.outliner.ui :as ui-outliner-tx]
             [frontend.state :as state]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 (defn insert-property
   [format content key value & args]
@@ -35,9 +35,9 @@
                  properties (:block/properties block)
                  properties-text-values (:block/properties-text-values block)
                  properties (-> (merge properties new-properties)
-                                gp-util/remove-nils-non-nested)
+                                common-util/remove-nils-non-nested)
                  properties-text-values (-> (merge properties-text-values new-properties)
-                                            gp-util/remove-nils-non-nested)
+                                            common-util/remove-nils-non-nested)
                  property-ks (->> (concat (:block/properties-order block)
                                           (map second items))
                                   (filter (set (keys properties)))

+ 5 - 5
src/main/frontend/handler/graph.cljs

@@ -8,7 +8,7 @@
             [frontend.util :as util]
             [frontend.handler.property.util :as pu]
             [frontend.config :as config]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 (defn- build-links
   [links]
@@ -90,8 +90,8 @@
         current-page (or (:block/name (db/get-current-page)) "")]
     (when-let [repo (state/get-current-repo)]
       (let [relation (db/get-pages-relation repo journal?)
-            tagged-pages (map (fn [[x y]] [x (gp-util/page-name-sanity-lc y)]) (db/get-all-tagged-pages repo))
-            namespaces (map (fn [[x y]] [x (gp-util/page-name-sanity-lc y)]) (db/get-all-namespace-relation repo))
+            tagged-pages (map (fn [[x y]] [x (common-util/page-name-sanity-lc y)]) (db/get-all-tagged-pages repo))
+            namespaces (map (fn [[x y]] [x (common-util/page-name-sanity-lc y)]) (db/get-all-namespace-relation repo))
             tags (set (map second tagged-pages))
             full-pages (db/get-all-pages repo)
             full-pages-map (into {} (map (juxt :block/name identity) full-pages))
@@ -144,7 +144,7 @@
             tags (remove #(= page %) tags)
             ref-pages (db/get-page-referenced-pages repo page)
             mentioned-pages (db/get-pages-that-mentioned-page repo page show-journal)
-            namespaces (map (fn [[x y]] [x (gp-util/page-name-sanity-lc y)]) (db/get-all-namespace-relation repo))
+            namespaces (map (fn [[x y]] [x (common-util/page-name-sanity-lc y)]) (db/get-all-namespace-relation repo))
             links (concat
                    namespaces
                    (map (fn [[p _aliases]]
@@ -196,7 +196,7 @@
   (let [dark? (= "dark" theme)]
     (when-let [repo (state/get-current-repo)]
       (let [ref-blocks (db/get-block-referenced-blocks block)
-            namespaces (map (fn [[x y]] [x (gp-util/page-name-sanity-lc y)]) (db/get-all-namespace-relation repo))
+            namespaces (map (fn [[x y]] [x (common-util/page-name-sanity-lc y)]) (db/get-all-namespace-relation repo))
             links (concat
                    (map (fn [[p _aliases]]
                           [block p]) ref-blocks)

+ 2 - 2
src/main/frontend/handler/import.cljs

@@ -13,7 +13,7 @@
             [frontend.format.mldoc :as mldoc]
             [frontend.format.block :as block]
             [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.whiteboard :as gp-whiteboard]
             [logseq.graph-parser.date-time-util :as date-time-util]
             [frontend.handler.page :as page-handler]
@@ -39,7 +39,7 @@
                                       (when journal?
                                         (date/journal-title->default title))
                                       (string/replace title "/" "-"))
-                               title (-> (gp-util/page-name-sanity title)
+                               title (-> (common-util/page-name-sanity title)
                                          (string/replace "\n" " "))
                                path (str (if journal?
                                            (config/get-journals-directory)

+ 8 - 8
src/main/frontend/handler/page.cljs

@@ -30,8 +30,8 @@
             [goog.object :as gobj]
             [lambdaisland.glogi :as log]
             [logseq.db.frontend.property :as db-property]
-            [logseq.graph-parser.config :as gp-config]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.config :as common-config]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.page-ref :as page-ref]
             [promesa.core :as p]
             [logseq.common.path :as path]
@@ -56,9 +56,9 @@
   (when-let [s (if journal?
                  (date/journal-title->default title)
                  ;; legacy in org-mode format, don't escape slashes except bug reported
-                 (gp-util/page-name-sanity (string/lower-case title)))]
+                 (common-util/page-name-sanity (string/lower-case title)))]
     ;; Win10 file path has a length limit of 260 chars
-    (gp-util/safe-subs s 0 200)))
+    (common-util/safe-subs s 0 200)))
 
 (defn toggle-favorite! []
   ;; NOTE: in journals or settings, current-page is nil
@@ -156,7 +156,7 @@
        (remove (fn [p]
                  (let [name (:block/name p)]
                    (or (util/uuid-string? name)
-                       (gp-config/draw? name)
+                       (common-config/draw? name)
                        (db/built-in-pages-names (string/upper-case name))
                        (db-property/built-in-properties-keys-str name)))))
        (common-handler/fix-pages-timestamps)))
@@ -204,9 +204,9 @@
         q (or
            (editor-handler/get-selected-text)
            (when hashtag?
-             (gp-util/safe-subs edit-content pos current-pos))
+             (common-util/safe-subs edit-content pos current-pos))
            (when (> (count edit-content) current-pos)
-             (gp-util/safe-subs edit-content pos current-pos)))
+             (common-util/safe-subs edit-content pos current-pos)))
         db-based? (config/db-based-graph? (state/get-current-repo))]
     (if hashtag?
       (fn [chosen e]
@@ -216,7 +216,7 @@
               chosen (-> chosen
                          (string/replace-first (str (t :new-class) " ") "")
                          (string/replace-first (str (t :new-page) " ") ""))
-              wrapped? (= page-ref/left-brackets (gp-util/safe-subs edit-content (- pos 2) pos))
+              wrapped? (= page-ref/left-brackets (common-util/safe-subs edit-content (- pos 2) pos))
               wrapped-tag (if (and (util/safe-re-find #"\s+" chosen) (not wrapped?))
                             (page-ref/->page-ref chosen)
                             chosen)

+ 7 - 7
src/main/frontend/handler/paste.cljs

@@ -2,7 +2,7 @@
   (:require [frontend.state :as state]
             [frontend.db :as db]
             [frontend.format.block :as block]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.block :as gp-block]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [clojure.string :as string]
@@ -64,7 +64,7 @@
 (defn- get-whiteboard-tldr-from-text
   [text]
   (when-let [matched-text (util/safe-re-find #"<whiteboard-tldr>(.*)</whiteboard-tldr>"
-                                             (gp-util/safe-decode-uri-component text))]
+                                             (common-util/safe-decode-uri-component text))]
     (try-parse-as-json (second matched-text))))
 
 (defn- selection-within-link?
@@ -94,7 +94,7 @@
                                           "web application/logseq"))))
           blocks-str (when blocks-blob (.text blocks-blob))]
          (when blocks-str
-           (gp-util/safe-read-string blocks-str))))
+           (common-util/safe-read-string blocks-str))))
 
 (defn- markdown-blocks?
   [text]
@@ -126,8 +126,8 @@
                           ;; text should always be prepared block-ref generated in tldr
                           text)
         {:keys [selection] :as selection-and-format} (editor-handler/get-selection-and-format)
-        text-url? (gp-util/url? text)
-        selection-url? (gp-util/url? selection)]
+        text-url? (common-util/url? text)
+        selection-url? (common-util/url? selection)]
     (cond
       (not (string/blank? shape-refs-text))
       (commands/simple-insert! input-id shape-refs-text nil)
@@ -160,7 +160,7 @@
                         (if (string/blank? result) nil result))
             text-blocks? (if (= format :markdown) markdown-blocks? org-blocks?)
             text' (or html-text
-                      (when (gp-util/url? text)
+                      (when (common-util/url? text)
                         (wrap-macro-url text))
                       text)
             blocks? (text-blocks? text')]
@@ -197,7 +197,7 @@
   (utils/getClipText
    (fn [clipboard-data]
      (when-let [_ (state/get-input)]
-       (if (gp-util/url? clipboard-data)
+       (if (common-util/url? clipboard-data)
          (if (string/blank? (util/get-selected-text))
            (editor-handler/insert (or (wrap-macro-url clipboard-data) clipboard-data) true)
            (editor-handler/html-link-format! clipboard-data))

+ 2 - 2
src/main/frontend/handler/property/util.cljs

@@ -4,7 +4,7 @@
   compatible with file graphs"
   (:require [frontend.config :as config]
             [frontend.state :as state]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.db :as db]
             [frontend.util :as util]
             [logseq.db.frontend.property :as db-property]))
@@ -28,7 +28,7 @@
   ;; Get a page's uuid given its unsanitized name
   ([property-name] (get-page-uuid (state/get-current-repo) property-name))
   ([repo property-name]
-   (:block/uuid (db/entity repo [:block/name (gp-util/page-name-sanity-lc (name property-name))]))))
+   (:block/uuid (db/entity repo [:block/name (common-util/page-name-sanity-lc (name property-name))]))))
 
 (defn get-pid
   "Get a property's id (name or uuid) given its name. For file and db graphs"

+ 2 - 2
src/main/frontend/handler/repo.cljs

@@ -28,7 +28,7 @@
             [shadow.resource :as rc]
             [frontend.db.persist :as db-persist]
             [logseq.graph-parser :as graph-parser]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [logseq.db.sqlite.create-graph :as sqlite-create-graph]
             [electron.ipc :as ipc]
             [cljs-bean.core :as bean]
@@ -204,7 +204,7 @@
       (async/go-loop [tx []]
         (if-let [item (async/<! chan)]
           (let [[idx file] item
-                whiteboard? (gp-config/whiteboard? (:file/path file))
+                whiteboard? (common-config/whiteboard? (:file/path file))
                 yield-for-ui? (or (not large-graph?)
                                   (zero? (rem idx 10))
                                   (<= (- total idx) 10)

+ 2 - 2
src/main/frontend/handler/shell.cljs

@@ -2,7 +2,7 @@
   "Git related handler fns"
   (:require [electron.ipc :as ipc]
             [clojure.string :as string]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.handler.notification :as notification]
             [promesa.core :as p]
             [frontend.db :as db]
@@ -42,7 +42,7 @@
   [command]
   (let [[command args]
         (if (and (string? command) (string/includes? command " "))
-          (gp-util/split-first " " command)
+          (common-util/split-first " " command)
           [command ""])
         command (and command (string/lower-case command))
         args (-> args str string/trim)]

+ 4 - 4
src/main/frontend/handler/web/nfs.cljs

@@ -19,7 +19,7 @@
             [frontend.util.fs :as util-fs]
             [goog.object :as gobj]
             [lambdaisland.glogi :as log]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [promesa.core :as p]
             [frontend.db.listener :as db-listener]
             [frontend.persist-db :as persist-db]))
@@ -52,7 +52,7 @@
      ;; TODO(andelf): use the same structure for both fields
      (mobile-util/native-platform?)
      (map (fn [{:keys [path content size mtime]}]
-            {:file/path             (gp-util/path-normalize path)
+            {:file/path             (common-util/path-normalize path)
              :file/last-modified-at mtime
              :file/size             size
              :file/content content})
@@ -61,7 +61,7 @@
      (util/electron?)
      (map (fn [{:keys [path stat content]}]
             (let [{:keys [mtime size]} stat]
-              {:file/path             (gp-util/path-normalize path)
+              {:file/path             (common-util/path-normalize path)
                :file/last-modified-at mtime
                :file/size             size
                :file/content content}))
@@ -70,7 +70,7 @@
      nfs?
      (map (fn [{:keys [path content size mtime type] :as file-obj}]
             (merge file-obj
-                   {:file/path             (gp-util/path-normalize path)
+                   {:file/path             (common-util/path-normalize path)
                     :file/last-modified-at mtime
                     :file/size             size
                     :file/type             type

+ 2 - 2
src/main/frontend/handler/whiteboard.cljs

@@ -13,7 +13,7 @@
             [frontend.config :as config]
             [frontend.storage :as storage]
             [frontend.util :as util]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.whiteboard :as gp-whiteboard]
             [promesa.core :as p]
             [goog.object :as gobj]
@@ -301,7 +301,7 @@
   []
   (p/let [^js res (js/fetch "./whiteboard/onboarding.edn") ;; do we need to cache it?
           text (.text res)
-          edn (gp-util/safe-read-string text)]
+          edn (common-util/safe-read-string text)]
     edn))
 
 (defn clone-whiteboard-from-edn

+ 2 - 2
src/main/frontend/mobile/deeplink.cljs

@@ -10,7 +10,7 @@
    [frontend.mobile.intent :as intent]
    [frontend.state :as state]
    [frontend.util.text :as text-util]
-   [logseq.graph-parser.util :as gp-util]))
+   [logseq.common.util :as common-util]))
 
 (def *link-to-another-graph (atom false))
 
@@ -73,7 +73,7 @@
                                    [(keyword key) (.get search-params key)])
                                  ["title" "url" "type" "payload"]))]
         (if (:payload result)
-          (let [raw (gp-util/safe-decode-uri-component (:payload result))
+          (let [raw (common-util/safe-decode-uri-component (:payload result))
                 payload (-> raw
                             js/JSON.parse
                             (js->clj :keywordize-keys true))]

+ 6 - 6
src/main/frontend/mobile/intent.cljs

@@ -17,8 +17,8 @@
             [frontend.util.fs :as fs-util]
             [goog.string :as gstring]
             [lambdaisland.glogi :as log]
-            [logseq.graph-parser.config :as gp-config]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.config :as common-config]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.util.page-ref :as page-ref]
             [promesa.core :as p]))
 
@@ -89,10 +89,10 @@
   (p/let [time (date/get-current-time)
           date-ref-name (date/today)
           title (some-> (or title (node-path/basename url))
-                        gp-util/safe-decode-uri-component
+                        common-util/safe-decode-uri-component
                         util/node-path.name
                         ;; make the title more user friendly
-                        gp-util/page-name-sanity)
+                        common-util/page-name-sanity)
           path (node-path/join (config/get-repo-dir (state/get-current-repo))
                                (config/get-pages-directory)
                                (str (js/encodeURI (fs-util/file-name-sanity title)) (node-path/extname url)))
@@ -127,7 +127,7 @@
           format (db/get-page-format page)
           application-type (last (string/split type "/"))
           content (cond
-                    (gp-config/mldoc-support? application-type)
+                    (common-config/mldoc-support? application-type)
                     (embed-text-file url title)
 
                     (contains? (set/union config/doc-formats config/media-formats)
@@ -158,7 +158,7 @@
 
                       :else
                       (if (mobile-util/native-ios?)
-                        (gp-util/safe-decode-uri-component v)
+                        (common-util/safe-decode-uri-component v)
                         v))])))
 
 (defn- handle-asset-file [url format]

+ 2 - 2
src/main/frontend/modules/outliner/core.cljs

@@ -7,7 +7,7 @@
             [frontend.modules.outliner.datascript :as ds]
             [logseq.outliner.tree :as otree]
             [frontend.modules.outliner.utils :as outliner-u]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [cljs.spec.alpha :as s]
             [logseq.db :as ldb]
             [frontend.worker.mldoc :as mldoc]
@@ -300,7 +300,7 @@
           m (-> data'
                 (dissoc :block/children :block/meta :block.temp/top? :block.temp/bottom?
                         :block/title :block/body :block/level)
-                gp-util/remove-nils
+                common-util/remove-nils
                 block-with-updated-at
                 fix-tag-ids)
           db @conn

+ 2 - 2
src/main/frontend/modules/outliner/datascript.cljs

@@ -1,5 +1,5 @@
 (ns frontend.modules.outliner.datascript
-  (:require [logseq.graph-parser.util :as gp-util]
+  (:require [logseq.common.util :as common-util]
             [logseq.graph-parser.util.block-ref :as block-ref]
             [frontend.worker.util :as worker-util]
             [logseq.db.sqlite.util :as sqlite-util]
@@ -17,7 +17,7 @@
 
 (defn- remove-nil-from-transaction
   [txs]
-  (some->> (gp-util/remove-nils txs)
+  (some->> (common-util/remove-nils txs)
            (map (fn [x]
                   (if (map? x)
                     (update-vals x (fn [v]

+ 2 - 2
src/main/frontend/search.cljs

@@ -9,7 +9,7 @@
             [promesa.core :as p]
             [frontend.search.browser :as search-browser]
             [frontend.search.fuzzy :as fuzzy]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [frontend.db.async :as db-async]
             [frontend.config :as config]
             [logseq.db.frontend.property :as db-property]
@@ -44,7 +44,7 @@
    (when-let [repo (state/get-current-repo)]
      (let [q (fuzzy/clean-str q)]
       (when-not (string/blank? q)
-        (p/let [mldoc-exts (set (map name gp-config/mldoc-support-formats))
+        (p/let [mldoc-exts (set (map name common-config/mldoc-support-formats))
                 result (db-async/<get-files repo)
                 files (->> result
                            (map first)

+ 2 - 2
src/main/frontend/state.cljs

@@ -15,7 +15,7 @@
             [frontend.util.cursor :as cursor]
             [goog.dom :as gdom]
             [goog.object :as gobj]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [medley.core :as medley]
             [promesa.core :as p]
             [rum.core :as rum]))
@@ -518,7 +518,7 @@ should be done through this fn in order to get global config and config defaults
 
 (defn get-date-formatter
   []
-  (gp-config/get-date-formatter (get-config)))
+  (common-config/get-date-formatter (get-config)))
 
 (defn shortcuts []
   (:shortcuts (get-config)))

+ 5 - 5
src/main/frontend/util.cljc

@@ -18,7 +18,7 @@
             [clojure.pprint]
             [dommy.core :as d]
             [frontend.mobile.util :as mobile-util]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [goog.dom :as gdom]
             [goog.object :as gobj]
             [goog.string :as gstring]
@@ -836,7 +836,7 @@
    (defn copy-to-clipboard!
      [text & {:keys [html blocks owner-window]}]
      (let [data (clj->js
-                 (gp-util/remove-nils-non-nested
+                 (common-util/remove-nils-non-nested
                   {:text text
                    :html html
                    :blocks (when (seq blocks) (pr-str blocks))}))]
@@ -1022,8 +1022,8 @@
 
 #?(:cljs
    (def page-name-sanity-lc
-     "Delegate to gp-util to loosely couple app usages to graph-parser"
-     gp-util/page-name-sanity-lc))
+     "Delegate to common-util to loosely couple app usages to graph-parser"
+     common-util/page-name-sanity-lc))
 
 #?(:cljs
    (def safe-page-name-sanity-lc worker-util/safe-page-name-sanity-lc))
@@ -1069,7 +1069,7 @@
      (and
       (string? file)
       (string/includes? file ".")
-      (some-> (gp-util/path->file-ext file) string/lower-case))))
+      (some-> (common-util/path->file-ext file) string/lower-case))))
 
 (defn get-dir-and-basename
   [path]

+ 2 - 2
src/main/frontend/util/fs.cljs

@@ -3,7 +3,7 @@
 (ns frontend.util.fs
   "Misc util fns built on top of frontend.fs"
   (:require ["path" :as node-path]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [clojure.string :as string]
             [frontend.state :as state]
             [frontend.fs :as fs]
@@ -82,7 +82,7 @@
   (and (string? page-name)
        (let [filename-format (state/get-filename-format)
              file-name  (file-name-sanity page-name filename-format)
-             page-name' (gp-util/title-parsing file-name filename-format)
+             page-name' (common-util/title-parsing file-name filename-format)
              result     (or (not= page-name page-name')
                             (include-reserved-chars? file-name))]
          result)))

+ 2 - 2
src/main/frontend/worker/date.cljs

@@ -1,7 +1,7 @@
 (ns frontend.worker.date
   "Date related fns that used by worker"
   (:require [cljs-time.format :as tf]
-            [logseq.graph-parser.util :as gp-util]))
+            [logseq.common.util :as common-util]))
 
 (def default-journal-filename-formatter (tf/formatter "yyyy_MM_dd"))
 
@@ -60,7 +60,7 @@
    Return format: 20220812T000000"
   [title date-formatter]
   (and title
-       (normalize-date (gp-util/capitalize-all title) date-formatter)))
+       (normalize-date (common-util/capitalize-all title) date-formatter)))
 
 (defn valid-journal-title?
   "This is a loose rule, requires double check by journal-title->custom-format.

+ 3 - 2
src/main/frontend/worker/file.cljs

@@ -12,7 +12,8 @@
             [logseq.db :as ldb]
             [malli.core :as m]
             [frontend.worker.state :as state]
-            [goog.object :as gobj]))
+            [goog.object :as gobj]
+            [logseq.db.sqlite.util :as sqlite-util]))
 
 (def *writes file/*writes)
 
@@ -93,7 +94,7 @@
 
 (defn sync-to-file
   [repo page-id tx-meta]
-  (when (and (worker-util/local-file-based-graph? repo)
+  (when (and (sqlite-util/local-file-based-graph? repo)
              page-id
              (not (:created-from-journal-template? tx-meta))
              (not (:delete-files? tx-meta)))

+ 3 - 3
src/main/frontend/worker/file/property_util.cljs

@@ -1,7 +1,7 @@
 (ns frontend.worker.file.property-util
   "Property fns needed by the rest of the app and not graph-parser"
   (:require [clojure.string :as string]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.property :as gp-property :refer [properties-start properties-end]]
             [frontend.worker.mldoc :as worker-mldoc]
             [frontend.worker.util :as util]))
@@ -70,7 +70,7 @@
                           middle (doall
                                   (->> (subvec lines (inc start-idx) end-idx)
                                        (mapv (fn [text]
-                                               (let [[k v] (gp-util/split-first ":" (subs text 1))]
+                                               (let [[k v] (common-util/split-first ":" (subs text 1))]
                                                  (if (and k v)
                                                    (let [key-exists? (= k key)
                                                          _ (when key-exists? (reset! exists? true))
@@ -93,7 +93,7 @@
                                                     (if (property-f (first lines))
                                                       (let [lines (doall
                                                                    (mapv (fn [text]
-                                                                           (let [[k v] (gp-util/split-first sym text)]
+                                                                           (let [[k v] (common-util/split-first sym text)]
                                                                              (if (and k v)
                                                                                (let [key-exists? (= k key)
                                                                                      _ (when key-exists? (reset! exists? true))

+ 4 - 4
src/main/frontend/worker/file/util.cljs

@@ -1,7 +1,7 @@
 (ns frontend.worker.file.util
   "File name fns"
   (:require [clojure.string :as string]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.worker.util :as util]))
 
 ;; Update repo/invalid-graph-name-warning if characters change
@@ -54,14 +54,14 @@
    Use triple lowbar as namespace separator"
   [title]
   (some-> title
-          gp-util/page-name-sanity ;; we want to preserve the case sensitive nature of most file systems, don't lowercase
-          (string/replace gp-util/url-encoded-pattern encode-url-percent) ;; pre-encode % in title on demand
+          common-util/page-name-sanity ;; we want to preserve the case sensitive nature of most file systems, don't lowercase
+          (string/replace common-util/url-encoded-pattern encode-url-percent) ;; pre-encode % in title on demand
           (string/replace reserved-chars-pattern url-encode-file-name)
           (escape-windows-reserved-filebodies) ;; do this before the lowbar encoding to avoid ambiguity
           (escape-namespace-slashes-and-multilowbars)))
 
 ;; Register sanitization / parsing fns in:
-;; logseq.graph-parser.util (parsing only)
+;; logseq.common.util (parsing only)
 ;; frontend.util.fs         (sanitization only)
 ;; frontend.handler.conversion (both)
 (defn file-name-sanity

+ 4 - 3
src/main/frontend/worker/search.cljs

@@ -7,7 +7,8 @@
             [goog.object :as gobj]
             [datascript.core :as d]
             [frontend.search.fuzzy :as fuzzy]
-            [frontend.worker.util :as util]))
+            [frontend.worker.util :as util]
+            [logseq.db.sqlite.util :as sqlite-util]))
 
 ;; TODO: use sqlite for fuzzy search
 (defonce indices (atom nil))
@@ -242,7 +243,7 @@
             :as block}]
   (let [page? (some? name)
         block? (nil? name)
-        db-based? (util/db-based-graph? repo)]
+        db-based? (sqlite-util/db-based-graph? repo)]
     (when-not (or
                (and page? name (whiteboard-page? db name))
                (and block? (> (count content) 10000))
@@ -352,7 +353,7 @@
                                     (filter #(= :block/uuid (:a %)))
                                     (map :e)
                                     (set))
-          blocks-to-add-set' (if (and (util/db-based-graph? repo) (seq blocks-to-add-set))
+          blocks-to-add-set' (if (and (sqlite-util/db-based-graph? repo) (seq blocks-to-add-set))
                                (->> blocks-to-add-set
                                     (mapcat (fn [id] (map :db/id (:block/_refs (d/entity db-after id)))))
                                     (concat blocks-to-add-set)

+ 5 - 17
src/main/frontend/worker/util.cljs

@@ -4,7 +4,7 @@
   (:require [clojure.string :as string]
             ["remove-accents" :as removeAccents]
             [medley.core :as medley]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [goog.string :as gstring]
             [clojure.core.async :as async]
             [cljs.core.async.impl.channels :refer [ManyToManyChannel]]
@@ -12,18 +12,6 @@
             [cljs-time.core :as t]
             [cljs-bean.core :as bean]))
 
-(defonce db-version-prefix "logseq_db_")
-(defonce local-db-prefix "logseq_local_")
-(defn db-based-graph?
-  [s]
-  (boolean
-   (and (string? s)
-        (string/starts-with? s db-version-prefix))))
-(defn local-file-based-graph?
-  [s]
-  (and (string? s)
-       (string/starts-with? s local-db-prefix)))
-
 (defn search-normalize
      "Normalize string for searching (loose)"
      [s remove-accents?]
@@ -33,13 +21,13 @@
            (removeAccents normalize-str)
            normalize-str))))
 
-(def safe-re-find gp-util/safe-re-find)
+(def safe-re-find common-util/safe-re-find)
 
-(def uuid-string? gp-util/uuid-string?)
+(def uuid-string? common-util/uuid-string?)
 
 (def page-name-sanity-lc
-  "Delegate to gp-util to loosely couple app usages to graph-parser"
-  gp-util/page-name-sanity-lc)
+  "Delegate to common-util to loosely couple app usages to graph-parser"
+  common-util/page-name-sanity-lc)
 
 (defn safe-page-name-sanity-lc
   [s]

+ 2 - 2
src/test/frontend/db/name_sanity_test.cljs

@@ -1,7 +1,7 @@
 (ns frontend.db.name-sanity-test
   (:require [cljs.test :refer [deftest testing is are]]
             [clojure.string :as string]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [frontend.handler.file-based.page :as file-page-handler]
             [frontend.handler.conversion :as conversion-handler]
             [frontend.util.fs :as fs-util]
@@ -12,7 +12,7 @@
   [page-name]
   (testing (str "Test sanitization page-name: " page-name)
     (let [file-name   (#'wfu/tri-lb-file-name-sanity page-name)
-          page-name'  (#'gp-util/tri-lb-title-parsing file-name)
+          page-name'  (#'common-util/tri-lb-title-parsing file-name)
           url-single  (js/encodeURIComponent file-name)
           url-double  (js/encodeURIComponent url-single)
           file-name'  (js/decodeURIComponent url-single)

+ 4 - 4
src/test/frontend/handler/repo_conversion_test.cljs

@@ -3,9 +3,9 @@
   (:require [cljs.test :refer [deftest use-fixtures is testing]]
             [clojure.string :as string]
             [logseq.graph-parser.cli :as gp-cli]
-            [logseq.graph-parser.util :as gp-util]
+            [logseq.common.util :as common-util]
             [logseq.graph-parser.test.docs-graph-helper :as docs-graph-helper]
-            [logseq.graph-parser.config :as gp-config]
+            [logseq.common.config :as common-config]
             [frontend.test.helper :as test-helper]
             [frontend.handler.file-based.page :as file-page-handler]
             [frontend.handler.conversion :as conversion-handler]
@@ -21,7 +21,7 @@
   (testing "Query based stats"
     (is (= (->> files
                 ;; logseq files aren't saved under :block/file
-                (remove #(string/includes? % (str graph-dir "/" gp-config/app-name "/")))
+                (remove #(string/includes? % (str graph-dir "/" common-config/app-name "/")))
                 set)
            (->> (d/q '[:find (pull ?b [* {:block/file [:file/path]}])
                        :where [?b :block/name] [?b :block/file]]
@@ -117,7 +117,7 @@
 
 (defn- convert-to-triple-lowbar
   [path]
-  (let [original-body (gp-util/path->file-body path)
+  (let [original-body (common-util/path->file-body path)
         ;; only test file name parsing, don't consider title prop overriding
         rename-target (:target (#'conversion-handler/calc-rename-target-impl :legacy :triple-lowbar original-body nil))]
     (if rename-target

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно