@openmrs/esm-state 4.0.0-pre.0 → 4.0.0-pre.1

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,12 +1,12 @@
1
- @openmrs/esm-state:build: cache hit, replaying output 6f4588c86dd90fba
2
- @openmrs/esm-state:build: $ webpack --mode=production
3
- @openmrs/esm-state:build: asset openmrs-esm-state.js 2.93 KiB [emitted] [minimized] (name: main) 1 related asset
4
- @openmrs/esm-state:build: runtime modules 1.76 KiB 6 modules
5
- @openmrs/esm-state:build: orphan modules 2.79 KiB [orphan] 2 modules
6
- @openmrs/esm-state:build: cacheable modules 6.09 KiB
7
- @openmrs/esm-state:build:  modules by path ../../../node_modules/systemjs-webpack-interop/auto-public-path/*.js 935 bytes
8
- @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
9
- @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
10
- @openmrs/esm-state:build:  ./src/index.ts + 2 modules 2.82 KiB [built] [code generated]
11
- @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
12
- @openmrs/esm-state:build: webpack 5.70.0 compiled successfully in 6850 ms
1
+ @openmrs/esm-state:build: cache hit, replaying output 57a7666620734323
2
+ @openmrs/esm-state:build: $ webpack --mode=production
3
+ @openmrs/esm-state:build: asset openmrs-esm-state.js 2.93 KiB [emitted] [minimized] (name: main) 1 related asset
4
+ @openmrs/esm-state:build: runtime modules 1.76 KiB 6 modules
5
+ @openmrs/esm-state:build: orphan modules 2.79 KiB [orphan] 2 modules
6
+ @openmrs/esm-state:build: cacheable modules 6.09 KiB
7
+ @openmrs/esm-state:build:  modules by path ../../../node_modules/systemjs-webpack-interop/auto-public-path/*.js 935 bytes
8
+ @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
9
+ @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
10
+ @openmrs/esm-state:build:  ./src/index.ts + 2 modules 2.82 KiB [built] [code generated]
11
+ @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
12
+ @openmrs/esm-state:build: webpack 5.70.0 compiled successfully in 22154 ms
@@ -1,2 +1,2 @@
1
- @openmrs/esm-state:lint: cache hit, replaying output ff3db7423bfec95f
2
- @openmrs/esm-state:lint: $ eslint src --ext ts,tsx
1
+ @openmrs/esm-state:lint: cache hit, replaying output 231f323f52cd31f2
2
+ @openmrs/esm-state:lint: $ eslint src --ext ts,tsx
@@ -1,3 +1,3 @@
1
- @openmrs/esm-state:test: cache hit, replaying output e18f52fd775a5b53
1
+ @openmrs/esm-state:test: cache hit, replaying output 1a0fe2f472126d43
2
2
  @openmrs/esm-state:test: $ jest --config jest.config.js --passWithNoTests
3
3
  @openmrs/esm-state:test: No tests found, exiting with code 0
@@ -1,2 +1,2 @@
1
- @openmrs/esm-state:typescript: cache hit, replaying output bc146951720a7d02
2
- @openmrs/esm-state:typescript: $ tsc
1
+ @openmrs/esm-state:typescript: cache hit, replaying output 12cd9d27a4089ea5
2
+ @openmrs/esm-state:typescript: $ tsc
@@ -0,0 +1 @@
1
+ export * from "./state";
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export { AppState, createGlobalStore, getGlobalStore, getAppState, subscribeTo, } from "./state";
@@ -0,0 +1,31 @@
1
+ /** @module @category Store */
2
+ import { Store } from "unistore";
3
+ /**
4
+ * Creates a Unistore [store](https://github.com/developit/unistore#store).
5
+ *
6
+ * @param name A name by which the store can be looked up later.
7
+ * Must be unique across the entire application.
8
+ * @param initialState An object which will be the initial state of the store.
9
+ * @returns The newly created store.
10
+ */
11
+ export declare function createGlobalStore<TState>(name: string, initialState: TState): Store<TState>;
12
+ /**
13
+ * Returns the existing [store](https://github.com/developit/unistore#store) named `name`,
14
+ * or creates a new store named `name` if none exists.
15
+ *
16
+ * @param name The name of the store to look up.
17
+ * @param fallbackState The initial value of the new store if no store named `name` exists.
18
+ * @returns The found or newly created store.
19
+ */
20
+ export declare function getGlobalStore<TState = any>(name: string, fallbackState?: TState): Store<TState>;
21
+ export interface AppState {
22
+ }
23
+ /**
24
+ * @internal
25
+ */
26
+ export declare function createAppState(initialState: AppState): Store<AppState>;
27
+ /**
28
+ * @returns The [store](https://github.com/developit/unistore#store) named `app`.
29
+ */
30
+ export declare function getAppState(): Store<AppState>;
31
+ export declare function subscribeTo<T, U>(store: Store<T>, select: (state: T) => U, handle: (subState: U) => void): import("unistore").Unsubscribe;
@@ -0,0 +1,24 @@
1
+ import { Store } from "unistore";
2
+ /**
3
+ * Convenience method to update a store's state with respect to its previous state.
4
+ *
5
+ * #### Examples
6
+ *
7
+ * ```js
8
+ * myStore.setState({ foo: 0, bar: 10 });
9
+ * myStore.subscribe(s => { console.log(s); });
10
+ * updateStore(myStore, s => ({ ...s, foo: 1 }));
11
+ * // console: { foo: 1, bar: 10 }
12
+ *
13
+ * updateStore(myStore, s => ({ ...s, foo: 2 }), ['bar']);
14
+ * // => { foo: 1, bar: 10 }
15
+ * ```
16
+ *
17
+ * @param store A Unistore store obtained with [[createGlobalStore]] or [[getGlobalStore]]
18
+ * @param updater A function operating on the store's state
19
+ * @param checkDeepEqualAtPath If undefined, the store is updated as long as the new
20
+ * state object does not referentially equal the old state object. If provided,
21
+ * it should be a path for accessing the value of the state that should be compared
22
+ * for deep equality before setting the state.
23
+ */
24
+ export declare function updateStore<T>(store: Store<T>, updater: (state: T) => T, checkDeepEqualAtPath?: Array<string>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-state",
3
- "version": "4.0.0-pre.0",
3
+ "version": "4.0.0-pre.1",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Frontend stores & state management for OpenMRS",
6
6
  "browser": "dist/openmrs-esm-state.js",
@@ -38,5 +38,5 @@
38
38
  "dependencies": {
39
39
  "unistore": "^3.5.2"
40
40
  },
41
- "gitHead": "254a7226212aac82df4434639b2584e24ac240e4"
41
+ "gitHead": "9f58b801f07526083a9edc1cc5a1e58660d71eb0"
42
42
  }