@mapsight/lib-redux 2.0.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/README.md +20 -0
- package/dist/README.md +20 -0
- package/dist/clone-action.d.ts +9 -0
- package/dist/clone-action.d.ts.map +1 -0
- package/dist/clone-action.js +30 -0
- package/dist/clone-action.js.map +1 -0
- package/dist/combine-sub-path-reducers.d.ts +13 -0
- package/dist/combine-sub-path-reducers.d.ts.map +1 -0
- package/dist/combine-sub-path-reducers.js +34 -0
- package/dist/combine-sub-path-reducers.js.map +1 -0
- package/dist/create-filtered-reducer-for-path.d.ts +13 -0
- package/dist/create-filtered-reducer-for-path.d.ts.map +1 -0
- package/dist/create-filtered-reducer-for-path.js +37 -0
- package/dist/create-filtered-reducer-for-path.js.map +1 -0
- package/dist/create-immutable-path-reducer.d.ts +13 -0
- package/dist/create-immutable-path-reducer.d.ts.map +1 -0
- package/dist/create-immutable-path-reducer.js +30 -0
- package/dist/create-immutable-path-reducer.js.map +1 -0
- package/dist/create-prefixed-async-action-middleware.d.ts +16 -0
- package/dist/create-prefixed-async-action-middleware.d.ts.map +1 -0
- package/dist/create-prefixed-async-action-middleware.js +25 -0
- package/dist/create-prefixed-async-action-middleware.js.map +1 -0
- package/dist/createSelectorUsingOwnProps.d.ts +23 -0
- package/dist/createSelectorUsingOwnProps.d.ts.map +1 -0
- package/dist/createSelectorUsingOwnProps.js +47 -0
- package/dist/createSelectorUsingOwnProps.js.map +1 -0
- package/dist/deep-change-state.d.ts +14 -0
- package/dist/deep-change-state.d.ts.map +1 -0
- package/dist/deep-change-state.js +29 -0
- package/dist/deep-change-state.js.map +1 -0
- package/dist/enable-async-dispatch.d.ts +13 -0
- package/dist/enable-async-dispatch.d.ts.map +1 -0
- package/dist/enable-async-dispatch.js +48 -0
- package/dist/enable-async-dispatch.js.map +1 -0
- package/dist/enable-controlled-dispatch-and-observe.d.ts +21 -0
- package/dist/enable-controlled-dispatch-and-observe.d.ts.map +1 -0
- package/dist/enable-controlled-dispatch-and-observe.js +59 -0
- package/dist/enable-controlled-dispatch-and-observe.js.map +1 -0
- package/dist/enable-initialization.d.ts +12 -0
- package/dist/enable-initialization.d.ts.map +1 -0
- package/dist/enable-initialization.js +25 -0
- package/dist/enable-initialization.js.map +1 -0
- package/dist/flatten-actions.d.ts +9 -0
- package/dist/flatten-actions.d.ts.map +1 -0
- package/dist/flatten-actions.js +18 -0
- package/dist/flatten-actions.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/local-storage.d.ts +15 -0
- package/dist/local-storage.d.ts.map +1 -0
- package/dist/local-storage.js +66 -0
- package/dist/local-storage.js.map +1 -0
- package/dist/matchPath.d.ts +15 -0
- package/dist/matchPath.d.ts.map +1 -0
- package/dist/matchPath.js +68 -0
- package/dist/matchPath.js.map +1 -0
- package/dist/matchesPath.d.ts +14 -0
- package/dist/matchesPath.d.ts.map +1 -0
- package/dist/matchesPath.js +19 -0
- package/dist/matchesPath.js.map +1 -0
- package/dist/observe-state.d.ts +8 -0
- package/dist/observe-state.d.ts.map +1 -0
- package/dist/observe-state.js +42 -0
- package/dist/observe-state.js.map +1 -0
- package/dist/package.json +52 -0
- package/dist/reducers/immutable/add-to.d.ts +4 -0
- package/dist/reducers/immutable/add-to.d.ts.map +1 -0
- package/dist/reducers/immutable/add-to.js +3 -0
- package/dist/reducers/immutable/add-to.js.map +1 -0
- package/dist/reducers/immutable/index.d.ts +4 -0
- package/dist/reducers/immutable/index.d.ts.map +1 -0
- package/dist/reducers/immutable/index.js +14 -0
- package/dist/reducers/immutable/index.js.map +1 -0
- package/dist/reducers/immutable/merge.d.ts +4 -0
- package/dist/reducers/immutable/merge.d.ts.map +1 -0
- package/dist/reducers/immutable/merge.js +9 -0
- package/dist/reducers/immutable/merge.js.map +1 -0
- package/dist/reducers/immutable/noop.d.ts +4 -0
- package/dist/reducers/immutable/noop.d.ts.map +1 -0
- package/dist/reducers/immutable/noop.js +3 -0
- package/dist/reducers/immutable/noop.js.map +1 -0
- package/dist/reducers/immutable/remove-from.d.ts +4 -0
- package/dist/reducers/immutable/remove-from.d.ts.map +1 -0
- package/dist/reducers/immutable/remove-from.js +3 -0
- package/dist/reducers/immutable/remove-from.js.map +1 -0
- package/dist/reducers/immutable/set.d.ts +4 -0
- package/dist/reducers/immutable/set.d.ts.map +1 -0
- package/dist/reducers/immutable/set.js +3 -0
- package/dist/reducers/immutable/set.js.map +1 -0
- package/dist/reducers/immutable-path/add-to.d.ts +3 -0
- package/dist/reducers/immutable-path/add-to.d.ts.map +1 -0
- package/dist/reducers/immutable-path/add-to.js +4 -0
- package/dist/reducers/immutable-path/add-to.js.map +1 -0
- package/dist/reducers/immutable-path/index.d.ts +11 -0
- package/dist/reducers/immutable-path/index.d.ts.map +1 -0
- package/dist/reducers/immutable-path/index.js +14 -0
- package/dist/reducers/immutable-path/index.js.map +1 -0
- package/dist/reducers/immutable-path/merge.d.ts +3 -0
- package/dist/reducers/immutable-path/merge.d.ts.map +1 -0
- package/dist/reducers/immutable-path/merge.js +4 -0
- package/dist/reducers/immutable-path/merge.js.map +1 -0
- package/dist/reducers/immutable-path/noop.d.ts +2 -0
- package/dist/reducers/immutable-path/noop.d.ts.map +1 -0
- package/dist/reducers/immutable-path/noop.js +4 -0
- package/dist/reducers/immutable-path/noop.js.map +1 -0
- package/dist/reducers/immutable-path/remove-from.d.ts +3 -0
- package/dist/reducers/immutable-path/remove-from.d.ts.map +1 -0
- package/dist/reducers/immutable-path/remove-from.js +4 -0
- package/dist/reducers/immutable-path/remove-from.js.map +1 -0
- package/dist/reducers/immutable-path/set.d.ts +3 -0
- package/dist/reducers/immutable-path/set.d.ts.map +1 -0
- package/dist/reducers/immutable-path/set.js +4 -0
- package/dist/reducers/immutable-path/set.js.map +1 -0
- package/dist/reducers/reduce-by-keys.d.ts +2 -0
- package/dist/reducers/reduce-by-keys.d.ts.map +1 -0
- package/dist/reducers/reduce-by-keys.js +14 -0
- package/dist/reducers/reduce-by-keys.js.map +1 -0
- package/package.json +51 -0
- package/src/js/clone-action.ts +36 -0
- package/src/js/combine-sub-path-reducers.ts +44 -0
- package/src/js/create-filtered-reducer-for-path.ts +52 -0
- package/src/js/create-immutable-path-reducer.ts +41 -0
- package/src/js/create-prefixed-async-action-middleware.ts +47 -0
- package/src/js/createSelectorUsingOwnProps.ts +84 -0
- package/src/js/deep-change-state.ts +37 -0
- package/src/js/enable-async-dispatch.ts +61 -0
- package/src/js/enable-controlled-dispatch-and-observe.ts +128 -0
- package/src/js/enable-initialization.ts +36 -0
- package/src/js/flatten-actions.ts +22 -0
- package/src/js/index.ts +1 -0
- package/src/js/local-storage.ts +96 -0
- package/src/js/matchPath.ts +78 -0
- package/src/js/matchesPath.ts +23 -0
- package/src/js/observe-state.ts +109 -0
- package/src/js/reducers/immutable/add-to.ts +6 -0
- package/src/js/reducers/immutable/index.ts +17 -0
- package/src/js/reducers/immutable/merge.ts +18 -0
- package/src/js/reducers/immutable/noop.ts +5 -0
- package/src/js/reducers/immutable/remove-from.ts +8 -0
- package/src/js/reducers/immutable/set.ts +5 -0
- package/src/js/reducers/immutable-path/add-to.ts +4 -0
- package/src/js/reducers/immutable-path/index.ts +17 -0
- package/src/js/reducers/immutable-path/merge.ts +4 -0
- package/src/js/reducers/immutable-path/noop.ts +3 -0
- package/src/js/reducers/immutable-path/remove-from.ts +4 -0
- package/src/js/reducers/immutable-path/set.ts +4 -0
- package/src/js/reducers/reduce-by-keys.ts +19 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Reducer } from "redux";
|
|
2
|
+
/**
|
|
3
|
+
* Add initialization reducer to existing reducer
|
|
4
|
+
*
|
|
5
|
+
* @deprecated Use redux preloadedState or mergeAll actions instead.
|
|
6
|
+
*
|
|
7
|
+
* @param reducer base reducer to enhance
|
|
8
|
+
* @param [actionName] name of action, default: 'INITIALIZE'
|
|
9
|
+
* @returns enhanced reducer
|
|
10
|
+
*/
|
|
11
|
+
export default function enableInitialization(reducer: Reducer, actionName?: string): Reducer;
|
|
12
|
+
//# sourceMappingURL=enable-initialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enable-initialization.d.ts","sourceRoot":"","sources":["../src/js/enable-initialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAC,MAAM,OAAO,CAAC;AAEzC;;;;;;;;GAQG;AAEH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC3C,OAAO,EAAE,OAAO,EAChB,UAAU,SAAe,WAqBzB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add initialization reducer to existing reducer
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Use redux preloadedState or mergeAll actions instead.
|
|
5
|
+
*
|
|
6
|
+
* @param reducer base reducer to enhance
|
|
7
|
+
* @param [actionName] name of action, default: 'INITIALIZE'
|
|
8
|
+
* @returns enhanced reducer
|
|
9
|
+
*/
|
|
10
|
+
export default function enableInitialization(reducer, actionName = "INITIALIZE") {
|
|
11
|
+
const aReducerWithInitialization = (state, action) => {
|
|
12
|
+
if (action.type === actionName) {
|
|
13
|
+
return action.value;
|
|
14
|
+
}
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
16
|
+
return reducer(state, action);
|
|
17
|
+
};
|
|
18
|
+
if (reducer.name) {
|
|
19
|
+
Object.defineProperty(aReducerWithInitialization, "name", {
|
|
20
|
+
value: reducer.name + "__with-initialization",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return aReducerWithInitialization;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=enable-initialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enable-initialization.js","sourceRoot":"","sources":["../src/js/enable-initialization.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC3C,OAAgB,EAChB,UAAU,GAAG,YAAY;IAEzB,MAAM,0BAA0B,GAAY,CAC3C,KAAQ,EACR,MAAiB,EAChB,EAAE;QACH,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO,MAAM,CAAC,KAAU,CAAC;QAC1B,CAAC;QAED,+DAA+D;QAC/D,OAAO,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,CAAC,cAAc,CAAC,0BAA0B,EAAE,MAAM,EAAE;YACzD,KAAK,EAAE,OAAO,CAAC,IAAI,GAAG,uBAAuB;SAC7C,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,0BAA0B,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AnyAction } from "redux";
|
|
2
|
+
/**
|
|
3
|
+
* Flattens (deeply) batched actions into a flat array of actions
|
|
4
|
+
*
|
|
5
|
+
* @param {object} action the root action
|
|
6
|
+
* @returns {Array<object>} flattened array of actions
|
|
7
|
+
*/
|
|
8
|
+
export default function flattenActions(action: AnyAction): Array<AnyAction>;
|
|
9
|
+
//# sourceMappingURL=flatten-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten-actions.d.ts","sourceRoot":"","sources":["../src/js/flatten-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAa1E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens (deeply) batched actions into a flat array of actions
|
|
3
|
+
*
|
|
4
|
+
* @param {object} action the root action
|
|
5
|
+
* @returns {Array<object>} flattened array of actions
|
|
6
|
+
*/
|
|
7
|
+
export default function flattenActions(action) {
|
|
8
|
+
if ("meta" in action &&
|
|
9
|
+
"payload" in action &&
|
|
10
|
+
Array.isArray(action.payload) &&
|
|
11
|
+
typeof action.meta === "object" &&
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
13
|
+
action.meta.batch === true) {
|
|
14
|
+
return action.payload.flatMap(flattenActions);
|
|
15
|
+
}
|
|
16
|
+
return [action];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=flatten-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten-actions.js","sourceRoot":"","sources":["../src/js/flatten-actions.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,MAAiB;IACvD,IACC,MAAM,IAAI,MAAM;QAChB,SAAS,IAAI,MAAM;QACnB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAC7B,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC/B,sEAAsE;QACtE,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,EACzB,CAAC;QACF,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/js/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/js/index.ts"],"names":[],"mappings":";AAAA,EAAE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Store } from "redux";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a storage object to access local storage.
|
|
4
|
+
*
|
|
5
|
+
* @param [storageKey=null] key to be used in local storage
|
|
6
|
+
* @returns storage adapter
|
|
7
|
+
*/
|
|
8
|
+
export declare function createStorage(storageKey?: string | null): {
|
|
9
|
+
setStorageKey: (k: string | null) => void;
|
|
10
|
+
getLocalStorageState: () => unknown;
|
|
11
|
+
setLocalStorageState: (state: unknown) => void;
|
|
12
|
+
updateLocalStorageState: (path: Array<string> | string, value: unknown) => void;
|
|
13
|
+
synchronizePathsToLocalStorage: (store: Store, paths: Array<string | Array<string>>) => void;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=local-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../src/js/local-storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAI5B;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,GAAE,MAAM,GAAG,IAAW;uBACnC,MAAM,GAAG,IAAI;gCAIN,OAAO;kCAeH,OAAO;oCAarC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,SACrB,OAAO;4CAoBP,KAAK,SACL,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;EA4BrC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import get from "lodash/get";
|
|
2
|
+
import set from "lodash/set";
|
|
3
|
+
import { observeState } from "./observe-state";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a storage object to access local storage.
|
|
6
|
+
*
|
|
7
|
+
* @param [storageKey=null] key to be used in local storage
|
|
8
|
+
* @returns storage adapter
|
|
9
|
+
*/
|
|
10
|
+
export function createStorage(storageKey = null) {
|
|
11
|
+
function setStorageKey(k) {
|
|
12
|
+
storageKey = k;
|
|
13
|
+
}
|
|
14
|
+
function getLocalStorageState() {
|
|
15
|
+
if (!storageKey) {
|
|
16
|
+
throw Error("@mapsight/lib-redux: Cannot access local storage without a key. Please set a storage key using the `string: storageKey` property on `createStorage(string?: storageKey)` or using the `setStorageKey(string: storageKey)` method on an existing storage object.");
|
|
17
|
+
}
|
|
18
|
+
if (typeof window !== "undefined") {
|
|
19
|
+
const value = window.localStorage.getItem(storageKey);
|
|
20
|
+
return window.localStorage && value ? JSON.parse(value) : null;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function setLocalStorageState(state) {
|
|
25
|
+
if (!storageKey) {
|
|
26
|
+
throw Error("@mapsight/lib-redux: Cannot access local storage without a key. Please set a storage key using the `string: storageKey` property on `createStorage(string?: storageKey)` or using the `setStorageKey(string: storageKey)` method on an existing storage object.");
|
|
27
|
+
}
|
|
28
|
+
if (window.localStorage) {
|
|
29
|
+
window.localStorage.setItem(storageKey, JSON.stringify(state));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function updateLocalStorageState(path, value) {
|
|
33
|
+
if (!storageKey) {
|
|
34
|
+
throw Error("@mapsight/lib-redux: Cannot access local storage without a key. Please set a storage key using the `string: storageKey` property on `createStorage(string?: storageKey)` or using the `setStorageKey(string: storageKey)` method on an existing storage object.");
|
|
35
|
+
}
|
|
36
|
+
setLocalStorageState(set(getLocalStorageState(), path, value));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Observes and synchronizes the state of the given store with local storage.
|
|
40
|
+
*
|
|
41
|
+
* @see lodash/get for path definition
|
|
42
|
+
*
|
|
43
|
+
* @param store the store to observe
|
|
44
|
+
* @param paths array of path strings (string[]) or path arrays (string[][])
|
|
45
|
+
*/
|
|
46
|
+
function synchronizePathsToLocalStorage(store, paths) {
|
|
47
|
+
if (!storageKey) {
|
|
48
|
+
throw Error("@mapsight/lib-redux: Cannot access local storage without a key. Please set a storage key using the `string: storageKey` property on `createStorage(string?: storageKey)` or using the `setStorageKey(string: storageKey)` method on an existing storage object.");
|
|
49
|
+
}
|
|
50
|
+
if (window.localStorage) {
|
|
51
|
+
paths.forEach(function synchronizePathToLocalStorage(path) {
|
|
52
|
+
observeState(store, (state) =>
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
54
|
+
get(state, path), (value) => updateLocalStorageState(path, value));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
setStorageKey: setStorageKey,
|
|
60
|
+
getLocalStorageState: getLocalStorageState,
|
|
61
|
+
setLocalStorageState: setLocalStorageState,
|
|
62
|
+
updateLocalStorageState: updateLocalStorageState,
|
|
63
|
+
synchronizePathsToLocalStorage: synchronizePathsToLocalStorage,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=local-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../src/js/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,GAAG,MAAM,YAAY,CAAC;AAG7B,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,aAA4B,IAAI;IAC7D,SAAS,aAAa,CAAC,CAAgB;QACtC,UAAU,GAAG,CAAC,CAAC;IAChB,CAAC;IAED,SAAS,oBAAoB;QAC5B,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,MAAM,KAAK,CACV,iQAAiQ,CACjQ,CAAC;QACH,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACtD,OAAO,MAAM,CAAC,YAAY,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAChE,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED,SAAS,oBAAoB,CAAC,KAAc;QAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,MAAM,KAAK,CACV,iQAAiQ,CACjQ,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACzB,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QAChE,CAAC;IACF,CAAC;IAED,SAAS,uBAAuB,CAC/B,IAA4B,EAC5B,KAAc;QAEd,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,MAAM,KAAK,CACV,iQAAiQ,CACjQ,CAAC;QACH,CAAC;QAED,oBAAoB,CAAC,GAAG,CAAM,oBAAoB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;OAOG;IACH,SAAS,8BAA8B,CACtC,KAAY,EACZ,KAAoC;QAEpC,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,MAAM,KAAK,CACV,iQAAiQ,CACjQ,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACzB,KAAK,CAAC,OAAO,CAAC,SAAS,6BAA6B,CAAC,IAAI;gBACxD,YAAY,CACX,KAAK,EACL,CAAC,KAAK,EAAW,EAAE;gBAClB,6DAA6D;gBAC7D,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,EACjB,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAC,CAC/C,CAAC;YACH,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IAED,OAAO;QACN,aAAa,EAAE,aAAa;QAC5B,oBAAoB,EAAE,oBAAoB;QAC1C,oBAAoB,EAAE,oBAAoB;QAC1C,uBAAuB,EAAE,uBAAuB;QAChD,8BAA8B,EAAE,8BAA8B;KAC9D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function matches the given path array to a path pattern. The pattern consists of / delimited names and/or
|
|
3
|
+
* named parameters defined as `:name` where name may be any string which will be used in the returned object to
|
|
4
|
+
* access the parameter value.
|
|
5
|
+
*
|
|
6
|
+
* If the path matches the pattern, the return value will be an object containing any present
|
|
7
|
+
* named parameter values that may be in the pattern, otherwise it will return false if any path segment does not
|
|
8
|
+
* match the specified pattern.
|
|
9
|
+
*
|
|
10
|
+
* @param pathArr path array
|
|
11
|
+
* @param pattern pattern to match
|
|
12
|
+
* @returns object containing matched named parameter values or false if the path did not patch the pattern
|
|
13
|
+
*/
|
|
14
|
+
export default function matchPath(pathArr: Array<string>, pattern: string): false | Record<string, string>;
|
|
15
|
+
//# sourceMappingURL=matchPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchPath.d.ts","sourceRoot":"","sources":["../src/js/matchPath.ts"],"names":[],"mappings":"AA4CA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAChC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EACtB,OAAO,EAAE,MAAM,GACb,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBhC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { zip } from "@mapsight/lib-js/array";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a pattern segment.
|
|
4
|
+
*
|
|
5
|
+
* @param patternSegment segment string
|
|
6
|
+
* @returns parsed segment
|
|
7
|
+
*/
|
|
8
|
+
function parsePatternSegment(patternSegment) {
|
|
9
|
+
if (patternSegment.startsWith(":")) {
|
|
10
|
+
return {
|
|
11
|
+
isParam: true,
|
|
12
|
+
name: patternSegment.slice(1),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return {
|
|
17
|
+
isParam: false,
|
|
18
|
+
name: patternSegment,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// TODO: lru/limit cache?
|
|
23
|
+
const parsePathPatternCache = {};
|
|
24
|
+
/**
|
|
25
|
+
* Parses a path pattern
|
|
26
|
+
*
|
|
27
|
+
* @param pattern path pattern
|
|
28
|
+
* @returns parsed pattern
|
|
29
|
+
*/
|
|
30
|
+
function parsePathPattern(pattern) {
|
|
31
|
+
const fromCache = parsePathPatternCache[pattern];
|
|
32
|
+
if (fromCache !== undefined) {
|
|
33
|
+
return fromCache;
|
|
34
|
+
}
|
|
35
|
+
const patternSegments = pattern.split("/").map(parsePatternSegment);
|
|
36
|
+
parsePathPatternCache[pattern] = patternSegments;
|
|
37
|
+
return patternSegments;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* This function matches the given path array to a path pattern. The pattern consists of / delimited names and/or
|
|
41
|
+
* named parameters defined as `:name` where name may be any string which will be used in the returned object to
|
|
42
|
+
* access the parameter value.
|
|
43
|
+
*
|
|
44
|
+
* If the path matches the pattern, the return value will be an object containing any present
|
|
45
|
+
* named parameter values that may be in the pattern, otherwise it will return false if any path segment does not
|
|
46
|
+
* match the specified pattern.
|
|
47
|
+
*
|
|
48
|
+
* @param pathArr path array
|
|
49
|
+
* @param pattern pattern to match
|
|
50
|
+
* @returns object containing matched named parameter values or false if the path did not patch the pattern
|
|
51
|
+
*/
|
|
52
|
+
export default function matchPath(pathArr, pattern) {
|
|
53
|
+
const patternSegments = parsePathPattern(pattern);
|
|
54
|
+
if (patternSegments.length !== pathArr.length) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const params = {};
|
|
58
|
+
for (const [pathValue, patternSegment] of zip(pathArr, patternSegments)) {
|
|
59
|
+
if (patternSegment.isParam) {
|
|
60
|
+
params[patternSegment.name] = pathValue;
|
|
61
|
+
}
|
|
62
|
+
else if (pathValue !== patternSegment.name) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return params;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=matchPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchPath.js","sourceRoot":"","sources":["../src/js/matchPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,wBAAwB,CAAC;AAI3C;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,cAAsB;IAClD,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,OAAO;YACN,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;SAC7B,CAAC;IACH,CAAC;SAAM,CAAC;QACP,OAAO;YACN,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,cAAc;SACpB,CAAC;IACH,CAAC;AACF,CAAC;AAED,yBAAyB;AACzB,MAAM,qBAAqB,GAA0C,EAAE,CAAC;AAExE;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACxC,MAAM,SAAS,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACpE,qBAAqB,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC;IACjD,OAAO,eAAe,CAAC;AACxB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAChC,OAAsB,EACtB,OAAe;IAEf,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,eAAe,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC;QACzE,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;YAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;QACzC,CAAC;aAAM,IAAI,SAAS,KAAK,cAAc,CAAC,IAAI,EAAE,CAAC;YAC9C,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function matches the given path array to a path pattern. The pattern consists of / delimited names and/or
|
|
3
|
+
* named parameters defined as `:name` where name may be any string which will be used in the returned object to
|
|
4
|
+
* access the parameter value.
|
|
5
|
+
*
|
|
6
|
+
* If the path matches the pattern it will return an object containing any present
|
|
7
|
+
* named parameter values that may be in the pattern otherwise an empty object is returned.
|
|
8
|
+
*
|
|
9
|
+
* @param pathArr path array
|
|
10
|
+
* @param pattern pattern to match
|
|
11
|
+
* @returns 2-ary array with boolean that is true if the path did match the pattern and an object containing matched named parameter values
|
|
12
|
+
*/
|
|
13
|
+
export default function matchesPath(pathArr: Array<string>, pattern: string): [boolean, Record<string, string>];
|
|
14
|
+
//# sourceMappingURL=matchesPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchesPath.d.ts","sourceRoot":"","sources":["../src/js/matchesPath.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAClC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EACtB,OAAO,EAAE,MAAM,GACb,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAGnC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import matchPath from "./matchPath";
|
|
2
|
+
const noMatch = {};
|
|
3
|
+
/**
|
|
4
|
+
* This function matches the given path array to a path pattern. The pattern consists of / delimited names and/or
|
|
5
|
+
* named parameters defined as `:name` where name may be any string which will be used in the returned object to
|
|
6
|
+
* access the parameter value.
|
|
7
|
+
*
|
|
8
|
+
* If the path matches the pattern it will return an object containing any present
|
|
9
|
+
* named parameter values that may be in the pattern otherwise an empty object is returned.
|
|
10
|
+
*
|
|
11
|
+
* @param pathArr path array
|
|
12
|
+
* @param pattern pattern to match
|
|
13
|
+
* @returns 2-ary array with boolean that is true if the path did match the pattern and an object containing matched named parameter values
|
|
14
|
+
*/
|
|
15
|
+
export default function matchesPath(pathArr, pattern) {
|
|
16
|
+
const match = matchPath(pathArr, pattern);
|
|
17
|
+
return match ? [true, match] : [false, noMatch];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=matchesPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchesPath.js","sourceRoot":"","sources":["../src/js/matchesPath.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,OAAO,GAA2B,EAAE,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAClC,OAAsB,EACtB,OAAe;IAEf,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Store } from "redux";
|
|
2
|
+
declare function strictEqualCompare<T>(a: T, b: T): boolean;
|
|
3
|
+
export declare const AbortObserving: unique symbol;
|
|
4
|
+
export declare function observeState<State = unknown, Value = unknown>(store: Store<State>, selector: (state: State) => Value, listener: (newValue: Value, oldValue: Value | null, state: State) => void | typeof AbortObserving, compare?: typeof strictEqualCompare): import("redux").Unsubscribe;
|
|
5
|
+
export declare function observeStateOnce<State = unknown, Value = unknown>(store: Store, selector: (state: State) => Value, listener: (newValue: Value, oldValue: Value | null, state: State) => void | typeof AbortObserving, compare?: typeof strictEqualCompare): import("redux").Unsubscribe;
|
|
6
|
+
export declare function getAndObserveState<State = unknown, Value = unknown>(store: Store<State>, selector: (state: State) => Value, listener: (newValue: Value, oldValue: Value | null, state: State) => void | typeof AbortObserving, compare?: typeof strictEqualCompare): import("redux").Unsubscribe;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=observe-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-state.d.ts","sourceRoot":"","sources":["../src/js/observe-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAE5B,iBAAS,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAElD;AAID,eAAO,MAAM,cAAc,eAAW,CAAC;AAgCvC,wBAAgB,YAAY,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAC5D,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,EACjC,QAAQ,EAAE,CACT,QAAQ,EAAE,KAAK,EACf,QAAQ,EAAE,KAAK,GAAG,IAAI,EACtB,KAAK,EAAE,KAAK,KACR,IAAI,GAAG,OAAO,cAAc,EACjC,OAAO,4BAAqB,+BAU5B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAChE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,EACjC,QAAQ,EAAE,CACT,QAAQ,EAAE,KAAK,EACf,QAAQ,EAAE,KAAK,GAAG,IAAI,EACtB,KAAK,EAAE,KAAK,KACR,IAAI,GAAG,OAAO,cAAc,EACjC,OAAO,4BAAqB,+BAa5B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAClE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,EACjC,QAAQ,EAAE,CACT,QAAQ,EAAE,KAAK,EACf,QAAQ,EAAE,KAAK,GAAG,IAAI,EACtB,KAAK,EAAE,KAAK,KACR,IAAI,GAAG,OAAO,cAAc,EACjC,OAAO,4BAAqB,+BAiB5B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function strictEqualCompare(a, b) {
|
|
2
|
+
return a === b;
|
|
3
|
+
}
|
|
4
|
+
//const jsonCompare = (a, b) => JSON.stringify(a) !== JSON.stringify(b);
|
|
5
|
+
export const AbortObserving = Symbol(); // TODO: Use Symbol()
|
|
6
|
+
function internalObserveState(store, selector, listener, compare = strictEqualCompare, initialValue = null) {
|
|
7
|
+
let currentValue = initialValue;
|
|
8
|
+
const unsubscribe = store.subscribe(function onStateChange() {
|
|
9
|
+
const state = store.getState();
|
|
10
|
+
const newValue = selector(state);
|
|
11
|
+
if (!compare(currentValue, newValue)) {
|
|
12
|
+
const oldValue = currentValue;
|
|
13
|
+
currentValue = newValue;
|
|
14
|
+
const returnValue = listener(newValue, oldValue, state);
|
|
15
|
+
if (returnValue === AbortObserving) {
|
|
16
|
+
unsubscribe();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return unsubscribe;
|
|
21
|
+
}
|
|
22
|
+
export function observeState(store, selector, listener, compare = strictEqualCompare) {
|
|
23
|
+
const initialValue = selector(store.getState());
|
|
24
|
+
return internalObserveState(store, selector, listener, compare, initialValue);
|
|
25
|
+
}
|
|
26
|
+
export function observeStateOnce(store, selector, listener, compare = strictEqualCompare) {
|
|
27
|
+
const unsubscribe = observeState(store, selector, function handleChange(newValue, oldValue, state) {
|
|
28
|
+
listener(newValue, oldValue, state);
|
|
29
|
+
unsubscribe();
|
|
30
|
+
}, compare);
|
|
31
|
+
return unsubscribe;
|
|
32
|
+
}
|
|
33
|
+
export function getAndObserveState(store, selector, listener, compare = strictEqualCompare) {
|
|
34
|
+
const initialState = store.getState();
|
|
35
|
+
const initialValue = selector(initialState);
|
|
36
|
+
const initialReturnValue = listener(initialValue, null, initialState);
|
|
37
|
+
if (initialReturnValue === AbortObserving) {
|
|
38
|
+
return () => undefined;
|
|
39
|
+
}
|
|
40
|
+
return internalObserveState(store, selector, listener, compare, initialValue);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=observe-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-state.js","sourceRoot":"","sources":["../src/js/observe-state.ts"],"names":[],"mappings":"AAEA,SAAS,kBAAkB,CAAI,CAAI,EAAE,CAAI;IACxC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChB,CAAC;AAED,yEAAyE;AAEzE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,EAAE,CAAC,CAAC,qBAAqB;AAE7D,SAAS,oBAAoB,CAC5B,KAAmB,EACnB,QAAiC,EACjC,QAIiC,EACjC,OAAO,GAAG,kBAAkB,EAC5B,eAA6B,IAAI;IAEjC,IAAI,YAAY,GAAG,YAAY,CAAC;IAChC,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,aAAa;QACzD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEjC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,YAAY,CAAC;YAC9B,YAAY,GAAG,QAAQ,CAAC;YAExB,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YACxD,IAAI,WAAW,KAAK,cAAc,EAAE,CAAC;gBACpC,WAAW,EAAE,CAAC;YACf,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,YAAY,CAC3B,KAAmB,EACnB,QAAiC,EACjC,QAIiC,EACjC,OAAO,GAAG,kBAAkB;IAE5B,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChD,OAAO,oBAAoB,CAC1B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,YAAY,CACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC/B,KAAY,EACZ,QAAiC,EACjC,QAIiC,EACjC,OAAO,GAAG,kBAAkB;IAE5B,MAAM,WAAW,GAAG,YAAY,CAC/B,KAAK,EACL,QAAQ,EACR,SAAS,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAY;QACrD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACpC,WAAW,EAAE,CAAC;IACf,CAAC,EACD,OAAO,CACP,CAAC;IAEF,OAAO,WAAW,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,kBAAkB,CACjC,KAAmB,EACnB,QAAiC,EACjC,QAIiC,EACjC,OAAO,GAAG,kBAAkB;IAE5B,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;IACtC,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IAE5C,MAAM,kBAAkB,GAAG,QAAQ,CAAC,YAAY,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACtE,IAAI,kBAAkB,KAAK,cAAc,EAAE,CAAC;QAC3C,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,OAAO,oBAAoB,CAC1B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,YAAY,CACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mapsight/lib-redux",
|
|
3
|
+
"description": "Mapsight Redux Library",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@mapsight/lib-js": "workspace:^",
|
|
8
|
+
"lodash": "catalog:",
|
|
9
|
+
"redux-thunk": "catalog:"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/lodash": "catalog:",
|
|
13
|
+
"cpx2": "^8.0.2",
|
|
14
|
+
"redux": "catalog:"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./*": {
|
|
22
|
+
"types": "./dist/*.d.ts",
|
|
23
|
+
"import": "./dist/*.js"
|
|
24
|
+
},
|
|
25
|
+
"./reducers/immutable": {
|
|
26
|
+
"types": "./dist/reducers/immutable/index.d.ts",
|
|
27
|
+
"import": "./dist/reducers/immutable/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./reducers/immutable-path": {
|
|
30
|
+
"types": "./dist/reducers/immutable-path/index.d.ts",
|
|
31
|
+
"import": "./dist/reducers/immutable-path/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"license": "UNLICENSED",
|
|
35
|
+
"main": "index.js",
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"redux": "catalog:"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "npm-run-all build:setup build:modules build:copy",
|
|
41
|
+
"build:copy": "cpx '{package.json,README.md}' dist/",
|
|
42
|
+
"build:modules": "tsc",
|
|
43
|
+
"build:setup": "mkdirp dist",
|
|
44
|
+
"clean": "rimraf dist/*",
|
|
45
|
+
"clean-build": "run-s clean build",
|
|
46
|
+
"prepublishOnly": "pnpm run clean-build",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"watch": "run-p watch:*",
|
|
49
|
+
"watch:copy": "pnpm run build:copy --watch",
|
|
50
|
+
"watch:modules": "pnpm run build:modules --watch"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to.d.ts","sourceRoot":"","sources":["../../../src/js/reducers/immutable/add-to.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,QAAA,MAAM,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CACI,CAAC;AAExC,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to.js","sourceRoot":"","sources":["../../../src/js/reducers/immutable/add-to.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CACxD,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAExC,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/reducers/immutable/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAQ9B,QAAA,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAMrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import addTo from "./add-to";
|
|
2
|
+
import merge from "./merge";
|
|
3
|
+
import noop from "./noop";
|
|
4
|
+
import removeFrom from "./remove-from";
|
|
5
|
+
import set from "./set";
|
|
6
|
+
const reducers = {
|
|
7
|
+
addTo: addTo,
|
|
8
|
+
merge: merge,
|
|
9
|
+
noop: noop,
|
|
10
|
+
removeFrom: removeFrom,
|
|
11
|
+
set: set,
|
|
12
|
+
};
|
|
13
|
+
export default reducers;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/reducers/immutable/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,UAAU,CAAC;AAC7B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB,MAAM,QAAQ,GAA4B;IACzC,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,UAAU;IACtB,GAAG,EAAE,GAAG;CACR,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/js/reducers/immutable/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAC,MAAM,OAAO,CAAC;AAEzC,QAAA,MAAM,YAAY,EAAE,OAYnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import merge from "lodash/merge";
|
|
2
|
+
const mergeReducer = (state, action) => {
|
|
3
|
+
const result = (Array.isArray(state) ? [] : {});
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
5
|
+
merge(result, state, action.value);
|
|
6
|
+
return result;
|
|
7
|
+
};
|
|
8
|
+
export default mergeReducer;
|
|
9
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/js/reducers/immutable/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAGjC,MAAM,YAAY,GAAY,CAG7B,KAAQ,EACR,MAAiB,EACb,EAAE;IACN,MAAM,MAAM,GAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAM,CAAC;IAExD,6DAA6D;IAC7D,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAEnC,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../../src/js/reducers/immutable/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,QAAA,MAAM,WAAW,EAAE,OAAmC,CAAC;AAEvD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.js","sourceRoot":"","sources":["../../../src/js/reducers/immutable/noop.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAY,CAAI,KAAQ,EAAK,EAAE,CAAC,KAAK,CAAC;AAEvD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-from.d.ts","sourceRoot":"","sources":["../../../src/js/reducers/immutable/remove-from.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAC,MAAM,OAAO,CAAC;AAEzC,QAAA,MAAM,iBAAiB,EAAE,OAGiC,CAAC;AAE3D,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-from.js","sourceRoot":"","sources":["../../../src/js/reducers/immutable/remove-from.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAY,CAClC,KAAQ,EACR,MAAiB,EAChB,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC;AAE3D,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/js/reducers/immutable/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAC,MAAM,OAAO,CAAC;AAEzC,QAAA,MAAM,UAAU,EAAE,OAA6D,CAAC;AAEhF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../src/js/reducers/immutable/set.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAY,CAAC,KAAK,EAAE,MAAiB,EAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;AAEhF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to.d.ts","sourceRoot":"","sources":["../../../src/js/reducers/immutable-path/add-to.ts"],"names":[],"mappings":";AAGA,wBAAiD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to.js","sourceRoot":"","sources":["../../../src/js/reducers/immutable-path/add-to.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAExC,eAAe,0BAA0B,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/reducers/immutable-path/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAI9B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAI1B,QAAA,MAAM,QAAQ;;;;;;CAMqB,CAAC;AAEpC,eAAe,QAAQ,CAAC"}
|