perf: use datascript.transit instead of edn for ui<>worker messages

pull/11102/head
Tienson Qin 2024-03-06 16:12:54 +08:00
parent d603c165ef
commit eb1270fff9
21 changed files with 139 additions and 144 deletions

View File

@ -97,9 +97,11 @@
;; (cljs.pprint/pprint txs)
(try
(.time js/console "DB transact")
(when-not (exists? js/process) ; UI thread
(.time js/console "DB transact"))
(let [result (ldb/transact! conn txs (assoc tx-meta :outliner/transact? true))]
(p/then result (fn [] (.timeEnd js/console "DB transact")))
(when-not (exists? js/process)
(p/then result (fn [] (.timeEnd js/console "DB transact"))))
result)
(catch :default e
(js/console.error e)

View File

@ -34,7 +34,7 @@
[goog.functions :refer [debounce]]
[logseq.common.graph :as common-graph]
[promesa.core :as p]
[clojure.edn :as edn]))
[datascript.transit :as dt]))
(defmethod handle :mkdir [_window [_ dir]]
(fs/mkdirSync dir))
@ -315,8 +315,8 @@
(defmethod handle :db-transact [_window [_ repo tx-data-str tx-meta-str]]
(when-let [conn (sqlite-db/get-conn repo)]
(let [tx-data (edn/read-string tx-data-str)
tx-meta (edn/read-string tx-meta-str)]
(let [tx-data (dt/read-transit-str tx-data-str)
tx-meta (dt/read-transit-str tx-meta-str)]
(sqlite-db/transact! repo tx-data tx-meta)
(:max-tx @conn))))

View File

@ -11,12 +11,12 @@
[frontend.db :as db]
[frontend.db.model :as db-model]
[frontend.persist-db.browser :as db-browser]
[clojure.edn :as edn]
[datascript.core :as d]
[frontend.db.react :as react]
[frontend.date :as date]
[cljs-time.core :as t]
[cljs-time.format :as tf]))
[cljs-time.format :as tf]
[datascript.transit :as dt]))
(def <q db-async-util/<q)
(def <pull db-async-util/<pull)
@ -148,7 +148,7 @@
(when-let [^Object sqlite @db-browser/*worker]
(state/update-state! :db/async-queries (fn [s] (conj s name')))
(p/let [result (.get-block-and-children sqlite graph name' children?)
{:keys [block children] :as result'} (edn/read-string result)
{:keys [block children] :as result'} (dt/read-transit-str result)
conn (db/get-db graph false)
block-and-children (cons block children)
_ (d/transact! conn block-and-children)]
@ -165,7 +165,7 @@
(assert (integer? db-id))
(when-let [^Object worker @db-browser/*worker]
(p/let [result-str (.get-right-sibling worker graph db-id)
result (edn/read-string result-str)
result (dt/read-transit-str result-str)
conn (db/get-db graph false)
_ (when result (d/transact! conn [result]))]
result)))
@ -177,7 +177,7 @@
(when-let [block-id (:block/uuid (db/entity graph id))]
(state/update-state! :db/async-queries (fn [s] (conj s (str block-id "-parents"))))
(p/let [result-str (.get-block-parents worker graph id depth)
result (edn/read-string result-str)
result (dt/read-transit-str result-str)
conn (db/get-db graph false)
_ (d/transact! conn result)]
(state/update-state! :db/async-queries (fn [s] (disj s (str block-id "-parents"))))
@ -189,7 +189,7 @@
(when-let [^Object worker @db-browser/*worker]
(state/update-state! :db/async-queries (fn [s] (conj s (str eid "-refs"))))
(p/let [result-str (.get-block-refs worker graph eid)
result (edn/read-string result-str)
result (dt/read-transit-str result-str)
conn (db/get-db graph false)
_ (d/transact! conn result)]
(state/update-state! :db/async-queries (fn [s] (disj s (str eid "-refs"))))

View File

@ -2,17 +2,17 @@
"Async util helper"
(:require [frontend.state :as state]
[promesa.core :as p]
[clojure.edn :as edn]
[frontend.db.conn :as db-conn]
[datascript.core :as d]))
[datascript.core :as d]
[datascript.transit :as dt]))
(defn <q
[graph & inputs]
(assert (not-any? fn? inputs) "Async query inputs can't include fns because fn can't be serialized")
(when-let [^Object sqlite @state/*db-worker]
(p/let [result (.q sqlite graph (pr-str inputs))]
(p/let [result (.q sqlite graph (dt/write-transit-str inputs))]
(when result
(let [result' (edn/read-string result)]
(let [result' (dt/read-transit-str result)]
(when (and (seq result') (coll? result'))
(when-let [conn (db-conn/get-db graph false)]
(let [tx-data (->>
@ -34,9 +34,9 @@
(<pull graph '[*] id))
([graph selector id]
(when-let [^Object sqlite @state/*db-worker]
(p/let [result (.pull sqlite graph (pr-str selector) (pr-str id))]
(p/let [result (.pull sqlite graph (dt/write-transit-str selector) (dt/write-transit-str id))]
(when result
(let [result' (edn/read-string result)]
(let [result' (dt/read-transit-str result)]
(when-let [conn (db-conn/get-db graph false)]
(d/transact! conn [result']))
result'))))))
@ -46,6 +46,6 @@
[graph selector ids]
(assert (seq ids))
(when-let [^Object sqlite @state/*db-worker]
(p/let [result (.pull-many sqlite graph (pr-str selector) (pr-str ids))]
(p/let [result (.pull-many sqlite graph (dt/write-transit-str selector) (dt/write-transit-str ids))]
(when result
(edn/read-string result))))))
(dt/read-transit-str result))))))

View File

@ -7,7 +7,7 @@
[promesa.core :as p]
[cljs-time.core :as t]
[logseq.db.sqlite.common-db :as sqlite-common-db]
[clojure.edn :as edn]
[datascript.transit :as dt]
[frontend.db.async :as db-async]
[clojure.core.async :as async]))
@ -18,7 +18,7 @@
(p/let [start-time (t/now)
data (persist-db/<fetch-init-data repo)
_ (assert (some? data) "No data found when reloading db")
data' (edn/read-string data)
data' (dt/read-transit-str data)
db-schema (db-conn/get-schema repo)
conn (sqlite-common-db/restore-initial-data data' db-schema)
db-name (db-conn/datascript-db repo)

View File

@ -4,6 +4,7 @@
[datascript.storage :refer [IStorage]]
[clojure.edn :as edn]
[datascript.core :as d]
[datascript.transit :as dt]
[logseq.db.sqlite.common-db :as sqlite-common-db]
[shadow.cljs.modern :refer [defclass]]
["@logseq/sqlite-wasm" :default sqlite3InitModule]
@ -281,43 +282,43 @@
(q [_this repo inputs-str]
"Datascript q"
(when-let [conn (worker-state/get-datascript-conn repo)]
(let [inputs (edn/read-string inputs-str)
(let [inputs (dt/read-transit-str inputs-str)
result (apply d/q (first inputs) @conn (rest inputs))]
(pr-str result))))
(dt/write-transit-str result))))
(pull
[_this repo selector-str id-str]
(when-let [conn (worker-state/get-datascript-conn repo)]
(let [selector (edn/read-string selector-str)
id (edn/read-string id-str)
(let [selector (dt/read-transit-str selector-str)
id (dt/read-transit-str id-str)
result (->> (d/pull @conn selector id)
(sqlite-common-db/with-parent-and-left @conn))]
(pr-str result))))
(dt/write-transit-str result))))
(pull-many
[_this repo selector-str ids-str]
(when-let [conn (worker-state/get-datascript-conn repo)]
(let [selector (edn/read-string selector-str)
ids (edn/read-string ids-str)
(let [selector (dt/read-transit-str selector-str)
ids (dt/read-transit-str ids-str)
result (d/pull-many @conn selector ids)]
(pr-str result))))
(dt/write-transit-str result))))
(get-right-sibling
[_this repo db-id]
(when-let [conn (worker-state/get-datascript-conn repo)]
(let [result (ldb/get-right-sibling @conn db-id)]
(pr-str result))))
(dt/write-transit-str result))))
(get-block-and-children
[_this repo name children?]
(assert (string? name))
(when-let [conn (worker-state/get-datascript-conn repo)]
(pr-str (sqlite-common-db/get-block-and-children @conn name children?))))
(dt/write-transit-str (sqlite-common-db/get-block-and-children @conn name children?))))
(get-block-refs
[_this repo id]
(when-let [conn (worker-state/get-datascript-conn repo)]
(pr-str (ldb/get-block-refs @conn id))))
(dt/write-transit-str (ldb/get-block-refs @conn id))))
(get-block-refs-count
[_this repo id]
@ -330,13 +331,13 @@
(let [block-id (:block/uuid (d/entity @conn id))
parents (->> (ldb/get-block-parents @conn block-id {:depth (or depth 3)})
(map (fn [b] (d/pull @conn '[*] (:db/id b)))))]
(pr-str parents))))
(dt/write-transit-str parents))))
(get-page-unlinked-refs
[_this repo page-id search-result-eids-str]
(when-let [conn (worker-state/get-datascript-conn repo)]
(let [search-result-eids (edn/read-string search-result-eids-str)]
(pr-str (ldb/get-page-unlinked-refs @conn page-id search-result-eids)))))
(let [search-result-eids (dt/read-transit-str search-result-eids-str)]
(dt/write-transit-str (ldb/get-page-unlinked-refs @conn page-id search-result-eids)))))
(transact
[_this repo tx-data tx-meta context]
@ -344,13 +345,13 @@
(when-let [conn (worker-state/get-datascript-conn repo)]
(try
(let [tx-data (if (string? tx-data)
(edn/read-string tx-data)
(dt/read-transit-str tx-data)
tx-data)
tx-meta (if (string? tx-meta)
(edn/read-string tx-meta)
(dt/read-transit-str tx-meta)
tx-meta)
context (if (string? context)
(edn/read-string context)
(dt/read-transit-str context)
context)
_ (when context (worker-state/set-context! context))
tx-meta' (if (:new-graph? tx-meta)
@ -378,7 +379,7 @@
(getInitialData
[_this repo]
(when-let [conn (worker-state/get-datascript-conn repo)]
(pr-str (sqlite-common-db/get-initial-data @conn))))
(dt/write-transit-str (sqlite-common-db/get-initial-data @conn))))
(fetch-all-pages
[_this repo]
@ -387,11 +388,10 @@
(let [all-pages (sqlite-common-db/get-all-pages @conn)
partitioned-data (map-indexed (fn [idx p] [idx p]) (partition-all 2000 all-pages))]
(doseq [[idx tx-data] partitioned-data]
(worker-util/post-message :sync-db-changes (pr-str
{:repo repo
:tx-data tx-data
:tx-meta {:initial-pages? true
:end? (= idx (dec (count partitioned-data)))}}))
(worker-util/post-message :sync-db-changes {:repo repo
:tx-data tx-data
:tx-meta {:initial-pages? true
:end? (= idx (dec (count partitioned-data)))}})
(async/<! (async/timeout 100)))))
nil))
@ -482,10 +482,10 @@
(apply-outliner-ops
[this repo ops-str opts-str]
(when-let [conn (worker-state/get-datascript-conn repo)]
(let [ops (edn/read-string ops-str)
opts (edn/read-string opts-str)
(let [ops (dt/read-transit-str ops-str)
opts (dt/read-transit-str opts-str)
result (outliner-op/apply-ops! repo conn ops (worker-state/get-date-formatter repo) opts)]
(pr-str result))))
(dt/write-transit-str result))))
(file-writes-finished?
[this repo]
@ -511,7 +511,7 @@
(sync-app-state
[this new-state-str]
(let [new-state (edn/read-string new-state-str)]
(let [new-state (dt/read-transit-str new-state-str)]
(worker-state/set-new-state! new-state)
nil))
@ -520,18 +520,18 @@
[this repo block-uuid-or-page-name tree->file-opts context]
(when-let [conn (worker-state/get-datascript-conn repo)]
(worker-export/block->content repo @conn block-uuid-or-page-name
(edn/read-string tree->file-opts)
(edn/read-string context))))
(dt/read-transit-str tree->file-opts)
(dt/read-transit-str context))))
(get-all-pages
[this repo]
(when-let [conn (worker-state/get-datascript-conn repo)]
(pr-str (worker-export/get-all-pages repo @conn))))
(dt/write-transit-str (worker-export/get-all-pages repo @conn))))
(get-all-page->content
[this repo]
(when-let [conn (worker-state/get-datascript-conn repo)]
(pr-str (worker-export/get-all-page->content repo @conn))))
(dt/write-transit-str (worker-export/get-all-page->content repo @conn))))
;; RTC
(rtc-start
@ -571,15 +571,13 @@
(<! (rtc-updown/<upload-graph state repo conn))
(rtc-db-listener/listen-db-to-generate-ops repo conn))
(worker-util/post-message :notification
(pr-str
[[:div
[:p "Upload graph successfully"]]]))
[[:div
[:p "Upload graph successfully"]]])
(catch :default e
(worker-util/post-message :notification
(pr-str
[[:div
[:p "upload graph failed"]]
:error]))
[[:div
[:p "upload graph failed"]]
:error])
(prn ::download-graph-failed e))))
nil))
@ -590,15 +588,13 @@
(try
(<? (rtc-updown/<download-graph state repo graph-uuid))
(worker-util/post-message :notification
(pr-str
[[:div
[:p "download graph successfully"]]]))
[[:div
[:p "download graph successfully"]]])
(catch :default e
(worker-util/post-message :notification
(pr-str
[[:div
[:p "download graph failed"]]
:error]))
[[:div
[:p "download graph failed"]]
:error])
(prn ::download-graph-failed e)))))
nil)

View File

@ -68,7 +68,7 @@
[rum.core :as rum]
[frontend.handler.db-based.property :as db-property-handler]
[frontend.fs.capacitor-fs :as capacitor-fs]
[clojure.edn :as edn]))
[datascript.transit :as dt]))
;; FIXME: should support multiple images concurrently uploading
@ -2098,7 +2098,7 @@
:replace-empty-target? replace-empty-target?
:keep-uuid? keep-uuid?}))))]
(state/set-block-op-type! nil)
(when result (edit-last-block-after-inserted! (edn/read-string result))))))
(when result (edit-last-block-after-inserted! (dt/read-transit-str result))))))
(defn- block-tree->blocks
"keep-uuid? - maintain the existing :uuid in tree vec"
@ -2205,7 +2205,7 @@
(save-current-block!))
(outliner-op/insert-blocks! blocks' target
(assoc opts :sibling? sibling?')))]
(when result (edit-last-block-after-inserted! (edn/read-string result))))
(when result (edit-last-block-after-inserted! (dt/read-transit-str result))))
(catch :default ^js/Error e
(notification/show!

View File

@ -81,7 +81,8 @@
[frontend.db.rtc.debug-ui :as rtc-debug-ui]
[frontend.modules.outliner.pipeline :as pipeline]
[electron.ipc :as ipc]
[frontend.date :as date]))
[frontend.date :as date]
[datascript.transit :as dt]))
;; TODO: should we move all events here?
@ -973,7 +974,9 @@
(pipeline/invoke-hooks data)
(when (util/electron?)
(ipc/ipc :db-transact repo (pr-str (:tx-data data)) (pr-str (:tx-meta data))))
(ipc/ipc :db-transact repo
(dt/write-transit-str (:tx-data data))
(dt/write-transit-str (:tx-meta data))))
nil))

View File

@ -3,14 +3,15 @@
(:require [cljs-bean.core :as bean]
[frontend.handler.file :as file-handler]
[frontend.handler.notification :as notification]
[clojure.edn :as edn]
[frontend.state :as state]
[promesa.core :as p]))
[promesa.core :as p]
[datascript.transit :as dt]
[frontend.util :as util]))
(defmulti handle identity)
(defmethod handle :write-files [_ ^js worker data]
(let [{:keys [request-id page-id repo files]} (edn/read-string data)]
(let [{:keys [request-id page-id repo files]} data]
(->
(p/let [_ (file-handler/alter-files repo files {})]
(.page-file-saved worker request-id page-id))
@ -23,18 +24,17 @@
(.page-file-saved worker request-id page-id))))))
(defmethod handle :notification [_ _worker data]
(apply notification/show! (edn/read-string data)))
(apply notification/show! data))
(defmethod handle :add-repo [_ _worker data]
(state/add-repo! {:url (:repo (edn/read-string data))}))
(state/add-repo! {:url (:repo data)}))
(defmethod handle :rtc-sync-state [_ _worker data]
(let [state (edn/read-string data)]
(let [state data]
(state/pub-event! [:rtc/sync-state state])))
(defmethod handle :sync-db-changes [_ _worker data]
(let [data (edn/read-string data)]
(state/pub-event! [:db/sync-changes data])))
(state/pub-event! [:db/sync-changes data]))
(defmethod handle :default [_ _worker data]
(prn :debug "Worker data not handled: " data))
@ -53,5 +53,7 @@
(if (.-isError (.-value data))
(js/console.error "Unexpected webworker error:" (-> data bean/->clj (get-in [:value :value])))
(js/console.error "Unexpected webworker error:" data))
(let [[e payload] (bean/->clj data)]
(handle (keyword e) wrapped-worker payload))))))))
(if (string? data)
(let [[e payload] (util/profile "UI read transit: " (dt/read-transit-str data))]
(handle (keyword e) wrapped-worker payload))
(js/console.error "Worker received invalid data from worker: " data))))))))

View File

@ -26,8 +26,8 @@
(when (and worker# (seq r#))
(let [request-id# (state/get-worker-next-request-id)
request# #(.apply-outliner-ops ^Object worker# (state/get-current-repo)
(pr-str r#)
(pr-str (assoc ~opts :request-id request-id#)))
(datascript.transit/write-transit-str r#)
(datascript.transit/write-transit-str (assoc ~opts :request-id request-id#)))
response# (state/add-worker-request! request-id# request#)]
response#))))))))))

View File

@ -14,7 +14,8 @@
[frontend.handler.worker :as worker-handler]
[logseq.db :as ldb]
[frontend.db.transact :as db-transact]
[frontend.date :as date]))
[frontend.date :as date]
[datascript.transit :as dt]))
(defonce *worker state/*db-worker)
@ -37,12 +38,12 @@
(not= (:config prev) (:config current))
(assoc :config (:config current)))]
(when (seq new-state)
(.sync-app-state worker (pr-str new-state)))))))
(.sync-app-state worker (dt/write-transit-str new-state)))))))
(defn transact!
[^js worker repo tx-data tx-meta]
(let [tx-meta' (pr-str tx-meta)
tx-data' (pr-str tx-data)
(let [tx-meta' (dt/write-transit-str tx-meta)
tx-data' (dt/write-transit-str tx-data)
;; TODO: a better way to share those information with worker, maybe using the state watcher to notify the worker?
context {:dev? config/dev?
:node-test? util/node-test?
@ -58,7 +59,7 @@
:pages-directory (config/get-pages-directory)}]
(if worker
(.transact worker repo tx-data' tx-meta'
(pr-str context))
(dt/write-transit-str context))
(notification/show! "Latest change was not saved! Please restart the application." :error))))
(defn start-db-worker!
@ -73,7 +74,7 @@
(reset! *worker wrapped-worker)
(-> (p/let [_ (.init wrapped-worker config/RTC-WS-URL)
_ (.sync-app-state wrapped-worker
(pr-str
(dt/write-transit-str
{:git/current-repo (state/get-current-repo)
:config (:config @state/state)}))
_ (sync-app-state! wrapped-worker)

View File

@ -18,7 +18,7 @@
[frontend.db :as db]
[frontend.db.model :as db-model]
[frontend.db.utils :as db-utils]
[clojure.edn :as edn]))
[datascript.transit :as dt]))
(def fuzzy-search fuzzy/fuzzy-search)
@ -145,8 +145,8 @@
result (block-search repo q {:limit 100})
eids (map (fn [b] [:block/uuid (:block/uuid b)]) result)
result (when (seq eids)
(.get-page-unlinked-refs ^Object @state/*db-worker repo (:db/id page) (pr-str eids)))
result' (when result (edn/read-string result))]
(.get-page-unlinked-refs ^Object @state/*db-worker repo (:db/id page) (dt/write-transit-str eids)))
result' (when result (dt/read-transit-str result))]
(when result' (db/transact! repo result'))
(some->> result'
db-model/sort-by-left-recursive

View File

@ -28,9 +28,9 @@
(prn :debug "Broken chain:")
(pprint/pprint error-data)
(worker-util/post-message :notification
(pr-str [[:div
(str "Broken chain detected:\n" error-data)]
:error])))
[[:div
(str "Broken chain detected:\n" error-data)]
:error]))
(let [first-child-id (:db/id (ldb/get-by-parent-&-left db parent-id parent-id))
*ids (atom children-ids)
sections (loop [sections []]
@ -111,12 +111,12 @@
[db conflicts page-id]
(when (seq conflicts)
(prn :debug "Parent left id conflicts:")
(worker-util/post-message :notification (pr-str [[:div
(str "Parent-left conflicts detected on page "
(pr-str (:block/original-name (d/entity db page-id)))
":\n"
conflicts)]
:error])))
(worker-util/post-message :notification [[:div
(str "Parent-left conflicts detected on page "
(:block/original-name (d/entity db page-id))
":\n"
conflicts)]
:error]))
(mapcat
(fn [[_parent-left blocks]]
(let [items (sort-by :block/created-at blocks)

View File

@ -100,11 +100,10 @@
(try (do-write-file! repo conn page-id outliner-op context request-id)
(catch :default e
(worker-util/post-message :notification
(pr-str
[[:div
[:p "Write file failed, please copy the changes to other editors in case of losing data."]
"Error: " (str (gobj/get e "stack"))]
:error]))
[[:div
[:p "Write file failed, please copy the changes to other editors in case of losing data."]
"Error: " (str (gobj/get e "stack"))]
:error])
(log/error :file/write-file-error {:error e})
(dissoc-request! request-id)))))))

View File

@ -172,10 +172,10 @@
(let [files [[file-path new-content]]]
(when (seq files)
(let [page-id (:db/id page-block)]
(worker-util/post-message :write-files (pr-str {:request-id request-id
:page-id page-id
:repo repo
:files files}))
(worker-util/post-message :write-files {:request-id request-id
:page-id page-id
:repo repo
:files files})
:sent)))))
;; In e2e tests, "card" page in db has no :file/path
(js/console.error "File path from page-block is not valid" page-block tree))]

View File

@ -66,7 +66,7 @@
(let [valid? (db-validate/validate-tx-report! tx-report (:validate-db-options context))]
(when (and (get-in context [:validate-db-options :fail-invalid?]) (not valid?))
(worker-util/post-message :notification
(pr-str [["Invalid DB!"] :error])))))
[["Invalid DB!"] :error]))))
(when (and (:dev? context)
(not (:node-test? context)))
(fix-db! conn tx-report)))

View File

@ -997,10 +997,9 @@
c2 (asset-sync/<loop-for-assets-sync state-for-asset-sync graph-uuid repo conn)]
(<! c1)
(<! c2))
(worker-util/post-message :notification (pr-str
[[:div
[:p "RTC is not supported for this graph"]]
:error]))))))
(worker-util/post-message :notification [[:div
[:p "RTC is not supported for this graph"]]
:error])))))
(defn <stop-rtc
[]
@ -1037,4 +1036,4 @@
old-state (get-debug-state @*repo old)]
(when (or (not= new-state old-state)
(= :open (:rtc-state new-state)))
(worker-util/post-message :rtc-sync-state (pr-str new-state)))))))
(worker-util/post-message :rtc-sync-state new-state))))))

View File

@ -211,13 +211,12 @@
result (worker-pipeline/invoke-hooks repo conn tx-report (worker-state/get-context))
tx-report' (or (:tx-report result) tx-report)]
(when-not pipeline-replace?
(let [data (pr-str
(merge
{:request-id (:request-id tx-meta)
:repo repo
:tx-data (:tx-data tx-report')
:tx-meta tx-meta}
(dissoc result :tx-report)))]
(let [data (merge
{:request-id (:request-id tx-meta)
:repo repo
:tx-data (:tx-data tx-report')
:tx-meta tx-meta}
(dissoc result :tx-report))]
(worker-util/post-message :sync-db-changes data))
(when-not from-disk?

View File

@ -135,7 +135,7 @@
(.closeDB worker-obj repo))]
(<? (p->c work))
(worker-util/post-message :add-repo (pr-str {:repo repo}))
(worker-util/post-message :add-repo {:repo repo})
(op-mem-layer/update-local-tx! repo t))))
(defn <download-graph

View File

@ -7,7 +7,19 @@
[logseq.common.util :as common-util]
[clojure.core.async :as async]
[cljs.core.async.impl.channels :refer [ManyToManyChannel]]
[cljs-bean.core :as bean])))
[datascript.transit :as dt])))
;; Copied from https://github.com/tonsky/datascript-todo
#?(:clj
(defmacro profile
[k & body]
`(if goog.DEBUG
(let [k# ~k]
(.time js/console k#)
(let [res# (do ~@body)]
(.timeEnd js/console k#)
res#))
(do ~@body))))
#?(:cljs
(do
@ -81,16 +93,4 @@
(defn post-message
[type data]
(when (exists? js/self)
(.postMessage js/self (bean/->js [type data]))))))
;; Copied from https://github.com/tonsky/datascript-todo
#?(:clj
(defmacro profile
[k & body]
`(if goog.DEBUG
(let [k# ~k]
(.time js/console k#)
(let [res# (do ~@body)]
(.timeEnd js/console k#)
res#))
(do ~@body))))
(.postMessage js/self (frontend.worker.util/profile "Worker write transit: " (dt/write-transit-str [type data])))))))

View File

@ -258,12 +258,6 @@ This can be called in synchronous contexts as no async fns should be invoked"
{:before #(start-test-db! {:db-graph? true})
:after #(destroy-test-db!)})
(def start-and-destroy-db-map-fixture
"To avoid 'Fixtures may not be of mixed types' error
when use together with other map-type fixtures"
{:before #(start-test-db!)
:after #(destroy-test-db!)})
(defn save-block!
"Wrapper around editor-handler/save-block! that also adds tags"
[repo block-uuid content {:keys [tags]}]