Comparing version 2.0.2 to 2.0.3
import type { ErrorHandler, NotFoundHandler } from './hono'; | ||
export declare const compose: <C>(middleware: Function[], onError?: ErrorHandler, onNotFound?: NotFoundHandler) => (context: C, next?: Function) => Promise<C>; | ||
export declare const compose: <C>(middleware: Function[], onError?: ErrorHandler<{ | ||
[x: string]: any; | ||
}> | undefined, onNotFound?: NotFoundHandler<{ | ||
[x: string]: any; | ||
}> | undefined) => (context: C, next?: Function | undefined) => Promise<C>; |
@@ -51,5 +51,5 @@ /// <reference types="@cloudflare/workers-types" /> | ||
handleEvent(event: FetchEvent): Promise<Response>; | ||
fetch: (request: Request, env?: E, executionCtx?: ExecutionContext) => Promise<Response>; | ||
fetch: (request: Request, env?: E | undefined, executionCtx?: ExecutionContext | undefined) => Promise<Response>; | ||
request(input: RequestInfo, requestInit?: RequestInit): Promise<Response>; | ||
} | ||
export {}; |
@@ -7,3 +7,3 @@ import type { Context } from '../../context'; | ||
} | ||
export declare const compress: (options?: CompressionOptions) => (ctx: Context, next: Next) => Promise<void>; | ||
export declare const compress: (options?: CompressionOptions | undefined) => (ctx: Context, next: Next) => Promise<void>; | ||
export {}; |
@@ -11,3 +11,3 @@ import type { Context } from '../../context'; | ||
}; | ||
export declare const cors: (options?: CORSOptions) => (c: Context, next: Next) => Promise<void>; | ||
export declare const cors: (options?: CORSOptions | undefined) => (c: Context, next: Next) => Promise<void>; | ||
export {}; |
@@ -9,3 +9,4 @@ import type { HtmlEscapedString } from '../../utils/html'; | ||
} | ||
export declare const jsx: (tag: string | Function, props: Record<string, any>, ...children: (string | HtmlEscapedString)[]) => HtmlEscapedString; | ||
export { jsxFn as jsx }; | ||
declare const jsxFn: (tag: string | Function, props: Record<string, any>, ...children: (string | HtmlEscapedString)[]) => HtmlEscapedString; | ||
declare type FC<T = Record<string, any>> = (props: T) => HtmlEscapedString; | ||
@@ -17,2 +18,1 @@ export declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>; | ||
}) => HtmlEscapedString; | ||
export {}; |
@@ -22,3 +22,3 @@ "use strict"; | ||
]; | ||
const jsx = (tag, props, ...children) => { | ||
const jsxFn = (tag, props, ...children) => { | ||
if (typeof tag === 'function') { | ||
@@ -71,3 +71,3 @@ return tag.call(null, { ...props, children: children.length <= 1 ? children[0] : children }); | ||
}; | ||
exports.jsx = jsx; | ||
exports.jsx = jsxFn; | ||
const shallowEqual = (a, b) => { | ||
@@ -102,4 +102,4 @@ if (a === b) { | ||
const Fragment = (props) => { | ||
return (0, exports.jsx)('', {}, ...(props.children || [])); | ||
return jsxFn('', {}, ...(props.children || [])); | ||
}; | ||
exports.Fragment = Fragment; |
@@ -105,4 +105,17 @@ "use strict"; | ||
const tempNodes = []; | ||
let matched = false; | ||
for (let j = 0, len2 = curNodes.length; j < len2; j++) { | ||
const node = curNodes[j]; | ||
const nextNode = node.children[part]; | ||
if (nextNode) { | ||
if (isLast === true) { | ||
// '/hello/*' => match '/hello' | ||
if (nextNode.children['*']) { | ||
handlerSets.push(...this.getHandlerSets(nextNode.children['*'], method, true)); | ||
} | ||
handlerSets.push(...this.getHandlerSets(nextNode, method)); | ||
matched = true; | ||
} | ||
tempNodes.push(nextNode); | ||
} | ||
for (let k = 0, len3 = node.patterns.length; k < len3; k++) { | ||
@@ -132,3 +145,7 @@ const pattern = node.patterns[k]; | ||
} | ||
if (typeof name === 'string') { | ||
// '/book/a' => not-slug | ||
// '/book/:slug' => slug | ||
// GET /book/a ~> no-slug, param['slug'] => undefined | ||
// GET /book/foo ~> slug, param['slug'] => foo | ||
if (typeof name === 'string' && !matched) { | ||
params[name] = part; | ||
@@ -138,13 +155,2 @@ } | ||
} | ||
const nextNode = node.children[part]; | ||
if (nextNode) { | ||
if (isLast === true) { | ||
// '/hello/*' => match '/hello' | ||
if (nextNode.children['*']) { | ||
handlerSets.push(...this.getHandlerSets(nextNode.children['*'], method, true)); | ||
} | ||
handlerSets.push(...this.getHandlerSets(nextNode, method)); | ||
} | ||
tempNodes.push(nextNode); | ||
} | ||
} | ||
@@ -151,0 +157,0 @@ curNodes = tempNodes; |
export declare const equal: (a: ArrayBuffer, b: ArrayBuffer) => boolean; | ||
export declare const timingSafeEqual: (a: string | object | boolean, b: string | object | boolean, hashFunction?: Function) => Promise<boolean>; | ||
export declare const timingSafeEqual: (a: string | object | boolean, b: string | object | boolean, hashFunction?: Function | undefined) => Promise<boolean>; | ||
export declare const bufferToString: (buffer: ArrayBuffer) => string; |
@@ -6,2 +6,2 @@ /// <reference types="@cloudflare/workers-types" /> | ||
}; | ||
export declare const getContentFromKVAsset: (path: string, options?: KVAssetOptions) => Promise<ArrayBuffer | null>; | ||
export declare const getContentFromKVAsset: (path: string, options?: KVAssetOptions | undefined) => Promise<ArrayBuffer | null>; |
{ | ||
"name": "hono", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Ultrafast web framework for Cloudflare Workers.", | ||
@@ -13,3 +13,4 @@ "main": "dist/index.js", | ||
"test:deno": "deno test --allow-read deno_test", | ||
"test:bun": "bun wiptest bun_test/index.test.ts", | ||
"test:bun": "bun wiptest --jsx-import-source ../src/middleware/jsx/jsx-dev-runtime bun_test/index.test.tsx", | ||
"test:all": "yarn test && yarn test:deno && yarn test:bun", | ||
"lint": "eslint --ext js,ts src .eslintrc.js", | ||
@@ -27,2 +28,4 @@ "lint:fix": "eslint --ext js,ts src .eslintrc.js --fix", | ||
"./bearer-auth": "./dist/middleware/bearer-auth/index.js", | ||
"./cache": "./dist/middleware/cache/index.js", | ||
"./compress": "./dist/middleware/compress/index.js", | ||
"./cors": "./dist/middleware/cors/index.js", | ||
@@ -32,2 +35,4 @@ "./etag": "./dist/middleware/etag/index.js", | ||
"./jsx": "./dist/middleware/jsx/index.js", | ||
"./jsx/jsx-dev-runtime": "./dist/middleware/jsx/jsx-dev-runtime.js", | ||
"./jsx/jsx-runtime": "./dist/middleware/jsx/jsx-runtime.js", | ||
"./jwt": "./dist/middleware/jwt/index.js", | ||
@@ -53,5 +58,8 @@ "./logger": "./dist/middleware/logger/index.js", | ||
], | ||
"cookie": [ | ||
"./dist/middleware/cookie" | ||
"cache": [ | ||
"./dist/middleware/cache" | ||
], | ||
"compress": [ | ||
"./dist/middleware/compress" | ||
], | ||
"cors": [ | ||
@@ -69,2 +77,8 @@ "./dist/middleware/cors" | ||
], | ||
"jsx-runtime": [ | ||
"./dist/middleware/jsx/jsx-runtime.d.ts" | ||
], | ||
"jsx-dev-runtime": [ | ||
"./dist/middleware/jsx/jsx-dev-runtime.d.ts" | ||
], | ||
"jwt": [ | ||
@@ -134,3 +148,2 @@ "./dist/middleware/jwt" | ||
"@types/jest": "^27.4.1", | ||
"@types/mustache": "^4.1.2", | ||
"@types/node": "^17.0.29", | ||
@@ -152,3 +165,2 @@ "@typescript-eslint/eslint-plugin": "^5.21.0", | ||
"jest-environment-miniflare": "^2.6.0", | ||
"mustache": "^4.2.0", | ||
"np": "^7.6.2", | ||
@@ -155,0 +167,0 @@ "prettier": "^2.6.2", |
@@ -64,3 +64,3 @@ <div align="center"> | ||
Migration guide is available on [docs/MIGRATION.md](docs/MIGRATION.md) | ||
Migration guide is available on [docs/MIGRATION.md](docs/MIGRATION.md). | ||
@@ -71,10 +71,10 @@ ## Contributing | ||
- Fix bugs. | ||
- Create built-in or third-party middleware. | ||
- Propose new feature. | ||
- Refactor the code. | ||
- Write an article about Hono on your Blog. | ||
- Fix a typo. | ||
- etc. | ||
- Create an Issue - Propose a new feature. Report a bug. | ||
- Pull Request - Fix a bug and typo. Refactor the code. | ||
- Create third-party middleware - Instruct below. | ||
- Share - Share your thoughts on the Blog, Twitter, and others. | ||
- Make your application - Please try to use Hono. | ||
For more details, see [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md). | ||
## Contributors | ||
@@ -81,0 +81,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113256
24
93
2872