@openmrs/esm-config 4.3.2-pre.680 → 4.4.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/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[32m@openmrs/esm-config:build[0m: cache hit, replaying output [
|
|
1
|
+
[32m@openmrs/esm-config:build[0m: cache hit, replaying output [2m779deb5340561cd6[0m
|
|
2
2
|
[32m@openmrs/esm-config:build: [0mBrowserslist: caniuse-lite is outdated. Please run:
|
|
3
3
|
[32m@openmrs/esm-config:build: [0m npx update-browserslist-db@latest
|
|
4
4
|
[32m@openmrs/esm-config:build: [0m Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
[32m@openmrs/esm-config:build: [0m [1m./src/index.ts + 38 modules[39m[22m 82.3 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
10
10
|
[32m@openmrs/esm-config:build: [0m [1mexternal "@openmrs/esm-state"[39m[22m 42 bytes [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
11
11
|
[32m@openmrs/esm-config:build: [0m [1mexternal "single-spa"[39m[22m 42 bytes [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
12
|
-
[32m@openmrs/esm-config:build: [0mwebpack 5.77.0 compiled [1m[32msuccessfully[39m[22m in
|
|
12
|
+
[32m@openmrs/esm-config:build: [0mwebpack 5.77.0 compiled [1m[32msuccessfully[39m[22m in 14812 ms
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import createStore,
|
|
2
|
-
|
|
1
|
+
import { createStore, StoreApi } from "zustand";
|
|
3
2
|
interface StoreEntity {
|
|
4
|
-
value:
|
|
3
|
+
value: StoreApi<any>;
|
|
5
4
|
active: boolean;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
export type MockedStore<T> =
|
|
9
|
-
|
|
7
|
+
export type MockedStore<T> = StoreApi<T> & {
|
|
8
|
+
resetMock: () => void;
|
|
9
|
+
};
|
|
10
10
|
const initialStates: Record<string, any> = {};
|
|
11
11
|
|
|
12
12
|
const availableStores: Record<string, StoreEntity> = {};
|
|
13
13
|
|
|
14
14
|
export const mockStores = availableStores;
|
|
15
15
|
|
|
16
|
-
export function createGlobalStore<
|
|
16
|
+
export function createGlobalStore<T>(
|
|
17
17
|
name: string,
|
|
18
|
-
initialState:
|
|
19
|
-
):
|
|
18
|
+
initialState: T
|
|
19
|
+
): StoreApi<T> {
|
|
20
20
|
const available = availableStores[name];
|
|
21
21
|
|
|
22
22
|
if (available) {
|
|
@@ -31,7 +31,7 @@ export function createGlobalStore<TState>(
|
|
|
31
31
|
available.active = true;
|
|
32
32
|
return available.value;
|
|
33
33
|
} else {
|
|
34
|
-
const store = createStore(initialState);
|
|
34
|
+
const store = createStore<T>()(() => initialState);
|
|
35
35
|
initialStates[name] = initialState;
|
|
36
36
|
|
|
37
37
|
availableStores[name] = {
|
|
@@ -43,14 +43,14 @@ export function createGlobalStore<TState>(
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function getGlobalStore<
|
|
46
|
+
export function getGlobalStore<T>(
|
|
47
47
|
name: string,
|
|
48
|
-
fallbackState?:
|
|
49
|
-
):
|
|
48
|
+
fallbackState?: T
|
|
49
|
+
): StoreApi<T> {
|
|
50
50
|
const available = availableStores[name];
|
|
51
51
|
|
|
52
52
|
if (!available) {
|
|
53
|
-
const store = createStore(fallbackState);
|
|
53
|
+
const store = createStore<T>()(() => fallbackState ?? ({} as unknown as T));
|
|
54
54
|
initialStates[name] = fallbackState;
|
|
55
55
|
availableStores[name] = {
|
|
56
56
|
value: store,
|
|
@@ -62,12 +62,11 @@ export function getGlobalStore<TState = any>(
|
|
|
62
62
|
return instrumentedStore(name, available.value);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
function instrumentedStore<T>(name: string, store:
|
|
65
|
+
function instrumentedStore<T>(name: string, store: StoreApi<T>) {
|
|
66
66
|
return {
|
|
67
67
|
getState: jest.spyOn(store, "getState"),
|
|
68
68
|
setState: jest.spyOn(store, "setState"),
|
|
69
69
|
subscribe: jest.spyOn(store, "subscribe"),
|
|
70
|
-
unsubscribe: jest.spyOn(store, "unsubscribe"),
|
|
71
70
|
resetMock: () => store.setState(initialStates[name]),
|
|
72
71
|
} as any as MockedStore<T>;
|
|
73
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "A configuration library for the OpenMRS Single-Spa framework.",
|
|
6
6
|
"browser": "dist/openmrs-esm-module-config.js",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"systemjs": "6.x"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@openmrs/esm-globals": "^4.
|
|
49
|
-
"@openmrs/esm-state": "^4.
|
|
48
|
+
"@openmrs/esm-globals": "^4.4.0",
|
|
49
|
+
"@openmrs/esm-state": "^4.4.0",
|
|
50
50
|
"@types/ramda": "^0.26.44",
|
|
51
51
|
"@types/systemjs": "^6.1.0",
|
|
52
52
|
"babel-plugin-ramda": "^2.0.0",
|
|
53
53
|
"single-spa": "^5.9.2"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "fdaefeded76bee4ec6503ca6590737e89ebe4b26"
|
|
56
56
|
}
|