bluera-knowledge 0.9.32 → 0.9.36
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/.claude/hooks/post-edit-check.sh +5 -3
- package/.claude/skills/atomic-commits/SKILL.md +3 -1
- package/.husky/pre-commit +3 -2
- package/.prettierrc +9 -0
- package/.versionrc.json +1 -1
- package/CHANGELOG.md +70 -0
- package/CLAUDE.md +6 -0
- package/README.md +25 -13
- package/bun.lock +277 -33
- package/dist/{chunk-L2YVNC63.js → chunk-6FHWC36B.js} +9 -1
- package/dist/chunk-6FHWC36B.js.map +1 -0
- package/dist/{chunk-RST4XGRL.js → chunk-DC7CGSGT.js} +288 -241
- package/dist/chunk-DC7CGSGT.js.map +1 -0
- package/dist/{chunk-6PBP5DVD.js → chunk-WFNPNAAP.js} +3212 -3054
- package/dist/chunk-WFNPNAAP.js.map +1 -0
- package/dist/{chunk-WT2DAEO7.js → chunk-Z2KKVH45.js} +548 -482
- package/dist/chunk-Z2KKVH45.js.map +1 -0
- package/dist/index.js +871 -758
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +3 -3
- package/dist/watch.service-BJV3TI3F.js +7 -0
- package/dist/workers/background-worker-cli.js +97 -71
- package/dist/workers/background-worker-cli.js.map +1 -1
- package/eslint.config.js +43 -1
- package/package.json +18 -11
- package/plugin.json +8 -0
- package/python/requirements.txt +1 -1
- package/src/analysis/ast-parser.test.ts +12 -11
- package/src/analysis/ast-parser.ts +28 -22
- package/src/analysis/code-graph.test.ts +52 -62
- package/src/analysis/code-graph.ts +9 -13
- package/src/analysis/dependency-usage-analyzer.test.ts +91 -271
- package/src/analysis/dependency-usage-analyzer.ts +52 -24
- package/src/analysis/go-ast-parser.test.ts +22 -22
- package/src/analysis/go-ast-parser.ts +18 -25
- package/src/analysis/parser-factory.test.ts +9 -9
- package/src/analysis/parser-factory.ts +3 -3
- package/src/analysis/python-ast-parser.test.ts +27 -27
- package/src/analysis/python-ast-parser.ts +2 -2
- package/src/analysis/repo-url-resolver.test.ts +82 -82
- package/src/analysis/rust-ast-parser.test.ts +19 -19
- package/src/analysis/rust-ast-parser.ts +17 -27
- package/src/analysis/tree-sitter-parser.test.ts +3 -3
- package/src/analysis/tree-sitter-parser.ts +10 -16
- package/src/cli/commands/crawl.test.ts +40 -24
- package/src/cli/commands/crawl.ts +186 -166
- package/src/cli/commands/index-cmd.test.ts +90 -90
- package/src/cli/commands/index-cmd.ts +52 -36
- package/src/cli/commands/mcp.test.ts +6 -6
- package/src/cli/commands/mcp.ts +2 -2
- package/src/cli/commands/plugin-api.test.ts +16 -18
- package/src/cli/commands/plugin-api.ts +9 -6
- package/src/cli/commands/search.test.ts +16 -7
- package/src/cli/commands/search.ts +124 -87
- package/src/cli/commands/serve.test.ts +67 -25
- package/src/cli/commands/serve.ts +18 -3
- package/src/cli/commands/setup.test.ts +176 -101
- package/src/cli/commands/setup.ts +140 -117
- package/src/cli/commands/store.test.ts +82 -53
- package/src/cli/commands/store.ts +56 -37
- package/src/cli/program.ts +2 -2
- package/src/crawl/article-converter.test.ts +4 -1
- package/src/crawl/article-converter.ts +46 -31
- package/src/crawl/bridge.test.ts +240 -132
- package/src/crawl/bridge.ts +87 -30
- package/src/crawl/claude-client.test.ts +124 -56
- package/src/crawl/claude-client.ts +7 -15
- package/src/crawl/intelligent-crawler.test.ts +65 -22
- package/src/crawl/intelligent-crawler.ts +86 -53
- package/src/crawl/markdown-utils.ts +1 -4
- package/src/db/embeddings.ts +4 -6
- package/src/db/lance.test.ts +4 -4
- package/src/db/lance.ts +16 -12
- package/src/index.ts +26 -17
- package/src/logging/index.ts +1 -5
- package/src/logging/logger.ts +3 -5
- package/src/logging/payload.test.ts +1 -1
- package/src/logging/payload.ts +3 -5
- package/src/mcp/commands/index.ts +2 -2
- package/src/mcp/commands/job.commands.ts +12 -18
- package/src/mcp/commands/meta.commands.ts +13 -13
- package/src/mcp/commands/registry.ts +5 -8
- package/src/mcp/commands/store.commands.ts +19 -19
- package/src/mcp/handlers/execute.handler.test.ts +10 -10
- package/src/mcp/handlers/execute.handler.ts +4 -5
- package/src/mcp/handlers/index.ts +10 -14
- package/src/mcp/handlers/job.handler.test.ts +10 -10
- package/src/mcp/handlers/job.handler.ts +22 -25
- package/src/mcp/handlers/search.handler.test.ts +36 -65
- package/src/mcp/handlers/search.handler.ts +135 -104
- package/src/mcp/handlers/store.handler.test.ts +41 -52
- package/src/mcp/handlers/store.handler.ts +108 -88
- package/src/mcp/schemas/index.test.ts +73 -68
- package/src/mcp/schemas/index.ts +18 -12
- package/src/mcp/server.test.ts +1 -1
- package/src/mcp/server.ts +59 -46
- package/src/plugin/commands.test.ts +230 -95
- package/src/plugin/commands.ts +24 -25
- package/src/plugin/dependency-analyzer.test.ts +52 -52
- package/src/plugin/dependency-analyzer.ts +85 -22
- package/src/plugin/git-clone.test.ts +24 -13
- package/src/plugin/git-clone.ts +3 -7
- package/src/server/app.test.ts +109 -109
- package/src/server/app.ts +32 -23
- package/src/server/index.test.ts +64 -66
- package/src/services/chunking.service.test.ts +32 -32
- package/src/services/chunking.service.ts +16 -9
- package/src/services/code-graph.service.test.ts +30 -36
- package/src/services/code-graph.service.ts +24 -10
- package/src/services/code-unit.service.test.ts +55 -11
- package/src/services/code-unit.service.ts +85 -11
- package/src/services/config.service.test.ts +37 -18
- package/src/services/config.service.ts +30 -7
- package/src/services/index.service.test.ts +49 -18
- package/src/services/index.service.ts +98 -48
- package/src/services/index.ts +6 -9
- package/src/services/job.service.test.ts +22 -22
- package/src/services/job.service.ts +18 -18
- package/src/services/project-root.service.test.ts +1 -3
- package/src/services/search.service.test.ts +248 -120
- package/src/services/search.service.ts +286 -156
- package/src/services/services.test.ts +1 -1
- package/src/services/snippet.service.test.ts +14 -6
- package/src/services/snippet.service.ts +7 -5
- package/src/services/store.service.test.ts +68 -29
- package/src/services/store.service.ts +41 -12
- package/src/services/watch.service.test.ts +34 -14
- package/src/services/watch.service.ts +11 -1
- package/src/types/brands.test.ts +3 -1
- package/src/types/index.ts +2 -13
- package/src/types/search.ts +10 -8
- package/src/utils/type-guards.test.ts +20 -15
- package/src/utils/type-guards.ts +1 -1
- package/src/workers/background-worker-cli.ts +28 -30
- package/src/workers/background-worker.test.ts +54 -40
- package/src/workers/background-worker.ts +76 -60
- package/src/workers/pid-file.test.ts +167 -0
- package/src/workers/pid-file.ts +82 -0
- package/src/workers/spawn-worker.test.ts +22 -10
- package/src/workers/spawn-worker.ts +6 -6
- package/tests/analysis/ast-parser.test.ts +3 -3
- package/tests/analysis/code-graph.test.ts +5 -5
- package/tests/fixtures/code-snippets/api/error-handling.ts +4 -15
- package/tests/fixtures/code-snippets/api/rest-controller.ts +3 -9
- package/tests/fixtures/code-snippets/auth/jwt-auth.ts +5 -21
- package/tests/fixtures/code-snippets/auth/oauth-flow.ts +4 -4
- package/tests/fixtures/code-snippets/database/repository-pattern.ts +11 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/handler.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/handler.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/client/client.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/client/types.ts +22 -20
- package/tests/fixtures/corpus/oss-repos/hono/src/context.ts +13 -10
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/accepts.ts +10 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/adapter/index.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/index.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/factory/index.ts +16 -16
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/ssg.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/hono-base.ts +3 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/hono.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/css.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/intrinsic-element/components.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/render.ts +7 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/hooks/index.ts +3 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/components.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/utils.ts +6 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jsx-renderer/index.ts +3 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/serve-static/index.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/quick.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/tiny.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/router.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/node.ts +4 -4
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/router.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/node.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/types.ts +166 -169
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/body.ts +8 -8
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/color.ts +3 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/cookie.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/encode.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/types.ts +30 -33
- package/tests/fixtures/corpus/oss-repos/hono/src/validator/validator.ts +2 -2
- package/tests/fixtures/test-server.ts +3 -2
- package/tests/helpers/performance-metrics.ts +8 -25
- package/tests/helpers/search-relevance.ts +14 -69
- package/tests/integration/cli-consistency.test.ts +6 -5
- package/tests/integration/python-bridge.test.ts +13 -3
- package/tests/mcp/server.test.ts +1 -1
- package/tests/services/code-unit.service.test.ts +48 -0
- package/tests/services/job.service.test.ts +124 -0
- package/tests/services/search.progressive-context.test.ts +2 -2
- package/.claude-plugin/plugin.json +0 -13
- package/dist/chunk-6PBP5DVD.js.map +0 -1
- package/dist/chunk-L2YVNC63.js.map +0 -1
- package/dist/chunk-RST4XGRL.js.map +0 -1
- package/dist/chunk-WT2DAEO7.js.map +0 -1
- package/dist/watch.service-YAIKKDCF.js +0 -7
- package/skills/atomic-commits/SKILL.md +0 -77
- /package/dist/{watch.service-YAIKKDCF.js.map → watch.service-BJV3TI3F.js.map} +0 -0
|
@@ -54,8 +54,8 @@ type BlankRecordToNever<T> = T extends any
|
|
|
54
54
|
? T extends null
|
|
55
55
|
? null
|
|
56
56
|
: keyof T extends never
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
? never
|
|
58
|
+
: T
|
|
59
59
|
: never
|
|
60
60
|
|
|
61
61
|
type ClientResponseOfEndpoint<T extends Endpoint = Endpoint> = T extends {
|
|
@@ -69,15 +69,16 @@ type ClientResponseOfEndpoint<T extends Endpoint = Endpoint> = T extends {
|
|
|
69
69
|
export interface ClientResponse<
|
|
70
70
|
T,
|
|
71
71
|
U extends number = StatusCode,
|
|
72
|
-
F extends ResponseFormat = ResponseFormat
|
|
73
|
-
>
|
|
72
|
+
F extends ResponseFormat = ResponseFormat,
|
|
73
|
+
>
|
|
74
|
+
extends globalThis.Response {
|
|
74
75
|
readonly body: ReadableStream | null
|
|
75
76
|
readonly bodyUsed: boolean
|
|
76
77
|
ok: U extends SuccessStatusCode
|
|
77
78
|
? true
|
|
78
79
|
: U extends Exclude<StatusCode, SuccessStatusCode>
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
? false
|
|
81
|
+
: boolean
|
|
81
82
|
status: U
|
|
82
83
|
statusText: string
|
|
83
84
|
headers: Headers
|
|
@@ -87,8 +88,8 @@ export interface ClientResponse<
|
|
|
87
88
|
json(): F extends 'text'
|
|
88
89
|
? Promise<never>
|
|
89
90
|
: F extends 'json'
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
? Promise<BlankRecordToNever<T>>
|
|
92
|
+
: Promise<unknown>
|
|
92
93
|
text(): F extends 'text' ? (T extends string ? Promise<T> : Promise<never>) : Promise<string>
|
|
93
94
|
blob(): Promise<Blob>
|
|
94
95
|
formData(): Promise<FormData>
|
|
@@ -147,25 +148,26 @@ export type InferRequestOptionsType<T> = T extends (
|
|
|
147
148
|
type PathToChain<
|
|
148
149
|
Path extends string,
|
|
149
150
|
E extends Schema,
|
|
150
|
-
Original extends string = Path
|
|
151
|
+
Original extends string = Path,
|
|
151
152
|
> = Path extends `/${infer P}`
|
|
152
153
|
? PathToChain<P, E, Path>
|
|
153
154
|
: Path extends `${infer P}/${infer R}`
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
? { [K in P]: PathToChain<R, E, Original> }
|
|
156
|
+
: {
|
|
157
|
+
[K in Path extends '' ? 'index' : Path]: ClientRequest<
|
|
158
|
+
E extends Record<string, unknown> ? E[Original] : never
|
|
159
|
+
>
|
|
160
|
+
}
|
|
160
161
|
|
|
161
162
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
|
-
export type Client<T> =
|
|
163
|
-
|
|
164
|
-
?
|
|
165
|
-
?
|
|
163
|
+
export type Client<T> =
|
|
164
|
+
T extends Hono<any, infer S, any>
|
|
165
|
+
? S extends Record<infer K, Schema>
|
|
166
|
+
? K extends string
|
|
167
|
+
? PathToChain<K, S>
|
|
168
|
+
: never
|
|
166
169
|
: never
|
|
167
170
|
: never
|
|
168
|
-
: never
|
|
169
171
|
|
|
170
172
|
export type Callback = (opts: CallbackOptions) => unknown
|
|
171
173
|
|
|
@@ -134,8 +134,10 @@ interface TextRespond {
|
|
|
134
134
|
status?: U,
|
|
135
135
|
headers?: HeaderRecord
|
|
136
136
|
): Response & TypedResponse<T, U, 'text'>
|
|
137
|
-
<T extends string, U extends StatusCode = StatusCode>(
|
|
138
|
-
|
|
137
|
+
<T extends string, U extends StatusCode = StatusCode>(
|
|
138
|
+
text: T,
|
|
139
|
+
init?: ResponseInit
|
|
140
|
+
): Response & TypedResponse<T, U, 'text'>
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
/**
|
|
@@ -154,7 +156,7 @@ interface TextRespond {
|
|
|
154
156
|
interface JSONRespond {
|
|
155
157
|
<
|
|
156
158
|
T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue,
|
|
157
|
-
U extends StatusCode = StatusCode
|
|
159
|
+
U extends StatusCode = StatusCode,
|
|
158
160
|
>(
|
|
159
161
|
object: T,
|
|
160
162
|
status?: U,
|
|
@@ -162,7 +164,7 @@ interface JSONRespond {
|
|
|
162
164
|
): JSONRespondReturn<T, U>
|
|
163
165
|
<
|
|
164
166
|
T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue,
|
|
165
|
-
U extends StatusCode = StatusCode
|
|
167
|
+
U extends StatusCode = StatusCode,
|
|
166
168
|
>(
|
|
167
169
|
object: T,
|
|
168
170
|
init?: ResponseInit
|
|
@@ -177,7 +179,7 @@ interface JSONRespond {
|
|
|
177
179
|
*/
|
|
178
180
|
type JSONRespondReturn<
|
|
179
181
|
T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue,
|
|
180
|
-
U extends StatusCode
|
|
182
|
+
U extends StatusCode,
|
|
181
183
|
> = Response &
|
|
182
184
|
TypedResponse<
|
|
183
185
|
SimplifyDeepArray<T> extends JSONValue
|
|
@@ -205,9 +207,10 @@ interface HTMLRespond {
|
|
|
205
207
|
status?: StatusCode,
|
|
206
208
|
headers?: HeaderRecord
|
|
207
209
|
): T extends string ? Response : Promise<Response>
|
|
208
|
-
<T extends string | Promise<string>>(
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
<T extends string | Promise<string>>(
|
|
211
|
+
html: T,
|
|
212
|
+
init?: ResponseInit
|
|
213
|
+
): T extends string ? Response : Promise<Response>
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
/**
|
|
@@ -345,7 +348,7 @@ export class Context<
|
|
|
345
348
|
E extends Env = any,
|
|
346
349
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
347
350
|
P extends string = any,
|
|
348
|
-
I extends Input = {}
|
|
351
|
+
I extends Input = {},
|
|
349
352
|
> {
|
|
350
353
|
#rawRequest: Request
|
|
351
354
|
#req: HonoRequest<P, I['out']> | undefined
|
|
@@ -835,7 +838,7 @@ export class Context<
|
|
|
835
838
|
*/
|
|
836
839
|
json: JSONRespond = <
|
|
837
840
|
T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue,
|
|
838
|
-
U extends StatusCode = StatusCode
|
|
841
|
+
U extends StatusCode = StatusCode,
|
|
839
842
|
>(
|
|
840
843
|
object: T,
|
|
841
844
|
arg?: U | ResponseInit,
|
|
@@ -34,13 +34,16 @@ export const parseAccept = (acceptHeader: string): Accept[] => {
|
|
|
34
34
|
const params = parts.slice(1) // ['q=0.9', 'image/webp']
|
|
35
35
|
const q = params.find((param) => param.startsWith('q='))
|
|
36
36
|
|
|
37
|
-
const paramsObject = params.reduce(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const paramsObject = params.reduce(
|
|
38
|
+
(acc, param) => {
|
|
39
|
+
const keyValue = param.split('=')
|
|
40
|
+
const key = keyValue[0].trim()
|
|
41
|
+
const value = keyValue[1].trim()
|
|
42
|
+
acc[key] = value
|
|
43
|
+
return acc
|
|
44
|
+
},
|
|
45
|
+
{} as { [key: string]: string }
|
|
46
|
+
)
|
|
44
47
|
|
|
45
48
|
return {
|
|
46
49
|
type: type,
|
|
@@ -28,8 +28,8 @@ export const env = <T extends Record<string, unknown>, C extends Context = Conte
|
|
|
28
28
|
},
|
|
29
29
|
workerd: () => c.env,
|
|
30
30
|
// On Fastly Compute, you can use the ConfigStore to manage user-defined data.
|
|
31
|
-
fastly: () => ({} as T
|
|
32
|
-
other: () => ({} as T
|
|
31
|
+
fastly: () => ({}) as T,
|
|
32
|
+
other: () => ({}) as T,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return runtimeEnvHandlers[runtime]()
|
|
@@ -26,7 +26,7 @@ type CssClassName = HtmlEscapedString & CssClassNameCommon
|
|
|
26
26
|
|
|
27
27
|
type usedClassNameData = [
|
|
28
28
|
Record<string, string>, // class name to add
|
|
29
|
-
Record<string, true
|
|
29
|
+
Record<string, true>, // class name already added
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
interface CssType {
|
|
@@ -10,9 +10,9 @@ import type { Env, H, HandlerResponse, Input, MiddlewareHandler } from '../../ty
|
|
|
10
10
|
type InitApp<E extends Env = Env> = (app: Hono<E>) => void
|
|
11
11
|
|
|
12
12
|
export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
13
|
-
<I extends Input = {}, R extends HandlerResponse<any> = any>(
|
|
14
|
-
H<E, P, I, R>
|
|
15
|
-
]
|
|
13
|
+
<I extends Input = {}, R extends HandlerResponse<any> = any>(
|
|
14
|
+
handler1: H<E, P, I, R>
|
|
15
|
+
): [H<E, P, I, R>]
|
|
16
16
|
// handler x2
|
|
17
17
|
<I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(
|
|
18
18
|
handler1: H<E, P, I, R>,
|
|
@@ -24,7 +24,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
24
24
|
I extends Input = {},
|
|
25
25
|
I2 extends Input = I,
|
|
26
26
|
I3 extends Input = I & I2,
|
|
27
|
-
R extends HandlerResponse<any> = any
|
|
27
|
+
R extends HandlerResponse<any> = any,
|
|
28
28
|
>(
|
|
29
29
|
handler1: H<E, P, I, R>,
|
|
30
30
|
handler2: H<E, P, I2, R>,
|
|
@@ -37,7 +37,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
37
37
|
I2 extends Input = I,
|
|
38
38
|
I3 extends Input = I & I2,
|
|
39
39
|
I4 extends Input = I & I2 & I3,
|
|
40
|
-
R extends HandlerResponse<any> = any
|
|
40
|
+
R extends HandlerResponse<any> = any,
|
|
41
41
|
>(
|
|
42
42
|
handler1: H<E, P, I, R>,
|
|
43
43
|
handler2: H<E, P, I2, R>,
|
|
@@ -52,7 +52,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
52
52
|
I3 extends Input = I & I2,
|
|
53
53
|
I4 extends Input = I & I2 & I3,
|
|
54
54
|
I5 extends Input = I & I2 & I3 & I4,
|
|
55
|
-
R extends HandlerResponse<any> = any
|
|
55
|
+
R extends HandlerResponse<any> = any,
|
|
56
56
|
>(
|
|
57
57
|
handler1: H<E, P, I, R>,
|
|
58
58
|
handler2: H<E, P, I2, R>,
|
|
@@ -69,7 +69,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
69
69
|
I4 extends Input = I & I2 & I3,
|
|
70
70
|
I5 extends Input = I & I2 & I3 & I4,
|
|
71
71
|
I6 extends Input = I & I2 & I3 & I4 & I5,
|
|
72
|
-
R extends HandlerResponse<any> = any
|
|
72
|
+
R extends HandlerResponse<any> = any,
|
|
73
73
|
>(
|
|
74
74
|
handler1: H<E, P, I, R>,
|
|
75
75
|
handler2: H<E, P, I2, R>,
|
|
@@ -88,7 +88,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
88
88
|
I5 extends Input = I & I2 & I3 & I4,
|
|
89
89
|
I6 extends Input = I & I2 & I3 & I4 & I5,
|
|
90
90
|
I7 extends Input = I & I2 & I3 & I4 & I5 & I6,
|
|
91
|
-
R extends HandlerResponse<any> = any
|
|
91
|
+
R extends HandlerResponse<any> = any,
|
|
92
92
|
>(
|
|
93
93
|
handler1: H<E, P, I, R>,
|
|
94
94
|
handler2: H<E, P, I2, R>,
|
|
@@ -104,7 +104,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
104
104
|
H<E, P, I4, R>,
|
|
105
105
|
H<E, P, I5, R>,
|
|
106
106
|
H<E, P, I6, R>,
|
|
107
|
-
H<E, P, I7, R
|
|
107
|
+
H<E, P, I7, R>,
|
|
108
108
|
]
|
|
109
109
|
|
|
110
110
|
// handler x8
|
|
@@ -117,7 +117,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
117
117
|
I6 extends Input = I & I2 & I3 & I4 & I5,
|
|
118
118
|
I7 extends Input = I & I2 & I3 & I4 & I5 & I6,
|
|
119
119
|
I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7,
|
|
120
|
-
R extends HandlerResponse<any> = any
|
|
120
|
+
R extends HandlerResponse<any> = any,
|
|
121
121
|
>(
|
|
122
122
|
handler1: H<E, P, I, R>,
|
|
123
123
|
handler2: H<E, P, I2, R>,
|
|
@@ -135,7 +135,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
135
135
|
H<E, P, I5, R>,
|
|
136
136
|
H<E, P, I6, R>,
|
|
137
137
|
H<E, P, I7, R>,
|
|
138
|
-
H<E, P, I8, R
|
|
138
|
+
H<E, P, I8, R>,
|
|
139
139
|
]
|
|
140
140
|
|
|
141
141
|
// handler x9
|
|
@@ -149,7 +149,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
149
149
|
I7 extends Input = I & I2 & I3 & I4 & I5 & I6,
|
|
150
150
|
I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7,
|
|
151
151
|
I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8,
|
|
152
|
-
R extends HandlerResponse<any> = any
|
|
152
|
+
R extends HandlerResponse<any> = any,
|
|
153
153
|
>(
|
|
154
154
|
handler1: H<E, P, I, R>,
|
|
155
155
|
handler2: H<E, P, I2, R>,
|
|
@@ -169,7 +169,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
169
169
|
H<E, P, I6, R>,
|
|
170
170
|
H<E, P, I7, R>,
|
|
171
171
|
H<E, P, I8, R>,
|
|
172
|
-
H<E, P, I9, R
|
|
172
|
+
H<E, P, I9, R>,
|
|
173
173
|
]
|
|
174
174
|
|
|
175
175
|
// handler x10
|
|
@@ -184,7 +184,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
184
184
|
I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7,
|
|
185
185
|
I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8,
|
|
186
186
|
I10 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9,
|
|
187
|
-
R extends HandlerResponse<any> = any
|
|
187
|
+
R extends HandlerResponse<any> = any,
|
|
188
188
|
>(
|
|
189
189
|
handler1: H<E, P, I, R>,
|
|
190
190
|
handler2: H<E, P, I2, R>,
|
|
@@ -206,7 +206,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
|
|
|
206
206
|
H<E, P, I7, R>,
|
|
207
207
|
H<E, P, I8, R>,
|
|
208
208
|
H<E, P, I9, R>,
|
|
209
|
-
H<E, P, I10, R
|
|
209
|
+
H<E, P, I10, R>,
|
|
210
210
|
]
|
|
211
211
|
}
|
|
212
212
|
|
|
@@ -240,7 +240,7 @@ export const createFactory = <E extends Env = any, P extends string = any>(init?
|
|
|
240
240
|
export const createMiddleware = <
|
|
241
241
|
E extends Env = any,
|
|
242
242
|
P extends string = string,
|
|
243
|
-
I extends Input = {}
|
|
243
|
+
I extends Input = {},
|
|
244
244
|
>(
|
|
245
245
|
middleware: MiddlewareHandler<E, P, I>
|
|
246
246
|
): MiddlewareHandler<E, P, I> => createFactory<E, P>().createMiddleware<I>(middleware)
|
|
@@ -169,7 +169,7 @@ export interface ToSSGOptions {
|
|
|
169
169
|
export const fetchRoutesContent = function* <
|
|
170
170
|
E extends Env = Env,
|
|
171
171
|
S extends Schema = {},
|
|
172
|
-
BasePath extends string = '/'
|
|
172
|
+
BasePath extends string = '/',
|
|
173
173
|
>(
|
|
174
174
|
app: Hono<E, S, BasePath>,
|
|
175
175
|
beforeRequestHook?: BeforeRequestHook,
|
|
@@ -323,7 +323,7 @@ export interface ToSSGInterface {
|
|
|
323
323
|
export interface ToSSGAdaptorInterface<
|
|
324
324
|
E extends Env = Env,
|
|
325
325
|
S extends Schema = {},
|
|
326
|
-
BasePath extends string = '/'
|
|
326
|
+
BasePath extends string = '/',
|
|
327
327
|
> {
|
|
328
328
|
(app: Hono<E, S, BasePath>, options?: ToSSGOptions): Promise<ToSSGResult>
|
|
329
329
|
}
|
|
@@ -171,7 +171,7 @@ class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string =
|
|
|
171
171
|
const strict = options.strict ?? true
|
|
172
172
|
delete options.strict
|
|
173
173
|
Object.assign(this, options)
|
|
174
|
-
this.getPath = strict ? options.getPath ?? getPath : getPathNoStrict
|
|
174
|
+
this.getPath = strict ? (options.getPath ?? getPath) : getPathNoStrict
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
private clone(): Hono<E, S, BasePath> {
|
|
@@ -208,7 +208,7 @@ class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string =
|
|
|
208
208
|
SubPath extends string,
|
|
209
209
|
SubEnv extends Env,
|
|
210
210
|
SubSchema extends Schema,
|
|
211
|
-
SubBasePath extends string
|
|
211
|
+
SubBasePath extends string,
|
|
212
212
|
>(
|
|
213
213
|
path: SubPath,
|
|
214
214
|
app: Hono<SubEnv, SubSchema, SubBasePath>
|
|
@@ -434,7 +434,7 @@ class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string =
|
|
|
434
434
|
resolved || (c.finalized ? c.res : this.notFoundHandler(c))
|
|
435
435
|
)
|
|
436
436
|
.catch((err: Error) => this.handleError(err, c))
|
|
437
|
-
: res ?? this.notFoundHandler(c)
|
|
437
|
+
: (res ?? this.notFoundHandler(c))
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
const composed = compose<Context>(matchResult[0], this.errorHandler, this.notFoundHandler)
|
|
@@ -16,7 +16,7 @@ import type { BlankEnv, BlankSchema, Env, Schema } from './types'
|
|
|
16
16
|
export class Hono<
|
|
17
17
|
E extends Env = BlankEnv,
|
|
18
18
|
S extends Schema = BlankSchema,
|
|
19
|
-
BasePath extends string = '/'
|
|
19
|
+
BasePath extends string = '/',
|
|
20
20
|
> extends HonoBase<E, S, BasePath> {
|
|
21
21
|
/**
|
|
22
22
|
* Creates an instance of the Hono class.
|
|
@@ -66,7 +66,7 @@ interface CreateCssJsxDomObjectsType {
|
|
|
66
66
|
{
|
|
67
67
|
toString(this: CssClassName): string
|
|
68
68
|
},
|
|
69
|
-
FC<PropsWithChildren<void
|
|
69
|
+
FC<PropsWithChildren<void>>,
|
|
70
70
|
]
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -133,7 +133,7 @@ export const createCssJsxDomObjects: CreateCssJsxDomObjectsType = ({ id }) => {
|
|
|
133
133
|
),
|
|
134
134
|
},
|
|
135
135
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
-
} as any
|
|
136
|
+
}) as any
|
|
137
137
|
|
|
138
138
|
return [cssObject, Style] as const
|
|
139
139
|
}
|
|
@@ -108,7 +108,7 @@ const documentMetadataTag = (
|
|
|
108
108
|
existingElements = head.querySelectorAll<HTMLElement>(tag)
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
precedence = supportSort ? precedence ?? '' : undefined
|
|
111
|
+
precedence = supportSort ? (precedence ?? '') : undefined
|
|
112
112
|
if (supportSort) {
|
|
113
113
|
restProps[dataPrecedenceAttr] = precedence
|
|
114
114
|
}
|
|
@@ -51,7 +51,7 @@ export type NodeObject = {
|
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
52
|
any[][], // stash for hooks
|
|
53
53
|
LocalJSXContexts, // context
|
|
54
|
-
[Context, Function, NodeObject] // [context, error handler, node] for closest error boundary or suspense
|
|
54
|
+
[Context, Function, NodeObject], // [context, error handler, node] for closest error boundary or suspense
|
|
55
55
|
]
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
57
|
| [number, any[][]]
|
|
@@ -88,7 +88,7 @@ export type Context =
|
|
|
88
88
|
UpdateHook, // update hook
|
|
89
89
|
boolean, // is in view transition
|
|
90
90
|
boolean, // is in top level render
|
|
91
|
-
[Context, Function, NodeObject][] // [context, error handler, node] stack for this context
|
|
91
|
+
[Context, Function, NodeObject][], // [context, error handler, node] stack for this context
|
|
92
92
|
]
|
|
93
93
|
| [PendingType, boolean, UpdateHook, boolean]
|
|
94
94
|
| [PendingType, boolean, UpdateHook]
|
|
@@ -462,8 +462,8 @@ export const build = (context: Context, node: NodeObject, children?: Child[]): v
|
|
|
462
462
|
const oldVChildren: Node[] | undefined = buildWithPreviousChildren
|
|
463
463
|
? [...(node.pC as Node[])]
|
|
464
464
|
: node.vC
|
|
465
|
-
|
|
466
|
-
|
|
465
|
+
? [...node.vC]
|
|
466
|
+
: undefined
|
|
467
467
|
const vChildren: Node[] = []
|
|
468
468
|
let prevNode: Node | undefined
|
|
469
469
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -491,8 +491,8 @@ export const build = (context: Context, node: NodeObject, children?: Child[]): v
|
|
|
491
491
|
isNodeString(child)
|
|
492
492
|
? (c) => isNodeString(c)
|
|
493
493
|
: child.key !== undefined
|
|
494
|
-
|
|
495
|
-
|
|
494
|
+
? (c) => c.key === (child as Node).key && c.tag === (child as Node).tag
|
|
495
|
+
: (c) => c.tag === (child as Node).tag
|
|
496
496
|
)
|
|
497
497
|
|
|
498
498
|
if (i !== -1) {
|
|
@@ -769,4 +769,4 @@ export const createPortal = (children: Child, container: HTMLElement, key?: stri
|
|
|
769
769
|
e: container,
|
|
770
770
|
p: 1,
|
|
771
771
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
772
|
-
} as any
|
|
772
|
+
}) as any
|
|
@@ -16,7 +16,7 @@ export type EffectData = [
|
|
|
16
16
|
(() => void | (() => void)) | undefined, // layout effect
|
|
17
17
|
(() => void) | undefined, // cleanup
|
|
18
18
|
(() => void) | undefined, // effect
|
|
19
|
-
(() => void) | undefined // insertion effect
|
|
19
|
+
(() => void) | undefined, // insertion effect
|
|
20
20
|
]
|
|
21
21
|
|
|
22
22
|
const resolvedPromiseValueMap: WeakMap<Promise<unknown>, unknown> = new WeakMap<
|
|
@@ -36,7 +36,7 @@ const isDepsChanged = (
|
|
|
36
36
|
let viewTransitionState:
|
|
37
37
|
| [
|
|
38
38
|
boolean, // isUpdating
|
|
39
|
-
boolean // useViewTransition() is called
|
|
39
|
+
boolean, // useViewTransition() is called
|
|
40
40
|
]
|
|
41
41
|
| undefined = undefined
|
|
42
42
|
|
|
@@ -208,7 +208,7 @@ export const useState: UseStateType = <T>(
|
|
|
208
208
|
if (pendingStack.length) {
|
|
209
209
|
const [pendingType, pendingPromise] = pendingStack.at(-1) as [
|
|
210
210
|
PendingType | 3,
|
|
211
|
-
Promise<void
|
|
211
|
+
Promise<void>,
|
|
212
212
|
]
|
|
213
213
|
Promise.all([
|
|
214
214
|
pendingType === 3
|
|
@@ -85,7 +85,7 @@ const documentMetadataTag = (tag: string, children: Child, props: Props, sort: b
|
|
|
85
85
|
|
|
86
86
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
87
|
let { precedence, blocking, ...restProps } = props
|
|
88
|
-
precedence = sort ? precedence ?? '' : undefined
|
|
88
|
+
precedence = sort ? (precedence ?? '') : undefined
|
|
89
89
|
if (sort) {
|
|
90
90
|
restProps[dataPrecedenceAttr] = precedence
|
|
91
91
|
}
|
|
@@ -25,12 +25,12 @@ export const styleObjectForEach = (
|
|
|
25
25
|
v == null
|
|
26
26
|
? null
|
|
27
27
|
: typeof v === 'number'
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
? !key.match(
|
|
29
|
+
/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/
|
|
30
|
+
)
|
|
31
|
+
? `${v}px`
|
|
32
|
+
: `${v}`
|
|
33
|
+
: v
|
|
34
34
|
)
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -37,8 +37,8 @@ const createRenderer =
|
|
|
37
37
|
typeof options?.docType === 'string'
|
|
38
38
|
? options.docType
|
|
39
39
|
: options?.docType === false
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
? ''
|
|
41
|
+
: '<!DOCTYPE html>'
|
|
42
42
|
|
|
43
43
|
const currentLayout = component
|
|
44
44
|
? jsx(
|
|
@@ -148,7 +148,7 @@ export const jsxRenderer = (
|
|
|
148
148
|
export const useRequestContext = <
|
|
149
149
|
E extends Env = any,
|
|
150
150
|
P extends string = any,
|
|
151
|
-
I extends Input = {}
|
|
151
|
+
I extends Input = {},
|
|
152
152
|
>(): Context<E, P, I> => {
|
|
153
153
|
const c = useContext(RequestContext)
|
|
154
154
|
if (!c) {
|
|
@@ -97,7 +97,7 @@ export const serveStatic = <E extends Env = Env>(
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
const mimeType = options.mimes
|
|
100
|
-
? getMimeType(path, options.mimes) ?? getMimeType(path)
|
|
100
|
+
? (getMimeType(path, options.mimes) ?? getMimeType(path))
|
|
101
101
|
: getMimeType(path)
|
|
102
102
|
|
|
103
103
|
if (mimeType) {
|
|
@@ -13,7 +13,7 @@ import type { BlankEnv, BlankSchema, Env, Schema } from '../types'
|
|
|
13
13
|
export class Hono<
|
|
14
14
|
E extends Env = BlankEnv,
|
|
15
15
|
S extends Schema = BlankSchema,
|
|
16
|
-
BasePath extends string = '/'
|
|
16
|
+
BasePath extends string = '/',
|
|
17
17
|
> extends HonoBase<E, S, BasePath> {
|
|
18
18
|
constructor(options: HonoOptions<E> = {}) {
|
|
19
19
|
super(options)
|
|
@@ -11,7 +11,7 @@ import type { BlankEnv, BlankSchema, Env, Schema } from '../types'
|
|
|
11
11
|
export class Hono<
|
|
12
12
|
E extends Env = BlankEnv,
|
|
13
13
|
S extends Schema = BlankSchema,
|
|
14
|
-
BasePath extends string = '/'
|
|
14
|
+
BasePath extends string = '/',
|
|
15
15
|
> extends HonoBase<E, S, BasePath> {
|
|
16
16
|
constructor(options: HonoOptions<E> = {}) {
|
|
17
17
|
super(options)
|
|
@@ -23,8 +23,8 @@ export class PatternRouter<T> implements Router<T> {
|
|
|
23
23
|
return match
|
|
24
24
|
? `/(?<${match[1]}>${match[2] || '[^/]+'})`
|
|
25
25
|
: part === '/*'
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
? '/[^/]+'
|
|
27
|
+
: part.replace(/[.\\+*[^\]$()]/g, '\\$&')
|
|
28
28
|
}
|
|
29
29
|
)
|
|
30
30
|
|
|
@@ -73,8 +73,8 @@ export class Node {
|
|
|
73
73
|
? ['', '', ONLY_WILDCARD_REG_EXP_STR] // '*' matches to all the trailing paths
|
|
74
74
|
: ['', '', LABEL_REG_EXP_STR]
|
|
75
75
|
: token === '/*'
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
? ['', '', TAIL_WILDCARD_REG_EXP_STR] // '/path/to/*' is /\/path\/to(?:|/.*)$
|
|
77
|
+
: token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/)
|
|
78
78
|
|
|
79
79
|
let node
|
|
80
80
|
if (pattern) {
|
|
@@ -138,8 +138,8 @@ export class Node {
|
|
|
138
138
|
(typeof c.varIndex === 'number'
|
|
139
139
|
? `(${k})@${c.varIndex}`
|
|
140
140
|
: regExpMetaChars.has(k)
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
? `\\${k}`
|
|
142
|
+
: k) + c.buildRegExpStr()
|
|
143
143
|
)
|
|
144
144
|
})
|
|
145
145
|
|
|
@@ -259,7 +259,7 @@ export class RegExpRouter<T> implements Router<T> {
|
|
|
259
259
|
routes.push(
|
|
260
260
|
...(Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]]) as [
|
|
261
261
|
string,
|
|
262
|
-
HandlerWithMetadata<T>[]
|
|
262
|
+
HandlerWithMetadata<T>[],
|
|
263
263
|
][])
|
|
264
264
|
)
|
|
265
265
|
}
|
|
@@ -103,7 +103,7 @@ export class Node<T> {
|
|
|
103
103
|
handlerSet.possibleKeys.forEach((key) => {
|
|
104
104
|
const processed = processedSet[handlerSet.name]
|
|
105
105
|
handlerSet.params[key] =
|
|
106
|
-
params[key] && !processed ? params[key] : nodeParams[key] ?? params[key]
|
|
106
|
+
params[key] && !processed ? params[key] : (nodeParams[key] ?? params[key])
|
|
107
107
|
processedSet[handlerSet.name] = true
|
|
108
108
|
})
|
|
109
109
|
handlerSets.push(handlerSet)
|