diff --git a/deps/shui/src/logseq/shui/util.cljs b/deps/shui/src/logseq/shui/util.cljs index 9e451a34fb..7f5d9037a2 100644 --- a/deps/shui/src/logseq/shui/util.cljs +++ b/deps/shui/src/logseq/shui/util.cljs @@ -42,14 +42,25 @@ (defn $LSUtils [] (aget js/window "LSUtils")) (def dev? (some-> ($LSUtils) (aget "isDev"))) +(defn- callable-export + [module] + (or (when (fn? module) + module) + (when-let [default (some-> module (gobj/get "default"))] + (when (fn? default) + default)) + (when-let [module-exports (some-> module (gobj/get "module.exports"))] + (when (fn? module-exports) + module-exports)))) + (defn uuid-color [uuid-str] - (some-> ($LSUtils) (aget "uniqolor") - (apply [uuid-str - #js {:saturation #js [55, 70], - :lightness 70, - :differencePoint 60}]) - (aget "color"))) + (when-let [uniqolor (some-> ($LSUtils) (aget "uniqolor") callable-export)] + (some-> (uniqolor uuid-str + #js {:saturation #js [55, 70], + :lightness 70, + :differencePoint 60}) + (aget "color")))) (defn get-path "Returns the component path." diff --git a/resources/package.json b/resources/package.json index 1124921be1..2a7754ce68 100644 --- a/resources/package.json +++ b/resources/package.json @@ -47,5 +47,11 @@ }, "resolutions": { "node-abi": "4.28.0" + }, + "pnpm": { + "onlyBuiltDependencies": [ + "electron", + "keytar" + ] } } diff --git a/scripts/static-pipeline.mjs b/scripts/static-pipeline.mjs index 29fe20c8da..6a633dff99 100644 --- a/scripts/static-pipeline.mjs +++ b/scripts/static-pipeline.mjs @@ -23,9 +23,19 @@ const staticCleanKeep = new Set([ ]) function run(command, args, options = {}) { + const env = { ...process.env } + + for (const [key, value] of Object.entries(options.env ?? {})) { + if (value == null) { + delete env[key] + } else { + env[key] = value + } + } + execFileSync(command, args, { cwd: options.cwd ?? rootDir, - env: { ...process.env, ...(options.env ?? {}) }, + env, shell: process.platform === 'win32', stdio: 'inherit', }) @@ -56,7 +66,10 @@ function ensureStaticNodeModules() { function electron() { ensureStaticNodeModules() - run('pnpm', ['electron:dev'], { cwd: staticDir }) + run('pnpm', ['electron:dev'], { + cwd: staticDir, + env: { ELECTRON_RUN_AS_NODE: null }, + }) } function versionFromSource() { diff --git a/src/main/frontend/util/js_module.cljs b/src/main/frontend/util/js_module.cljs index a5b44edf53..9432a5a837 100644 --- a/src/main/frontend/util/js_module.cljs +++ b/src/main/frontend/util/js_module.cljs @@ -5,7 +5,9 @@ (defn default-export "Returns the callable/default value from ESM, CommonJS interop, or namespace-shaped modules." [module] - (or (when (some? module) + (or (when (fn? module) + module) + (when (some? module) (gobj/get module "default")) (when (some? module) (gobj/get module "module.exports"))