@pawover/kit 0.0.0-beta.29 → 0.0.0-beta.30
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/hooks-alova.d.ts +6 -6
- package/dist/hooks-alova.d.ts.map +1 -1
- package/dist/hooks-alova.js +30 -30
- package/dist/hooks-alova.js.map +1 -1
- package/dist/hooks-react.d.ts +2 -2
- package/dist/hooks-react.d.ts.map +1 -1
- package/dist/hooks-react.js +3 -3
- package/dist/hooks-react.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/patches-fetchEventSource.js +1 -1
- package/dist/{utils-BL6hgQli.js → utils-RGh-N7TJ.js} +16 -12
- package/dist/utils-RGh-N7TJ.js.map +1 -0
- package/package.json +5 -5
- package/dist/utils-BL6hgQli.js.map +0 -1
package/dist/hooks-alova.d.ts
CHANGED
|
@@ -3,30 +3,30 @@ import { AlovaFrontMiddlewareContext, AlovaMethodHandler, CompleteHandler, Error
|
|
|
3
3
|
import { AlovaGenerics, Method } from "alova";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/alova/useAlovaPagination.d.ts
|
|
6
|
-
interface
|
|
6
|
+
interface HookOptions$2<AG extends AlovaGenerics, L extends any[], Args extends any[]> extends PaginationHookConfig<AG, L> {
|
|
7
7
|
onBeforeRequest?: ((context: AlovaFrontMiddlewareContext<AG, any[]>) => void) | undefined;
|
|
8
8
|
onSuccess?: SuccessHandler<AG, Args> | undefined;
|
|
9
9
|
onError?: ErrorHandler<AG, Args> | undefined;
|
|
10
10
|
onComplete?: CompleteHandler<AG, Args> | undefined;
|
|
11
11
|
}
|
|
12
|
-
declare function useAlovaPagination<AG extends AlovaGenerics, L extends any[], Args extends any[]>(methodHandler: (page: number, pageSize: number, ...args: Args) => Method<AG>,
|
|
12
|
+
declare function useAlovaPagination<AG extends AlovaGenerics, L extends any[], Args extends any[]>(methodHandler: (page: number, pageSize: number, ...args: Args) => Method<AG>, hookOptions?: HookOptions$2<AG, L, Args> | undefined): alova_client0.UsePaginationExposure<AG, L, Args>;
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/hooks/alova/useAlovaRequest.d.ts
|
|
15
|
-
interface
|
|
15
|
+
interface HookOptions$1<AG extends AlovaGenerics, Args extends any[]> extends RequestHookConfig<AG, Args> {
|
|
16
16
|
onBeforeRequest?: ((context: AlovaFrontMiddlewareContext<AG, Args>) => void) | undefined;
|
|
17
17
|
onSuccess?: SuccessHandler<AG, Args> | undefined;
|
|
18
18
|
onError?: ErrorHandler<AG, Args> | undefined;
|
|
19
19
|
onComplete?: CompleteHandler<AG, Args> | undefined;
|
|
20
20
|
}
|
|
21
|
-
declare function useAlovaRequest<AG extends AlovaGenerics, Args extends any[] = any[]>(methodHandler: Method<AG> | AlovaMethodHandler<AG, Args>,
|
|
21
|
+
declare function useAlovaRequest<AG extends AlovaGenerics, Args extends any[] = any[]>(methodHandler: Method<AG> | AlovaMethodHandler<AG, Args>, hookOptions?: HookOptions$1<AG, Args> | undefined): alova_client0.UseHookExposure<AG, Args, unknown>;
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/hooks/alova/useAlovaWatcher.d.ts
|
|
24
|
-
interface
|
|
24
|
+
interface HookOptions<AG extends AlovaGenerics, Args extends any[]> extends WatcherHookConfig<AG, Args> {
|
|
25
25
|
onSuccess?: SuccessHandler<AG, Args> | undefined;
|
|
26
26
|
onError?: ErrorHandler<AG, Args> | undefined;
|
|
27
27
|
onComplete?: CompleteHandler<AG, Args> | undefined;
|
|
28
28
|
}
|
|
29
|
-
declare function useAlovaWatcher<AG extends AlovaGenerics, Args extends any[] = any[]>(methodHandler: Method<AG> | AlovaMethodHandler<AG, Args>, watchingStates: AG["StatesExport"]["Watched"][],
|
|
29
|
+
declare function useAlovaWatcher<AG extends AlovaGenerics, Args extends any[] = any[]>(methodHandler: Method<AG> | AlovaMethodHandler<AG, Args>, watchingStates: AG["StatesExport"]["Watched"][], hookOptions?: HookOptions<AG, Args>): alova_client0.UseHookExposure<AG, Args, unknown>;
|
|
30
30
|
//#endregion
|
|
31
31
|
export { useAlovaPagination, useAlovaRequest, useAlovaWatcher };
|
|
32
32
|
//# sourceMappingURL=hooks-alova.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-alova.d.ts","names":[],"sources":["../src/hooks/alova/useAlovaPagination.ts","../src/hooks/alova/useAlovaRequest.ts","../src/hooks/alova/useAlovaWatcher.ts"],"sourcesContent":[],"mappings":";;;;;UAYU,
|
|
1
|
+
{"version":3,"file":"hooks-alova.d.ts","names":[],"sources":["../src/hooks/alova/useAlovaPagination.ts","../src/hooks/alova/useAlovaRequest.ts","../src/hooks/alova/useAlovaWatcher.ts"],"sourcesContent":[],"mappings":";;;;;UAYU,yBAAuB,4DAA4D,qBAAqB,IAAI;+BACvF,4BAA4B;cAC7C,eAAe,IAAI;EAFvB,OAAA,CAAA,EAGE,YAHS,CAGI,EAHJ,EAGQ,IAHR,CAAA,GAAA,SAAA;EAAY,UAAA,CAAA,EAIlB,eAJkB,CAIF,EAJE,EAIE,IAJF,CAAA,GAAA,SAAA;;AAAqF,iBAOtG,kBAPsG,CAAA,WAOxE,aAPwE,EAAA,UAAA,GAAA,EAAA,EAAA,aAAA,GAAA,EAAA,CAAA,CAAA,aAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAQ3D,IAR2D,EAAA,GAQlD,MARkD,CAQ3C,EAR2C,CAAA,EAAA,WAAA,CAAA,EAStG,aATsG,CAS1F,EAT0F,EAStF,CATsF,EASnF,IATmF,CAAA,GAAA,SAAA,CAAA,EASlE,aAAA,CAAA,qBATkE,CASlE,EATkE,EASlE,CATkE,EASlE,IATkE,CAAA;;;UCC5G,yBAAuB,2CAA2C,kBAAkB,IAAI;+BACnE,4BAA4B,IAAI;cACjD,eAAe,IAAI;EDHvB,OAAA,CAAA,ECIE,YDJS,CCII,EDJJ,ECIQ,IDJR,CAAA,GAAA,SAAA;EAAY,UAAA,CAAA,ECKlB,eDLkB,CCKF,EDLE,ECKE,IDLF,CAAA,GAAA,SAAA;;AAAqF,iBCQtG,eDRsG,CAAA,WCQ3E,aDR2E,EAAA,aAAA,GAAA,EAAA,GAAA,GAAA,EAAA,CAAA,CAAA,aAAA,ECSrG,MDTqG,CCS9F,EDT8F,CAAA,GCSxF,kBDTwF,CCSrE,EDTqE,ECSjE,IDTiE,CAAA,EAAA,WAAA,CAAA,ECUtG,aDVsG,CCU1F,EDV0F,ECUtF,IDVsF,CAAA,GAAA,SAAA,CAAA,ECUrE,aAAA,CAAA,eDVqE,CCUrE,EDVqE,ECUrE,IDVqE,EAAA,OAAA,CAAA;;;UEA5G,uBAAuB,2CAA2C,kBAAkB,IAAI;cACpF,eAAe,IAAI;YACrB,aAAa,IAAI;EFFnB,UAAA,CAAA,EEGK,eFHM,CEGU,EFHV,EEGc,IFHd,CAAA,GAAA,SAAA;;AAA6F,iBEMlG,eFNkG,CAAA,WEMvE,aFNuE,EAAA,aAAA,GAAA,EAAA,GAAA,GAAA,EAAA,CAAA,CAAA,aAAA,EEOjG,MFPiG,CEO1F,EFP0F,CAAA,GEOpF,kBFPoF,CEOjE,EFPiE,EEO7D,IFP6D,CAAA,EAAA,cAAA,EEQhG,EFRgG,CAAA,cAAA,CAAA,CAAA,SAAA,CAAA,EAAA,EAAA,WAAA,CAAA,EESnG,WFTmG,CESvF,EFTuF,EESnF,IFTmF,CAAA,CAAA,EESzE,aAAA,CAAA,eFTyE,CESzE,EFTyE,EESzE,IFTyE,EAAA,OAAA,CAAA"}
|
package/dist/hooks-alova.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { usePagination, useRequest, useWatcher } from "alova/client";
|
|
2
2
|
|
|
3
3
|
//#region src/hooks/alova/useAlovaPagination.ts
|
|
4
|
-
function useAlovaPagination(methodHandler,
|
|
5
|
-
const
|
|
6
|
-
...
|
|
7
|
-
immediate:
|
|
4
|
+
function useAlovaPagination(methodHandler, hookOptions) {
|
|
5
|
+
const options = {
|
|
6
|
+
...hookOptions,
|
|
7
|
+
immediate: hookOptions?.immediate ?? true
|
|
8
8
|
};
|
|
9
9
|
let isBeforeExecuted = false;
|
|
10
10
|
let isMiddlewareExecuted = false;
|
|
11
|
-
if (
|
|
12
|
-
const middleware =
|
|
13
|
-
|
|
14
|
-
!isBeforeExecuted &&
|
|
11
|
+
if (options.onBeforeRequest) {
|
|
12
|
+
const middleware = options.middleware;
|
|
13
|
+
options.middleware = async (context, next) => {
|
|
14
|
+
!isBeforeExecuted && options.onBeforeRequest?.(context);
|
|
15
15
|
isBeforeExecuted = true;
|
|
16
16
|
if (middleware && !isMiddlewareExecuted) {
|
|
17
17
|
isMiddlewareExecuted = true;
|
|
@@ -19,26 +19,26 @@ function useAlovaPagination(methodHandler, hookConfig) {
|
|
|
19
19
|
} else await next();
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
const exposure = usePagination(methodHandler,
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
if (
|
|
22
|
+
const exposure = usePagination(methodHandler, options);
|
|
23
|
+
if (options.onSuccess) exposure.onSuccess(options.onSuccess);
|
|
24
|
+
if (options.onError) exposure.onError(options.onError);
|
|
25
|
+
if (options.onComplete) exposure.onComplete(options.onComplete);
|
|
26
26
|
return exposure;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/hooks/alova/useAlovaRequest.ts
|
|
31
|
-
function useAlovaRequest(methodHandler,
|
|
32
|
-
const
|
|
33
|
-
...
|
|
34
|
-
immediate:
|
|
31
|
+
function useAlovaRequest(methodHandler, hookOptions) {
|
|
32
|
+
const options = {
|
|
33
|
+
...hookOptions,
|
|
34
|
+
immediate: hookOptions?.immediate ?? true
|
|
35
35
|
};
|
|
36
36
|
let isBeforeExecuted = false;
|
|
37
37
|
let isMiddlewareExecuted = false;
|
|
38
|
-
if (
|
|
39
|
-
const middleware =
|
|
40
|
-
|
|
41
|
-
!isBeforeExecuted &&
|
|
38
|
+
if (options.onBeforeRequest) {
|
|
39
|
+
const middleware = options.middleware;
|
|
40
|
+
options.middleware = async (context, next) => {
|
|
41
|
+
!isBeforeExecuted && options.onBeforeRequest?.(context);
|
|
42
42
|
isBeforeExecuted = true;
|
|
43
43
|
if (middleware && !isMiddlewareExecuted) {
|
|
44
44
|
isMiddlewareExecuted = true;
|
|
@@ -46,21 +46,21 @@ function useAlovaRequest(methodHandler, hookConfig) {
|
|
|
46
46
|
} else await next();
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
const exposure = useRequest(methodHandler,
|
|
50
|
-
if (
|
|
51
|
-
if (
|
|
52
|
-
if (
|
|
49
|
+
const exposure = useRequest(methodHandler, options);
|
|
50
|
+
if (options.onSuccess) exposure.onSuccess(options.onSuccess);
|
|
51
|
+
if (options.onError) exposure.onError(options.onError);
|
|
52
|
+
if (options.onComplete) exposure.onComplete(options.onComplete);
|
|
53
53
|
return exposure;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/hooks/alova/useAlovaWatcher.ts
|
|
58
|
-
function useAlovaWatcher(methodHandler, watchingStates,
|
|
59
|
-
const
|
|
60
|
-
const exposure = useWatcher(methodHandler, watchingStates,
|
|
61
|
-
if (
|
|
62
|
-
if (
|
|
63
|
-
if (
|
|
58
|
+
function useAlovaWatcher(methodHandler, watchingStates, hookOptions = {}) {
|
|
59
|
+
const options = hookOptions || {};
|
|
60
|
+
const exposure = useWatcher(methodHandler, watchingStates, options);
|
|
61
|
+
if (options.onSuccess) exposure.onSuccess(options.onSuccess);
|
|
62
|
+
if (options.onError) exposure.onError(options.onError);
|
|
63
|
+
if (options.onComplete) exposure.onComplete(options.onComplete);
|
|
64
64
|
return exposure;
|
|
65
65
|
}
|
|
66
66
|
|
package/dist/hooks-alova.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-alova.js","names":[],"sources":["../src/hooks/alova/useAlovaPagination.ts","../src/hooks/alova/useAlovaRequest.ts","../src/hooks/alova/useAlovaWatcher.ts"],"sourcesContent":["/* eslint-disable ts/no-explicit-any */\n\nimport type { AlovaGenerics, Method } from \"alova\";\nimport {\n usePagination,\n type AlovaFrontMiddlewareContext,\n type CompleteHandler,\n type ErrorHandler,\n type PaginationHookConfig,\n type SuccessHandler,\n} from \"alova/client\";\n\ninterface
|
|
1
|
+
{"version":3,"file":"hooks-alova.js","names":[],"sources":["../src/hooks/alova/useAlovaPagination.ts","../src/hooks/alova/useAlovaRequest.ts","../src/hooks/alova/useAlovaWatcher.ts"],"sourcesContent":["/* eslint-disable ts/no-explicit-any */\n\nimport type { AlovaGenerics, Method } from \"alova\";\nimport {\n usePagination,\n type AlovaFrontMiddlewareContext,\n type CompleteHandler,\n type ErrorHandler,\n type PaginationHookConfig,\n type SuccessHandler,\n} from \"alova/client\";\n\ninterface HookOptions<AG extends AlovaGenerics, L extends any[], Args extends any[]> extends PaginationHookConfig<AG, L> {\n onBeforeRequest?: ((context: AlovaFrontMiddlewareContext<AG, any[]>) => void) | undefined;\n onSuccess?: SuccessHandler<AG, Args> | undefined;\n onError?: ErrorHandler<AG, Args> | undefined;\n onComplete?: CompleteHandler<AG, Args> | undefined;\n}\n\nexport function useAlovaPagination<AG extends AlovaGenerics, L extends any[], Args extends any[]> (\n methodHandler: (page: number, pageSize: number, ...args: Args) => Method<AG>,\n hookOptions?: HookOptions<AG, L, Args> | undefined,\n) {\n const options = { ...hookOptions, immediate: hookOptions?.immediate ?? true };\n let isBeforeExecuted = false;\n let isMiddlewareExecuted = false;\n\n if (options.onBeforeRequest) {\n const middleware = options.middleware;\n options.middleware = async (context, next) => {\n !isBeforeExecuted && options.onBeforeRequest?.(context);\n isBeforeExecuted = true;\n\n if (middleware && !isMiddlewareExecuted) {\n isMiddlewareExecuted = true;\n await middleware?.(context, next);\n } else {\n await next();\n }\n };\n }\n\n const exposure = usePagination(methodHandler, options);\n\n if (options.onSuccess) {\n exposure.onSuccess(options.onSuccess);\n }\n if (options.onError) {\n exposure.onError(options.onError);\n }\n if (options.onComplete) {\n exposure.onComplete(options.onComplete);\n }\n\n return exposure;\n}\n","/* eslint-disable ts/no-explicit-any */\n\nimport type { AlovaGenerics, Method } from \"alova\";\nimport {\n type AlovaFrontMiddlewareContext,\n type AlovaMethodHandler,\n type CompleteHandler,\n type ErrorHandler,\n type RequestHookConfig,\n type SuccessHandler,\n useRequest,\n} from \"alova/client\";\n\ninterface HookOptions<AG extends AlovaGenerics, Args extends any[]> extends RequestHookConfig<AG, Args> {\n onBeforeRequest?: ((context: AlovaFrontMiddlewareContext<AG, Args>) => void) | undefined;\n onSuccess?: SuccessHandler<AG, Args> | undefined;\n onError?: ErrorHandler<AG, Args> | undefined;\n onComplete?: CompleteHandler<AG, Args> | undefined;\n}\n\nexport function useAlovaRequest<AG extends AlovaGenerics, Args extends any[] = any[]> (\n methodHandler: Method<AG> | AlovaMethodHandler<AG, Args>,\n hookOptions?: HookOptions<AG, Args> | undefined,\n) {\n const options = { ...hookOptions, immediate: hookOptions?.immediate ?? true };\n let isBeforeExecuted = false;\n let isMiddlewareExecuted = false;\n\n if (options.onBeforeRequest) {\n const middleware = options.middleware;\n options.middleware = async (context, next) => {\n !isBeforeExecuted && options.onBeforeRequest?.(context);\n isBeforeExecuted = true;\n\n if (middleware && !isMiddlewareExecuted) {\n isMiddlewareExecuted = true;\n await middleware?.(context, next);\n } else {\n await next();\n }\n };\n }\n\n const exposure = useRequest(methodHandler, options);\n\n if (options.onSuccess) {\n exposure.onSuccess(options.onSuccess);\n }\n if (options.onError) {\n exposure.onError(options.onError);\n }\n if (options.onComplete) {\n exposure.onComplete(options.onComplete);\n }\n\n return exposure;\n}\n","/* eslint-disable ts/no-explicit-any */\n\nimport type { AlovaGenerics, Method } from \"alova\";\nimport {\n type AlovaMethodHandler,\n type CompleteHandler,\n type ErrorHandler,\n type SuccessHandler,\n type WatcherHookConfig,\n useWatcher,\n} from \"alova/client\";\n\ninterface HookOptions<AG extends AlovaGenerics, Args extends any[]> extends WatcherHookConfig<AG, Args> {\n onSuccess?: SuccessHandler<AG, Args> | undefined;\n onError?: ErrorHandler<AG, Args> | undefined;\n onComplete?: CompleteHandler<AG, Args> | undefined;\n}\n\nexport function useAlovaWatcher<AG extends AlovaGenerics, Args extends any[] = any[]> (\n methodHandler: Method<AG> | AlovaMethodHandler<AG, Args>,\n watchingStates: AG[\"StatesExport\"][\"Watched\"][],\n hookOptions: HookOptions<AG, Args> = {},\n) {\n const options = hookOptions || {};\n const exposure = useWatcher(methodHandler, watchingStates, options);\n\n if (options.onSuccess) {\n exposure.onSuccess(options.onSuccess);\n }\n if (options.onError) {\n exposure.onError(options.onError);\n }\n if (options.onComplete) {\n exposure.onComplete(options.onComplete);\n }\n\n return exposure;\n}\n"],"mappings":";;;AAmBA,SAAgB,mBACd,eACA,aACA;CACA,MAAM,UAAU;EAAE,GAAG;EAAa,WAAW,aAAa,aAAa;EAAM;CAC7E,IAAI,mBAAmB;CACvB,IAAI,uBAAuB;AAE3B,KAAI,QAAQ,iBAAiB;EAC3B,MAAM,aAAa,QAAQ;AAC3B,UAAQ,aAAa,OAAO,SAAS,SAAS;AAC5C,IAAC,oBAAoB,QAAQ,kBAAkB,QAAQ;AACvD,sBAAmB;AAEnB,OAAI,cAAc,CAAC,sBAAsB;AACvC,2BAAuB;AACvB,UAAM,aAAa,SAAS,KAAK;SAEjC,OAAM,MAAM;;;CAKlB,MAAM,WAAW,cAAc,eAAe,QAAQ;AAEtD,KAAI,QAAQ,UACV,UAAS,UAAU,QAAQ,UAAU;AAEvC,KAAI,QAAQ,QACV,UAAS,QAAQ,QAAQ,QAAQ;AAEnC,KAAI,QAAQ,WACV,UAAS,WAAW,QAAQ,WAAW;AAGzC,QAAO;;;;;AClCT,SAAgB,gBACd,eACA,aACA;CACA,MAAM,UAAU;EAAE,GAAG;EAAa,WAAW,aAAa,aAAa;EAAM;CAC7E,IAAI,mBAAmB;CACvB,IAAI,uBAAuB;AAE3B,KAAI,QAAQ,iBAAiB;EAC3B,MAAM,aAAa,QAAQ;AAC3B,UAAQ,aAAa,OAAO,SAAS,SAAS;AAC5C,IAAC,oBAAoB,QAAQ,kBAAkB,QAAQ;AACvD,sBAAmB;AAEnB,OAAI,cAAc,CAAC,sBAAsB;AACvC,2BAAuB;AACvB,UAAM,aAAa,SAAS,KAAK;SAEjC,OAAM,MAAM;;;CAKlB,MAAM,WAAW,WAAW,eAAe,QAAQ;AAEnD,KAAI,QAAQ,UACV,UAAS,UAAU,QAAQ,UAAU;AAEvC,KAAI,QAAQ,QACV,UAAS,QAAQ,QAAQ,QAAQ;AAEnC,KAAI,QAAQ,WACV,UAAS,WAAW,QAAQ,WAAW;AAGzC,QAAO;;;;;ACrCT,SAAgB,gBACd,eACA,gBACA,cAAqC,EAAE,EACvC;CACA,MAAM,UAAU,eAAe,EAAE;CACjC,MAAM,WAAW,WAAW,eAAe,gBAAgB,QAAQ;AAEnE,KAAI,QAAQ,UACV,UAAS,UAAU,QAAQ,UAAU;AAEvC,KAAI,QAAQ,QACV,UAAS,QAAQ,QAAQ,QAAQ;AAEnC,KAAI,QAAQ,WACV,UAAS,WAAW,QAAQ,WAAW;AAGzC,QAAO"}
|
package/dist/hooks-react.d.ts
CHANGED
|
@@ -109,10 +109,10 @@ declare function useResponsive(options?: ResponsiveHookOptions): {
|
|
|
109
109
|
};
|
|
110
110
|
//#endregion
|
|
111
111
|
//#region src/hooks/react/useTitle.d.ts
|
|
112
|
-
interface
|
|
112
|
+
interface TitleHookOptions {
|
|
113
113
|
isRestoreOnUnmount?: boolean;
|
|
114
114
|
}
|
|
115
|
-
declare function useTitle(title: string,
|
|
115
|
+
declare function useTitle(title: string, options?: TitleHookOptions | undefined): void;
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/hooks/react/useUnmount.d.ts
|
|
118
118
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-react.d.ts","names":["TupleToUnion","ArrayType"],"sources":["../src/hooks/react/useCreation.ts","../src/hooks/react/useLatest.ts","../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/tuple-to-union.d.ts","../src/hooks/react/useMount.ts","../src/hooks/react/useResponsive.ts","../src/hooks/react/useTitle.ts","../src/hooks/react/useUnmount.ts"],"sourcesContent":["/**\nConvert a tuple/array into a union type of its elements.\n\nThis can be useful when you have a fixed set of allowed values and want a type defining only the allowed values, but do not want to repeat yourself.\n\n@example\n```\nimport type {TupleToUnion} from 'type-fest';\n\nconst destinations = ['a', 'b', 'c'] as const;\n\ntype Destination = TupleToUnion<typeof destinations>;\n//=> 'a' | 'b' | 'c'\n\nfunction verifyDestination(destination: unknown): destination is Destination {\n\treturn destinations.includes(destination as any);\n}\n\ntype RequestBody = {\n\tdeliverTo: Destination;\n};\n\nfunction verifyRequestBody(body: unknown): body is RequestBody {\n\tconst {deliverTo} = (body as any);\n\treturn typeof body === 'object' && body !== null && verifyDestination(deliverTo);\n}\n```\n\nAlternatively, you may use `typeof destinations[number]`. If `destinations` is a tuple, there is no difference. However if `destinations` is a string, the resulting type will the union of the characters in the string. Other types of `destinations` may result in a compile error. In comparison, TupleToUnion will return `never` if a tuple is not provided.\n\n@example\n```\nconst destinations = ['a', 'b', 'c'] as const;\n\ntype Destination = typeof destinations[number];\n//=> 'a' | 'b' | 'c'\n\nconst erroringType = new Set(['a', 'b', 'c']);\n\n// @ts-expect-error\ntype ErroringType = typeof erroringType[number];\n// Error: Type 'Set<string>' has no matching index signature for type 'number'. ts(2537)\n\nconst numberBool: {[n: number]: boolean} = {1: true};\n\ntype NumberBool = typeof numberBool[number];\n//=> boolean\n```\n\n@category Array\n*/\nexport type TupleToUnion<ArrayType> = ArrayType extends readonly unknown[] ? ArrayType[number] : never;\n\nexport {};\n"],"x_google_ignoreList":[2],"mappings":";;;;;;;;;;AAgBA;;;AAAsE,iBAAtD,WAAsD,CAAA,CAAA,CAAA,CAAA,OAAA,EAAA,GAAA,GAAvB,CAAuB,EAAA,IAAA,EAAd,cAAc,CAAA,EAAA,CAAA;;;;;;;AAAtE;;AAAwD,iBCRxC,SDQwC,CAAA,CAAA,CAAA,CAAA,KAAA,ECRnB,CDQmB,CAAA,ECRf,SDQe,CCRL,CDQK,CAAA;;;;;;;;AAAxD;;;;;;;;ACRA;;;;;;;;AC2CA;;;;AClDuD;AAavD;;;;ACX8C;AAEhB;AAGA;AAS9B;AAUA;;;;;;;;;ACpBA;;;;ACIA;;;;KJwCYA,0BAA0BC,uCAAuCA;;;KC9CxE,aAAA,GAAgB,iBAAiB;;;AHWtC;;;;;iBGFgB,QAAA,SAAkB;;;KCT7B,UAAA,GAAa,oBAAoB;KAGjC,gBAAA,GAAmB,OAAO;cAEzB;AJMU,UICC,qBAAA,CJDU;EAAoB;;;;;sBIOzB;;EHfN,gBAAS,CAAA,EGiBJ,sBHjBI;;AAA0B,iBGmBnC,aAAA,CHnBmC,OAAA,CAAA,EGmBV,qBHnBU,CAAA,EAAA;EAAV,UAAA,kBAAA;EAAS,OAAA,EAAA,MAAA,GAAA,KAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA;;;;;;UIJxC,
|
|
1
|
+
{"version":3,"file":"hooks-react.d.ts","names":["TupleToUnion","ArrayType"],"sources":["../src/hooks/react/useCreation.ts","../src/hooks/react/useLatest.ts","../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/tuple-to-union.d.ts","../src/hooks/react/useMount.ts","../src/hooks/react/useResponsive.ts","../src/hooks/react/useTitle.ts","../src/hooks/react/useUnmount.ts"],"sourcesContent":["/**\nConvert a tuple/array into a union type of its elements.\n\nThis can be useful when you have a fixed set of allowed values and want a type defining only the allowed values, but do not want to repeat yourself.\n\n@example\n```\nimport type {TupleToUnion} from 'type-fest';\n\nconst destinations = ['a', 'b', 'c'] as const;\n\ntype Destination = TupleToUnion<typeof destinations>;\n//=> 'a' | 'b' | 'c'\n\nfunction verifyDestination(destination: unknown): destination is Destination {\n\treturn destinations.includes(destination as any);\n}\n\ntype RequestBody = {\n\tdeliverTo: Destination;\n};\n\nfunction verifyRequestBody(body: unknown): body is RequestBody {\n\tconst {deliverTo} = (body as any);\n\treturn typeof body === 'object' && body !== null && verifyDestination(deliverTo);\n}\n```\n\nAlternatively, you may use `typeof destinations[number]`. If `destinations` is a tuple, there is no difference. However if `destinations` is a string, the resulting type will the union of the characters in the string. Other types of `destinations` may result in a compile error. In comparison, TupleToUnion will return `never` if a tuple is not provided.\n\n@example\n```\nconst destinations = ['a', 'b', 'c'] as const;\n\ntype Destination = typeof destinations[number];\n//=> 'a' | 'b' | 'c'\n\nconst erroringType = new Set(['a', 'b', 'c']);\n\n// @ts-expect-error\ntype ErroringType = typeof erroringType[number];\n// Error: Type 'Set<string>' has no matching index signature for type 'number'. ts(2537)\n\nconst numberBool: {[n: number]: boolean} = {1: true};\n\ntype NumberBool = typeof numberBool[number];\n//=> boolean\n```\n\n@category Array\n*/\nexport type TupleToUnion<ArrayType> = ArrayType extends readonly unknown[] ? ArrayType[number] : never;\n\nexport {};\n"],"x_google_ignoreList":[2],"mappings":";;;;;;;;;;AAgBA;;;AAAsE,iBAAtD,WAAsD,CAAA,CAAA,CAAA,CAAA,OAAA,EAAA,GAAA,GAAvB,CAAuB,EAAA,IAAA,EAAd,cAAc,CAAA,EAAA,CAAA;;;;;;;AAAtE;;AAAwD,iBCRxC,SDQwC,CAAA,CAAA,CAAA,CAAA,KAAA,ECRnB,CDQmB,CAAA,ECRf,SDQe,CCRL,CDQK,CAAA;;;;;;;;AAAxD;;;;;;;;ACRA;;;;;;;;AC2CA;;;;AClDuD;AAavD;;;;ACX8C;AAEhB;AAGA;AAS9B;AAUA;;;;;;;;;ACpBA;;;;ACIA;;;;KJwCYA,0BAA0BC,uCAAuCA;;;KC9CxE,aAAA,GAAgB,iBAAiB;;;AHWtC;;;;;iBGFgB,QAAA,SAAkB;;;KCT7B,UAAA,GAAa,oBAAoB;KAGjC,gBAAA,GAAmB,OAAO;cAEzB;AJMU,UICC,qBAAA,CJDU;EAAoB;;;;;sBIOzB;;EHfN,gBAAS,CAAA,EGiBJ,sBHjBI;;AAA0B,iBGmBnC,aAAA,CHnBmC,OAAA,CAAA,EGmBV,qBHnBU,CAAA,EAAA;EAAV,UAAA,kBAAA;EAAS,OAAA,EAAA,MAAA,GAAA,KAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA;;;;;;UIJxC,gBAAA;;;iBAGM,QAAA,0BAAmC;;;;;;;ALSnD;;AAAwD,iBMLxC,UAAA,CNKwC,MAAA,EMLpB,WNKoB,CAAA,EAAA,IAAA"}
|
package/dist/hooks-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as arrayZipToObject, Ft as isFunction, R as isBrowser, S as objectAssign, kt as isEqual, pt as isPromiseLike, y as objectKeys } from "./utils-
|
|
1
|
+
import { B as arrayZipToObject, Ft as isFunction, R as isBrowser, S as objectAssign, kt as isEqual, pt as isPromiseLike, y as objectKeys } from "./utils-RGh-N7TJ.js";
|
|
2
2
|
import { n as BREAK_POINT_TOKEN_ENUM } from "./enums-XkYDzrre.js";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
|
|
@@ -151,14 +151,14 @@ function useUnmount(effect) {
|
|
|
151
151
|
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/hooks/react/useTitle.ts
|
|
154
|
-
function useTitle(title,
|
|
154
|
+
function useTitle(title, options) {
|
|
155
155
|
if (!isBrowser()) return;
|
|
156
156
|
const titleRef = useRef(document.title);
|
|
157
157
|
useEffect(() => {
|
|
158
158
|
document.title = title;
|
|
159
159
|
}, [title]);
|
|
160
160
|
useUnmount(() => {
|
|
161
|
-
if (
|
|
161
|
+
if (options?.isRestoreOnUnmount) document.title = titleRef.current;
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
|
package/dist/hooks-react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-react.js","names":["defaultResponsiveValues: ResponsiveValues","responsiveConfig: ResponsiveConfig","responsiveValues: ResponsiveValues","tokens: BREAK_POINT_TOKEN_TYPE"],"sources":["../src/hooks/react/useCreation.ts","../src/hooks/react/useLatest.ts","../src/hooks/react/useMount.ts","../src/hooks/react/useResponsive.ts","../src/hooks/react/useUnmount.ts","../src/hooks/react/useTitle.ts"],"sourcesContent":["import { useRef, type DependencyList } from \"react\";\nimport { isEqual } from \"src/utils\";\n\ninterface RefObject<T> {\n deps: DependencyList;\n result: T;\n isInitialized: boolean;\n}\n\n/**\n * useCreation\n * @reference https://ahooks.js.org/zh-CN/hooks/use-creation\n *\n * @param factory\n * @param deps\n */\nexport function useCreation<T> (factory: () => T, deps: DependencyList) {\n const { current } = useRef<RefObject<T>>({ deps, result: undefined!, isInitialized: false });\n\n if (current.isInitialized === false || !isEqual(current.deps, deps)) {\n current.deps = deps;\n current.result = factory();\n current.isInitialized = true;\n }\n\n return current.result;\n}\n","import { useRef, type RefObject } from \"react\";\n\n/**\n * 返回当前最新值的 Hook\n * @reference https://ahooks.js.org/zh-CN/hooks/use-latest\n *\n * @param value\n */\nexport function useLatest<T> (value: T): RefObject<T> {\n const ref = useRef(value);\n ref.current = value;\n\n return ref;\n}\n","import type { AnyAsyncFunction } from \"@pawover/types\";\nimport { useEffect, type EffectCallback } from \"react\";\nimport { isFunction, isPromiseLike } from \"src/utils\";\nimport { useLatest } from \"./useLatest\";\n\ntype MountCallback = EffectCallback | AnyAsyncFunction;\n\n/**\n * 在组件初始化时执行的 Hook\n * - 即使在严格模式下也只执行一次\n * @reference https://ahooks.js.org/hooks/use-mount\n *\n * @param effect 副作用函数\n */\nexport function useMount (effect: MountCallback) {\n if (!isFunction(effect)) {\n console.error(`useMount expected parameter is a function, but got ${typeof effect}`);\n }\n\n let isMounted = false;\n const effectRef = useLatest(effect);\n\n useEffect(() => {\n if (isMounted) {\n return;\n }\n\n isMounted = true;\n const result = effectRef.current?.();\n // If fn returns a Promise, don't return it as cleanup function\n if (isPromiseLike(result)) {\n return;\n }\n\n return result as ReturnType<EffectCallback>;\n }, []);\n}\n","import { useEffect, useState } from \"react\";\nimport { BREAK_POINT_TOKEN_ENUM, type BREAK_POINT_TOKEN_TYPE } from \"src/enums\";\nimport { arrayZipToObject, objectAssign, objectKeys } from \"src/utils\";\nimport type { TupleToUnion } from \"type-fest\";\n\ntype Breakpoint = TupleToUnion<typeof tuple>;\ntype Subscriber = () => void;\ntype ResponsiveConfig = Record<Breakpoint, number>;\ntype ResponsiveValues = Record<Breakpoint, boolean>;\n\nconst tuple = [\"xxxl\", \"xxl\", \"xl\", \"lg\", \"md\", \"sm\", \"xs\"] as const;\nconst TUPLE = [\"XXXL\", \"XXL\", \"XL\", \"LG\", \"MD\", \"SM\", \"XS\"] as const;\nconst subscriberList = new Set<Subscriber>();\nconst defaultResponsiveValues: ResponsiveValues = arrayZipToObject(tuple, tuple.map(() => false));\nlet responsiveConfig: ResponsiveConfig = arrayZipToObject(tuple, TUPLE.map((t) => BREAK_POINT_TOKEN_ENUM[t]));\nlet responsiveValues: ResponsiveValues = { ...defaultResponsiveValues };\n\nexport interface ResponsiveHookOptions {\n /**\n * 紧凑布局断点\n * - 低于此断点时使用紧凑布局\n * @default \"xl\"\n */\n compactBreakPoint?: Breakpoint;\n /** 屏幕响应断点 token 配置 */\n breakPointTokens?: BREAK_POINT_TOKEN_TYPE;\n}\nexport function useResponsive (options?: ResponsiveHookOptions) {\n const { compactBreakPoint = \"xl\", breakPointTokens = {} } = options || {};\n const tokens: BREAK_POINT_TOKEN_TYPE = objectAssign(BREAK_POINT_TOKEN_ENUM, breakPointTokens);\n responsiveConfig = arrayZipToObject(tuple, TUPLE.map((t) => tokens[t]));\n\n calculate();\n\n const [responsive, setResponsive] = useState<ResponsiveValues>(responsiveValues);\n const isCompact = !responsive[compactBreakPoint];\n const current = objectKeys(defaultResponsiveValues).find((key) => responsive[key] === true) || \"xs\";\n\n useEffect(() => {\n addListener();\n\n const subscriber = () => {\n setResponsive(responsiveValues);\n };\n\n subscriberList.add(subscriber);\n\n return () => {\n subscriberList.delete(subscriber);\n\n if (subscriberList.size === 0) {\n removeListener();\n }\n };\n }, []);\n\n return { responsive, current, isCompact, breakPointTokens: tokens };\n}\n\nfunction resizeListener () {\n const oldInfo = responsiveValues;\n calculate();\n\n if (oldInfo === responsiveValues) {\n return;\n }\n\n for (const subscriber of subscriberList) {\n subscriber();\n }\n}\nfunction addListener () {\n window.addEventListener(\"resize\", resizeListener);\n}\nfunction removeListener () {\n window.removeEventListener(\"resize\", resizeListener);\n}\nfunction calculate () {\n const width = window.innerWidth;\n const newValues = { ...defaultResponsiveValues };\n let shouldUpdate = false;\n\n for (const key of objectKeys(responsiveConfig)) {\n newValues[key] = width >= responsiveConfig[key];\n if (newValues[key] !== responsiveValues[key]) {\n shouldUpdate = true;\n }\n }\n if (shouldUpdate) {\n responsiveValues = newValues;\n }\n}\n","import type { AnyFunction } from \"@pawover/types\";\nimport { useEffect } from \"react\";\nimport { isFunction } from \"src/utils\";\nimport { useLatest } from \"./useLatest\";\n\n/**\n * 在组件卸载时执行的 Hook\n * @reference https://ahooks.js.org/zh-CN/hooks/use-unmount\n *\n * @param effect 副作用函数\n */\nexport function useUnmount (effect: AnyFunction) {\n if (!isFunction(effect)) {\n console.error(`useUnmount expected parameter is a function, got ${typeof effect}`);\n }\n\n const effectRef = useLatest(effect);\n\n useEffect(\n () => () => {\n effectRef.current?.();\n },\n [],\n );\n}\n","import { useEffect, useRef } from \"react\";\nimport { isBrowser } from \"../../utils\";\nimport { useUnmount } from \"./useUnmount\";\n\ninterface
|
|
1
|
+
{"version":3,"file":"hooks-react.js","names":["defaultResponsiveValues: ResponsiveValues","responsiveConfig: ResponsiveConfig","responsiveValues: ResponsiveValues","tokens: BREAK_POINT_TOKEN_TYPE"],"sources":["../src/hooks/react/useCreation.ts","../src/hooks/react/useLatest.ts","../src/hooks/react/useMount.ts","../src/hooks/react/useResponsive.ts","../src/hooks/react/useUnmount.ts","../src/hooks/react/useTitle.ts"],"sourcesContent":["import { useRef, type DependencyList } from \"react\";\nimport { isEqual } from \"src/utils\";\n\ninterface RefObject<T> {\n deps: DependencyList;\n result: T;\n isInitialized: boolean;\n}\n\n/**\n * useCreation\n * @reference https://ahooks.js.org/zh-CN/hooks/use-creation\n *\n * @param factory\n * @param deps\n */\nexport function useCreation<T> (factory: () => T, deps: DependencyList) {\n const { current } = useRef<RefObject<T>>({ deps, result: undefined!, isInitialized: false });\n\n if (current.isInitialized === false || !isEqual(current.deps, deps)) {\n current.deps = deps;\n current.result = factory();\n current.isInitialized = true;\n }\n\n return current.result;\n}\n","import { useRef, type RefObject } from \"react\";\n\n/**\n * 返回当前最新值的 Hook\n * @reference https://ahooks.js.org/zh-CN/hooks/use-latest\n *\n * @param value\n */\nexport function useLatest<T> (value: T): RefObject<T> {\n const ref = useRef(value);\n ref.current = value;\n\n return ref;\n}\n","import type { AnyAsyncFunction } from \"@pawover/types\";\nimport { useEffect, type EffectCallback } from \"react\";\nimport { isFunction, isPromiseLike } from \"src/utils\";\nimport { useLatest } from \"./useLatest\";\n\ntype MountCallback = EffectCallback | AnyAsyncFunction;\n\n/**\n * 在组件初始化时执行的 Hook\n * - 即使在严格模式下也只执行一次\n * @reference https://ahooks.js.org/hooks/use-mount\n *\n * @param effect 副作用函数\n */\nexport function useMount (effect: MountCallback) {\n if (!isFunction(effect)) {\n console.error(`useMount expected parameter is a function, but got ${typeof effect}`);\n }\n\n let isMounted = false;\n const effectRef = useLatest(effect);\n\n useEffect(() => {\n if (isMounted) {\n return;\n }\n\n isMounted = true;\n const result = effectRef.current?.();\n // If fn returns a Promise, don't return it as cleanup function\n if (isPromiseLike(result)) {\n return;\n }\n\n return result as ReturnType<EffectCallback>;\n }, []);\n}\n","import { useEffect, useState } from \"react\";\nimport { BREAK_POINT_TOKEN_ENUM, type BREAK_POINT_TOKEN_TYPE } from \"src/enums\";\nimport { arrayZipToObject, objectAssign, objectKeys } from \"src/utils\";\nimport type { TupleToUnion } from \"type-fest\";\n\ntype Breakpoint = TupleToUnion<typeof tuple>;\ntype Subscriber = () => void;\ntype ResponsiveConfig = Record<Breakpoint, number>;\ntype ResponsiveValues = Record<Breakpoint, boolean>;\n\nconst tuple = [\"xxxl\", \"xxl\", \"xl\", \"lg\", \"md\", \"sm\", \"xs\"] as const;\nconst TUPLE = [\"XXXL\", \"XXL\", \"XL\", \"LG\", \"MD\", \"SM\", \"XS\"] as const;\nconst subscriberList = new Set<Subscriber>();\nconst defaultResponsiveValues: ResponsiveValues = arrayZipToObject(tuple, tuple.map(() => false));\nlet responsiveConfig: ResponsiveConfig = arrayZipToObject(tuple, TUPLE.map((t) => BREAK_POINT_TOKEN_ENUM[t]));\nlet responsiveValues: ResponsiveValues = { ...defaultResponsiveValues };\n\nexport interface ResponsiveHookOptions {\n /**\n * 紧凑布局断点\n * - 低于此断点时使用紧凑布局\n * @default \"xl\"\n */\n compactBreakPoint?: Breakpoint;\n /** 屏幕响应断点 token 配置 */\n breakPointTokens?: BREAK_POINT_TOKEN_TYPE;\n}\nexport function useResponsive (options?: ResponsiveHookOptions) {\n const { compactBreakPoint = \"xl\", breakPointTokens = {} } = options || {};\n const tokens: BREAK_POINT_TOKEN_TYPE = objectAssign(BREAK_POINT_TOKEN_ENUM, breakPointTokens);\n responsiveConfig = arrayZipToObject(tuple, TUPLE.map((t) => tokens[t]));\n\n calculate();\n\n const [responsive, setResponsive] = useState<ResponsiveValues>(responsiveValues);\n const isCompact = !responsive[compactBreakPoint];\n const current = objectKeys(defaultResponsiveValues).find((key) => responsive[key] === true) || \"xs\";\n\n useEffect(() => {\n addListener();\n\n const subscriber = () => {\n setResponsive(responsiveValues);\n };\n\n subscriberList.add(subscriber);\n\n return () => {\n subscriberList.delete(subscriber);\n\n if (subscriberList.size === 0) {\n removeListener();\n }\n };\n }, []);\n\n return { responsive, current, isCompact, breakPointTokens: tokens };\n}\n\nfunction resizeListener () {\n const oldInfo = responsiveValues;\n calculate();\n\n if (oldInfo === responsiveValues) {\n return;\n }\n\n for (const subscriber of subscriberList) {\n subscriber();\n }\n}\nfunction addListener () {\n window.addEventListener(\"resize\", resizeListener);\n}\nfunction removeListener () {\n window.removeEventListener(\"resize\", resizeListener);\n}\nfunction calculate () {\n const width = window.innerWidth;\n const newValues = { ...defaultResponsiveValues };\n let shouldUpdate = false;\n\n for (const key of objectKeys(responsiveConfig)) {\n newValues[key] = width >= responsiveConfig[key];\n if (newValues[key] !== responsiveValues[key]) {\n shouldUpdate = true;\n }\n }\n if (shouldUpdate) {\n responsiveValues = newValues;\n }\n}\n","import type { AnyFunction } from \"@pawover/types\";\nimport { useEffect } from \"react\";\nimport { isFunction } from \"src/utils\";\nimport { useLatest } from \"./useLatest\";\n\n/**\n * 在组件卸载时执行的 Hook\n * @reference https://ahooks.js.org/zh-CN/hooks/use-unmount\n *\n * @param effect 副作用函数\n */\nexport function useUnmount (effect: AnyFunction) {\n if (!isFunction(effect)) {\n console.error(`useUnmount expected parameter is a function, got ${typeof effect}`);\n }\n\n const effectRef = useLatest(effect);\n\n useEffect(\n () => () => {\n effectRef.current?.();\n },\n [],\n );\n}\n","import { useEffect, useRef } from \"react\";\nimport { isBrowser } from \"../../utils\";\nimport { useUnmount } from \"./useUnmount\";\n\ninterface TitleHookOptions {\n isRestoreOnUnmount?: boolean;\n}\nexport function useTitle (title: string, options?: TitleHookOptions | undefined) {\n if (!isBrowser()) {\n return;\n }\n\n const titleRef = useRef(document.title);\n\n useEffect(() => {\n document.title = title;\n }, [title]);\n\n useUnmount(() => {\n if (options?.isRestoreOnUnmount) {\n document.title = titleRef.current;\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,YAAgB,SAAkB,MAAsB;CACtE,MAAM,EAAE,YAAY,OAAqB;EAAE;EAAM,QAAQ;EAAY,eAAe;EAAO,CAAC;AAE5F,KAAI,QAAQ,kBAAkB,SAAS,CAAC,QAAQ,QAAQ,MAAM,KAAK,EAAE;AACnE,UAAQ,OAAO;AACf,UAAQ,SAAS,SAAS;AAC1B,UAAQ,gBAAgB;;AAG1B,QAAO,QAAQ;;;;;;;;;;;ACjBjB,SAAgB,UAAc,OAAwB;CACpD,MAAM,MAAM,OAAO,MAAM;AACzB,KAAI,UAAU;AAEd,QAAO;;;;;;;;;;;;ACET,SAAgB,SAAU,QAAuB;AAC/C,KAAI,CAAC,WAAW,OAAO,CACrB,SAAQ,MAAM,sDAAsD,OAAO,SAAS;CAGtF,IAAI,YAAY;CAChB,MAAM,YAAY,UAAU,OAAO;AAEnC,iBAAgB;AACd,MAAI,UACF;AAGF,cAAY;EACZ,MAAM,SAAS,UAAU,WAAW;AAEpC,MAAI,cAAc,OAAO,CACvB;AAGF,SAAO;IACN,EAAE,CAAC;;;;;ACzBR,MAAM,QAAQ;CAAC;CAAQ;CAAO;CAAM;CAAM;CAAM;CAAM;CAAK;AAC3D,MAAM,QAAQ;CAAC;CAAQ;CAAO;CAAM;CAAM;CAAM;CAAM;CAAK;AAC3D,MAAM,iCAAiB,IAAI,KAAiB;AAC5C,MAAMA,0BAA4C,iBAAiB,OAAO,MAAM,UAAU,MAAM,CAAC;AACjG,IAAIC,mBAAqC,iBAAiB,OAAO,MAAM,KAAK,MAAM,uBAAuB,GAAG,CAAC;AAC7G,IAAIC,mBAAqC,EAAE,GAAG,yBAAyB;AAYvE,SAAgB,cAAe,SAAiC;CAC9D,MAAM,EAAE,oBAAoB,MAAM,mBAAmB,EAAE,KAAK,WAAW,EAAE;CACzE,MAAMC,SAAiC,aAAa,wBAAwB,iBAAiB;AAC7F,oBAAmB,iBAAiB,OAAO,MAAM,KAAK,MAAM,OAAO,GAAG,CAAC;AAEvE,YAAW;CAEX,MAAM,CAAC,YAAY,iBAAiB,SAA2B,iBAAiB;CAChF,MAAM,YAAY,CAAC,WAAW;CAC9B,MAAM,UAAU,WAAW,wBAAwB,CAAC,MAAM,QAAQ,WAAW,SAAS,KAAK,IAAI;AAE/F,iBAAgB;AACd,eAAa;EAEb,MAAM,mBAAmB;AACvB,iBAAc,iBAAiB;;AAGjC,iBAAe,IAAI,WAAW;AAE9B,eAAa;AACX,kBAAe,OAAO,WAAW;AAEjC,OAAI,eAAe,SAAS,EAC1B,iBAAgB;;IAGnB,EAAE,CAAC;AAEN,QAAO;EAAE;EAAY;EAAS;EAAW,kBAAkB;EAAQ;;AAGrE,SAAS,iBAAkB;CACzB,MAAM,UAAU;AAChB,YAAW;AAEX,KAAI,YAAY,iBACd;AAGF,MAAK,MAAM,cAAc,eACvB,aAAY;;AAGhB,SAAS,cAAe;AACtB,QAAO,iBAAiB,UAAU,eAAe;;AAEnD,SAAS,iBAAkB;AACzB,QAAO,oBAAoB,UAAU,eAAe;;AAEtD,SAAS,YAAa;CACpB,MAAM,QAAQ,OAAO;CACrB,MAAM,YAAY,EAAE,GAAG,yBAAyB;CAChD,IAAI,eAAe;AAEnB,MAAK,MAAM,OAAO,WAAW,iBAAiB,EAAE;AAC9C,YAAU,OAAO,SAAS,iBAAiB;AAC3C,MAAI,UAAU,SAAS,iBAAiB,KACtC,gBAAe;;AAGnB,KAAI,aACF,oBAAmB;;;;;;;;;;;AC9EvB,SAAgB,WAAY,QAAqB;AAC/C,KAAI,CAAC,WAAW,OAAO,CACrB,SAAQ,MAAM,oDAAoD,OAAO,SAAS;CAGpF,MAAM,YAAY,UAAU,OAAO;AAEnC,uBACc;AACV,YAAU,WAAW;IAEvB,EAAE,CACH;;;;;AChBH,SAAgB,SAAU,OAAe,SAAwC;AAC/E,KAAI,CAAC,WAAW,CACd;CAGF,MAAM,WAAW,OAAO,SAAS,MAAM;AAEvC,iBAAgB;AACd,WAAS,QAAQ;IAChB,CAAC,MAAM,CAAC;AAEX,kBAAiB;AACf,MAAI,SAAS,mBACX,UAAS,QAAQ,SAAS;GAE5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -925,7 +925,7 @@ declare function arrayCast<T>(candidate: T | T[] | null | undefined, checkEmpty?
|
|
|
925
925
|
* arrayCompete(list, (a, b) => (a < b ? a : b)); // 1
|
|
926
926
|
* ```
|
|
927
927
|
*/
|
|
928
|
-
declare function arrayCompete<T>(initialList: readonly T[], match: (a: T, b: T) => T): T | null;
|
|
928
|
+
declare function arrayCompete<T>(initialList: readonly T[], match: (a: T, b: T, index: number) => T): T | null;
|
|
929
929
|
//#endregion
|
|
930
930
|
//#region src/utils/array/arrayCounting.d.ts
|
|
931
931
|
/**
|
|
@@ -944,7 +944,7 @@ declare function arrayCompete<T>(initialList: readonly T[], match: (a: T, b: T)
|
|
|
944
944
|
* arrayCounting(users, (u) => u.group); // { A: 2, B: 1 }
|
|
945
945
|
* ```
|
|
946
946
|
*/
|
|
947
|
-
declare function arrayCounting<T, K$1 extends PropertyKey>(initialList: readonly T[], match: (row: T) => K$1): Record<string, number>;
|
|
947
|
+
declare function arrayCounting<T, K$1 extends PropertyKey>(initialList: readonly T[], match: (row: T, index: number) => K$1): Record<string, number>;
|
|
948
948
|
//#endregion
|
|
949
949
|
//#region src/utils/array/arrayDifference.d.ts
|
|
950
950
|
/**
|
|
@@ -961,7 +961,7 @@ declare function arrayCounting<T, K$1 extends PropertyKey>(initialList: readonly
|
|
|
961
961
|
* arrayDifference([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 1 }]
|
|
962
962
|
* ```
|
|
963
963
|
*/
|
|
964
|
-
declare function arrayDifference<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T) => unknown): T[];
|
|
964
|
+
declare function arrayDifference<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T, index: number) => unknown): T[];
|
|
965
965
|
//#endregion
|
|
966
966
|
//#region src/utils/array/arrayFirst.d.ts
|
|
967
967
|
/**
|
|
@@ -992,7 +992,7 @@ declare function arrayFirst<T>(initialList: readonly T[], saveValue: T): T;
|
|
|
992
992
|
* arrayFork([1, 2, 3, 4], (n) => n % 2 === 0); // [[2, 4], [1, 3]]
|
|
993
993
|
* ```
|
|
994
994
|
*/
|
|
995
|
-
declare function arrayFork<T>(initialList: readonly T[], match: (
|
|
995
|
+
declare function arrayFork<T>(initialList: readonly T[], match: (row: T, index: number) => boolean): [T[], T[]];
|
|
996
996
|
//#endregion
|
|
997
997
|
//#region src/utils/array/arrayIntersection.d.ts
|
|
998
998
|
/**
|
|
@@ -1009,7 +1009,7 @@ declare function arrayFork<T>(initialList: readonly T[], match: (item: T) => boo
|
|
|
1009
1009
|
* arrayIntersection([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 2 }]
|
|
1010
1010
|
* ```
|
|
1011
1011
|
*/
|
|
1012
|
-
declare function arrayIntersection<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T) => unknown): T[];
|
|
1012
|
+
declare function arrayIntersection<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T, index: number) => unknown): T[];
|
|
1013
1013
|
//#endregion
|
|
1014
1014
|
//#region src/utils/array/arrayLast.d.ts
|
|
1015
1015
|
/**
|
|
@@ -1049,7 +1049,7 @@ declare function arrayLast<T>(initialList: readonly T[], saveValue: T): T;
|
|
|
1049
1049
|
* // [{ id: 1, val: "a" }, { id: 2, val: "new" }] -> id:3 被忽略
|
|
1050
1050
|
* ```
|
|
1051
1051
|
*/
|
|
1052
|
-
declare function arrayMerge<T>(initialList: readonly T[], mergeList: readonly T[], match?: (item: T) => unknown): T[];
|
|
1052
|
+
declare function arrayMerge<T>(initialList: readonly T[], mergeList: readonly T[], match?: (item: T, index: number) => unknown): T[];
|
|
1053
1053
|
//#endregion
|
|
1054
1054
|
//#region src/utils/array/arrayPick.d.ts
|
|
1055
1055
|
/**
|