diff options
Diffstat (limited to 'packages/shared/src')
-rw-r--r-- | packages/shared/src/contextBridge/SophieRenderer.ts | 2 | ||||
-rw-r--r-- | packages/shared/src/index.ts | 41 | ||||
-rw-r--r-- | packages/shared/src/stores/GlobalSettings.ts (renamed from packages/shared/src/stores/Config.ts) | 17 | ||||
-rw-r--r-- | packages/shared/src/stores/Profile.ts | 10 | ||||
-rw-r--r-- | packages/shared/src/stores/ProfileSettings.ts (renamed from packages/shared/src/stores/RuntimeService.ts) | 28 | ||||
-rw-r--r-- | packages/shared/src/stores/Service.ts | 23 | ||||
-rw-r--r-- | packages/shared/src/stores/ServiceSettings.ts | 38 | ||||
-rw-r--r-- | packages/shared/src/stores/SharedStore.ts | 9 |
8 files changed, 95 insertions, 73 deletions
diff --git a/packages/shared/src/contextBridge/SophieRenderer.ts b/packages/shared/src/contextBridge/SophieRenderer.ts index 9858aa9..28dc0b7 100644 --- a/packages/shared/src/contextBridge/SophieRenderer.ts +++ b/packages/shared/src/contextBridge/SophieRenderer.ts | |||
@@ -21,7 +21,7 @@ | |||
21 | import { Action } from '../schemas'; | 21 | import { Action } from '../schemas'; |
22 | import { SharedStoreListener } from '../stores/SharedStore'; | 22 | import { SharedStoreListener } from '../stores/SharedStore'; |
23 | 23 | ||
24 | export interface SophieRenderer { | 24 | export default interface SophieRenderer { |
25 | onSharedStoreChange(this: void, listener: SharedStoreListener): Promise<void>; | 25 | onSharedStoreChange(this: void, listener: SharedStoreListener): Promise<void>; |
26 | 26 | ||
27 | dispatchAction(this: void, action: Action): void; | 27 | dispatchAction(this: void, action: Action): void; |
diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index df02854..55cf5ce 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts | |||
@@ -18,7 +18,7 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | export type { SophieRenderer } from './contextBridge/SophieRenderer'; | 21 | export type { default as SophieRenderer } from './contextBridge/SophieRenderer'; |
22 | 22 | ||
23 | export { MainToRendererIpcMessage, RendererToMainIpcMessage } from './ipc'; | 23 | export { MainToRendererIpcMessage, RendererToMainIpcMessage } from './ipc'; |
24 | 24 | ||
@@ -26,34 +26,33 @@ export type { Action, BrowserViewBounds, ThemeSource } from './schemas'; | |||
26 | export { action, browserViewBounds, themeSource } from './schemas'; | 26 | export { action, browserViewBounds, themeSource } from './schemas'; |
27 | 27 | ||
28 | export type { | 28 | export type { |
29 | Config, | 29 | GlobalSettings, |
30 | ConfigSnapshotIn, | 30 | GlobalSettingsSnapshotIn, |
31 | ConfigSnapshotOut, | 31 | GlobalSettingsSnapshotOut, |
32 | } from './stores/Config'; | 32 | } from './stores/GlobalSettings'; |
33 | export { config } from './stores/Config'; | 33 | export { globalSettings } from './stores/GlobalSettings'; |
34 | 34 | ||
35 | export type { | 35 | export type { Profile } from './stores/Profile'; |
36 | Profile, | ||
37 | ProfileSnapshotIn, | ||
38 | ProfileSnapshotOut, | ||
39 | } from './stores/Profile'; | ||
40 | export { profile } from './stores/Profile'; | 36 | export { profile } from './stores/Profile'; |
41 | 37 | ||
42 | export type { | 38 | export type { |
43 | RuntimeService, | 39 | ProfileSettings, |
44 | RuntimeServiceSnapshotIn, | 40 | ProfileSettingsSnapshotIn, |
45 | RuntimeServiceSnapshotOut, | 41 | ProfileSettingsSnapshotOut, |
46 | } from './stores/RuntimeService'; | 42 | } from './stores/ProfileSettings'; |
47 | export { runtimeService } from './stores/RuntimeService'; | 43 | export { profileSettings } from './stores/ProfileSettings'; |
48 | 44 | ||
49 | export type { | 45 | export type { Service } from './stores/Service'; |
50 | Service, | ||
51 | ServiceSnapshotIn, | ||
52 | ServiceSnapshotOut, | ||
53 | } from './stores/Service'; | ||
54 | export { service } from './stores/Service'; | 46 | export { service } from './stores/Service'; |
55 | 47 | ||
56 | export type { | 48 | export type { |
49 | ServiceSettings, | ||
50 | ServiceSettingsSnapshotIn, | ||
51 | ServiceSettingsSnapshotOut, | ||
52 | } from './stores/ServiceSettings'; | ||
53 | export { serviceSettings } from './stores/ServiceSettings'; | ||
54 | |||
55 | export type { | ||
57 | SharedStore, | 56 | SharedStore, |
58 | SharedStoreListener, | 57 | SharedStoreListener, |
59 | SharedStoreSnapshotIn, | 58 | SharedStoreSnapshotIn, |
diff --git a/packages/shared/src/stores/Config.ts b/packages/shared/src/stores/GlobalSettings.ts index 1d97e7d..bd0155a 100644 --- a/packages/shared/src/stores/Config.ts +++ b/packages/shared/src/stores/GlobalSettings.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2021-2022 Kristóf Marussy <kristof@marussy.com> | 2 | * Copyright (C) 2022 Kristóf Marussy <kristof@marussy.com> |
3 | * | 3 | * |
4 | * This file is part of Sophie. | 4 | * This file is part of Sophie. |
5 | * | 5 | * |
@@ -22,17 +22,14 @@ import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; | |||
22 | 22 | ||
23 | import { themeSource } from '../schemas'; | 23 | import { themeSource } from '../schemas'; |
24 | 24 | ||
25 | import { profile } from './Profile'; | 25 | export const globalSettings = types.model('GlobalSettings', { |
26 | import { service } from './Service'; | ||
27 | |||
28 | export const config = types.model('Config', { | ||
29 | profiles: types.array(profile), | ||
30 | services: types.array(service), | ||
31 | themeSource: types.optional(types.enumeration(themeSource.options), 'system'), | 26 | themeSource: types.optional(types.enumeration(themeSource.options), 'system'), |
32 | }); | 27 | }); |
33 | 28 | ||
34 | export interface Config extends Instance<typeof config> {} | 29 | export interface GlobalSettings extends Instance<typeof globalSettings> {} |
35 | 30 | ||
36 | export interface ConfigSnapshotIn extends SnapshotIn<typeof config> {} | 31 | export interface GlobalSettingsSnapshotIn |
32 | extends SnapshotIn<typeof globalSettings> {} | ||
37 | 33 | ||
38 | export interface ConfigSnapshotOut extends SnapshotOut<typeof config> {} | 34 | export interface GlobalSettingsSnapshotOut |
35 | extends SnapshotOut<typeof globalSettings> {} | ||
diff --git a/packages/shared/src/stores/Profile.ts b/packages/shared/src/stores/Profile.ts index 88a0f4d..bb058f6 100644 --- a/packages/shared/src/stores/Profile.ts +++ b/packages/shared/src/stores/Profile.ts | |||
@@ -18,15 +18,13 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; | 21 | import { Instance, types } from 'mobx-state-tree'; |
22 | |||
23 | import { profileSettings } from './ProfileSettings'; | ||
22 | 24 | ||
23 | export const profile = types.model('Profile', { | 25 | export const profile = types.model('Profile', { |
24 | id: types.identifier, | 26 | id: types.identifier, |
25 | name: types.string, | 27 | settings: profileSettings, |
26 | }); | 28 | }); |
27 | 29 | ||
28 | export interface Profile extends Instance<typeof profile> {} | 30 | export interface Profile extends Instance<typeof profile> {} |
29 | |||
30 | export interface ProfileSnapshotIn extends SnapshotIn<typeof profile> {} | ||
31 | |||
32 | export interface ProfileSnapshotOut extends SnapshotOut<typeof profile> {} | ||
diff --git a/packages/shared/src/stores/RuntimeService.ts b/packages/shared/src/stores/ProfileSettings.ts index c5b9031..ec8da5f 100644 --- a/packages/shared/src/stores/RuntimeService.ts +++ b/packages/shared/src/stores/ProfileSettings.ts | |||
@@ -20,28 +20,14 @@ | |||
20 | 20 | ||
21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; | 21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; |
22 | 22 | ||
23 | export const runtimeService = types.model({ | 23 | export const profileSettings = types.model('ProfileSettings', { |
24 | url: types.maybe(types.string), | 24 | name: types.string, |
25 | canGoBack: false, | ||
26 | canGoForward: false, | ||
27 | title: types.maybe(types.string), | ||
28 | state: types.optional( | ||
29 | types.enumeration('ServiceState', [ | ||
30 | 'hibernated', | ||
31 | 'loading', | ||
32 | 'loaded', | ||
33 | 'crashed', | ||
34 | ]), | ||
35 | 'hibernated', | ||
36 | ), | ||
37 | directMessageCount: 0, | ||
38 | indirectMessageCount: 0, | ||
39 | }); | 25 | }); |
40 | 26 | ||
41 | export interface RuntimeService extends Instance<typeof runtimeService> {} | 27 | export interface ProfileSettings extends Instance<typeof profileSettings> {} |
42 | 28 | ||
43 | export interface RuntimeServiceSnapshotIn | 29 | export interface ProfileSettingsSnapshotIn |
44 | extends SnapshotIn<typeof runtimeService> {} | 30 | extends SnapshotIn<typeof profileSettings> {} |
45 | 31 | ||
46 | export interface RuntimeServiceSnapshotOut | 32 | export interface ProfileSettingsSnapshotOut |
47 | extends SnapshotOut<typeof runtimeService> {} | 33 | extends SnapshotOut<typeof profileSettings> {} |
diff --git a/packages/shared/src/stores/Service.ts b/packages/shared/src/stores/Service.ts index ed2cd9a..36acd3d 100644 --- a/packages/shared/src/stores/Service.ts +++ b/packages/shared/src/stores/Service.ts | |||
@@ -18,20 +18,23 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; | 21 | import { Instance, types } from 'mobx-state-tree'; |
22 | 22 | ||
23 | import { profile } from './Profile'; | 23 | import { serviceSettings } from './ServiceSettings'; |
24 | 24 | ||
25 | export const service = types.model('Service', { | 25 | export const service = types.model('Service', { |
26 | id: types.identifier, | 26 | id: types.identifier, |
27 | name: types.string, | 27 | settings: serviceSettings, |
28 | profile: types.reference(profile), | 28 | currentUrl: types.maybe(types.string), |
29 | // TODO: Remove this once recipes are added. | 29 | canGoBack: false, |
30 | url: types.string, | 30 | canGoForward: false, |
31 | title: types.maybe(types.string), | ||
32 | state: types.optional( | ||
33 | types.enumeration('ServiceState', ['loading', 'loaded', 'crashed']), | ||
34 | 'loading', | ||
35 | ), | ||
36 | directMessageCount: 0, | ||
37 | indirectMessageCount: 0, | ||
31 | }); | 38 | }); |
32 | 39 | ||
33 | export interface Service extends Instance<typeof service> {} | 40 | export interface Service extends Instance<typeof service> {} |
34 | |||
35 | export interface ServiceSnapshotIn extends SnapshotIn<typeof service> {} | ||
36 | |||
37 | export interface ServiceSnapshotOut extends SnapshotOut<typeof service> {} | ||
diff --git a/packages/shared/src/stores/ServiceSettings.ts b/packages/shared/src/stores/ServiceSettings.ts new file mode 100644 index 0000000..54cd7eb --- /dev/null +++ b/packages/shared/src/stores/ServiceSettings.ts | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright (C) 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 | |||
21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; | ||
22 | |||
23 | import { profile } from './Profile'; | ||
24 | |||
25 | export const serviceSettings = types.model('ServiceSettings', { | ||
26 | name: types.string, | ||
27 | profile: types.reference(profile), | ||
28 | // TODO: Remove this once recipes are added. | ||
29 | url: types.string, | ||
30 | }); | ||
31 | |||
32 | export interface ServiceSettings extends Instance<typeof serviceSettings> {} | ||
33 | |||
34 | export interface ServiceSettingsSnapshotIn | ||
35 | extends SnapshotIn<typeof serviceSettings> {} | ||
36 | |||
37 | export interface ServiceSettingsSnapshotOut | ||
38 | extends SnapshotOut<typeof serviceSettings> {} | ||
diff --git a/packages/shared/src/stores/SharedStore.ts b/packages/shared/src/stores/SharedStore.ts index e6e2cad..a04f4bf 100644 --- a/packages/shared/src/stores/SharedStore.ts +++ b/packages/shared/src/stores/SharedStore.ts | |||
@@ -26,13 +26,14 @@ import { | |||
26 | SnapshotOut, | 26 | SnapshotOut, |
27 | } from 'mobx-state-tree'; | 27 | } from 'mobx-state-tree'; |
28 | 28 | ||
29 | import { config } from './Config'; | 29 | import { globalSettings } from './GlobalSettings'; |
30 | import { runtimeService } from './RuntimeService'; | 30 | import { profile } from './Profile'; |
31 | import { service } from './Service'; | 31 | import { service } from './Service'; |
32 | 32 | ||
33 | export const sharedStore = types.model('SharedStore', { | 33 | export const sharedStore = types.model('SharedStore', { |
34 | config: types.optional(config, {}), | 34 | settings: types.optional(globalSettings, {}), |
35 | runtimeServices: types.map(runtimeService), | 35 | profiles: types.array(profile), |
36 | services: types.array(service), | ||
36 | selectedService: types.safeReference(service), | 37 | selectedService: types.safeReference(service), |
37 | shouldUseDarkColors: false, | 38 | shouldUseDarkColors: false, |
38 | }); | 39 | }); |