@openmrs/esm-state 10.0.1-pre.5704 → 10.0.1-pre.5707
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 +1 -1
- package/dist/state.d.ts +14 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +14 -0
- package/package.json +5 -5
- package/src/state.ts +18 -0
package/.turbo/turbo-build.log
CHANGED
package/dist/state.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StoreApi } from 'zustand/vanilla';
|
|
2
|
+
export type { StoreApi } from 'zustand/vanilla';
|
|
2
3
|
type StorageType = 'none' | 'sessionStorage';
|
|
3
4
|
/**
|
|
4
5
|
* Creates a Zustand store.
|
|
@@ -10,6 +11,19 @@ type StorageType = 'none' | 'sessionStorage';
|
|
|
10
11
|
* @returns The newly created store.
|
|
11
12
|
*/
|
|
12
13
|
export declare function createGlobalStore<T>(name: string, initialState: T, storageType?: StorageType): StoreApi<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a Zustand store that is NOT registered in the global store registry.
|
|
16
|
+
*
|
|
17
|
+
* Unlike {@link createGlobalStore}, this store has no name and is never added to `availableStores`,
|
|
18
|
+
* so it does not appear on `window.stores`, cannot collide with another store's name, and is
|
|
19
|
+
* garbage-collected once no longer referenced. Use this for per-instance/component-local state that
|
|
20
|
+
* must be isolated from every other instance (for example, one store per rendered component), where
|
|
21
|
+
* a named global store would either collide across instances or leak.
|
|
22
|
+
*
|
|
23
|
+
* @param initialState An object which will be the initial state of the store.
|
|
24
|
+
* @returns The newly created store.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createLocalStore<T>(initialState: T): StoreApi<T>;
|
|
13
27
|
/**
|
|
14
28
|
* Registers an existing Zustand store.
|
|
15
29
|
*
|
|
@@ -45,5 +59,4 @@ export declare function getGlobalStore<T>(name: string, fallbackState?: T, fallb
|
|
|
45
59
|
*/
|
|
46
60
|
export declare function subscribeTo<T, U = T>(store: StoreApi<T>, handle: (state: T) => void): () => void;
|
|
47
61
|
export declare function subscribeTo<T, U>(store: StoreApi<T>, select: (state: T) => U, handle: (subState: U) => void): () => void;
|
|
48
|
-
export {};
|
|
49
62
|
//# sourceMappingURL=state.d.ts.map
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIhD,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAyChD,KAAK,WAAW,GAAG,MAAM,GAAG,gBAAgB,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE,WAAW,GAAE,WAAoB,GAAG,QAAQ,CAAC,CAAC,CAAC,CAwBlH;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAEhE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAsBpF;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,IAAI,EAAE,MAAM,EACZ,aAAa,CAAC,EAAE,CAAC,EACjB,mBAAmB,GAAE,WAAoB,GACxC,QAAQ,CAAC,CAAC,CAAC,CAab;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;AAClG,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EACvB,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,GAC5B,MAAM,IAAI,CAAC"}
|
package/dist/state.js
CHANGED
|
@@ -55,6 +55,20 @@ globalThis.setTimeout?.(()=>{
|
|
|
55
55
|
return store;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a Zustand store that is NOT registered in the global store registry.
|
|
60
|
+
*
|
|
61
|
+
* Unlike {@link createGlobalStore}, this store has no name and is never added to `availableStores`,
|
|
62
|
+
* so it does not appear on `window.stores`, cannot collide with another store's name, and is
|
|
63
|
+
* garbage-collected once no longer referenced. Use this for per-instance/component-local state that
|
|
64
|
+
* must be isolated from every other instance (for example, one store per rendered component), where
|
|
65
|
+
* a named global store would either collide across instances or leak.
|
|
66
|
+
*
|
|
67
|
+
* @param initialState An object which will be the initial state of the store.
|
|
68
|
+
* @returns The newly created store.
|
|
69
|
+
*/ export function createLocalStore(initialState) {
|
|
70
|
+
return createStore()(()=>initialState);
|
|
71
|
+
}
|
|
58
72
|
/**
|
|
59
73
|
* Registers an existing Zustand store.
|
|
60
74
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-state",
|
|
3
|
-
"version": "10.0.1-pre.
|
|
3
|
+
"version": "10.0.1-pre.5707",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Frontend stores & state management for OpenMRS",
|
|
6
6
|
"type": "module",
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
"zustand": "^4.5.5"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@openmrs/esm-globals": "^10.0.1-pre.
|
|
62
|
-
"@openmrs/esm-utils": "^10.0.1-pre.
|
|
61
|
+
"@openmrs/esm-globals": "^10.0.1-pre.5707",
|
|
62
|
+
"@openmrs/esm-utils": "^10.0.1-pre.5707"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@openmrs/esm-globals": "10.0.1-pre.
|
|
66
|
-
"@openmrs/esm-utils": "10.0.1-pre.
|
|
65
|
+
"@openmrs/esm-globals": "10.0.1-pre.5707",
|
|
66
|
+
"@openmrs/esm-utils": "10.0.1-pre.5707",
|
|
67
67
|
"@swc/cli": "0.8.1",
|
|
68
68
|
"@swc/core": "1.15.21",
|
|
69
69
|
"@vitest/coverage-v8": "^4.1.2",
|
package/src/state.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { StoreApi } from 'zustand/vanilla';
|
|
|
6
6
|
import { createStore } from 'zustand/vanilla';
|
|
7
7
|
import { isTestEnvironment } from './utils';
|
|
8
8
|
|
|
9
|
+
export type { StoreApi } from 'zustand/vanilla';
|
|
10
|
+
|
|
9
11
|
interface StoreEntity {
|
|
10
12
|
value: StoreApi<unknown>;
|
|
11
13
|
active: boolean;
|
|
@@ -82,6 +84,22 @@ export function createGlobalStore<T>(name: string, initialState: T, storageType:
|
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Creates a Zustand store that is NOT registered in the global store registry.
|
|
89
|
+
*
|
|
90
|
+
* Unlike {@link createGlobalStore}, this store has no name and is never added to `availableStores`,
|
|
91
|
+
* so it does not appear on `window.stores`, cannot collide with another store's name, and is
|
|
92
|
+
* garbage-collected once no longer referenced. Use this for per-instance/component-local state that
|
|
93
|
+
* must be isolated from every other instance (for example, one store per rendered component), where
|
|
94
|
+
* a named global store would either collide across instances or leak.
|
|
95
|
+
*
|
|
96
|
+
* @param initialState An object which will be the initial state of the store.
|
|
97
|
+
* @returns The newly created store.
|
|
98
|
+
*/
|
|
99
|
+
export function createLocalStore<T>(initialState: T): StoreApi<T> {
|
|
100
|
+
return createStore<T>()(() => initialState);
|
|
101
|
+
}
|
|
102
|
+
|
|
85
103
|
/**
|
|
86
104
|
* Registers an existing Zustand store.
|
|
87
105
|
*
|