From 9b57580962412e30e6e8189d9074b70670cd2d44 Mon Sep 17 00:00:00 2001 From: charlie Date: Thu, 1 Sep 2022 12:16:45 +0800 Subject: [PATCH 1/9] chore(dev): just one command for ios/android development --- capacitor.config.ts | 58 +++++++++++++++++++++++++-------------------- gulpfile.js | 47 ++++++++++++++++++++++++++++++++---- package.json | 7 ++++-- yarn.lock | 10 ++++++++ 4 files changed, 89 insertions(+), 33 deletions(-) diff --git a/capacitor.config.ts b/capacitor.config.ts index d41e12112..ece8c5223 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -1,32 +1,38 @@ -import { CapacitorConfig } from '@capacitor/cli'; +import { CapacitorConfig } from '@capacitor/cli' const config: CapacitorConfig = { - appId: 'com.logseq.app', - appName: 'Logseq', - bundledWebRuntime: false, - webDir: 'public', - plugins: { - SplashScreen: { - launchShowDuration: 500, - launchAutoHide: false, - androidScaleType: "CENTER_CROP", - splashImmersive: false, - backgroundColor: "#002b36" - }, - - Keyboard: { - resize: "none" - } + appId: 'com.logseq.app', + appName: 'Logseq', + bundledWebRuntime: false, + webDir: 'public', + plugins: { + SplashScreen: { + launchShowDuration: 500, + launchAutoHide: false, + androidScaleType: 'CENTER_CROP', + splashImmersive: false, + backgroundColor: '#002b36' }, - ios: { - scheme: "Logseq" + + Keyboard: { + resize: 'none' } - // do not commit this into source control - // source: https://capacitorjs.com/docs/guides/live-reload - // , server: { - // url: process.env.LOGSEQ_APP_SERVER_URL, - // cleartext: true - // } -}; + }, + ios: { + scheme: 'Logseq' + } +} + +if ( + process.env.PLATFORM && + process.env.LOGSEQ_APP_SERVER_URL +) { + Object.assign(config, { + server: { + url: process.env.LOGSEQ_APP_SERVER_URL, + cleartext: true + } + }) +} export = config; diff --git a/gulpfile.js b/gulpfile.js index 13b8ae154..788576ffd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,6 +6,7 @@ const path = require('path') const gulp = require('gulp') const cleanCSS = require('gulp-clean-css') const del = require('del') +const ip = require('ip') const outputPath = path.join(__dirname, 'static') const resourcesPath = path.join(__dirname, 'resources') @@ -49,13 +50,13 @@ const common = { syncAssetFiles (...params) { return gulp.series( () => gulp.src([ - "./node_modules/@excalidraw/excalidraw/dist/excalidraw-assets/**", - "!**/*/i18n-*.js" - ]) + './node_modules/@excalidraw/excalidraw/dist/excalidraw-assets/**', + '!**/*/i18n-*.js' + ]) .pipe(gulp.dest(path.join(outputPath, 'js', 'excalidraw-assets'))), - () => gulp.src("node_modules/@tabler/icons/iconfont/tabler-icons.min.css") + () => gulp.src('node_modules/@tabler/icons/iconfont/tabler-icons.min.css') .pipe(gulp.dest(path.join(outputPath, 'css'))), - () => gulp.src("node_modules/@tabler/icons/iconfont/fonts/**") + () => gulp.src('node_modules/@tabler/icons/iconfont/fonts/**') .pipe(gulp.dest(path.join(outputPath, 'css', 'fonts'))), )(...params) }, @@ -83,6 +84,41 @@ const common = { path.join(outputPath, 'js/**'), path.join(outputPath, 'css/**') ], { ignoreInitial: true }, common.syncJS_CSSinRt) + }, + + async env (cb) { + const mode = process.env.PLATFORM || 'ios' + + const IP = ip.address() + const LOGSEQ_APP_SERVER_URL = `http://${IP}:3001` + + if (typeof global.fetch != null) { + try { + await fetch(LOGSEQ_APP_SERVER_URL) + } catch (e) { + return cb(new Error(`/* ❌ Please check if the service is ON. (${LOGSEQ_APP_SERVER_URL}) ❌ */`)) + } + } + + console.log(`------ Cap ${mode.toUpperCase()} -----`) + console.log(`Dev serve at: ${LOGSEQ_APP_SERVER_URL}`) + console.log(`--------------------------------------`) + + cp.execSync(`npx cap sync ${mode}`, { + stdio: 'inherit', + env: Object.assign(process.env, { + LOGSEQ_APP_SERVER_URL + }) + }) + + cp.execSync(`npx cap run ${mode} --external`, { + stdio: 'inherit', + env: Object.assign(process.env, { + LOGSEQ_APP_SERVER_URL + }) + }) + + cb() } } @@ -130,6 +166,7 @@ exports.electronMaker = async () => { }) } +exports.env = common.env exports.clean = common.clean exports.watch = gulp.series(common.syncResourceFile, common.syncAssetFiles, common.syncAllStatic, gulp.parallel(common.keepSyncResourceFile, css.watchCSS)) diff --git a/package.json b/package.json index d8c5d1a7e..9fa1ab0ec 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "stylelint": "^13.8.0", "stylelint-config-standard": "^20.0.0", "tailwindcss": "2.2.16", - "typescript": "^4.4.3" + "typescript": "^4.4.3", + "ip": "1.1.8" }, "scripts": { "watch": "run-p gulp:watch cljs:watch", @@ -63,7 +64,9 @@ "cljs:debug": "clojure -M:cljs release app --debug", "cljs:report": "clojure -M:cljs run shadow.cljs.build-report app report.html", "cljs:build-electron": "clojure -A:cljs compile app electron", - "cljs:lint": "clojure -M:clj-kondo --parallel --lint src --cache false" + "cljs:lint": "clojure -M:clj-kondo --parallel --lint src --cache false", + "ios:dev": "cross-env PLATFORM=ios gulp env", + "android:dev": "cross-env PLATFORM=android gulp env" }, "dependencies": { "@capacitor/android": "3.2.2", diff --git a/yarn.lock b/yarn.lock index 68872da9c..cb16b466a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3706,6 +3706,16 @@ invert-kv@^2.0.0: resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== +ip@1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48" + integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg== + +is-absolute-url@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-2.1.0.tgz#50530dfb84fcc9aa7dbe7852e83a37b93b9f2aa6" + integrity sha1-UFMN+4T8yap9vnhS6Do3uTufKqY= + is-absolute@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576" From fd92a53940f7322ad73598c629b22a1882f450f8 Mon Sep 17 00:00:00 2001 From: charlie Date: Thu, 1 Sep 2022 12:20:57 +0800 Subject: [PATCH 2/9] fix: conditions --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 788576ffd..8046e0073 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -92,7 +92,7 @@ const common = { const IP = ip.address() const LOGSEQ_APP_SERVER_URL = `http://${IP}:3001` - if (typeof global.fetch != null) { + if (typeof global.fetch === 'function') { try { await fetch(LOGSEQ_APP_SERVER_URL) } catch (e) { From 79c73eaee6c29844423f4154c654e513efe97c5c Mon Sep 17 00:00:00 2001 From: charlie Date: Thu, 1 Sep 2022 21:17:43 +0800 Subject: [PATCH 3/9] chore: typos --- capacitor.config.ts | 5 +---- gulpfile.js | 4 ++-- package.json | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/capacitor.config.ts b/capacitor.config.ts index ece8c5223..b097fa7f7 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -23,10 +23,7 @@ const config: CapacitorConfig = { } } -if ( - process.env.PLATFORM && - process.env.LOGSEQ_APP_SERVER_URL -) { +if (process.env.LOGSEQ_APP_SERVER_URL) { Object.assign(config, { server: { url: process.env.LOGSEQ_APP_SERVER_URL, diff --git a/gulpfile.js b/gulpfile.js index 8046e0073..d1e1672fe 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -86,7 +86,7 @@ const common = { ], { ignoreInitial: true }, common.syncJS_CSSinRt) }, - async env (cb) { + async runCapWithLocalDevServerEntry (cb) { const mode = process.env.PLATFORM || 'ios' const IP = ip.address() @@ -166,7 +166,7 @@ exports.electronMaker = async () => { }) } -exports.env = common.env +exports.cap = common.runCapWithLocalDevServerEntry exports.clean = common.clean exports.watch = gulp.series(common.syncResourceFile, common.syncAssetFiles, common.syncAllStatic, gulp.parallel(common.keepSyncResourceFile, css.watchCSS)) diff --git a/package.json b/package.json index 9fa1ab0ec..7e38922ca 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,8 @@ "cljs:report": "clojure -M:cljs run shadow.cljs.build-report app report.html", "cljs:build-electron": "clojure -A:cljs compile app electron", "cljs:lint": "clojure -M:clj-kondo --parallel --lint src --cache false", - "ios:dev": "cross-env PLATFORM=ios gulp env", - "android:dev": "cross-env PLATFORM=android gulp env" + "ios:dev": "cross-env PLATFORM=ios gulp cap", + "android:dev": "cross-env PLATFORM=android gulp cap" }, "dependencies": { "@capacitor/android": "3.2.2", From d384f6164005dc41691a076834508c980f2d2ec0 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 14 Sep 2022 11:14:20 +0800 Subject: [PATCH 4/9] chore: yarn.lock --- yarn.lock | 5 ----- 1 file changed, 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index cb16b466a..94aa49249 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3711,11 +3711,6 @@ ip@1.1.8: resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48" integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg== -is-absolute-url@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-2.1.0.tgz#50530dfb84fcc9aa7dbe7852e83a37b93b9f2aa6" - integrity sha1-UFMN+4T8yap9vnhS6Do3uTufKqY= - is-absolute@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576" From 7a0075491fe1f49590a88b9d84e6722cdd5fe168 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 14 Sep 2022 11:25:07 +0800 Subject: [PATCH 5/9] Add capacitor.config.json to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 61053ea8e..b40ad5ac6 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,5 @@ startup.png /src/test/docs ~*~ + +ios/App/App/capacitor.config.json From a06d9005235db741b1ee031b71db4142cde58049 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 14 Sep 2022 12:01:13 +0800 Subject: [PATCH 6/9] Delete capacitor.config.json --- ios/App/App/capacitor.config.json | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 ios/App/App/capacitor.config.json diff --git a/ios/App/App/capacitor.config.json b/ios/App/App/capacitor.config.json deleted file mode 100644 index 4882e518a..000000000 --- a/ios/App/App/capacitor.config.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "appId": "com.logseq.app", - "appName": "Logseq", - "bundledWebRuntime": false, - "webDir": "public", - "plugins": { - "SplashScreen": { - "launchShowDuration": 500, - "launchAutoHide": false, - "androidScaleType": "CENTER_CROP", - "splashImmersive": false, - "backgroundColor": "#002b36" - }, - "Keyboard": { - "resize": "none" - } - }, - "ios": { - "scheme": "Logseq" - } -} From 6bb72c1252fb209bec8ba98aca4253874d78ab9c Mon Sep 17 00:00:00 2001 From: Andelf Date: Wed, 14 Sep 2022 12:18:24 +0800 Subject: [PATCH 7/9] fix(ios): use .default qos for encription --- ios/App/App/FileSync/FileSync.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/App/App/FileSync/FileSync.swift b/ios/App/App/FileSync/FileSync.swift index 0d16f90ad..c37592351 100644 --- a/ios/App/App/FileSync/FileSync.swift +++ b/ios/App/App/FileSync/FileSync.swift @@ -225,13 +225,13 @@ public class FileSync: CAPPlugin, SyncDebugDelegate { call.reject("required parameters: passphrase, content") return } - guard let ciphertext = content.data(using: .utf8) else { + guard let plaintext = content.data(using: .utf8) else { call.reject("cannot decode ciphertext with utf8") return } call.keepAlive = true - DispatchQueue.global(qos: .background).async { - if let encrypted = AgeEncryption.encryptWithPassphrase(ciphertext, passphrase, armor: true) { + DispatchQueue.global(qos: .default).async { + if let encrypted = AgeEncryption.encryptWithPassphrase(plaintext, passphrase, armor: true) { call.resolve(["data": String(data: encrypted, encoding: .utf8) as Any]) } else { call.reject("cannot encrypt with passphrase") @@ -251,7 +251,7 @@ public class FileSync: CAPPlugin, SyncDebugDelegate { return } call.keepAlive = true - DispatchQueue.global(qos: .background).async { + DispatchQueue.global(qos: .default).async { if let decrypted = AgeEncryption.decryptWithPassphrase(ciphertext, passphrase) { call.resolve(["data": String(data: decrypted, encoding: .utf8) as Any]) } else { From bd914615ef57bd12f39a9fd26cd8f83fb54981bb Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 14 Sep 2022 12:13:47 +0800 Subject: [PATCH 8/9] fix: clicking sync icon restarts the file sync This can result in app crash when clicking the icon multiple times. --- src/main/frontend/components/file_sync.cljs | 3 ++- src/main/frontend/handler/file_sync.cljs | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/components/file_sync.cljs b/src/main/frontend/components/file_sync.cljs index 299a75468..5997f1df7 100644 --- a/src/main/frontend/components/file_sync.cljs +++ b/src/main/frontend/components/file_sync.cljs @@ -182,7 +182,7 @@ status (:state sync-state) status (or (nil? status) (keyword (name status))) - off? (or (nil? sync-state) (fs-sync/sync-state--stopped? sync-state)) + off? (file-sync-handler/sync-off? sync-state) full-syncing? (contains? #{:local->remote-full-sync :remote->local-full-sync} status) syncing? (or full-syncing? (contains? #{:local->remote :remote->local} status)) idle? (contains? #{:idle} status) @@ -211,6 +211,7 @@ nil (and synced-file-graph? + (file-sync-handler/graph-sync-off? current-repo) (second @fs-sync/graphs-txid) (async/ Date: Wed, 14 Sep 2022 09:41:05 +0300 Subject: [PATCH 9/9] Revert "chore: increase the max width of main container" This reverts commit 5bc0537954925ac9c17b5282e49788239f870656. --- resources/css/common.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/css/common.css b/resources/css/common.css index f4410b462..4ffacc317 100644 --- a/resources/css/common.css +++ b/resources/css/common.css @@ -3,7 +3,7 @@ --ls-tag-text-hover-opacity: 1; --ls-page-text-size: 1em; --ls-page-title-size: 36px; - --ls-main-content-max-width: 1200px; + --ls-main-content-max-width: 810px; --ls-main-content-max-width-wide: 100%; --ls-font-family: Inter; --ls-scrollbar-width: 6px;