prostgles-client 4.0.320 → 4.0.321
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/dist/auth/useAuthState.d.ts.map +1 -1
- package/dist/auth/useAuthState.js +14 -13
- package/dist/hooks/reactImports.d.ts +8 -3
- package/dist/hooks/reactImports.d.ts.map +1 -1
- package/dist/hooks/reactImports.js +4 -6
- package/dist/hooks/useAsyncEffectQueue.d.ts.map +1 -1
- package/dist/hooks/useAsyncEffectQueue.js +7 -6
- package/dist/hooks/useEffectAsync.d.ts.map +1 -1
- package/dist/hooks/useEffectAsync.js +3 -2
- package/dist/hooks/useEffectDeep.d.ts +1 -1
- package/dist/hooks/useEffectDeep.d.ts.map +1 -1
- package/dist/hooks/useEffectDeep.js +5 -3
- package/dist/hooks/useFetch.d.ts.map +1 -1
- package/dist/hooks/useFetch.js +3 -2
- package/dist/hooks/useIsMounted.d.ts.map +1 -1
- package/dist/hooks/useIsMounted.js +5 -4
- package/dist/hooks/usePromise.d.ts.map +1 -1
- package/dist/hooks/usePromise.js +3 -2
- package/dist/hooks/useSubscribe.d.ts.map +1 -1
- package/dist/hooks/useSubscribe.js +4 -3
- package/dist/hooks/useSync.d.ts.map +1 -1
- package/dist/hooks/useSync.js +3 -2
- package/dist/index.js +1 -1
- package/dist/index.no-sync.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthState.d.ts","sourceRoot":"","sources":["../../lib/auth/useAuthState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"useAuthState.d.ts","sourceRoot":"","sources":["../../lib/auth/useAuthState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA2BvF,eAAO,MAAM,YAAY,GAAI,UAAU;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAa/C,OAAO;iBACP,MAAM;;;CA2MlB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;CA8B7B,CAAC"}
|
|
@@ -3,20 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ERR_CODE_MESSAGES = exports.useAuthState = void 0;
|
|
4
4
|
const prostgles_types_1 = require("prostgles-types");
|
|
5
5
|
const reactImports_1 = require("../hooks/reactImports");
|
|
6
|
+
const { useEffect, useState } = reactImports_1.reactImports;
|
|
6
7
|
const loginStates = ["login", "loginTotp", "loginTotpRecovery"];
|
|
7
8
|
const useAuthState = ({ auth }) => {
|
|
8
|
-
const [loading, setIsLoading] =
|
|
9
|
-
const [state, setState] =
|
|
10
|
-
const [username, setUsername] =
|
|
11
|
-
const [password, setPassword] =
|
|
12
|
-
const [emailVerificationCode, setEmailVerificationCode] =
|
|
13
|
-
const [totpToken, setTotpToken] =
|
|
14
|
-
const [totpRecoveryCode, setTotpRecoveryCode] =
|
|
15
|
-
const [confirmPassword, setConfirmPassword] =
|
|
16
|
-
const [usernamesWithPassword, setUsernamesWithPassword] =
|
|
17
|
-
const [error, _setError] =
|
|
18
|
-
const [result, setResult] =
|
|
19
|
-
const [authResponse, setAuthResponse] =
|
|
9
|
+
const [loading, setIsLoading] = useState(false);
|
|
10
|
+
const [state, setState] = useState("login");
|
|
11
|
+
const [username, setUsername] = useState("");
|
|
12
|
+
const [password, setPassword] = useState("");
|
|
13
|
+
const [emailVerificationCode, setEmailVerificationCode] = useState("");
|
|
14
|
+
const [totpToken, setTotpToken] = useState("");
|
|
15
|
+
const [totpRecoveryCode, setTotpRecoveryCode] = useState("");
|
|
16
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
17
|
+
const [usernamesWithPassword, setUsernamesWithPassword] = useState([]);
|
|
18
|
+
const [error, _setError] = useState("");
|
|
19
|
+
const [result, setResult] = useState();
|
|
20
|
+
const [authResponse, setAuthResponse] = useState();
|
|
20
21
|
// const [searchParams, setSearchParams] = useSearchParams();
|
|
21
22
|
// const verifiedEmail = searchParams.get(EMAIL_CONFIRMED_SEARCH_PARAM);
|
|
22
23
|
// useEffect(() => {
|
|
@@ -26,7 +27,7 @@ const useAuthState = ({ auth }) => {
|
|
|
26
27
|
// message: SIGNUP_CODE_MESSAGES["email-verified"],
|
|
27
28
|
// });
|
|
28
29
|
// }, [verifiedEmail, setSearchParams]);
|
|
29
|
-
|
|
30
|
+
useEffect(() => {
|
|
30
31
|
_setError("");
|
|
31
32
|
}, [username, password, totpToken, totpRecoveryCode, confirmPassword]);
|
|
32
33
|
const formHandlers = state === "login" && auth.loginType === "email" ?
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
type ReactT = typeof import("react");
|
|
2
|
-
declare let React: ReactT;
|
|
3
2
|
export declare const getReact: (throwError?: boolean) => ReactT;
|
|
4
|
-
declare const
|
|
5
|
-
|
|
3
|
+
declare const reactImports: {
|
|
4
|
+
useEffect: typeof import("react").useEffect;
|
|
5
|
+
useCallback: typeof import("react").useCallback;
|
|
6
|
+
useRef: typeof import("react").useRef;
|
|
7
|
+
useState: typeof import("react").useState;
|
|
8
|
+
getReact: () => typeof import("react");
|
|
9
|
+
};
|
|
10
|
+
export { reactImports };
|
|
6
11
|
export declare const __prglReactInstalled: () => boolean;
|
|
7
12
|
//# sourceMappingURL=reactImports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactImports.d.ts","sourceRoot":"","sources":["../../lib/hooks/reactImports.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,GAAG,cAAc,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"reactImports.d.ts","sourceRoot":"","sources":["../../lib/hooks/reactImports.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,GAAG,cAAc,OAAO,CAAC,CAAC;AASrC,eAAO,MAAM,QAAQ,GAAI,aAAa,OAAO,KAAG,MAQ/C,CAAC;AAUF,QAAA,MAAM,YAAY;;;;;;CAAsE,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,eAAO,MAAM,oBAAoB,eAA0C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.__prglReactInstalled = exports.
|
|
4
|
+
exports.__prglReactInstalled = exports.reactImports = exports.getReact = void 0;
|
|
5
5
|
let React;
|
|
6
6
|
const alertNoReact = (...args) => {
|
|
7
7
|
throw "Must install react";
|
|
@@ -12,7 +12,7 @@ const alertNoReactT = (...args) => {
|
|
|
12
12
|
const getReact = (throwError) => {
|
|
13
13
|
try {
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-require-imports
|
|
15
|
-
React !== null && React !== void 0 ? React : (
|
|
15
|
+
React !== null && React !== void 0 ? React : (React = require("react"));
|
|
16
16
|
}
|
|
17
17
|
catch (err) { }
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
@@ -25,9 +25,7 @@ exports.getReact = getReact;
|
|
|
25
25
|
const { useEffect = alertNoReact, useCallback = alertNoReact, useRef, useState = alertNoReactT,
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
27
27
|
} = (_a = React) !== null && _a !== void 0 ? _a : {};
|
|
28
|
-
|
|
29
|
-
exports.
|
|
30
|
-
exports.useRef = useRef;
|
|
31
|
-
exports.useState = useState;
|
|
28
|
+
const reactImports = { useEffect, useCallback, useRef, useState, getReact: () => React };
|
|
29
|
+
exports.reactImports = reactImports;
|
|
32
30
|
const __prglReactInstalled = () => Boolean(React && useRef);
|
|
33
31
|
exports.__prglReactInstalled = __prglReactInstalled;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsyncEffectQueue.d.ts","sourceRoot":"","sources":["../../lib/hooks/useAsyncEffectQueue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAsyncEffectQueue.d.ts","sourceRoot":"","sources":["../../lib/hooks/useAsyncEffectQueue.ts"],"names":[],"mappings":"AAMA,KAAK,UAAU,GAAG,MAAM,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAQrD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,UAAU,EAAE,MAAM,GAAG,EAAE,EAAE,WAAW,MAAM,SAuErF,CAAC"}
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useAsyncEffectQueue = void 0;
|
|
4
4
|
const useEffectDeep_1 = require("./useEffectDeep");
|
|
5
|
-
const reactImports_1 = require("
|
|
5
|
+
const reactImports_1 = require("../hooks/reactImports");
|
|
6
|
+
const { useRef } = reactImports_1.reactImports;
|
|
6
7
|
/**
|
|
7
8
|
* Debounce with execute first
|
|
8
9
|
* Used to ensure subscriptions are always cleaned up
|
|
9
10
|
*/
|
|
10
11
|
const useAsyncEffectQueue = (effect, deps, debounce) => {
|
|
11
|
-
const idRef =
|
|
12
|
-
const isMounted =
|
|
13
|
-
const newEffect =
|
|
14
|
-
const activeEffect =
|
|
12
|
+
const idRef = useRef(0);
|
|
13
|
+
const isMounted = useRef(true);
|
|
14
|
+
const newEffect = useRef();
|
|
15
|
+
const activeEffect = useRef();
|
|
15
16
|
const onRender = async () => {
|
|
16
17
|
var _a, _b;
|
|
17
18
|
/**
|
|
@@ -51,7 +52,7 @@ const useAsyncEffectQueue = (effect, deps, debounce) => {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
|
-
const timerRef =
|
|
55
|
+
const timerRef = useRef(null);
|
|
55
56
|
const scheduleRender = () => {
|
|
56
57
|
if (!debounce) {
|
|
57
58
|
onRender();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEffectAsync.d.ts","sourceRoot":"","sources":["../../lib/hooks/useEffectAsync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEffectAsync.d.ts","sourceRoot":"","sources":["../../lib/hooks/useEffectAsync.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,QAAQ,GAAG,EAAE,SAsBvF,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useEffectAsync = void 0;
|
|
4
|
-
const reactImports_1 = require("
|
|
4
|
+
const reactImports_1 = require("../hooks/reactImports");
|
|
5
|
+
const { useRef } = reactImports_1.reactImports;
|
|
5
6
|
const useEffectDeep_1 = require("./useEffectDeep");
|
|
6
7
|
const useEffectAsync = (effect, inputs) => {
|
|
7
|
-
const onCleanup =
|
|
8
|
+
const onCleanup = useRef({
|
|
8
9
|
cleanup: undefined,
|
|
9
10
|
effect,
|
|
10
11
|
cleanupEffect: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEffectDeep.d.ts","sourceRoot":"","sources":["../../lib/hooks/useEffectDeep.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEffectDeep.d.ts","sourceRoot":"","sources":["../../lib/hooks/useEffectDeep.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,KAAK,wBAAa,CAAC;AACzB,KAAK,KAAK,GAAG,cAAc,OAAO,CAAC,CAAC;AACpC,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,YAQnD,CAAC;AAEF,eAAO,MAAM,WAAW,EAGlB,KAAK,CAAC,SAAS,CAAC,CAAC;AAEvB,eAAO,MAAM,aAAa,EAGpB,KAAK,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useEffectDeep = exports.useMemoDeep = exports.useDeepCompareMemoize = void 0;
|
|
4
4
|
const prostgles_types_1 = require("prostgles-types");
|
|
5
5
|
const reactImports_1 = require("./reactImports");
|
|
6
|
+
const { getReact, useEffect, useRef } = reactImports_1.reactImports;
|
|
7
|
+
const React = getReact();
|
|
6
8
|
const useDeepCompareMemoize = (value) => {
|
|
7
|
-
const ref =
|
|
9
|
+
const ref = useRef();
|
|
8
10
|
if (!(0, prostgles_types_1.isEqual)(value, ref.current)) {
|
|
9
11
|
ref.current = value;
|
|
10
12
|
}
|
|
@@ -13,9 +15,9 @@ const useDeepCompareMemoize = (value) => {
|
|
|
13
15
|
exports.useDeepCompareMemoize = useDeepCompareMemoize;
|
|
14
16
|
exports.useMemoDeep = ((callback, deps) => {
|
|
15
17
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
|
-
return
|
|
18
|
+
return React.useMemo(callback, deps.map(exports.useDeepCompareMemoize));
|
|
17
19
|
});
|
|
18
20
|
exports.useEffectDeep = ((callback, deps) => {
|
|
19
21
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
-
|
|
22
|
+
useEffect(callback, deps === null || deps === void 0 ? void 0 : deps.map(exports.useDeepCompareMemoize));
|
|
21
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetch.d.ts","sourceRoot":"","sources":["../../lib/hooks/useFetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useFetch.d.ts","sourceRoot":"","sources":["../../lib/hooks/useFetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOhD,eAAO,MAAM,QAAQ,GACnB,WAAW,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACzC,OAAM,GAAG,EAAO,EAChB,cAAc,WAAW;;;;CAoB1B,CAAC"}
|
package/dist/hooks/useFetch.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFetch = void 0;
|
|
4
|
-
const reactImports_1 = require("
|
|
4
|
+
const reactImports_1 = require("../hooks/reactImports");
|
|
5
|
+
const { useState } = reactImports_1.reactImports;
|
|
5
6
|
const useAsyncEffectQueue_1 = require("./useAsyncEffectQueue");
|
|
6
7
|
const useIsMounted_1 = require("./useIsMounted");
|
|
7
8
|
const useFetch = (fetchFunc, args = [], hookOptions) => {
|
|
8
9
|
const { skip, deps = [] } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
9
10
|
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
10
|
-
const [{ data, error, isLoading }, setResult] =
|
|
11
|
+
const [{ data, error, isLoading }, setResult] = useState(defaultLoadingResult);
|
|
11
12
|
const getIsMounted = (0, useIsMounted_1.useIsMounted)();
|
|
12
13
|
(0, useAsyncEffectQueue_1.useAsyncEffectQueue)(async () => {
|
|
13
14
|
if (!getIsMounted() || skip)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMounted.d.ts","sourceRoot":"","sources":["../../lib/hooks/useIsMounted.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsMounted.d.ts","sourceRoot":"","sources":["../../lib/hooks/useIsMounted.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,qBAaxB,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useIsMounted = void 0;
|
|
4
|
-
const reactImports_1 = require("
|
|
4
|
+
const reactImports_1 = require("../hooks/reactImports");
|
|
5
|
+
const { useEffect, useRef, useCallback } = reactImports_1.reactImports;
|
|
5
6
|
const useIsMounted = () => {
|
|
6
|
-
const isMountedRef =
|
|
7
|
-
const isMounted =
|
|
8
|
-
|
|
7
|
+
const isMountedRef = useRef(true);
|
|
8
|
+
const isMounted = useCallback(() => isMountedRef.current, []);
|
|
9
|
+
useEffect(() => {
|
|
9
10
|
/** React 18 Strict Mode fix (new strict mode restores the previous state on the second mount) */
|
|
10
11
|
isMountedRef.current = true;
|
|
11
12
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePromise.d.ts","sourceRoot":"","sources":["../../lib/hooks/usePromise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePromise.d.ts","sourceRoot":"","sources":["../../lib/hooks/usePromise.ts"],"names":[],"mappings":"AAMA,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;AACtC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE/C,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,WAAW,GAAG,WAAW,EAC5D,GAAG,CAAC,EACJ,OAAM,GAAG,EAAO,KACf,CAAC,SAAS,WAAW,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAE,GAC1E,CAAC,SAAS,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAC1D,SAwDD,CAAC"}
|
package/dist/hooks/usePromise.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.usePromise = void 0;
|
|
4
4
|
const prostgles_types_1 = require("prostgles-types");
|
|
5
|
-
const reactImports_1 = require("
|
|
5
|
+
const reactImports_1 = require("../hooks/reactImports");
|
|
6
|
+
const { useState } = reactImports_1.reactImports;
|
|
6
7
|
const useAsyncEffectQueue_1 = require("./useAsyncEffectQueue");
|
|
7
8
|
const useIsMounted_1 = require("./useIsMounted");
|
|
8
9
|
const usePromise = (f, deps = []) => {
|
|
@@ -38,7 +39,7 @@ const usePromise = (f, deps = []) => {
|
|
|
38
39
|
}
|
|
39
40
|
return data;
|
|
40
41
|
};
|
|
41
|
-
const [result, setResult] =
|
|
42
|
+
const [result, setResult] = useState(isNamedObj(f) ? {} : undefined);
|
|
42
43
|
const getIsMounted = (0, useIsMounted_1.useIsMounted)();
|
|
43
44
|
(0, useAsyncEffectQueue_1.useAsyncEffectQueue)(async () => {
|
|
44
45
|
let promiseResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSubscribe.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSubscribe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"useSubscribe.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSubscribe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAIrD,eAAO,MAAM,YAAY,GACvB,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,mBAAmB,CAAC,EAC/F,YAAY,OAAO,EACnB,QAAQ,GAAG,EACX,SAAS,GAAG,EACZ,cAAc,WAAW,wBAyC1B,CAAC"}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSubscribe = void 0;
|
|
4
4
|
const prostgles_types_1 = require("prostgles-types");
|
|
5
|
-
const reactImports_1 = require("
|
|
5
|
+
const reactImports_1 = require("../hooks/reactImports");
|
|
6
|
+
const { useRef, useState } = reactImports_1.reactImports;
|
|
6
7
|
const useIsMounted_1 = require("./useIsMounted");
|
|
7
8
|
const useAsyncEffectQueue_1 = require("./useAsyncEffectQueue");
|
|
8
9
|
const useSubscribe = (subFunc, expectsOne, filter, options, hookOptions) => {
|
|
9
10
|
const { skip } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
10
11
|
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
11
|
-
const [hookResult, setHookResult] =
|
|
12
|
-
const hookResultRef =
|
|
12
|
+
const [hookResult, setHookResult] = useState(defaultLoadingResult);
|
|
13
|
+
const hookResultRef = useRef(hookResult);
|
|
13
14
|
hookResultRef.current = hookResult;
|
|
14
15
|
const getIsMounted = (0, useIsMounted_1.useIsMounted)();
|
|
15
16
|
(0, useAsyncEffectQueue_1.useAsyncEffectQueue)(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSync.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useSync.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMpE,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,KAAK,CAAA;CAAE,GAClD;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,KAAK,CAAA;CAAE,GACtD;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC;AAE7D,eAAO,MAAM,OAAO,GAClB,UAAU,QAAQ,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,EACxF,aAAa,UAAU,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAChE,aAAa,UAAU,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAChE,cAAc,WAAW;;;;CA6B1B,CAAC"}
|
package/dist/hooks/useSync.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSync = void 0;
|
|
4
|
-
const reactImports_1 = require("
|
|
4
|
+
const reactImports_1 = require("../hooks/reactImports");
|
|
5
|
+
const { useState } = reactImports_1.reactImports;
|
|
5
6
|
const useAsyncEffectQueue_1 = require("./useAsyncEffectQueue");
|
|
6
7
|
const useIsMounted_1 = require("./useIsMounted");
|
|
7
8
|
const useSync = (syncFunc, basicFilter, syncOptions, hookOptions) => {
|
|
8
9
|
const { skip } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
9
10
|
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
10
|
-
const [{ data, error, isLoading }, setResult] =
|
|
11
|
+
const [{ data, error, isLoading }, setResult] = useState(defaultLoadingResult);
|
|
11
12
|
const getIsMounted = (0, useIsMounted_1.useIsMounted)();
|
|
12
13
|
(0, useAsyncEffectQueue_1.useAsyncEffectQueue)(async () => {
|
|
13
14
|
if (!getIsMounted() || skip)
|