Use web workers to speed up parsing (#2655)

* wip: use web workers to speed up parsing

* chore: uncomment forget.config.js

* fix: parser pool initialization

* fix: extract parser-worker

* fix: can't run the parser worker in the release mode

* fix: extract async tests

* fix: dsl query async test

* fix: img path in dev mode
This commit is contained in:
Tienson Qin
2021-08-18 17:02:40 +08:00
committed by GitHub
parent 0b3c2bf3f3
commit e87f83c395
23 changed files with 5289 additions and 228 deletions

View File

@@ -10,7 +10,9 @@
[lambdaisland.glogi :as log]
[medley.core :as medley]
["mldoc" :as mldoc :refer [Mldoc]]
[linked.core :as linked]))
[linked.core :as linked]
[promesa.core :as p]
[frontend.util.pool :as pool]))
(defonce parseJson (gobj/get Mldoc "parseJson"))
(defonce parseInlineJson (gobj/get Mldoc "parseInlineJson"))
@@ -230,7 +232,7 @@
[content config]
(try
(if (string/blank? content)
{}
[]
(-> content
(parse-json config)
(util/json->clj)
@@ -240,6 +242,22 @@
(log/error :edn/convert-failed e)
[])))
(defn ->edn-async
[content config]
(if util/node-test?
(p/resolved (->edn content config))
(try
(if (string/blank? content)
(p/resolved [])
(p/let [v (pool/add-parse-job! content config)]
(-> v
(util/json->clj)
(update-src-full-content content)
(collect-page-properties))))
(catch js/Error e
(log/error :edn/convert-failed e)
(p/resolved [])))))
(defn opml->edn
[content]
(try