@8ms/helpers 2.4.13 → 2.4.15
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/api/deleteRequest.cjs +2 -0
- package/dist/api/deleteRequest.mjs +2 -0
- package/dist/api/get.cjs +2 -0
- package/dist/api/get.mjs +2 -0
- package/dist/api/post.cjs +3 -1
- package/dist/api/post.mjs +3 -1
- package/dist/drizzle/server/DrizzleNamespace.d.cts +0 -1
- package/dist/drizzle/server/DrizzleNamespace.d.mts +1 -0
- package/dist/nextJs/client/useAsyncEffect.cjs +14 -10
- package/dist/nextJs/client/useAsyncEffect.d.cts +2 -5
- package/dist/nextJs/client/useAsyncEffect.d.mts +2 -5
- package/dist/nextJs/client/useAsyncEffect.mjs +14 -10
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@ const require_api_ApiResponseClass = require("./ApiResponseClass.cjs");
|
|
|
8
8
|
const deleteRequest = async (url, config = {}) => {
|
|
9
9
|
const { default: ky } = await import("ky");
|
|
10
10
|
return await ky.delete(url, {
|
|
11
|
+
retry: 0,
|
|
12
|
+
timeout: false,
|
|
11
13
|
throwHttpErrors: false,
|
|
12
14
|
...config
|
|
13
15
|
}).then(async (response) => {
|
|
@@ -7,6 +7,8 @@ import { ApiResponseClass } from "./ApiResponseClass.mjs";
|
|
|
7
7
|
const deleteRequest = async (url, config = {}) => {
|
|
8
8
|
const { default: ky } = await import("ky");
|
|
9
9
|
return await ky.delete(url, {
|
|
10
|
+
retry: 0,
|
|
11
|
+
timeout: false,
|
|
10
12
|
throwHttpErrors: false,
|
|
11
13
|
...config
|
|
12
14
|
}).then(async (response) => {
|
package/dist/api/get.cjs
CHANGED
|
@@ -7,6 +7,8 @@ const require_api_ApiResponseClass = require("./ApiResponseClass.cjs");
|
|
|
7
7
|
const get = async (url, config = {}) => {
|
|
8
8
|
const { default: ky } = await import("ky");
|
|
9
9
|
return await ky.get(url, {
|
|
10
|
+
retry: 0,
|
|
11
|
+
timeout: false,
|
|
10
12
|
throwHttpErrors: false,
|
|
11
13
|
...config
|
|
12
14
|
}).then(async (response) => {
|
package/dist/api/get.mjs
CHANGED
|
@@ -6,6 +6,8 @@ import { ApiResponseClass } from "./ApiResponseClass.mjs";
|
|
|
6
6
|
const get = async (url, config = {}) => {
|
|
7
7
|
const { default: ky } = await import("ky");
|
|
8
8
|
return await ky.get(url, {
|
|
9
|
+
retry: 0,
|
|
10
|
+
timeout: false,
|
|
9
11
|
throwHttpErrors: false,
|
|
10
12
|
...config
|
|
11
13
|
}).then(async (response) => {
|
package/dist/api/post.cjs
CHANGED
|
@@ -7,8 +7,10 @@ const require_api_ApiResponseClass = require("./ApiResponseClass.cjs");
|
|
|
7
7
|
const post = async (url, data = {}, config = {}) => {
|
|
8
8
|
const { default: ky } = await import("ky");
|
|
9
9
|
return await ky.post(url, {
|
|
10
|
-
throwHttpErrors: false,
|
|
11
10
|
json: data,
|
|
11
|
+
retry: 0,
|
|
12
|
+
timeout: false,
|
|
13
|
+
throwHttpErrors: false,
|
|
12
14
|
...config
|
|
13
15
|
}).then(async (response) => {
|
|
14
16
|
const responseData = await response.json();
|
package/dist/api/post.mjs
CHANGED
|
@@ -6,8 +6,10 @@ import { ApiResponseClass } from "./ApiResponseClass.mjs";
|
|
|
6
6
|
const post = async (url, data = {}, config = {}) => {
|
|
7
7
|
const { default: ky } = await import("ky");
|
|
8
8
|
return await ky.post(url, {
|
|
9
|
-
throwHttpErrors: false,
|
|
10
9
|
json: data,
|
|
10
|
+
retry: 0,
|
|
11
|
+
timeout: false,
|
|
12
|
+
throwHttpErrors: false,
|
|
11
13
|
...config
|
|
12
14
|
}).then(async (response) => {
|
|
13
15
|
const responseData = await response.json();
|
|
@@ -2,21 +2,25 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
//#region src/nextJs/client/useAsyncEffect.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Based on https://github.com/rauldeheer/use-async-effect/tree/master
|
|
7
|
+
*/
|
|
8
|
+
function useAsyncEffect(effect, destroy, inputs) {
|
|
9
|
+
const hasDestroy = typeof destroy === "function";
|
|
10
|
+
(0, react.useEffect)(function() {
|
|
9
11
|
let result;
|
|
10
12
|
let mounted = true;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
let maybePromise = effect(function() {
|
|
14
|
+
return mounted;
|
|
15
|
+
});
|
|
16
|
+
Promise.resolve(maybePromise).then(function(value) {
|
|
13
17
|
result = value;
|
|
14
18
|
});
|
|
15
|
-
return ()
|
|
19
|
+
return function() {
|
|
16
20
|
mounted = false;
|
|
17
|
-
if (hasDestroy
|
|
21
|
+
if (hasDestroy) destroy(result);
|
|
18
22
|
};
|
|
19
|
-
}, hasDestroy ? inputs :
|
|
20
|
-
}
|
|
23
|
+
}, hasDestroy ? inputs : destroy);
|
|
24
|
+
}
|
|
21
25
|
//#endregion
|
|
22
26
|
exports.useAsyncEffect = useAsyncEffect;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
//#region src/nextJs/client/useAsyncEffect.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<T>(effect: (isMounted: () => boolean) => T | Promise<T>, destroy?: (result?: T) => void, inputs?: any[]): void;
|
|
5
|
-
};
|
|
6
|
-
declare const useAsyncEffect: UseAsyncEffect;
|
|
2
|
+
declare function useAsyncEffect(effect: (isMounted: () => boolean) => unknown | Promise<unknown>, inputs?: any[]): void;
|
|
3
|
+
declare function useAsyncEffect<V>(effect: (isMounted: () => boolean) => V | Promise<V>, destroy?: (result?: V) => void, inputs?: any[]): void;
|
|
7
4
|
//#endregion
|
|
8
5
|
export { useAsyncEffect };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
//#region src/nextJs/client/useAsyncEffect.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<T>(effect: (isMounted: () => boolean) => T | Promise<T>, destroy?: (result?: T) => void, inputs?: any[]): void;
|
|
5
|
-
};
|
|
6
|
-
declare const useAsyncEffect: UseAsyncEffect;
|
|
2
|
+
declare function useAsyncEffect(effect: (isMounted: () => boolean) => unknown | Promise<unknown>, inputs?: any[]): void;
|
|
3
|
+
declare function useAsyncEffect<V>(effect: (isMounted: () => boolean) => V | Promise<V>, destroy?: (result?: V) => void, inputs?: any[]): void;
|
|
7
4
|
//#endregion
|
|
8
5
|
export { useAsyncEffect };
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
//#region src/nextJs/client/useAsyncEffect.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Based on https://github.com/rauldeheer/use-async-effect/tree/master
|
|
5
|
+
*/
|
|
6
|
+
function useAsyncEffect(effect, destroy, inputs) {
|
|
7
|
+
const hasDestroy = typeof destroy === "function";
|
|
8
|
+
useEffect(function() {
|
|
7
9
|
let result;
|
|
8
10
|
let mounted = true;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
let maybePromise = effect(function() {
|
|
12
|
+
return mounted;
|
|
13
|
+
});
|
|
14
|
+
Promise.resolve(maybePromise).then(function(value) {
|
|
11
15
|
result = value;
|
|
12
16
|
});
|
|
13
|
-
return ()
|
|
17
|
+
return function() {
|
|
14
18
|
mounted = false;
|
|
15
|
-
if (hasDestroy
|
|
19
|
+
if (hasDestroy) destroy(result);
|
|
16
20
|
};
|
|
17
|
-
}, hasDestroy ? inputs :
|
|
18
|
-
}
|
|
21
|
+
}, hasDestroy ? inputs : destroy);
|
|
22
|
+
}
|
|
19
23
|
//#endregion
|
|
20
24
|
export { useAsyncEffect };
|