@exodus/ui-config 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/api/index.js +8 -17
- package/atoms/index.js +19 -0
- package/index.js +5 -25
- package/package.json +11 -9
- package/plugin/index.js +20 -18
- package/redux/index.js +3 -8
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [3.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/ui-config@3.1.1...@exodus/ui-config@3.2.0) (2023-10-04)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **ui-config:** do not emit using atom id ([#4342](https://github.com/ExodusMovement/exodus-hydra/issues/4342)) ([df9d7b6](https://github.com/ExodusMovement/exodus-hydra/commit/df9d7b67bbca1c351128afd2e7a76a718dd71a79))
|
|
11
|
+
- **ui-config:** support unecrypted ui-configs ([#4286](https://github.com/ExodusMovement/exodus-hydra/issues/4286)) ([b4f7923](https://github.com/ExodusMovement/exodus-hydra/commit/b4f792369c145a7d84b30bf2e2237f9be053caf9))
|
|
12
|
+
|
|
13
|
+
## [3.1.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/ui-config@3.1.0...@exodus/ui-config@3.1.1) (2023-09-19)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- **ui-config:** watch on app restart ([#4086](https://github.com/ExodusMovement/exodus-hydra/issues/4086)) ([cc7ef5b](https://github.com/ExodusMovement/exodus-hydra/commit/cc7ef5b3b8df9d3a28fd6277a695e3778948a745))
|
|
18
|
+
|
|
19
|
+
## [3.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/ui-config@3.0.0...@exodus/ui-config@3.1.0) (2023-09-05)
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
- ui-config redux ([#3842](https://github.com/ExodusMovement/exodus-hydra/issues/3842)) ([d9e9f33](https://github.com/ExodusMovement/exodus-hydra/commit/d9e9f33cd6d2d0b96f48a821d2eb3f331ebb570c))
|
|
24
|
+
|
|
25
|
+
## [3.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/ui-config@2.0.0...@exodus/ui-config@3.0.0) (2023-09-01)
|
|
26
|
+
|
|
27
|
+
### ⚠ BREAKING CHANGES
|
|
28
|
+
|
|
29
|
+
- **ui-config:** expose utils to compute events (#3819)
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- **ui-config:** expose utils to compute events ([#3819](https://github.com/ExodusMovement/exodus-hydra/issues/3819)) ([32d8bfd](https://github.com/ExodusMovement/exodus-hydra/commit/32d8bfd0a992ee25c9771dfe875683a4b8c8ae3d))
|
|
34
|
+
|
|
35
|
+
## [2.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/ui-config@1.0.0...@exodus/ui-config@2.0.0) (2023-08-11)
|
|
36
|
+
|
|
37
|
+
### ⚠ BREAKING CHANGES
|
|
38
|
+
|
|
39
|
+
- change ui config data structure (#3294)
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
- change ui config data structure ([#3294](https://github.com/ExodusMovement/exodus-hydra/issues/3294)) ([eaceb99](https://github.com/ExodusMovement/exodus-hydra/commit/eaceb99ad4310255ff70769435f16f2daa43ce5a))
|
package/api/index.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const createUiConfigApiDefinition = ({ configValues }) => {
|
|
2
|
+
const atomIds = configValues.map((v) => v.atomId)
|
|
3
3
|
|
|
4
|
-
const createUiConfigApiDefinition = ({ atomIds, atomConfigMap }) => {
|
|
5
4
|
return {
|
|
6
5
|
definition: {
|
|
7
6
|
type: 'api',
|
|
8
7
|
id: 'uiConfig',
|
|
9
8
|
factory: ({ ...atoms }) => {
|
|
10
|
-
const uiConfig =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get: atom.get,
|
|
17
|
-
},
|
|
18
|
-
}))
|
|
19
|
-
)
|
|
20
|
-
)
|
|
21
|
-
return {
|
|
22
|
-
uiConfig,
|
|
23
|
-
}
|
|
9
|
+
const uiConfig = configValues.reduce((acc, { id, atomId }) => {
|
|
10
|
+
acc[id] = { get: atoms[atomId].get, set: atoms[atomId].set }
|
|
11
|
+
return acc
|
|
12
|
+
}, {})
|
|
13
|
+
|
|
14
|
+
return { uiConfig }
|
|
24
15
|
},
|
|
25
16
|
dependencies: atomIds,
|
|
26
17
|
},
|
package/atoms/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createStorageAtomFactory } from '@exodus/atoms'
|
|
2
|
+
|
|
3
|
+
const createUiConfigAtomDefinitions = ({ configValues }) => {
|
|
4
|
+
return configValues.map(({ id, atomId, encrypted }) => ({
|
|
5
|
+
definition: {
|
|
6
|
+
id: atomId,
|
|
7
|
+
type: 'atom',
|
|
8
|
+
factory: ({ storage }) =>
|
|
9
|
+
createStorageAtomFactory({ storage })({ key: id, isSoleWriter: true }),
|
|
10
|
+
dependencies: ['storage'],
|
|
11
|
+
},
|
|
12
|
+
aliases: [
|
|
13
|
+
{ implementationId: encrypted ? 'storage' : 'unsafeStorage', interfaceId: 'storage' },
|
|
14
|
+
],
|
|
15
|
+
storage: { namespace: 'uiConfig' },
|
|
16
|
+
}))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default createUiConfigAtomDefinitions
|
package/index.js
CHANGED
|
@@ -1,39 +1,19 @@
|
|
|
1
|
-
import { createStorageAtomFactory } from '@exodus/atoms'
|
|
2
|
-
|
|
3
1
|
import createUiConfigApiDefinition from './api'
|
|
2
|
+
import createUiConfigAtomDefinitions from './atoms'
|
|
4
3
|
import createUiConfigPluginDefinition from './plugin'
|
|
5
4
|
import { getAtomId } from './utils'
|
|
6
5
|
|
|
7
6
|
export { getConfigReduxEvents, getEventReduxMap } from './utils'
|
|
8
7
|
|
|
9
8
|
const createUiConfigFeatureDefinition = ({ config }) => {
|
|
10
|
-
const configValues = Object.values(config)
|
|
11
|
-
const configAtomMap = Object.fromEntries(configValues.map(({ id }) => [id, getAtomId(id)]))
|
|
12
|
-
const atomConfigMap = Object.fromEntries(
|
|
13
|
-
Object.keys(configAtomMap).map((configId) => [configAtomMap[configId], configId])
|
|
14
|
-
)
|
|
15
|
-
const atoms = configValues.map(({ id }) => ({
|
|
16
|
-
definition: {
|
|
17
|
-
id: configAtomMap[id],
|
|
18
|
-
type: 'atom',
|
|
19
|
-
factory: ({ storage, config }) =>
|
|
20
|
-
createStorageAtomFactory({ storage })({
|
|
21
|
-
key: id,
|
|
22
|
-
isSoleWriter: true,
|
|
23
|
-
}),
|
|
24
|
-
dependencies: ['storage'],
|
|
25
|
-
},
|
|
26
|
-
storage: { namespace: 'uiConfig' },
|
|
27
|
-
}))
|
|
28
|
-
|
|
29
|
-
const atomIds = Object.keys(atomConfigMap)
|
|
9
|
+
const configValues = Object.values(config).map((v) => ({ ...v, atomId: getAtomId(v.id) }))
|
|
30
10
|
|
|
31
11
|
return {
|
|
32
12
|
id: 'uiConfigFeatureDefinition',
|
|
33
13
|
definitions: [
|
|
34
|
-
...
|
|
35
|
-
createUiConfigApiDefinition({
|
|
36
|
-
createUiConfigPluginDefinition({
|
|
14
|
+
...createUiConfigAtomDefinitions({ configValues }),
|
|
15
|
+
createUiConfigApiDefinition({ configValues }),
|
|
16
|
+
createUiConfigPluginDefinition({ configValues }),
|
|
37
17
|
],
|
|
38
18
|
}
|
|
39
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ui-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Helper for storing various UI-specific settings/config.",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -14,13 +14,15 @@
|
|
|
14
14
|
},
|
|
15
15
|
"main": "index.js",
|
|
16
16
|
"files": [
|
|
17
|
-
"
|
|
18
|
-
"utils.js",
|
|
19
|
-
"plugin",
|
|
17
|
+
"!**/__tests__/**",
|
|
20
18
|
"api",
|
|
21
|
-
"
|
|
19
|
+
"atoms",
|
|
20
|
+
"plugin",
|
|
22
21
|
"redux",
|
|
23
|
-
"
|
|
22
|
+
"utils",
|
|
23
|
+
"CHANGELOG.md",
|
|
24
|
+
"utils.js",
|
|
25
|
+
"README.md"
|
|
24
26
|
],
|
|
25
27
|
"scripts": {
|
|
26
28
|
"lint": "eslint . --ignore-path ../../.gitignore",
|
|
@@ -28,9 +30,9 @@
|
|
|
28
30
|
"test": "jest"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
31
|
-
"@exodus/atoms": "^5.7.
|
|
33
|
+
"@exodus/atoms": "^5.7.1",
|
|
32
34
|
"@exodus/basic-utils": "^2.1.0",
|
|
33
|
-
"@exodus/formatting": "^1.2.
|
|
35
|
+
"@exodus/formatting": "^1.2.1",
|
|
34
36
|
"lodash": "^4.17.21"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
@@ -39,5 +41,5 @@
|
|
|
39
41
|
"jest": "^29.1.2",
|
|
40
42
|
"redux": "^4.2.1"
|
|
41
43
|
},
|
|
42
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "0bf201381bb809dcdd56df11c9208713e375da3a"
|
|
43
45
|
}
|
package/plugin/index.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { createAtomObserver } from '@exodus/atoms'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
createAtomObserver({ port, atom, event: atomId })
|
|
6
|
-
)
|
|
3
|
+
const createUiConfigPluginDefinition = ({ configValues }) => {
|
|
4
|
+
const atomIds = configValues.map((v) => v.atomId)
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
const factory = ({ port, ...atoms }) => {
|
|
7
|
+
const atomObservers = configValues.map(({ id, atomId }) =>
|
|
8
|
+
createAtomObserver({ port, atom: atoms[atomId], event: id })
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
onLoad: () => atomObservers.forEach((observer) => observer.start()),
|
|
13
|
+
onClear: () => Promise.all(Object.values(atoms).map((atom) => atom.set(undefined))),
|
|
14
|
+
onStop: () => atomObservers.forEach((observer) => observer.unregister()),
|
|
15
|
+
}
|
|
16
|
+
}
|
|
9
17
|
|
|
10
18
|
return {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
definition: {
|
|
20
|
+
type: 'plugin',
|
|
21
|
+
id: 'uiConfigPlugin',
|
|
22
|
+
factory,
|
|
23
|
+
dependencies: ['port', ...atomIds],
|
|
24
|
+
},
|
|
25
|
+
writesAtoms: atomIds,
|
|
14
26
|
}
|
|
15
27
|
}
|
|
16
28
|
|
|
17
|
-
const createUiConfigPluginDefinition = ({ atomIds }) => ({
|
|
18
|
-
definition: {
|
|
19
|
-
type: 'plugin',
|
|
20
|
-
id: 'uiConfigPlugin',
|
|
21
|
-
factory,
|
|
22
|
-
dependencies: ['port', ...atomIds],
|
|
23
|
-
},
|
|
24
|
-
writesAtoms: atomIds,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
29
|
export default createUiConfigPluginDefinition
|
package/redux/index.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import id from './id'
|
|
2
|
-
import { getAtomId } from '../utils'
|
|
3
2
|
|
|
4
3
|
const createUiConfigReduxDefinition = (config) => {
|
|
5
4
|
const configValues = Object.values(config)
|
|
6
|
-
|
|
5
|
+
|
|
7
6
|
const initialState = Object.fromEntries(configValues.map(({ id }) => [id, undefined]))
|
|
7
|
+
|
|
8
8
|
const eventReducers = Object.fromEntries(
|
|
9
|
-
|
|
10
|
-
atomId,
|
|
11
|
-
(state, payload) => {
|
|
12
|
-
return { ...state, [configId]: payload }
|
|
13
|
-
},
|
|
14
|
-
])
|
|
9
|
+
configValues.map(({ id }) => [id, (state, payload) => ({ ...state, [id]: payload })])
|
|
15
10
|
)
|
|
16
11
|
|
|
17
12
|
return {
|