AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(desktop): enable the WeChat share extension on launch
tianma-iff8d7e57271c9
diff --git a/apps/desktop/src/main/index.mjs b/apps/desktop/src/main/index.mjsindex 918e6937..1f1dae08 100644--- a/apps/desktop/src/main/index.mjs+++ b/apps/desktop/src/main/index.mjs@@ -11,6 +11,7 @@ import { resourceRequestHeaders } from "./resource-request.mjs";import { downloadContentDispositionFromRequest, isSafeResourceId, parseByteRangeHeader, resourceIdFromRequest } from "./resource-url.mjs";import { isSupportedAssociatedFile } from "./file-association.mjs";import { createWeChatShareController } from "./wechat-share-import.mjs";+import { enableMacShareExtension } from "./share-extension-registration.mjs";import { accountDataDirectory, accountScopeKey } from "./account-scope.mjs";import { rotateDiagnosticLog } from "./diagnostic-log.mjs";import { restrictDirectory, restrictFile } from "./file-permissions.mjs";@@ -1819,6 +1820,19 @@ const startApplication = async () => {// user-visible critical path so the first installed launch opens promptly.await ejectMountedMacInstallers();await confirmMacInstallation();+ void enableMacShareExtension({+ platform: process.platform,+ packaged: app.isPackaged,+ executablePath: process.execPath,+ exists: existsSync,+ execFile,+ }).then((result) => {+ if (result.enabled) void writeDiagnostic("share-extension.enabled");+ }).catch((error) => {+ void writeDiagnostic("share-extension.enable-failed", {+ message: error instanceof Error ? error.message : String(error),+ });+ });configureAutoUpdater();handleOpenTarget(process.argv);protocolUrlsReady = true;diff --git a/apps/desktop/src/main/share-extension-registration.mjs b/apps/desktop/src/main/share-extension-registration.mjsnew file mode 100644index 00000000..b22f79fb--- /dev/null+++ b/apps/desktop/src/main/share-extension-registration.mjs@@ -0,0 +1,30 @@+import { dirname, join } from "node:path";++export const SHARE_EXTENSION_BUNDLE_ID = "org.edgeever.desktop.share";++export const macShareExtensionPath = (executablePath) =>+ join(dirname(executablePath), "..", "PlugIns", "EdgeEverShare.appex");++// macOS leaves a newly installed share extension disabled. The host app has to+// elect it, or WeChat's share sheet never lists EdgeEver for that user.+export const enableMacShareExtension = async ({+ platform,+ packaged,+ executablePath,+ exists,+ execFile,+}) => {+ if (platform !== "darwin" || !packaged) return { enabled: false };+ const appexPath = macShareExtensionPath(executablePath);+ if (!exists(appexPath)) return { enabled: false };+ await runPluginkit(execFile, ["-a", appexPath]);+ await runPluginkit(execFile, ["-e", "use", "-i", SHARE_EXTENSION_BUNDLE_ID]);+ return { enabled: true };+};++const runPluginkit = (execFile, args) => new Promise((resolve, reject) => {+ execFile("/usr/bin/pluginkit", args, { timeout: 10_000 }, (error) => {+ if (error) reject(error);+ else resolve();+ });+});diff --git a/apps/desktop/src/main/share-extension-registration.test.mjs b/apps/desktop/src/main/share-extension-registration.test.mjsnew file mode 100644index 00000000..0479107f--- /dev/null+++ b/apps/desktop/src/main/share-extension-registration.test.mjs@@ -0,0 +1,56 @@+import { describe, expect, test } from "bun:test";+import { enableMacShareExtension, macShareExtensionPath } from "./share-extension-registration.mjs";++const executable = "/Applications/EdgeEver.app/Contents/MacOS/EdgeEver";++describe("macOS share extension registration", () => {+ test("points at the PlugIns copy next to the packaged executable", () => {+ expect(macShareExtensionPath(executable)).toBe(+ "/Applications/EdgeEver.app/Contents/PlugIns/EdgeEverShare.appex",+ );+ });++ test("elects the installed extension for the current user", async () => {+ const calls = [];+ const result = await enableMacShareExtension({+ platform: "darwin",+ packaged: true,+ executablePath: executable,+ exists: () => true,+ execFile: (_command, args, _options, callback) => {+ calls.push(args);+ callback(null);+ },+ });+ expect(result).toEqual({ enabled: true });+ expect(calls).toEqual([+ ["-a", "/Applications/EdgeEver.app/Contents/PlugIns/EdgeEverShare.appex"],+ ["-e", "use", "-i", "org.edgeever.desktop.share"],+ ]);+ });++ test("skips registration away from a packaged Mac app", async () => {+ const execFile = () => { throw new Error("should not run"); };+ expect(await enableMacShareExtension({+ platform: "win32",+ packaged: true,+ executablePath: executable,+ exists: () => true,+ execFile,+ })).toEqual({ enabled: false });+ expect(await enableMacShareExtension({+ platform: "darwin",+ packaged: false,+ executablePath: executable,+ exists: () => true,+ execFile,+ })).toEqual({ enabled: false });+ expect(await enableMacShareExtension({+ platform: "darwin",+ packaged: true,+ executablePath: executable,+ exists: () => false,+ execFile,+ })).toEqual({ enabled: false });+ });+});diff --git a/package.json b/package.jsonindex bd27d97d..2b8b6dc5 100644--- a/package.json+++ b/package.json@@ -63,7 +63,7 @@"release": "bun scripts/release.mjs","publish:stores": "bun scripts/store-delivery.mjs","test:desktop:sidecar": "bun scripts/test-desktop-sidecar.mjs",- "test:desktop": "bun test apps/desktop/src/main/account-scope.test.mjs apps/desktop/src/main/app-protocol.test.mjs apps/desktop/src/main/child-process-start.test.mjs apps/desktop/src/main/clipboard-write.test.mjs apps/desktop/src/main/desktop-diagnostics.test.mjs apps/desktop/src/main/desktop-menu.test.mjs apps/desktop/src/main/desktop-update-flow.test.mjs apps/desktop/src/main/diagnostic-log.test.mjs apps/desktop/src/main/file-association.test.mjs apps/desktop/src/main/wechat-chat-archive.test.mjs apps/desktop/src/main/wechat-share-import.test.mjs apps/desktop/src/main/file-permissions.test.mjs apps/desktop/src/main/installation-location.test.mjs apps/desktop/src/main/local-data-reset.test.mjs apps/desktop/src/main/ai-direct.test.mjs apps/desktop/src/main/plugin-public-network.test.mjs apps/desktop/src/main/renderer-recovery.test.mjs apps/desktop/src/main/renderer-hibernate.test.mjs apps/desktop/src/main/renderer-startup-guard.test.mjs apps/desktop/src/main/renderer-storage-migration.test.mjs apps/desktop/src/main/resource-request.test.mjs apps/desktop/src/main/resource-url.test.mjs apps/desktop/src/main/scheduled-task-scheduler.test.mjs apps/desktop/src/main/screenshot-capture.test.mjs apps/desktop/src/main/staged-resource.test.mjs apps/desktop/src/main/tray-icon.test.mjs apps/desktop/src/main/user-data-directory.test.mjs apps/desktop/src/main/window-open-policy.test.mjs apps/desktop/src/main/window-visibility.test.mjs apps/desktop/src/main/windows-update-trust.test.mjs apps/web/src/lib/api.test.mjs apps/web/src/lib/app-page-path.test.mjs apps/web/src/lib/clipboard.test.mjs apps/web/src/lib/desktop-renderer-ready.test.mjs apps/web/src/lib/desktop-workspace-restore.test.mjs apps/web/src/lib/desktop-repository.test.mjs apps/web/src/lib/desktop-resources.test.mjs apps/web/src/lib/desktop-sync.test.mjs apps/web/src/lib/local-mirror.test.mjs apps/web/src/lib/repository.test.mjs apps/web/src/lib/runtime.test.mjs apps/web/src/lib/screenshot-import.test.mjs apps/web/src/lib/wechat-chat-import.test.mjs apps/web/src/lib/sync-queue.test.mjs && bun run test:desktop:sidecar",+ "test:desktop": "bun test apps/desktop/src/main/account-scope.test.mjs apps/desktop/src/main/app-protocol.test.mjs apps/desktop/src/main/child-process-start.test.mjs apps/desktop/src/main/clipboard-write.test.mjs apps/desktop/src/main/desktop-diagnostics.test.mjs apps/desktop/src/main/desktop-menu.test.mjs apps/desktop/src/main/desktop-update-flow.test.mjs apps/desktop/src/main/diagnostic-log.test.mjs apps/desktop/src/main/file-association.test.mjs apps/desktop/src/main/wechat-chat-archive.test.mjs apps/desktop/src/main/wechat-share-import.test.mjs apps/desktop/src/main/share-extension-registration.test.mjs apps/desktop/src/main/file-permissions.test.mjs apps/desktop/src/main/installation-location.test.mjs apps/desktop/src/main/local-data-reset.test.mjs apps/desktop/src/main/ai-direct.test.mjs apps/desktop/src/main/plugin-public-network.test.mjs apps/desktop/src/main/renderer-recovery.test.mjs apps/desktop/src/main/renderer-hibernate.test.mjs apps/desktop/src/main/renderer-startup-guard.test.mjs apps/desktop/src/main/renderer-storage-migration.test.mjs apps/desktop/src/main/resource-request.test.mjs apps/desktop/src/main/resource-url.test.mjs apps/desktop/src/main/scheduled-task-scheduler.test.mjs apps/desktop/src/main/screenshot-capture.test.mjs apps/desktop/src/main/staged-resource.test.mjs apps/desktop/src/main/tray-icon.test.mjs apps/desktop/src/main/user-data-directory.test.mjs apps/desktop/src/main/window-open-policy.test.mjs apps/desktop/src/main/window-visibility.test.mjs apps/desktop/src/main/windows-update-trust.test.mjs apps/web/src/lib/api.test.mjs apps/web/src/lib/app-page-path.test.mjs apps/web/src/lib/clipboard.test.mjs apps/web/src/lib/desktop-renderer-ready.test.mjs apps/web/src/lib/desktop-workspace-restore.test.mjs apps/web/src/lib/desktop-repository.test.mjs apps/web/src/lib/desktop-resources.test.mjs apps/web/src/lib/desktop-sync.test.mjs apps/web/src/lib/local-mirror.test.mjs apps/web/src/lib/repository.test.mjs apps/web/src/lib/runtime.test.mjs apps/web/src/lib/screenshot-import.test.mjs apps/web/src/lib/wechat-chat-import.test.mjs apps/web/src/lib/sync-queue.test.mjs && bun run test:desktop:sidecar","verify:desktop-renderer": "bun scripts/verify-desktop-renderer.mjs","verify:renderer-origin-migration": "bun run --cwd apps/desktop verify-origin-migration","verify:desktop-cross-version-startup": "bun scripts/verify-desktop-cross-version-startup.mjs",