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.
@@ -48,6 +48,7 @@ class DetailedError extends Error {
48
48
  statusCode;
49
49
  constructor(message, options = {}) {
50
50
  super(message);
51
+ this.name = "DetailedError";
51
52
  this.log = options.log;
52
53
  this.detail = options.detail;
53
54
  this.code = options.code;
@@ -66,11 +66,11 @@ const replaceUrlProtocol = (urlString, protocol) => {
66
66
  return urlString.replace(/^ws/, "http");
67
67
  }
68
68
  };
69
- const removeIndexString = (urlSting) => {
70
- if (/^https?:\/\/[^\/]+?\/index$/.test(urlSting)) {
71
- return urlSting.replace(/\/index$/, "/");
69
+ const removeIndexString = (urlString) => {
70
+ if (/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(urlString)) {
71
+ return urlString.replace(/\/index(?=\?|$)/, "/");
72
72
  }
73
- return urlSting.replace(/\/index$/, "");
73
+ return urlString.replace(/\/index(?=\?|$)/, "");
74
74
  };
75
75
  function isObject(item) {
76
76
  return typeof item === "object" && item !== null && !Array.isArray(item);
@@ -25,6 +25,7 @@ var DetailedError = class extends Error {
25
25
  statusCode;
26
26
  constructor(message, options = {}) {
27
27
  super(message);
28
+ this.name = "DetailedError";
28
29
  this.log = options.log;
29
30
  this.detail = options.detail;
30
31
  this.code = options.code;
@@ -37,11 +37,11 @@ var replaceUrlProtocol = (urlString, protocol) => {
37
37
  return urlString.replace(/^ws/, "http");
38
38
  }
39
39
  };
40
- var removeIndexString = (urlSting) => {
41
- if (/^https?:\/\/[^\/]+?\/index$/.test(urlSting)) {
42
- return urlSting.replace(/\/index$/, "/");
40
+ var removeIndexString = (urlString) => {
41
+ if (/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(urlString)) {
42
+ return urlString.replace(/\/index(?=\?|$)/, "/");
43
43
  }
44
- return urlSting.replace(/\/index$/, "");
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: (urlSting: string) => string;
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 : never>;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.9.0",
3
+ "version": "4.9.2",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",