Comparing version 4.1.2 to 4.1.3
@@ -6,2 +6,6 @@ "use strict"; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
@@ -18,2 +22,7 @@ if (from && typeof from === "object" || typeof from === "function") { | ||
var helper_exports = {}; | ||
__export(helper_exports, { | ||
jwtDecode: () => import_jwt.decode, | ||
jwtSign: () => import_jwt.sign, | ||
jwtVerify: () => import_jwt.verify | ||
}); | ||
module.exports = __toCommonJS(helper_exports); | ||
@@ -31,1 +40,8 @@ __reExport(helper_exports, require("./helper/accepts"), module.exports); | ||
__reExport(helper_exports, require("./adapter/deno/websocket"), module.exports); | ||
var import_jwt = require("./middleware/jwt"); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
jwtDecode, | ||
jwtSign, | ||
jwtVerify | ||
}); |
@@ -77,11 +77,12 @@ "use strict"; | ||
let forGetInfoURLRequest = new Request(thisRouteBaseURL); | ||
if (beforeRequestHook) { | ||
const maybeRequest = beforeRequestHook(forGetInfoURLRequest); | ||
if (!maybeRequest) { | ||
continue; | ||
} | ||
forGetInfoURLRequest = maybeRequest; | ||
} | ||
yield new Promise(async (resolveGetInfo, rejectGetInfo) => { | ||
try { | ||
if (beforeRequestHook) { | ||
const maybeRequest = await beforeRequestHook(forGetInfoURLRequest); | ||
if (!maybeRequest) { | ||
resolveGetInfo(void 0); | ||
return; | ||
} | ||
forGetInfoURLRequest = maybeRequest; | ||
} | ||
await pool.run(() => app.fetch(forGetInfoURLRequest)); | ||
@@ -115,3 +116,3 @@ if (!forGetInfoURLRequest.ssgParams) { | ||
if (afterResponseHook) { | ||
const maybeResponse = afterResponseHook(response); | ||
const maybeResponse = await afterResponseHook(response); | ||
if (!maybeResponse) { | ||
@@ -118,0 +119,0 @@ resolveReq(void 0); |
@@ -138,3 +138,5 @@ "use strict"; | ||
}).join(";"); | ||
buffer[0] += ` style="${styles}"`; | ||
buffer[0] += ' style="'; | ||
(0, import_html2.escapeToBuffer)(styles, buffer); | ||
buffer[0] += '"'; | ||
} else if (typeof v === "string") { | ||
@@ -169,3 +171,3 @@ buffer[0] += ` ${key}="`; | ||
} | ||
if (emptyTags.includes(tag)) { | ||
if (emptyTags.includes(tag) && children.length === 0) { | ||
buffer[0] += "/>"; | ||
@@ -172,0 +174,0 @@ return; |
@@ -31,2 +31,3 @@ "use strict"; | ||
const contentType = c.req.header("Content-Type"); | ||
const bodyTypes = ["text", "arrayBuffer", "blob"]; | ||
switch (target) { | ||
@@ -39,7 +40,15 @@ case "json": | ||
if (c.req.bodyCache.json) { | ||
value = await c.req.bodyCache.json; | ||
value = c.req.bodyCache.json; | ||
break; | ||
} | ||
try { | ||
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer(); | ||
let arrayBuffer = void 0; | ||
for (const type of bodyTypes) { | ||
const body = c.req.bodyCache[type]; | ||
if (body) { | ||
arrayBuffer = await new Response(await body).arrayBuffer(); | ||
break; | ||
} | ||
} | ||
arrayBuffer ??= await c.req.raw.arrayBuffer(); | ||
value = await new Response(arrayBuffer).json(); | ||
@@ -54,2 +63,5 @@ c.req.bodyCache.json = value; | ||
case "form": { | ||
if (!contentType) { | ||
break; | ||
} | ||
if (c.req.bodyCache.formData) { | ||
@@ -60,14 +72,19 @@ value = c.req.bodyCache.formData; | ||
try { | ||
const contentType2 = c.req.header("Content-Type"); | ||
if (contentType2) { | ||
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer(); | ||
const formData = await (0, import_buffer.bufferToFormData)(arrayBuffer, contentType2); | ||
const form = {}; | ||
formData.forEach((value2, key) => { | ||
form[key] = value2; | ||
}); | ||
value = form; | ||
c.req.bodyCache.formData = formData; | ||
c.req.bodyCache.arrayBuffer = arrayBuffer; | ||
let arrayBuffer = void 0; | ||
for (const type of bodyTypes) { | ||
const body = c.req.bodyCache[type]; | ||
if (body) { | ||
arrayBuffer = await new Response(await body).arrayBuffer(); | ||
break; | ||
} | ||
} | ||
arrayBuffer ??= await c.req.arrayBuffer(); | ||
const formData = await (0, import_buffer.bufferToFormData)(arrayBuffer, contentType); | ||
const form = {}; | ||
formData.forEach((value2, key) => { | ||
form[key] = value2; | ||
}); | ||
value = form; | ||
c.req.bodyCache.formData = formData; | ||
c.req.bodyCache.arrayBuffer = arrayBuffer; | ||
} catch (e) { | ||
@@ -74,0 +91,0 @@ let message = "Malformed FormData request."; |
@@ -13,1 +13,7 @@ // src/helper.ts | ||
export * from "./adapter/deno/websocket.js"; | ||
import { decode, sign, verify } from "./middleware/jwt/index.js"; | ||
export { | ||
decode as jwtDecode, | ||
sign as jwtSign, | ||
verify as jwtVerify | ||
}; |
@@ -53,11 +53,12 @@ // src/helper/ssg/ssg.ts | ||
let forGetInfoURLRequest = new Request(thisRouteBaseURL); | ||
if (beforeRequestHook) { | ||
const maybeRequest = beforeRequestHook(forGetInfoURLRequest); | ||
if (!maybeRequest) { | ||
continue; | ||
} | ||
forGetInfoURLRequest = maybeRequest; | ||
} | ||
yield new Promise(async (resolveGetInfo, rejectGetInfo) => { | ||
try { | ||
if (beforeRequestHook) { | ||
const maybeRequest = await beforeRequestHook(forGetInfoURLRequest); | ||
if (!maybeRequest) { | ||
resolveGetInfo(void 0); | ||
return; | ||
} | ||
forGetInfoURLRequest = maybeRequest; | ||
} | ||
await pool.run(() => app.fetch(forGetInfoURLRequest)); | ||
@@ -91,3 +92,3 @@ if (!forGetInfoURLRequest.ssgParams) { | ||
if (afterResponseHook) { | ||
const maybeResponse = afterResponseHook(response); | ||
const maybeResponse = await afterResponseHook(response); | ||
if (!maybeResponse) { | ||
@@ -94,0 +95,0 @@ resolveReq(void 0); |
@@ -109,3 +109,5 @@ // src/jsx/base.ts | ||
}).join(";"); | ||
buffer[0] += ` style="${styles}"`; | ||
buffer[0] += ' style="'; | ||
escapeToBuffer(styles, buffer); | ||
buffer[0] += '"'; | ||
} else if (typeof v === "string") { | ||
@@ -140,3 +142,3 @@ buffer[0] += ` ${key}="`; | ||
} | ||
if (emptyTags.includes(tag)) { | ||
if (emptyTags.includes(tag) && children.length === 0) { | ||
buffer[0] += "/>"; | ||
@@ -143,0 +145,0 @@ return; |
@@ -24,4 +24,4 @@ import type { Hono } from '../../hono'; | ||
} | ||
export type BeforeRequestHook = (req: Request) => Request | false; | ||
export type AfterResponseHook = (res: Response) => Response | false; | ||
export type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>; | ||
export type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>; | ||
export type AfterGenerateHook = (result: ToSSGResult) => void | Promise<void>; | ||
@@ -28,0 +28,0 @@ export interface ToSSGOptions { |
@@ -9,2 +9,3 @@ // src/validator/validator.ts | ||
const contentType = c.req.header("Content-Type"); | ||
const bodyTypes = ["text", "arrayBuffer", "blob"]; | ||
switch (target) { | ||
@@ -17,7 +18,15 @@ case "json": | ||
if (c.req.bodyCache.json) { | ||
value = await c.req.bodyCache.json; | ||
value = c.req.bodyCache.json; | ||
break; | ||
} | ||
try { | ||
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer(); | ||
let arrayBuffer = void 0; | ||
for (const type of bodyTypes) { | ||
const body = c.req.bodyCache[type]; | ||
if (body) { | ||
arrayBuffer = await new Response(await body).arrayBuffer(); | ||
break; | ||
} | ||
} | ||
arrayBuffer ??= await c.req.raw.arrayBuffer(); | ||
value = await new Response(arrayBuffer).json(); | ||
@@ -32,2 +41,5 @@ c.req.bodyCache.json = value; | ||
case "form": { | ||
if (!contentType) { | ||
break; | ||
} | ||
if (c.req.bodyCache.formData) { | ||
@@ -38,14 +50,19 @@ value = c.req.bodyCache.formData; | ||
try { | ||
const contentType2 = c.req.header("Content-Type"); | ||
if (contentType2) { | ||
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer(); | ||
const formData = await bufferToFormData(arrayBuffer, contentType2); | ||
const form = {}; | ||
formData.forEach((value2, key) => { | ||
form[key] = value2; | ||
}); | ||
value = form; | ||
c.req.bodyCache.formData = formData; | ||
c.req.bodyCache.arrayBuffer = arrayBuffer; | ||
let arrayBuffer = void 0; | ||
for (const type of bodyTypes) { | ||
const body = c.req.bodyCache[type]; | ||
if (body) { | ||
arrayBuffer = await new Response(await body).arrayBuffer(); | ||
break; | ||
} | ||
} | ||
arrayBuffer ??= await c.req.arrayBuffer(); | ||
const formData = await bufferToFormData(arrayBuffer, contentType); | ||
const form = {}; | ||
formData.forEach((value2, key) => { | ||
form[key] = value2; | ||
}); | ||
value = form; | ||
c.req.bodyCache.formData = formData; | ||
c.req.bodyCache.arrayBuffer = arrayBuffer; | ||
} catch (e) { | ||
@@ -52,0 +69,0 @@ let message = "Malformed FormData request."; |
{ | ||
"name": "hono", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"description": "Ultrafast web framework for the Edges", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
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
745961
20740