/
configSchema.ts
47 lines (45 loc) · 1.22 KB
/
configSchema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { types } from 'mobx-state-tree'
import { ConfigurationSchema } from '../configuration'
import WebWorkerRpcDriverConfigSchema from './webWorkerRpcConfig'
import MainThreadRpcDriverConfigSchema from './mainThreadRpcConfig'
/**
* #config RpcOptions
*/
function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
export default ConfigurationSchema(
'RpcOptions',
{
/**
* #slot
*/
defaultDriver: {
type: 'string',
description:
'the RPC driver to use for tracks and tasks that are not configured to use a specific RPC backend',
defaultValue: 'MainThreadRpcDriver',
},
/**
* #slot
*/
drivers: types.optional(
types.map(
types.union(
MainThreadRpcDriverConfigSchema,
WebWorkerRpcDriverConfigSchema,
),
),
{
MainThreadRpcDriver: { type: 'MainThreadRpcDriver' },
WebWorkerRpcDriver: { type: 'WebWorkerRpcDriver' },
},
),
},
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
actions: (self: any) => ({
addDriverConfig(configName: string, configSnapshot: { type: string }) {
self.drivers.set(configName, configSnapshot)
},
}),
},
)