aboutsummaryrefslogtreecommitdiffstats
path: root/packages/service-preload
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-24 01:36:20 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-24 01:36:20 +0100
commitcf3ec7fc396125ed452c553b34ae2737329fc61d (patch)
tree6d2fdbb40b9c9b1d32168d1ccb2372b5602f1968 /packages/service-preload
parentfeat: Set up partition persistence (diff)
downloadsophie-cf3ec7fc396125ed452c553b34ae2737329fc61d.tar.gz
sophie-cf3ec7fc396125ed452c553b34ae2737329fc61d.tar.zst
sophie-cf3ec7fc396125ed452c553b34ae2737329fc61d.zip
feat: Service to main process communication
Diffstat (limited to 'packages/service-preload')
-rw-r--r--packages/service-preload/package.json22
-rw-r--r--packages/service-preload/src/index.ts29
-rw-r--r--packages/service-preload/tsconfig.json17
-rw-r--r--packages/service-preload/vite.config.js31
4 files changed, 99 insertions, 0 deletions
diff --git a/packages/service-preload/package.json b/packages/service-preload/package.json
new file mode 100644
index 0000000..1296cda
--- /dev/null
+++ b/packages/service-preload/package.json
@@ -0,0 +1,22 @@
1{
2 "name": "@sophie/service-preload",
3 "version": "0.1.0",
4 "private": true,
5 "sideEffects": false,
6 "main": "dist/index.cjs",
7 "types": "dist-types/index.d.ts",
8 "scripts": {
9 "clean": "rimraf dist dist-types tsconfig.tsbuildinfo",
10 "build": "vite build",
11 "typecheck": "tsc"
12 },
13 "dependencies": {
14 "@sophie/service-shared": "workspace:*",
15 "electron": "16.0.5"
16 },
17 "devDependencies": {
18 "rimraf": "^3.0.2",
19 "typescript": "^4.5.4",
20 "vite": "^2.7.6"
21 }
22}
diff --git a/packages/service-preload/src/index.ts b/packages/service-preload/src/index.ts
new file mode 100644
index 0000000..4e93a07
--- /dev/null
+++ b/packages/service-preload/src/index.ts
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2021-2022 Kristóf Marussy <kristof@marussy.com>
3 *
4 * This file is part of Sophie.
5 *
6 * Sophie is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: AGPL-3.0-only
19 */
20
21import { ipcRenderer } from 'electron';
22import { ServiceToMainIpcMessage } from '@sophie/service-shared';
23
24let i = 1;
25
26setInterval(() => {
27 ipcRenderer.send(ServiceToMainIpcMessage.SetUnreadCount, { direct: i });
28 i += 1;
29}, 1000);
diff --git a/packages/service-preload/tsconfig.json b/packages/service-preload/tsconfig.json
new file mode 100644
index 0000000..e5b8ccb
--- /dev/null
+++ b/packages/service-preload/tsconfig.json
@@ -0,0 +1,17 @@
1{
2 "extends": "../../tsconfig.json",
3 "compilerOptions": {
4 "composite": true,
5 "declarationDir": "dist-types",
6 "emitDeclarationOnly": true,
7 "rootDir": "src"
8 },
9 "references": [
10 {
11 "path": "../service-shared"
12 }
13 ],
14 "include": [
15 "src/**/*.ts"
16 ]
17}
diff --git a/packages/service-preload/vite.config.js b/packages/service-preload/vite.config.js
new file mode 100644
index 0000000..5af78d9
--- /dev/null
+++ b/packages/service-preload/vite.config.js
@@ -0,0 +1,31 @@
1// @ts-check
2
3import { builtinModules } from 'module';
4
5import { chrome, makeConfig } from '../../config/vite-common';
6
7/** @type string */
8const PACKAGE_ROOT = __dirname;
9
10/**
11 * @type {import('vite').UserConfig}
12 * @see https://vitejs.dev/config/
13 */
14const config = makeConfig({
15 root: PACKAGE_ROOT,
16 build: {
17 target: chrome,
18 lib: {
19 entry: 'src/index.ts',
20 formats: ['cjs'],
21 },
22 rollupOptions: {
23 external: [
24 'electron',
25 ...builtinModules,
26 ],
27 },
28 },
29});
30
31export default config;