Skip to content

Commit 387f55c

Browse files
committed
chore: upgrade vite
1 parent 8615193 commit 387f55c

File tree

6 files changed

+135
-52
lines changed

6 files changed

+135
-52
lines changed

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"test": "vitest",
1414
"test:ui": "vitest --ui",
1515
"coverage": "vitest run --coverage",
16-
"prepare": "husky install",
17-
"build:types": "cd packages/hooks && vue-tsc --noEmit && vite build --mode fullTypes"
16+
"prepare": "husky install"
1817
},
1918
"devDependencies": {
2019
"@commitlint/cli": "^17.1.2",
@@ -63,10 +62,10 @@
6362
"tsx": "^3.11.0",
6463
"typeit": "^8.7.0",
6564
"typescript": "^4.9.3",
66-
"vite": "3.0.2",
67-
"vite-plugin-build": "0.6.0",
68-
"vite-plugin-dts": "^1.4.1",
69-
"vitepress": "1.0.0-alpha.4",
65+
"vite": "^4.0.3",
66+
"vite-plugin-build": "0.7.1",
67+
"vite-plugin-dts": "^2.1.0",
68+
"vitepress": "1.0.0-alpha.60",
7069
"vitest": "0.25.3",
7170
"vue": "^3.2.25",
7271
"vue-tsc": "1.0.9",

packages/hooks/vite.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { defineConfig } from 'vite'
2-
import { buildConfig, buildFullTypesConfig } from './scripts/build'
2+
import { buildConfig } from './scripts/build'
33
// import config from './scripts/config'
44

5-
export default defineConfig(({ mode }) => {
6-
if (mode === 'fullTypes') {
7-
return buildFullTypesConfig
8-
}
5+
export default defineConfig(() => {
6+
// if (mode === 'fullTypes') {
7+
// return buildFullTypesConfig
8+
// }
99
return buildConfig
1010
})

packages/types/index.d.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ declare interface CachedData<TData = any, TParams = any> {
1717
time: number;
1818
}
1919

20-
export declare const clearCache: (key?: string | string[]) => void;
20+
export declare const clearUseRequestCache: (key?: string | string[]) => void;
21+
22+
export declare function createUseRequest<TData, TParams extends unknown[] = unknown[], PluginsOptions extends UseRequestPlugin<TData, TParams>[] = UseRequestPlugin<TData, TParams>[]>(service: UseRequestService<TData, TParams>, options?: UseRequestOptions<TData, TParams, PluginsOptions extends (infer P)[] ? P extends UseRequestPlugin<TData, TParams, infer R> ? R : any : any>, plugins?: PluginsOptions): useRequestResult<TData, TParams>;
2123

2224
declare interface DebounceOptions {
2325
/**
@@ -66,20 +68,26 @@ declare const eventEmitterOverall: EventEmitter<unknown>;
6668
declare class Fetch<TData, TParams extends unknown[] = any> {
6769
serviceRef: Ref<UseRequestService<TData, TParams>>;
6870
options: UseRequestOptions<TData, TParams, any>;
69-
setUpdateData: (s: any, key?: keyof UseRequestFetchState<TData, TParams>) => void;
71+
setUpdateData: (currentState: unknown, key?: keyof UseRequestFetchState<TData, TParams>) => void;
7072
initState: Partial<UseRequestFetchState<TData, TParams>>;
7173
pluginImpls: UseRequestPluginReturn<TData, TParams>[] | undefined;
7274
count: number;
7375
state: UseRequestFetchState<TData, TParams>;
74-
constructor(serviceRef: Ref<UseRequestService<TData, TParams>>, options: UseRequestOptions<TData, TParams, any>, setUpdateData: (s: any, key?: keyof UseRequestFetchState<TData, TParams>) => void, initState?: Partial<UseRequestFetchState<TData, TParams>>);
75-
setState(s?: Partial<UseRequestFetchState<TData, TParams>>): void;
76+
constructor(serviceRef: Ref<UseRequestService<TData, TParams>>, options: UseRequestOptions<TData, TParams, any>, setUpdateData: (currentState: unknown, key?: keyof UseRequestFetchState<TData, TParams>) => void, initState?: Partial<UseRequestFetchState<TData, TParams>>);
77+
setState(currentState?: Partial<UseRequestFetchState<TData, TParams>>): void;
78+
/**
79+
* should rename
80+
* @param data Result value `unknown`
81+
* @param key Result key `data`| `params` | `loading`| `error`
82+
*/
83+
setData(data: unknown, key?: keyof UseRequestFetchState<TData, TParams> | (keyof UseRequestFetchState<TData, TParams>)[]): void;
7684
/**
7785
*
78-
* @param data Result value `any`
86+
* @param data Result value `unknown`
7987
* @param key Result key `data`| `params` | `loading`| `error`
8088
*/
81-
setData(data: any, key?: keyof UseRequestFetchState<TData, TParams> | (keyof UseRequestFetchState<TData, TParams>)[]): void;
82-
runPluginHandler(event: keyof UseRequestPluginReturn<TData, TParams>, ...rest: any[]): any;
89+
setFetchState(data: unknown, key?: keyof UseRequestFetchState<TData, TParams> | (keyof UseRequestFetchState<TData, TParams>)[]): void;
90+
runPluginHandler(event: keyof UseRequestPluginReturn<TData, TParams>, ...rest: unknown[]): any;
8391
runAsync(...params: TParams): Promise<TData>;
8492
run(...params: TParams): void;
8593
cancel(): void;
@@ -216,7 +224,7 @@ declare interface UseBooleanActions {
216224

217225
declare type UseBooleanResult = [Ref<boolean>, UseBooleanActions];
218226

219-
export declare function useCookieState(cookieKey: string, options?: UseCookieStateOptions): readonly [Ref<UseCookieStateType>, (newValue: UseCookieStateType | ((prevState: UseCookieStateType) => UseCookieStateType), newOptions?: Cookies.CookieAttributes) => void];
227+
export declare function useCookieState(cookieKey: string, options?: UseCookieStateOptions): readonly [any, (newValue: UseCookieStateType | ((prevState: UseCookieStateType) => UseCookieStateType), newOptions?: Cookies.CookieAttributes) => void];
220228

221229
declare interface UseCookieStateOptions extends Cookies.CookieAttributes {
222230
defaultValue?: UseCookieStateType | (() => UseCookieStateType);
@@ -925,6 +933,8 @@ declare interface UseRequestPluginReturn<TData, TParams extends unknown[]> {
925933
onMutate?: (data: TData) => void;
926934
}
927935

936+
export declare function useRequestProvider(config: UseRequestOptions<unknown, any, any>): void;
937+
928938
declare interface useRequestResult<TData, TParams extends unknown[]> {
929939
/**
930940
* Is the service being executed.
@@ -990,7 +1000,7 @@ declare interface UseSetActions<T> {
9901000

9911001
export declare function useSetState<S extends Record<string, any>>(initialState: UseSetStateType<S>): [
9921002
DeepReadonly<UnwrapNestedRefs<[S] extends [Ref<any>] ? S : Ref<UnwrapRef<S>>>>,
993-
(patch: Record<string, any>) => void
1003+
(patch: Record<string, any>, cover?: boolean) => void
9941004
];
9951005

9961006
declare type UseSetStateType<S> = S | (() => S) | Ref<S> | (() => Ref<S>);
@@ -1090,7 +1100,7 @@ declare type UseSetStateType<S> = S | (() => S) | Ref<S> | (() => Ref<S>);
10901100
}
10911101

10921102
declare interface UseWebSocketResult {
1093-
latestMessage?: Ref<WebSocketEventMap['message']>;
1103+
latestMessage: Ref<WebSocketEventMap['message'] | undefined>;
10941104
sendMessage?: WebSocket['send'];
10951105
disconnect?: () => void;
10961106
connect?: () => void;

packages/types/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "./dist", //输出文件
5-
"lib": ["esnext", "dom"]
5+
"lib": ["esnext", "dom"],
66
// "baseUrl": "../hooks",
7-
// "rootDir": "../hooks"
7+
"rootDir": "../hooks/src"
88
},
99
"include": ["../hooks/src/**/*.ts"],
1010
"exclude": ["node_modules", "dist", "lib", "es", "example", "test-utils/*"]

packages/types/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default defineConfig({
77
dts({
88
include: ['../hooks/src/**/*.ts'],
99
outputDir: path.resolve(__dirname),
10+
tsConfigFilePath: './tsconfig.json',
1011
rollupTypes: true,
1112
}),
1213
],

0 commit comments

Comments
 (0)