Comparing version 4.2.3 to 4.2.4
// src/adapter/cloudflare-workers/utils.ts | ||
var getContentFromKVAsset = async (path, options) => { | ||
let ASSET_MANIFEST = {}; | ||
let ASSET_MANIFEST; | ||
if (options && options.manifest) { | ||
@@ -5,0 +5,0 @@ if (typeof options.manifest === "string") { |
@@ -25,3 +25,3 @@ "use strict"; | ||
const getContentFromKVAsset = async (path, options) => { | ||
let ASSET_MANIFEST = {}; | ||
let ASSET_MANIFEST; | ||
if (options && options.manifest) { | ||
@@ -28,0 +28,0 @@ if (typeof options.manifest === "string") { |
@@ -88,3 +88,2 @@ "use strict"; | ||
let methodUpperCase = this.method.toUpperCase(); | ||
let setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD"); | ||
const headerValues = { | ||
@@ -112,3 +111,3 @@ ...args?.header ?? {}, | ||
methodUpperCase = this.method.toUpperCase(); | ||
setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD"); | ||
const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD"); | ||
return (opt?.fetch || fetch)(url, { | ||
@@ -115,0 +114,0 @@ body: setBody ? this.rBody : void 0, |
@@ -168,3 +168,3 @@ "use strict"; | ||
const toSSG = async (app, fs, options) => { | ||
let result = void 0; | ||
let result; | ||
const getInfoPromises = []; | ||
@@ -171,0 +171,0 @@ const savePromises = []; |
@@ -29,3 +29,3 @@ "use strict"; | ||
}; | ||
return (0, import_client.hc)("", { fetch: customFetch }); | ||
return (0, import_client.hc)("http://localhost", { fetch: customFetch }); | ||
}; | ||
@@ -32,0 +32,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -113,32 +113,42 @@ "use strict"; | ||
const textEncoder = new TextEncoder(); | ||
const renderToReadableStream = (str) => { | ||
const renderToReadableStream = (str, onError = console.trace) => { | ||
const reader = new ReadableStream({ | ||
async start(controller) { | ||
const tmp = str instanceof Promise ? await str : await str.toString(); | ||
const context = typeof tmp === "object" ? tmp : {}; | ||
const resolved = await (0, import_html2.resolveCallback)( | ||
tmp, | ||
import_html2.HtmlEscapedCallbackPhase.BeforeStream, | ||
true, | ||
context | ||
); | ||
controller.enqueue(textEncoder.encode(resolved)); | ||
let resolvedCount = 0; | ||
const callbacks = []; | ||
const then = (promise) => { | ||
callbacks.push( | ||
promise.catch((err) => { | ||
console.trace(err); | ||
return ""; | ||
}).then(async (res) => { | ||
res = await (0, import_html2.resolveCallback)(res, import_html2.HtmlEscapedCallbackPhase.BeforeStream, true, context); | ||
res.callbacks?.map((c) => c({ phase: import_html2.HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then); | ||
resolvedCount++; | ||
controller.enqueue(textEncoder.encode(res)); | ||
}) | ||
try { | ||
const tmp = str instanceof Promise ? await str : await str.toString(); | ||
const context = typeof tmp === "object" ? tmp : {}; | ||
const resolved = await (0, import_html2.resolveCallback)( | ||
tmp, | ||
import_html2.HtmlEscapedCallbackPhase.BeforeStream, | ||
true, | ||
context | ||
); | ||
}; | ||
resolved.callbacks?.map((c) => c({ phase: import_html2.HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then); | ||
while (resolvedCount !== callbacks.length) { | ||
await Promise.all(callbacks); | ||
controller.enqueue(textEncoder.encode(resolved)); | ||
let resolvedCount = 0; | ||
const callbacks = []; | ||
const then = (promise) => { | ||
callbacks.push( | ||
promise.catch((err) => { | ||
console.log(err); | ||
onError(err); | ||
return ""; | ||
}).then(async (res) => { | ||
res = await (0, import_html2.resolveCallback)( | ||
res, | ||
import_html2.HtmlEscapedCallbackPhase.BeforeStream, | ||
true, | ||
context | ||
); | ||
res.callbacks?.map((c) => c({ phase: import_html2.HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then); | ||
resolvedCount++; | ||
controller.enqueue(textEncoder.encode(res)); | ||
}) | ||
); | ||
}; | ||
resolved.callbacks?.map((c) => c({ phase: import_html2.HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then); | ||
while (resolvedCount !== callbacks.length) { | ||
await Promise.all(callbacks); | ||
} | ||
} catch (e) { | ||
onError(e); | ||
} | ||
@@ -145,0 +155,0 @@ controller.close(); |
@@ -65,3 +65,3 @@ "use strict"; | ||
if (content) { | ||
let mimeType = void 0; | ||
let mimeType; | ||
if (options.mimes) { | ||
@@ -68,0 +68,0 @@ mimeType = (0, import_mime.getMimeType)(path, options.mimes) ?? (0, import_mime.getMimeType)(path); |
@@ -50,7 +50,5 @@ "use strict"; | ||
const possibleKeys = []; | ||
const parentPatterns = []; | ||
for (let i = 0, len = parts.length; i < len; i++) { | ||
const p = parts[i]; | ||
if (Object.keys(curNode.children).includes(p)) { | ||
parentPatterns.push(...curNode.patterns); | ||
curNode = curNode.children[p]; | ||
@@ -67,6 +65,4 @@ const pattern2 = (0, import_url.getPattern)(p); | ||
curNode.patterns.push(pattern); | ||
parentPatterns.push(...curNode.patterns); | ||
possibleKeys.push(pattern[1]); | ||
} | ||
parentPatterns.push(...curNode.patterns); | ||
curNode = curNode.children[p]; | ||
@@ -73,0 +69,0 @@ } |
@@ -37,3 +37,3 @@ "use strict"; | ||
function isTokenHeader(obj) { | ||
return typeof obj === "object" && obj !== null && "alg" in obj && Object.values(import_jwa.AlgorithmTypes).includes(obj.alg) && "typ" in obj && obj.typ === "JWT"; | ||
return typeof obj === "object" && obj !== null && "alg" in obj && Object.values(import_jwa.AlgorithmTypes).includes(obj.alg) && (!("typ" in obj) || obj.typ === "JWT"); | ||
} | ||
@@ -40,0 +40,0 @@ const sign = async (payload, privateKey, alg = "HS256") => { |
@@ -72,3 +72,2 @@ // src/client/client.ts | ||
let methodUpperCase = this.method.toUpperCase(); | ||
let setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD"); | ||
const headerValues = { | ||
@@ -96,3 +95,3 @@ ...args?.header ?? {}, | ||
methodUpperCase = this.method.toUpperCase(); | ||
setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD"); | ||
const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD"); | ||
return (opt?.fetch || fetch)(url, { | ||
@@ -99,0 +98,0 @@ body: setBody ? this.rBody : void 0, |
@@ -143,3 +143,3 @@ // src/helper/ssg/ssg.ts | ||
var toSSG = async (app, fs, options) => { | ||
let result = void 0; | ||
let result; | ||
const getInfoPromises = []; | ||
@@ -146,0 +146,0 @@ const savePromises = []; |
@@ -7,3 +7,3 @@ // src/helper/testing/index.ts | ||
}; | ||
return hc("", { fetch: customFetch }); | ||
return hc("http://localhost", { fetch: customFetch }); | ||
}; | ||
@@ -10,0 +10,0 @@ export { |
@@ -90,32 +90,42 @@ // src/jsx/streaming.ts | ||
var textEncoder = new TextEncoder(); | ||
var renderToReadableStream = (str) => { | ||
var renderToReadableStream = (str, onError = console.trace) => { | ||
const reader = new ReadableStream({ | ||
async start(controller) { | ||
const tmp = str instanceof Promise ? await str : await str.toString(); | ||
const context = typeof tmp === "object" ? tmp : {}; | ||
const resolved = await resolveCallback( | ||
tmp, | ||
HtmlEscapedCallbackPhase.BeforeStream, | ||
true, | ||
context | ||
); | ||
controller.enqueue(textEncoder.encode(resolved)); | ||
let resolvedCount = 0; | ||
const callbacks = []; | ||
const then = (promise) => { | ||
callbacks.push( | ||
promise.catch((err) => { | ||
console.trace(err); | ||
return ""; | ||
}).then(async (res) => { | ||
res = await resolveCallback(res, HtmlEscapedCallbackPhase.BeforeStream, true, context); | ||
res.callbacks?.map((c) => c({ phase: HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then); | ||
resolvedCount++; | ||
controller.enqueue(textEncoder.encode(res)); | ||
}) | ||
try { | ||
const tmp = str instanceof Promise ? await str : await str.toString(); | ||
const context = typeof tmp === "object" ? tmp : {}; | ||
const resolved = await resolveCallback( | ||
tmp, | ||
HtmlEscapedCallbackPhase.BeforeStream, | ||
true, | ||
context | ||
); | ||
}; | ||
resolved.callbacks?.map((c) => c({ phase: HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then); | ||
while (resolvedCount !== callbacks.length) { | ||
await Promise.all(callbacks); | ||
controller.enqueue(textEncoder.encode(resolved)); | ||
let resolvedCount = 0; | ||
const callbacks = []; | ||
const then = (promise) => { | ||
callbacks.push( | ||
promise.catch((err) => { | ||
console.log(err); | ||
onError(err); | ||
return ""; | ||
}).then(async (res) => { | ||
res = await resolveCallback( | ||
res, | ||
HtmlEscapedCallbackPhase.BeforeStream, | ||
true, | ||
context | ||
); | ||
res.callbacks?.map((c) => c({ phase: HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then); | ||
resolvedCount++; | ||
controller.enqueue(textEncoder.encode(res)); | ||
}) | ||
); | ||
}; | ||
resolved.callbacks?.map((c) => c({ phase: HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then); | ||
while (resolvedCount !== callbacks.length) { | ||
await Promise.all(callbacks); | ||
} | ||
} catch (e) { | ||
onError(e); | ||
} | ||
@@ -122,0 +132,0 @@ controller.close(); |
@@ -43,3 +43,3 @@ // src/middleware/serve-static/index.ts | ||
if (content) { | ||
let mimeType = void 0; | ||
let mimeType; | ||
if (options.mimes) { | ||
@@ -46,0 +46,0 @@ mimeType = getMimeType(path, options.mimes) ?? getMimeType(path); |
@@ -28,7 +28,5 @@ // src/router/trie-router/node.ts | ||
const possibleKeys = []; | ||
const parentPatterns = []; | ||
for (let i = 0, len = parts.length; i < len; i++) { | ||
const p = parts[i]; | ||
if (Object.keys(curNode.children).includes(p)) { | ||
parentPatterns.push(...curNode.patterns); | ||
curNode = curNode.children[p]; | ||
@@ -45,6 +43,4 @@ const pattern2 = getPattern(p); | ||
curNode.patterns.push(pattern); | ||
parentPatterns.push(...curNode.patterns); | ||
possibleKeys.push(pattern[1]); | ||
} | ||
parentPatterns.push(...curNode.patterns); | ||
curNode = curNode.children[p]; | ||
@@ -51,0 +47,0 @@ } |
@@ -16,2 +16,2 @@ import type { HtmlEscapedString } from '../utils/html'; | ||
*/ | ||
export declare const renderToReadableStream: (str: HtmlEscapedString | Promise<HtmlEscapedString>) => ReadableStream<Uint8Array>; | ||
export declare const renderToReadableStream: (str: HtmlEscapedString | Promise<HtmlEscapedString>, onError?: (e: unknown) => void) => ReadableStream<Uint8Array>; |
@@ -6,3 +6,3 @@ import type { SignatureAlgorithm } from './jwa'; | ||
alg: SignatureAlgorithm; | ||
typ: 'JWT'; | ||
typ?: 'JWT'; | ||
} | ||
@@ -9,0 +9,0 @@ export declare function isTokenHeader(obj: any): obj is TokenHeader; |
@@ -8,8 +8,8 @@ import type { Context } from '../context'; | ||
export declare const validator: <InputType, P extends string, M extends string, U extends ValidationTargetByMethod<M>, OutputType = ValidationTargets[U], OutputTypeExcludeResponseType = ExcludeResponseType<OutputType>, P2 extends string = P, V extends { | ||
in: { [K in U]: K extends "json" ? InputType : { [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2]; }; }; | ||
in: { [K in U]: K extends "json" ? unknown extends InputType ? OutputTypeExcludeResponseType : InputType : { [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2]; }; }; | ||
out: { [K_1 in U]: OutputTypeExcludeResponseType; }; | ||
} = { | ||
in: { [K_2 in U]: K_2 extends "json" ? InputType : { [K2_1 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K_2][K2_1]; }; }; | ||
in: { [K_2 in U]: K_2 extends "json" ? unknown extends InputType ? OutputTypeExcludeResponseType : InputType : { [K2_1 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K_2][K2_1]; }; }; | ||
out: { [K_3 in U]: OutputTypeExcludeResponseType; }; | ||
}, E extends Env = any>(target: U, validationFunc: ValidationFunction<unknown extends InputType ? ValidationTargets[U] : InputType, OutputType, E, P2>) => MiddlewareHandler<E, P, V>; | ||
export {}; |
@@ -18,3 +18,3 @@ // src/utils/jwt/jwt.ts | ||
function isTokenHeader(obj) { | ||
return typeof obj === "object" && obj !== null && "alg" in obj && Object.values(AlgorithmTypes).includes(obj.alg) && "typ" in obj && obj.typ === "JWT"; | ||
return typeof obj === "object" && obj !== null && "alg" in obj && Object.values(AlgorithmTypes).includes(obj.alg) && (!("typ" in obj) || obj.typ === "JWT"); | ||
} | ||
@@ -21,0 +21,0 @@ var sign = async (payload, privateKey, alg = "HS256") => { |
{ | ||
"name": "hono", | ||
"version": "4.2.3", | ||
"version": "4.2.4", | ||
"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
781241
21766