@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.
@@ -1,4 +1,4 @@
1
- @openmrs/esm-config:build: cache hit, replaying output a2fdcb147ab04c6a
1
+ @openmrs/esm-config:build: cache hit, replaying output 779deb5340561cd6
2
2
  @openmrs/esm-config:build: Browserslist: caniuse-lite is outdated. Please run:
3
3
  @openmrs/esm-config:build:  npx update-browserslist-db@latest
4
4
  @openmrs/esm-config:build:  Why you should do it regularly: https://github.com/browserslist/update-db#readme
@@ -9,4 +9,4 @@
9
9
  @openmrs/esm-config:build:  ./src/index.ts + 38 modules 82.3 KiB [built] [code generated]
10
10
  @openmrs/esm-config:build:  external "@openmrs/esm-state" 42 bytes [built] [code generated]
11
11
  @openmrs/esm-config:build:  external "single-spa" 42 bytes [built] [code generated]
12
- @openmrs/esm-config:build: webpack 5.77.0 compiled successfully in 10966 ms
12
+ @openmrs/esm-config:build: webpack 5.77.0 compiled successfully in 14812 ms
@@ -1,22 +1,22 @@
1
- import createStore, { Store } from "unistore";
2
-
1
+ import { createStore, StoreApi } from "zustand";
3
2
  interface StoreEntity {
4
- value: Store<any>;
3
+ value: StoreApi<any>;
5
4
  active: boolean;
6
5
  }
7
6
 
8
- export type MockedStore<T> = Store<T> & { resetMock: () => void };
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<TState>(
16
+ export function createGlobalStore<T>(
17
17
  name: string,
18
- initialState: TState
19
- ): Store<TState> {
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<TState = any>(
46
+ export function getGlobalStore<T>(
47
47
  name: string,
48
- fallbackState?: TState
49
- ): Store<TState> {
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: Store<T>) {
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.2-pre.680",
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.3.2-pre.680",
49
- "@openmrs/esm-state": "^4.3.2-pre.680",
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": "924a6261edaf89142bee78049ff388ef36b097ff"
55
+ "gitHead": "fdaefeded76bee4ec6503ca6590737e89ebe4b26"
56
56
  }