Ver código fonte

chore: use official sqlite-wasm

Tienson Qin 7 meses atrás
pai
commit
0ecf65aefb

+ 0 - 1
gulpfile.js

@@ -66,7 +66,6 @@ const common = {
         'node_modules/@isomorphic-git/lightning-fs/dist/lightning-fs.min.js',
         'packages/amplify/dist/amplify.js',
         'packages/ui/dist/ui.js',
-        'node_modules/@logseq/sqlite-wasm/sqlite-wasm/jswasm/sqlite3.wasm',
         'node_modules/react/umd/react.production.min.js',
         'node_modules/react/umd/react.development.js',
         'node_modules/react-dom/umd/react-dom.production.min.js',

+ 1 - 1
package.json

@@ -119,10 +119,10 @@
         "@logseq/capacitor-file-sync": "5.0.2",
         "@logseq/diff-merge": "0.2.2",
         "@logseq/react-tweet-embed": "1.3.1-1",
-        "@logseq/sqlite-wasm": "=0.1.0",
         "@radix-ui/colors": "^0.1.8",
         "@sentry/react": "^6.18.2",
         "@sentry/tracing": "^6.18.2",
+        "@sqlite.org/sqlite-wasm": "^3.49.1-build2",
         "@tabler/icons-react": "^2.47.0",
         "@tabler/icons-webfont": "^2.47.0",
         "@tippyjs/react": "4.2.5",

+ 1 - 1
public/index.html

@@ -55,7 +55,7 @@
 <script defer src="/static/js/lsplugin.core.js"></script>
 <script defer src="/static/js/react.production.min.js"></script>
 <script defer src="/static/js/react-dom.production.min.js"></script>
-<script defer src="/static/js/libs/main-bundle.js"></script>
+<script defer src="/static/js/main-bundle.js"></script>
 <script defer src="/static/js/ui.js"></script>
 <script defer src="/static/js/shared.js"></script>
 <script defer src="/static/js/main.js"></script>

+ 1 - 1
resources/index.html

@@ -54,7 +54,7 @@ const portal = new MagicPortal(worker);
 <script defer src="./js/lsplugin.core.js"></script>
 <script defer src="./js/react.production.min.js"></script>
 <script defer src="./js/react-dom.production.min.js"></script>
-<script defer src="./js/libs/main-bundle.js"></script>
+<script defer src="./js/main-bundle.js"></script>
 <script defer src="./js/ui.js"></script>
 <script defer src="./js/shared.js"></script>
 <script defer src="./js/main.js"></script>

+ 2 - 2
shadow-cljs.edn

@@ -80,12 +80,12 @@
                             {:init-fn frontend.worker.db-worker/init
                              :depends-on #{:shared}
                              :web-worker true
-                             :prepend "importScripts('libs/workers-bundle.js');\n"}
+                             :prepend "importScripts('workers-bundle.js');\n"}
                             :inference-worker
                             {:init-fn frontend.inference-worker.inference-worker/init
                              :depends-on #{:shared}
                              :web-worker true
-                             :prepend "importScripts('libs/workers-bundle.js');\n"}}
+                             :prepend "importScripts('workers-bundle.js');\n"}}
 
             :output-dir       "./static/js"
             :asset-path       "/static/js"

+ 1 - 1
src/main/frontend/persist_db/browser.cljs

@@ -1,5 +1,5 @@
 (ns frontend.persist-db.browser
-  "Browser db persist support, using @logseq/sqlite-wasm.
+  "Browser db persist support, using sqlite-wasm.
 
    This interface uses clj data format as input."
   (:require ["comlink" :as Comlink]

+ 2 - 12
src/main/frontend/worker/db_worker.cljs

@@ -1,6 +1,6 @@
 (ns frontend.worker.db-worker
   "Worker used for browser DB implementation"
-  (:require ["@logseq/sqlite-wasm" :default sqlite3InitModule]
+  (:require ["@sqlite.org/sqlite-wasm" :default sqlite3InitModule]
             ["comlink" :as Comlink]
             [cljs-bean.core :as bean]
             [clojure.edn :as edn]
@@ -68,17 +68,7 @@
 (defn- init-sqlite-module!
   []
   (when-not @*sqlite
-    (p/let [href (.. js/location -href)
-            electron? (string/includes? href "electron=true")
-            publishing? (string/includes? href "publishing=true")
-
-            _ (reset! *publishing? publishing?)
-            base-url (str js/self.location.protocol "//" js/self.location.host)
-            sqlite-wasm-url (if electron?
-                              (js/URL. "sqlite3.wasm" (.. js/location -href))
-                              (str base-url (string/replace js/self.location.pathname "db-worker.js" "")))
-            sqlite (sqlite3InitModule (clj->js {:url sqlite-wasm-url
-                                                :print js/console.log
+    (p/let [sqlite (sqlite3InitModule (clj->js {:print js/console.log
                                                 :printErr js/console.error}))]
       (reset! *sqlite sqlite)
       nil)))

+ 2 - 2
webpack.config.js

@@ -9,9 +9,9 @@ module.exports = {
   },
 
   output: {
-    path: path.resolve(__dirname, 'static/js/libs'),
+    path: path.resolve(__dirname, 'static/js'),
     filename: '[name]-bundle.js',
-    clean: true,
+    clean: false,
     chunkLoading: false,
   },
   module: {

+ 5 - 5
yarn.lock

@@ -771,11 +771,6 @@
   resolved "https://registry.yarnpkg.com/@logseq/react-tweet-embed/-/react-tweet-embed-1.3.1-1.tgz#119d22be8234de006fc35c3fa2a36f85634c5be6"
   integrity sha512-9O0oHs5depCvh6ZQvwtl1xb7B80YG5rUfY10uSUat5itOlcE3IWaYYpe6p/tcHErqHWnWgkXHitAB9M29FMbQg==
 
-"@logseq/sqlite-wasm@=0.1.0":
-  version "0.1.0"
-  resolved "https://registry.yarnpkg.com/@logseq/sqlite-wasm/-/sqlite-wasm-0.1.0.tgz#b866d22d7a83bfa6815fe7f4d8899097b49af642"
-  integrity sha512-Ft/ZY8b2s35pFS7L7NX0CKWa5WkeKueYB7l5AYFFvQ2QQ0s7O4zlEi+jIX/ZdO2vnf2p4ALg+QvgaPgu6w2o5w==
-
 "@mapbox/node-pre-gyp@^1.0.0":
   version "1.0.11"
   resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz#417db42b7f5323d79e93b34a6d7a2a12c0df43fa"
@@ -1167,6 +1162,11 @@
   resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz#821f8442f4175d8f0467b9daf26e3a18e2d02af2"
   integrity sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==
 
+"@sqlite.org/sqlite-wasm@^3.49.1-build2":
+  version "3.49.1-build2"
+  resolved "https://registry.yarnpkg.com/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.49.1-build2.tgz#dba6fc58f9e68b20812872e6a27b07a267b2f1de"
+  integrity sha512-pZi8OSjNDZEYkvefsTOFKNRRN0GG9S5mtB6qBmrFZ5sraF5vxElPnTOl0DbJgiz9twlsOF5OzVkOce6Uc1TXsw==
+
 "@stylelint/postcss-css-in-js@^0.37.2":
   version "0.37.3"
   resolved "https://registry.yarnpkg.com/@stylelint/postcss-css-in-js/-/postcss-css-in-js-0.37.3.tgz#d149a385e07ae365b0107314c084cb6c11adbf49"