@pawover/kit 0.0.0-beta.5 → 0.0.0-beta.50
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/package.json +61 -80
- package/packages/hooks/dist/alova.d.ts +31 -0
- package/packages/hooks/dist/alova.js +64 -0
- package/packages/hooks/dist/index.d.ts +1 -0
- package/packages/hooks/dist/index.js +0 -0
- package/packages/hooks/dist/metadata.json +16 -0
- package/packages/hooks/dist/react.d.ts +164 -0
- package/packages/hooks/dist/react.js +4419 -0
- package/packages/utils/dist/index.d.ts +4293 -0
- package/packages/utils/dist/index.js +1527 -0
- package/packages/utils/dist/math.d.ts +54 -0
- package/packages/utils/dist/math.js +56 -0
- package/packages/utils/dist/metadata.json +14 -0
- package/packages/utils/dist/string-CESQdidv.js +793 -0
- package/packages/utils/dist/vite.d.ts +16 -0
- package/packages/utils/dist/vite.js +26 -0
- package/packages/zod/dist/index.d.ts +58 -0
- package/packages/zod/dist/index.js +61 -0
- package/dist/enums.d.ts +0 -25
- package/dist/enums.d.ts.map +0 -1
- package/dist/enums.js +0 -25
- package/dist/enums.js.map +0 -1
- package/dist/hooks-alova.d.ts +0 -23
- package/dist/hooks-alova.d.ts.map +0 -1
- package/dist/hooks-alova.js +0 -39
- package/dist/hooks-alova.js.map +0 -1
- package/dist/hooks-react.d.ts +0 -89
- package/dist/hooks-react.d.ts.map +0 -1
- package/dist/hooks-react.js +0 -340
- package/dist/hooks-react.js.map +0 -1
- package/dist/index.d.ts +0 -2452
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1441
- package/dist/index.js.map +0 -1
- package/dist/patches-fetchEventSource.d.ts +0 -806
- package/dist/patches-fetchEventSource.d.ts.map +0 -1
- package/dist/patches-fetchEventSource.js +0 -315
- package/dist/patches-fetchEventSource.js.map +0 -1
- package/dist/vite.d.ts +0 -13
- package/dist/vite.d.ts.map +0 -1
- package/dist/vite.js +0 -23
- package/dist/vite.js.map +0 -1
- package/dist/zod.d.ts +0 -105
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js +0 -138
- package/dist/zod.js.map +0 -1
- package/metadata.json +0 -161
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pawover/kit",
|
|
3
|
-
"author":
|
|
4
|
-
|
|
3
|
+
"author": {
|
|
4
|
+
"name": "pawover",
|
|
5
|
+
"email": "pawover@outlook.com",
|
|
6
|
+
"url": "https://github.com/pawover"
|
|
7
|
+
},
|
|
8
|
+
"description": "一个基于 TypeScript 的开发工具包",
|
|
5
9
|
"license": "MIT",
|
|
6
10
|
"type": "module",
|
|
7
|
-
"version": "0.0.0-beta.
|
|
8
|
-
"packageManager": "pnpm@10.
|
|
11
|
+
"version": "0.0.0-beta.50",
|
|
12
|
+
"packageManager": "pnpm@10.28.2",
|
|
9
13
|
"engines": {
|
|
10
14
|
"node": ">=22.20.0"
|
|
11
15
|
},
|
|
@@ -16,95 +20,72 @@
|
|
|
16
20
|
"homepage": "https://github.com/pawover/pawover-kit#readme",
|
|
17
21
|
"repository": {
|
|
18
22
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/pawover/pawover-kit.git"
|
|
23
|
+
"url": "git+https://github.com/pawover/pawover-kit.git"
|
|
20
24
|
},
|
|
21
|
-
"main": "./dist/index.js",
|
|
22
|
-
"module": "./dist/index.js",
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
25
|
+
"main": "./packages/utils/dist/index.js",
|
|
26
|
+
"module": "./packages/utils/dist/index.js",
|
|
27
|
+
"types": "./packages/utils/dist/index.d.ts",
|
|
24
28
|
"files": [
|
|
25
|
-
"dist",
|
|
26
|
-
"
|
|
29
|
+
"packages/utils/dist",
|
|
30
|
+
"packages/hooks/dist",
|
|
31
|
+
"packages/zod/dist"
|
|
27
32
|
],
|
|
28
33
|
"exports": {
|
|
29
|
-
".": "./dist/index.js",
|
|
30
|
-
"./
|
|
31
|
-
"./vite": "./dist/vite.js",
|
|
32
|
-
"./
|
|
33
|
-
"./
|
|
34
|
-
"./
|
|
35
|
-
"./
|
|
36
|
-
"./
|
|
37
|
-
"./
|
|
34
|
+
".": "./packages/utils/dist/index.js",
|
|
35
|
+
"./math": "./packages/utils/dist/math.js",
|
|
36
|
+
"./vite": "./packages/utils/dist/vite.js",
|
|
37
|
+
"./metadata.json": "./packages/utils/dist/metadata.json",
|
|
38
|
+
"./utils": "./packages/utils/dist/index.js",
|
|
39
|
+
"./utils/math": "./packages/utils/dist/math.js",
|
|
40
|
+
"./utils/vite": "./packages/utils/dist/vite.js",
|
|
41
|
+
"./utils/*": "./packages/utils/dist/*",
|
|
42
|
+
"./hooks/alova": "./packages/hooks/dist/alova.js",
|
|
43
|
+
"./hooks/react": "./packages/hooks/dist/react.js",
|
|
44
|
+
"./hooks/*": "./packages/hooks/dist/*",
|
|
45
|
+
"./zod": "./packages/zod/dist/index.js",
|
|
46
|
+
"./zod/*": "./packages/zod/dist/*"
|
|
38
47
|
},
|
|
39
48
|
"scripts": {
|
|
40
|
-
"
|
|
41
|
-
"build
|
|
42
|
-
"
|
|
49
|
+
"test": "vitest",
|
|
50
|
+
"build": "turbo build-all",
|
|
51
|
+
"build:force": "turbo build-all --force",
|
|
52
|
+
"public": "turbo build-all && npm publish --access public --tag bate",
|
|
43
53
|
"check": "pnpm check:types & pnpm check:eslint & pnpm check:format",
|
|
44
54
|
"check:types": "tsc --noEmit",
|
|
45
55
|
"check:eslint": "eslint --fix \"**/*.{js,cjs,mjs,ts,cts,mts,jsx,tsx,vue}\" --cache-location=.cache/eslint.cache.json --cache",
|
|
46
|
-
"check:format": "prettier --write \"**/*.{html,json}\"
|
|
56
|
+
"check:format": "prettier --write \"**/*.{html,json}\" --cache-location=.cache/prettier.cache.json --cache",
|
|
47
57
|
"check:pack": "attw --pack .",
|
|
48
|
-
"clean": "
|
|
49
|
-
"clean:
|
|
50
|
-
"clean:
|
|
51
|
-
"clean:
|
|
58
|
+
"clean": "turbo clean & rimraf .cache node_modules dist",
|
|
59
|
+
"clean:turbo": "rimraf -g **/.turbo",
|
|
60
|
+
"clean:cache": "rimraf .cache",
|
|
61
|
+
"clean:lib": "turbo clean:lib",
|
|
62
|
+
"clean:output": "turbo clean:output",
|
|
52
63
|
"lib:up": "taze -I -r --exclude pnpm"
|
|
53
64
|
},
|
|
54
|
-
"dependencies": {
|
|
55
|
-
"alova": "^3.4.1",
|
|
56
|
-
"mathjs": "^15.1.0",
|
|
57
|
-
"react": "^19.2.3",
|
|
58
|
-
"vite": "^7.3.0",
|
|
59
|
-
"vue": "^3.5.26",
|
|
60
|
-
"zod": "^4.2.1"
|
|
61
|
-
},
|
|
62
65
|
"devDependencies": {
|
|
63
|
-
"@
|
|
64
|
-
"@pawover/
|
|
65
|
-
"@
|
|
66
|
+
"@eslint-react/eslint-plugin": "^4.2.3",
|
|
67
|
+
"@pawover/eslint-rules": "^0.0.2",
|
|
68
|
+
"@playwright/test": "^1.59.1",
|
|
69
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
66
70
|
"@types/fs-extra": "^11.0.4",
|
|
67
|
-
"@types/node": "^25.0
|
|
68
|
-
"@
|
|
69
|
-
"
|
|
70
|
-
"eslint
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"react": "
|
|
86
|
-
"vite": ">=4.0",
|
|
87
|
-
"vue": ">=3.5.0",
|
|
88
|
-
"zod": ">=4.1.0"
|
|
89
|
-
},
|
|
90
|
-
"peerDependenciesMeta": {
|
|
91
|
-
"alova": {
|
|
92
|
-
"optional": true
|
|
93
|
-
},
|
|
94
|
-
"mathjs": {
|
|
95
|
-
"optional": true
|
|
96
|
-
},
|
|
97
|
-
"react": {
|
|
98
|
-
"optional": true
|
|
99
|
-
},
|
|
100
|
-
"vite": {
|
|
101
|
-
"optional": true
|
|
102
|
-
},
|
|
103
|
-
"vue": {
|
|
104
|
-
"optional": true
|
|
105
|
-
},
|
|
106
|
-
"zod": {
|
|
107
|
-
"optional": true
|
|
108
|
-
}
|
|
71
|
+
"@types/node": "^25.6.0",
|
|
72
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
73
|
+
"@vitest/browser-playwright": "^4.1.5",
|
|
74
|
+
"eslint": "^10.2.1",
|
|
75
|
+
"eslint-plugin-antfu": "^3.2.2",
|
|
76
|
+
"eslint-plugin-import-lite": "^0.6.0",
|
|
77
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
78
|
+
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
79
|
+
"fs-extra": "^11.3.4",
|
|
80
|
+
"jsdom": "^29.0.2",
|
|
81
|
+
"prettier": "^3.8.3",
|
|
82
|
+
"rimraf": "^6.1.3",
|
|
83
|
+
"taze": "^19.11.0",
|
|
84
|
+
"tsdown": "^0.21.10",
|
|
85
|
+
"turbo": "^2.9.6",
|
|
86
|
+
"typescript": "^6.0.3",
|
|
87
|
+
"typescript-eslint": "^8.59.0",
|
|
88
|
+
"vitest": "^4.1.5",
|
|
89
|
+
"vitest-browser-react": "^2.2.0"
|
|
109
90
|
}
|
|
110
91
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as _$alova_client0 from "alova/client";
|
|
2
|
+
import { AlovaFrontMiddlewareContext, AlovaMethodHandler, CompleteHandler, ErrorHandler, PaginationHookConfig, RequestHookConfig, SuccessHandler, WatcherHookConfig } from "alova/client";
|
|
3
|
+
import { AlovaGenerics, Method } from "alova";
|
|
4
|
+
|
|
5
|
+
//#region src/alova/useAlovaPagination.d.ts
|
|
6
|
+
interface HookOptions$2<AG extends AlovaGenerics, L extends any[], Args extends any[]> extends PaginationHookConfig<AG, L> {
|
|
7
|
+
onBeforeRequest?: ((context: AlovaFrontMiddlewareContext<AG, any[]>) => void) | undefined;
|
|
8
|
+
onSuccess?: SuccessHandler<AG, Args> | undefined;
|
|
9
|
+
onError?: ErrorHandler<AG, Args> | undefined;
|
|
10
|
+
onComplete?: CompleteHandler<AG, Args> | undefined;
|
|
11
|
+
}
|
|
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
|
+
//#endregion
|
|
14
|
+
//#region src/alova/useAlovaRequest.d.ts
|
|
15
|
+
interface HookOptions$1<AG extends AlovaGenerics, Args extends any[]> extends RequestHookConfig<AG, Args> {
|
|
16
|
+
onBeforeRequest?: ((context: AlovaFrontMiddlewareContext<AG, Args>) => void) | undefined;
|
|
17
|
+
onSuccess?: SuccessHandler<AG, Args> | undefined;
|
|
18
|
+
onError?: ErrorHandler<AG, Args> | undefined;
|
|
19
|
+
onComplete?: CompleteHandler<AG, Args> | undefined;
|
|
20
|
+
}
|
|
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
|
+
//#endregion
|
|
23
|
+
//#region src/alova/useAlovaWatcher.d.ts
|
|
24
|
+
interface HookOptions<AG extends AlovaGenerics, Args extends any[]> extends WatcherHookConfig<AG, Args> {
|
|
25
|
+
onSuccess?: SuccessHandler<AG, Args> | undefined;
|
|
26
|
+
onError?: ErrorHandler<AG, Args> | undefined;
|
|
27
|
+
onComplete?: CompleteHandler<AG, Args> | undefined;
|
|
28
|
+
}
|
|
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
|
+
//#endregion
|
|
31
|
+
export { useAlovaPagination, useAlovaRequest, useAlovaWatcher };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { usePagination, useRequest, useWatcher } from "alova/client";
|
|
2
|
+
//#region src/alova/useAlovaPagination.ts
|
|
3
|
+
function useAlovaPagination(methodHandler, hookOptions) {
|
|
4
|
+
const options = {
|
|
5
|
+
...hookOptions,
|
|
6
|
+
immediate: hookOptions?.immediate ?? true
|
|
7
|
+
};
|
|
8
|
+
let isBeforeExecuted = false;
|
|
9
|
+
let isMiddlewareExecuted = false;
|
|
10
|
+
if (options.onBeforeRequest) {
|
|
11
|
+
const middleware = options.middleware;
|
|
12
|
+
options.middleware = async (context, next) => {
|
|
13
|
+
!isBeforeExecuted && options.onBeforeRequest?.(context);
|
|
14
|
+
isBeforeExecuted = true;
|
|
15
|
+
if (middleware && !isMiddlewareExecuted) {
|
|
16
|
+
isMiddlewareExecuted = true;
|
|
17
|
+
await middleware?.(context, next);
|
|
18
|
+
} else await next();
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const exposure = usePagination(methodHandler, options);
|
|
22
|
+
if (options.onSuccess) exposure.onSuccess(options.onSuccess);
|
|
23
|
+
if (options.onError) exposure.onError(options.onError);
|
|
24
|
+
if (options.onComplete) exposure.onComplete(options.onComplete);
|
|
25
|
+
return exposure;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/alova/useAlovaRequest.ts
|
|
29
|
+
function useAlovaRequest(methodHandler, hookOptions) {
|
|
30
|
+
const options = {
|
|
31
|
+
...hookOptions,
|
|
32
|
+
immediate: hookOptions?.immediate ?? true
|
|
33
|
+
};
|
|
34
|
+
let isBeforeExecuted = false;
|
|
35
|
+
let isMiddlewareExecuted = false;
|
|
36
|
+
if (options.onBeforeRequest) {
|
|
37
|
+
const middleware = options.middleware;
|
|
38
|
+
options.middleware = async (context, next) => {
|
|
39
|
+
!isBeforeExecuted && options.onBeforeRequest?.(context);
|
|
40
|
+
isBeforeExecuted = true;
|
|
41
|
+
if (middleware && !isMiddlewareExecuted) {
|
|
42
|
+
isMiddlewareExecuted = true;
|
|
43
|
+
await middleware?.(context, next);
|
|
44
|
+
} else await next();
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const exposure = useRequest(methodHandler, options);
|
|
48
|
+
if (options.onSuccess) exposure.onSuccess(options.onSuccess);
|
|
49
|
+
if (options.onError) exposure.onError(options.onError);
|
|
50
|
+
if (options.onComplete) exposure.onComplete(options.onComplete);
|
|
51
|
+
return exposure;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/alova/useAlovaWatcher.ts
|
|
55
|
+
function useAlovaWatcher(methodHandler, watchingStates, hookOptions = {}) {
|
|
56
|
+
const options = hookOptions || {};
|
|
57
|
+
const exposure = useWatcher(methodHandler, watchingStates, options);
|
|
58
|
+
if (options.onSuccess) exposure.onSuccess(options.onSuccess);
|
|
59
|
+
if (options.onError) exposure.onError(options.onError);
|
|
60
|
+
if (options.onComplete) exposure.onComplete(options.onComplete);
|
|
61
|
+
return exposure;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { useAlovaPagination, useAlovaRequest, useAlovaWatcher };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
File without changes
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { DependencyList, EffectCallback, RefObject } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/react/useCreation.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* 确保实例不会被重复创建
|
|
6
|
+
*
|
|
7
|
+
* @param factory
|
|
8
|
+
* @param deps
|
|
9
|
+
*/
|
|
10
|
+
declare function useCreation<T>(factory: () => T, deps: DependencyList): T;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/react/useLatest.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* 返回当前最新值的 Hook
|
|
15
|
+
*
|
|
16
|
+
* @param value
|
|
17
|
+
*/
|
|
18
|
+
declare function useLatest<T>(value: T): RefObject<T>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ../../node_modules/.pnpm/@pawover+types@0.0.1_@types+react@19.2.14_typescript@6.0.3/node_modules/@pawover/types/dist/index.d.ts
|
|
21
|
+
/** 描述函数类型 */
|
|
22
|
+
type AnyFunction<P extends any[] = any[], R = any> = (...arg: P) => R;
|
|
23
|
+
/** 描述异步函数类型 */
|
|
24
|
+
type AnyAsyncFunction<P extends any[] = any[], R = any> = (...args: P) => Promise<R>;
|
|
25
|
+
/** 描述生成器函数类型 */
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/react/useMount.d.ts
|
|
28
|
+
/**
|
|
29
|
+
* 在组件初始化时执行的 Hook
|
|
30
|
+
* - 即使在严格模式(React StrictMode)也只执行一次
|
|
31
|
+
* - 自动使用最新版 effect 函数
|
|
32
|
+
*
|
|
33
|
+
* @param effect 副作用函数(必须为同步函数;若为异步函数,清理逻辑需自行处理)
|
|
34
|
+
* @example
|
|
35
|
+
* useMount(() => {
|
|
36
|
+
* console.log('组件挂载');
|
|
37
|
+
* return () => console.log('组件卸载');
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* useMount(async () => {
|
|
41
|
+
* const data = await fetchData();
|
|
42
|
+
* // 清理逻辑需通过 ref/AbortController 自行管理
|
|
43
|
+
* // ❌ 不要 return cleanupFn(async 函数返回 Promise,无法作为清理函数)
|
|
44
|
+
* });
|
|
45
|
+
*/
|
|
46
|
+
declare function useMount(effect: EffectCallback | AnyAsyncFunction): void;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/tuple-to-union.d.ts
|
|
49
|
+
/**
|
|
50
|
+
Convert a tuple/array into a union type of its elements.
|
|
51
|
+
|
|
52
|
+
This 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.
|
|
53
|
+
|
|
54
|
+
@example
|
|
55
|
+
```
|
|
56
|
+
import type {TupleToUnion} from 'type-fest';
|
|
57
|
+
|
|
58
|
+
const destinations = ['a', 'b', 'c'] as const;
|
|
59
|
+
|
|
60
|
+
type Destination = TupleToUnion<typeof destinations>;
|
|
61
|
+
//=> 'a' | 'b' | 'c'
|
|
62
|
+
|
|
63
|
+
function verifyDestination(destination: unknown): destination is Destination {
|
|
64
|
+
return destinations.includes(destination as any);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type RequestBody = {
|
|
68
|
+
deliverTo: Destination;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function verifyRequestBody(body: unknown): body is RequestBody {
|
|
72
|
+
const {deliverTo} = (body as any);
|
|
73
|
+
return typeof body === 'object' && body !== null && verifyDestination(deliverTo);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Alternatively, 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.
|
|
78
|
+
|
|
79
|
+
@example
|
|
80
|
+
```
|
|
81
|
+
const destinations = ['a', 'b', 'c'] as const;
|
|
82
|
+
|
|
83
|
+
type Destination = typeof destinations[number];
|
|
84
|
+
//=> 'a' | 'b' | 'c'
|
|
85
|
+
|
|
86
|
+
const erroringType = new Set(['a', 'b', 'c']);
|
|
87
|
+
|
|
88
|
+
// @ts-expect-error
|
|
89
|
+
type ErroringType = typeof erroringType[number];
|
|
90
|
+
// Error: Type 'Set<string>' has no matching index signature for type 'number'. ts(2537)
|
|
91
|
+
|
|
92
|
+
const numberBool: {[n: number]: boolean} = {1: true};
|
|
93
|
+
|
|
94
|
+
type NumberBool = typeof numberBool[number];
|
|
95
|
+
//=> boolean
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
@category Array
|
|
99
|
+
*/
|
|
100
|
+
type TupleToUnion<ArrayType> = ArrayType extends readonly unknown[] ? ArrayType[number] : never;
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/react/useResponsive.d.ts
|
|
103
|
+
type Breakpoint = TupleToUnion<typeof BREAK_POINTS>;
|
|
104
|
+
type ResponsiveValues = Record<Breakpoint, boolean>;
|
|
105
|
+
type BreakPointTokens = Record<keyof typeof BREAK_POINT_TOKEN, number>;
|
|
106
|
+
/** 屏幕响应断点 token 配置 */
|
|
107
|
+
declare const BREAK_POINT_TOKEN: {
|
|
108
|
+
readonly XS: 480;
|
|
109
|
+
readonly XSMax: 575;
|
|
110
|
+
readonly XSMin: 480;
|
|
111
|
+
readonly SM: 576;
|
|
112
|
+
readonly SMMax: 767;
|
|
113
|
+
readonly SMMin: 576;
|
|
114
|
+
readonly MD: 768;
|
|
115
|
+
readonly MDMax: 991;
|
|
116
|
+
readonly MDMin: 768;
|
|
117
|
+
readonly LG: 992;
|
|
118
|
+
readonly LGMax: 1199;
|
|
119
|
+
readonly LGMin: 992;
|
|
120
|
+
readonly XL: 1200;
|
|
121
|
+
readonly XLMax: 1599;
|
|
122
|
+
readonly XLMin: 1200;
|
|
123
|
+
readonly XXL: 1600;
|
|
124
|
+
readonly XXLMax: 1919;
|
|
125
|
+
readonly XXLMin: 1600;
|
|
126
|
+
readonly XXXL: 1920;
|
|
127
|
+
readonly XXXLMin: 1920;
|
|
128
|
+
};
|
|
129
|
+
declare const BREAK_POINTS: readonly ["xxxl", "xxl", "xl", "lg", "md", "sm", "xs"];
|
|
130
|
+
interface ResponsiveHookOptions {
|
|
131
|
+
/** 屏幕响应断点 token 配置 */
|
|
132
|
+
breakPointTokens?: BreakPointTokens;
|
|
133
|
+
}
|
|
134
|
+
declare function useResponsive(options?: ResponsiveHookOptions | undefined): {
|
|
135
|
+
responsive: ResponsiveValues;
|
|
136
|
+
current: "xxxl" | "xxl" | "xl" | "lg" | "md" | "sm" | "xs";
|
|
137
|
+
breakPointTokens: BreakPointTokens;
|
|
138
|
+
};
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/react/useTitle.d.ts
|
|
141
|
+
interface TitleHookOptions {
|
|
142
|
+
/** 件卸载时是否恢复原始标题 */
|
|
143
|
+
isRestoreOnUnmount?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 设置页面标题
|
|
147
|
+
* - 轻量级,适用于无路由库时设置页面标题
|
|
148
|
+
* - 多个 `useTitle` 实例会互相干扰,需在顶层组件使用
|
|
149
|
+
* - 无法处理 `document.title` 固有的竞态问题
|
|
150
|
+
*
|
|
151
|
+
* @param title 页面标题
|
|
152
|
+
* @param options 配置选项
|
|
153
|
+
*/
|
|
154
|
+
declare function useTitle(title: string, options?: TitleHookOptions | undefined): void;
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/react/useUnmount.d.ts
|
|
157
|
+
/**
|
|
158
|
+
* 在组件卸载时执行的 Hook
|
|
159
|
+
*
|
|
160
|
+
* @param effect 副作用函数
|
|
161
|
+
*/
|
|
162
|
+
declare function useUnmount(effect: AnyFunction): void;
|
|
163
|
+
//#endregion
|
|
164
|
+
export { BREAK_POINT_TOKEN, BreakPointTokens, ResponsiveHookOptions, useCreation, useLatest, useMount, useResponsive, useTitle, useUnmount };
|