@pisell/utils 1.0.34 → 1.0.36
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/es/miniRedux.js +4 -2
- package/es/otherUtils.d.ts +1 -1
- package/es/otherUtils.js +1 -1
- package/lib/miniRedux.js +3 -1
- package/lib/otherUtils.d.ts +1 -1
- package/lib/otherUtils.js +2 -2
- package/package.json +2 -2
package/es/miniRedux.js
CHANGED
|
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
11
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { createContext, useCallback, useReducer, forwardRef } from 'react';
|
|
13
|
+
import React, { createContext, useCallback, useReducer, forwardRef, useRef } from 'react';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
export var miniRedux = function miniRedux(_ref2) {
|
|
16
16
|
var _ref2$namespace = _ref2.namespace,
|
|
@@ -24,6 +24,7 @@ export var miniRedux = function miniRedux(_ref2) {
|
|
|
24
24
|
var Provider = function Provider(ComponentUi) {
|
|
25
25
|
var Components = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
26
|
var _objectSpread2, _ref5;
|
|
27
|
+
var stateRef = useRef();
|
|
27
28
|
var _useReducer = useReducer(function (state, _ref3) {
|
|
28
29
|
var type = _ref3.type,
|
|
29
30
|
payload = _ref3.payload;
|
|
@@ -36,11 +37,12 @@ export var miniRedux = function miniRedux(_ref2) {
|
|
|
36
37
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
37
38
|
providerState = _useReducer2[0],
|
|
38
39
|
dispatch = _useReducer2[1];
|
|
40
|
+
stateRef.current = providerState;
|
|
39
41
|
var _dispatch = useCallback(function (_ref4) {
|
|
40
42
|
var type = _ref4.type,
|
|
41
43
|
payload = _ref4.payload;
|
|
42
44
|
if (effects[type]) {
|
|
43
|
-
effects[type].call(null, payload, dispatch);
|
|
45
|
+
effects[type].call(null, stateRef.current, payload, dispatch);
|
|
44
46
|
} else if (reducers[type]) {
|
|
45
47
|
dispatch({
|
|
46
48
|
type: type,
|
package/es/otherUtils.d.ts
CHANGED
package/es/otherUtils.js
CHANGED
package/lib/miniRedux.js
CHANGED
|
@@ -42,6 +42,7 @@ var miniRedux = ({
|
|
|
42
42
|
const Context = (0, import_react.createContext)({});
|
|
43
43
|
const Provider = (ComponentUi) => {
|
|
44
44
|
const Components = (0, import_react.forwardRef)((props, ref) => {
|
|
45
|
+
const stateRef = (0, import_react.useRef)();
|
|
45
46
|
const [providerState, dispatch] = (0, import_react.useReducer)(
|
|
46
47
|
(state2, { type, payload }) => {
|
|
47
48
|
if (reducers[type]) {
|
|
@@ -52,9 +53,10 @@ var miniRedux = ({
|
|
|
52
53
|
},
|
|
53
54
|
state
|
|
54
55
|
);
|
|
56
|
+
stateRef.current = providerState;
|
|
55
57
|
const _dispatch = (0, import_react.useCallback)(({ type, payload }) => {
|
|
56
58
|
if (effects[type]) {
|
|
57
|
-
effects[type].call(null, payload, dispatch);
|
|
59
|
+
effects[type].call(null, stateRef.current, payload, dispatch);
|
|
58
60
|
} else if (reducers[type]) {
|
|
59
61
|
dispatch({ type, payload });
|
|
60
62
|
}
|
package/lib/otherUtils.d.ts
CHANGED
package/lib/otherUtils.js
CHANGED
|
@@ -31,7 +31,7 @@ var otherUtils_exports = {};
|
|
|
31
31
|
__export(otherUtils_exports, {
|
|
32
32
|
changeArray: () => changeArray,
|
|
33
33
|
createArray: () => createArray,
|
|
34
|
-
detectIncognito: () =>
|
|
34
|
+
detectIncognito: () => import_detectincognitojs.detectIncognito,
|
|
35
35
|
generateUniqueIdByObj: () => generateUniqueIdByObj,
|
|
36
36
|
getItemByArray: () => getItemByArray,
|
|
37
37
|
getUniqueId: () => getUniqueId
|
|
@@ -39,7 +39,7 @@ __export(otherUtils_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(otherUtils_exports);
|
|
40
40
|
var import_md5 = __toESM(require("crypto-js/md5"));
|
|
41
41
|
var import_enc_hex = __toESM(require("crypto-js/enc-hex"));
|
|
42
|
-
var
|
|
42
|
+
var import_detectincognitojs = require("detectincognitojs");
|
|
43
43
|
var getUniqueId = (prefix = "", maxLength = 11) => {
|
|
44
44
|
return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
|
|
45
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"firebase": "10.5.0",
|
|
16
16
|
"crypto-js": "^4.2.0",
|
|
17
|
-
"
|
|
17
|
+
"detectincognitojs": "1.3.5"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"es",
|