hono 4.9.0 → 4.9.2
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/cjs/client/fetch-result-please.js +1 -0
- package/dist/cjs/client/utils.js +4 -4
- package/dist/client/fetch-result-please.js +1 -0
- package/dist/client/utils.js +4 -4
- package/dist/types/client/types.d.ts +4 -0
- package/dist/types/client/utils.d.ts +4 -3
- package/dist/types/jsx/intrinsic-elements.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/client/utils.js
CHANGED
|
@@ -66,11 +66,11 @@ const replaceUrlProtocol = (urlString, protocol) => {
|
|
|
66
66
|
return urlString.replace(/^ws/, "http");
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
const removeIndexString = (
|
|
70
|
-
if (/^https?:\/\/[^\/]+?\/index
|
|
71
|
-
return
|
|
69
|
+
const removeIndexString = (urlString) => {
|
|
70
|
+
if (/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(urlString)) {
|
|
71
|
+
return urlString.replace(/\/index(?=\?|$)/, "/");
|
|
72
72
|
}
|
|
73
|
-
return
|
|
73
|
+
return urlString.replace(/\/index(?=\?|$)/, "");
|
|
74
74
|
};
|
|
75
75
|
function isObject(item) {
|
|
76
76
|
return typeof item === "object" && item !== null && !Array.isArray(item);
|
package/dist/client/utils.js
CHANGED
|
@@ -37,11 +37,11 @@ var replaceUrlProtocol = (urlString, protocol) => {
|
|
|
37
37
|
return urlString.replace(/^ws/, "http");
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
var removeIndexString = (
|
|
41
|
-
if (/^https?:\/\/[^\/]+?\/index
|
|
42
|
-
return
|
|
40
|
+
var removeIndexString = (urlString) => {
|
|
41
|
+
if (/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(urlString)) {
|
|
42
|
+
return urlString.replace(/\/index(?=\?|$)/, "/");
|
|
43
43
|
}
|
|
44
|
-
return
|
|
44
|
+
return urlString.replace(/\/index(?=\?|$)/, "");
|
|
45
45
|
};
|
|
46
46
|
function isObject(item) {
|
|
47
47
|
return typeof item === "object" && item !== null && !Array.isArray(item);
|
|
@@ -89,6 +89,10 @@ type InferResponseTypeFromEndpoint<T extends Endpoint, U extends StatusCode> = T
|
|
|
89
89
|
} ? S extends U ? O : never : never;
|
|
90
90
|
export type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never;
|
|
91
91
|
export type InferRequestOptionsType<T> = T extends (args: any, options: infer R) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never;
|
|
92
|
+
/**
|
|
93
|
+
* Filter a ClientResponse type so it only includes responses of specific status codes.
|
|
94
|
+
*/
|
|
95
|
+
export type FilterClientResponseByStatusCode<T extends ClientResponse<any, any, any>, U extends number = StatusCode> = T extends ClientResponse<infer RT, infer RC, infer RF> ? RC extends U ? ClientResponse<RT, RC, RF> : never : never;
|
|
92
96
|
type PathToChain<Path extends string, E extends Schema, Original extends string = Path> = Path extends `/${infer P}` ? PathToChain<P, E, Path> : Path extends `${infer P}/${infer R}` ? {
|
|
93
97
|
[K in P]: PathToChain<R, E, Original>;
|
|
94
98
|
} : {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { ClientErrorStatusCode, ContentfulStatusCode, ServerErrorStatusCode } from '../utils/http-status';
|
|
1
2
|
import { DetailedError } from './fetch-result-please';
|
|
2
|
-
import type { ClientResponse } from './types';
|
|
3
|
+
import type { ClientResponse, FilterClientResponseByStatusCode } from './types';
|
|
3
4
|
export { DetailedError };
|
|
4
5
|
export declare const mergePath: (base: string, path: string) => string;
|
|
5
6
|
export declare const replaceUrlParam: (urlString: string, params: Record<string, string | undefined>) => string;
|
|
6
7
|
export declare const buildSearchParams: (query: Record<string, string | string[]>) => URLSearchParams;
|
|
7
8
|
export declare const replaceUrlProtocol: (urlString: string, protocol: "ws" | "http") => string;
|
|
8
|
-
export declare const removeIndexString: (
|
|
9
|
+
export declare const removeIndexString: (urlString: string) => string;
|
|
9
10
|
export declare function deepMerge<T>(target: T, source: Record<string, unknown>): T;
|
|
10
11
|
/**
|
|
11
12
|
* Shortcut to get a consumable response from `hc`'s fetch calls (Response), with types inference.
|
|
@@ -14,4 +15,4 @@ export declare function deepMerge<T>(target: T, source: Record<string, unknown>)
|
|
|
14
15
|
*
|
|
15
16
|
* @example const result = await parseResponse(client.posts.$get())
|
|
16
17
|
*/
|
|
17
|
-
export declare function parseResponse<T extends ClientResponse<any>>(fetchRes: T | Promise<T>): Promise<T extends ClientResponse<infer RT, infer _, infer RF> ? RF extends "json" ? RT : RT extends string ? RT : string :
|
|
18
|
+
export declare function parseResponse<T extends ClientResponse<any>>(fetchRes: T | Promise<T>): Promise<FilterClientResponseByStatusCode<T, Exclude<ContentfulStatusCode, ClientErrorStatusCode | ServerErrorStatusCode>> extends never ? undefined : FilterClientResponseByStatusCode<T, Exclude<ContentfulStatusCode, ClientErrorStatusCode | ServerErrorStatusCode>> extends ClientResponse<infer RT, infer _, infer RF> ? RF extends "json" ? RT : RT extends string ? RT : string : undefined>;
|
|
@@ -148,7 +148,7 @@ export declare namespace JSX {
|
|
|
148
148
|
autocapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined;
|
|
149
149
|
autofocus?: boolean | undefined;
|
|
150
150
|
class?: string | Promise<string> | undefined;
|
|
151
|
-
contenteditable?: boolean | "inherit" | undefined;
|
|
151
|
+
contenteditable?: boolean | "inherit" | "plaintext-only" | undefined;
|
|
152
152
|
contextmenu?: string | undefined;
|
|
153
153
|
dir?: string | undefined;
|
|
154
154
|
draggable?: "true" | "false" | boolean | undefined;
|