From cf3ec7fc396125ed452c553b34ae2737329fc61d Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 24 Dec 2021 01:36:20 +0100 Subject: feat: Service to main process communication --- packages/shared/package.json | 11 ++++---- .../shared/src/contextBridge/SophieRenderer.ts | 2 ++ packages/shared/src/index.ts | 6 +++-- packages/shared/src/ipc.ts | 31 ++++++++++++++++++++++ .../shared/src/ipc/MainToRendererIpcMessage.ts | 24 ----------------- .../shared/src/ipc/RendererToMainIpcMessage.ts | 25 ----------------- 6 files changed, 43 insertions(+), 56 deletions(-) create mode 100644 packages/shared/src/ipc.ts delete mode 100644 packages/shared/src/ipc/MainToRendererIpcMessage.ts delete mode 100644 packages/shared/src/ipc/RendererToMainIpcMessage.ts (limited to 'packages/shared') diff --git a/packages/shared/package.json b/packages/shared/package.json index f5d4f90..96e9b68 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -2,6 +2,7 @@ "name": "@sophie/shared", "version": "0.1.0", "private": true, + "sideEffects": false, "main": "dist/index.cjs", "module": "dist/index.es.js", "types": "dist-types/index.d.ts", @@ -10,14 +11,14 @@ "build": "vite build", "typecheck": "tsc" }, - "devDependencies": { - "rimraf": "^3.0.2", - "typescript": "^4.5.4", - "vite": "^2.7.6" - }, "dependencies": { "mobx": "^6.3.10", "mobx-state-tree": "^5.1.0", "zod": "^3.11.6" + }, + "devDependencies": { + "rimraf": "^3.0.2", + "typescript": "^4.5.4", + "vite": "^2.7.6" } } diff --git a/packages/shared/src/contextBridge/SophieRenderer.ts b/packages/shared/src/contextBridge/SophieRenderer.ts index f2e2180..e310829 100644 --- a/packages/shared/src/contextBridge/SophieRenderer.ts +++ b/packages/shared/src/contextBridge/SophieRenderer.ts @@ -28,4 +28,6 @@ export interface SophieRenderer { setBrowserViewBounds(bounds: BrowserViewBounds): void; setPaletteMode(mode: PaletteMode): void; + + reloadAllServices(): void; } diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 0a1ec40..f054571 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -20,8 +20,10 @@ export type { SophieRenderer } from './contextBridge/SophieRenderer'; -export { MainToRendererIpcMessage } from './ipc/MainToRendererIpcMessage'; -export { RendererToMainIpcMessage } from './ipc/RendererToMainIpcMessage'; +export { + MainToRendererIpcMessage, + RendererToMainIpcMessage, +} from './ipc'; export type { BrowserViewBounds, diff --git a/packages/shared/src/ipc.ts b/packages/shared/src/ipc.ts new file mode 100644 index 0000000..2e35d7a --- /dev/null +++ b/packages/shared/src/ipc.ts @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2021-2022 Kristóf Marussy + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export enum MainToRendererIpcMessage { + SharedStoreSnapshot = 'sophie-main-to-renderer:shared-store-snapshot', + SharedStorePatch = 'sophie-main-to-renderer:shared-store-patch', +} + +export enum RendererToMainIpcMessage { + SharedStoreSnapshotRequest = 'sophie-renderer-to-main:shared-store-snapshot-request', + SetBrowserViewBounds = 'sophie-renderer-to-main:set-browser-view-bounds', + SetPaletteMode = 'sophie-renderer-to-main:set-palette-mode', + ReloadAllServices = 'sophie-renderer-to-main:reload-all-services', +} diff --git a/packages/shared/src/ipc/MainToRendererIpcMessage.ts b/packages/shared/src/ipc/MainToRendererIpcMessage.ts deleted file mode 100644 index 92da489..0000000 --- a/packages/shared/src/ipc/MainToRendererIpcMessage.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2021-2022 Kristóf Marussy - * - * This file is part of Sophie. - * - * Sophie is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -export enum MainToRendererIpcMessage { - SharedStoreSnapshot = 'sophie-shared-store-snapshot', - SharedStorePatch = 'sophie-shared-store-patch', -} diff --git a/packages/shared/src/ipc/RendererToMainIpcMessage.ts b/packages/shared/src/ipc/RendererToMainIpcMessage.ts deleted file mode 100644 index ba354d1..0000000 --- a/packages/shared/src/ipc/RendererToMainIpcMessage.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2021-2022 Kristóf Marussy - * - * This file is part of Sophie. - * - * Sophie is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -export enum RendererToMainIpcMessage { - SharedStoreSnapshotRequest = 'sophie-shared-store-snapshot-request', - SetBrowserViewBounds = 'sophie-set-browser-view-bounds', - SetPaletteMode = 'sophie-set-palette-mode', -} -- cgit v1.2.3-54-g00ecf