hono 4.13.13 → 5.0.0-rc.0
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/README.md +2 -2
- package/dist/{types/compose.d.ts → compose.d.ts} +1 -0
- package/dist/compose.js +10 -5
- package/dist/{types/context.d.ts → context.d.ts} +15 -15
- package/dist/context.js +79 -47
- package/dist/helper/factory/define-handler.d.ts +150 -0
- package/dist/helper/factory/define-handler.js +165 -0
- package/dist/{types/helper → helper}/factory/index.d.ts +30 -1
- package/dist/helper/factory/index.js +31 -3
- package/dist/{types/helper → helper}/ssg/middleware.d.ts +0 -6
- package/dist/helper/ssg/middleware.js +1 -16
- package/dist/{types/helper → helper}/ssg/ssg.d.ts +0 -12
- package/dist/helper/ssg/ssg.js +0 -3
- package/dist/{types/hono-base.d.ts → hono-base.d.ts} +3 -60
- package/dist/hono-base.js +6 -97
- package/dist/{types/hono.d.ts → hono.d.ts} +1 -1
- package/dist/{types/middleware → middleware}/basic-auth/index.d.ts +4 -3
- package/dist/middleware/basic-auth/index.js +1 -1
- package/dist/{types/middleware → middleware}/bearer-auth/index.d.ts +4 -27
- package/dist/middleware/bearer-auth/index.js +4 -4
- package/dist/middleware/language/language.js +1 -1
- package/dist/middleware/logger/index.js +6 -8
- package/dist/{types/middleware → middleware}/serve-static/index.d.ts +0 -4
- package/dist/{types/preset → preset}/quick.d.ts +1 -1
- package/dist/{types/preset → preset}/tiny.d.ts +1 -1
- package/dist/{types/request.d.ts → request.d.ts} +3 -48
- package/dist/request.js +0 -49
- package/dist/router/linear-router/router.js +4 -6
- package/dist/router/pattern-router/router.js +2 -2
- package/dist/router/reg-exp-router/node.js +1 -1
- package/dist/router/trie-router/node.js +3 -3
- package/dist/utils/buffer.d.ts +11 -0
- package/dist/utils/buffer.js +1 -8
- package/dist/utils/color.d.ts +16 -0
- package/dist/utils/color.js +7 -23
- package/dist/{types/utils → utils}/http-status.d.ts +1 -9
- package/dist/{types/utils → utils}/url.d.ts +0 -5
- package/dist/utils/url.js +1 -11
- package/dist/{types/validator → validator}/validator.d.ts +5 -0
- package/dist/validator/validator.js +46 -49
- package/package.json +209 -350
- package/dist/adapter/aws-lambda/conninfo.js +0 -43
- package/dist/adapter/aws-lambda/handler.js +0 -342
- package/dist/adapter/aws-lambda/index.js +0 -3
- package/dist/adapter/aws-lambda/types.js +0 -1
- package/dist/adapter/bun/conninfo.js +0 -22
- package/dist/adapter/bun/index.js +0 -6
- package/dist/adapter/bun/serve-static.js +0 -30
- package/dist/adapter/bun/server.js +0 -11
- package/dist/adapter/bun/ssg.js +0 -27
- package/dist/adapter/bun/websocket.js +0 -66
- package/dist/adapter/cloudflare-pages/conninfo.js +0 -24
- package/dist/adapter/cloudflare-pages/handler.js +0 -64
- package/dist/adapter/cloudflare-pages/index.js +0 -3
- package/dist/adapter/cloudflare-workers/conninfo.js +0 -7
- package/dist/adapter/cloudflare-workers/index.js +0 -4
- package/dist/adapter/cloudflare-workers/serve-static-module.js +0 -7
- package/dist/adapter/cloudflare-workers/serve-static.js +0 -28
- package/dist/adapter/cloudflare-workers/utils.js +0 -22
- package/dist/adapter/cloudflare-workers/websocket.js +0 -33
- package/dist/adapter/deno/conninfo.js +0 -17
- package/dist/adapter/deno/deno.d.js +0 -1
- package/dist/adapter/deno/index.js +0 -5
- package/dist/adapter/deno/serve-static.js +0 -35
- package/dist/adapter/deno/ssg.js +0 -29
- package/dist/adapter/deno/websocket.js +0 -32
- package/dist/adapter/lambda-edge/conninfo.js +0 -7
- package/dist/adapter/lambda-edge/handler.js +0 -111
- package/dist/adapter/lambda-edge/index.js +0 -3
- package/dist/adapter/netlify/conninfo.js +0 -24
- package/dist/adapter/netlify/handler.js +0 -11
- package/dist/adapter/netlify/index.js +0 -3
- package/dist/adapter/netlify/mod.js +0 -3
- package/dist/adapter/service-worker/handler.js +0 -16
- package/dist/adapter/service-worker/index.js +0 -25
- package/dist/adapter/service-worker/types.js +0 -1
- package/dist/adapter/vercel/conninfo.js +0 -7
- package/dist/adapter/vercel/handler.js +0 -9
- package/dist/adapter/vercel/index.js +0 -3
- package/dist/cjs/_virtual/_rolldown/runtime.js +0 -33
- package/dist/cjs/adapter/aws-lambda/conninfo.js +0 -44
- package/dist/cjs/adapter/aws-lambda/handler.js +0 -352
- package/dist/cjs/adapter/aws-lambda/index.js +0 -7
- package/dist/cjs/adapter/aws-lambda/types.js +0 -0
- package/dist/cjs/adapter/bun/conninfo.js +0 -23
- package/dist/cjs/adapter/bun/index.js +0 -14
- package/dist/cjs/adapter/bun/serve-static.js +0 -31
- package/dist/cjs/adapter/bun/server.js +0 -12
- package/dist/cjs/adapter/bun/ssg.js +0 -29
- package/dist/cjs/adapter/bun/websocket.js +0 -70
- package/dist/cjs/adapter/cloudflare-pages/conninfo.js +0 -25
- package/dist/cjs/adapter/cloudflare-pages/handler.js +0 -67
- package/dist/cjs/adapter/cloudflare-pages/index.js +0 -7
- package/dist/cjs/adapter/cloudflare-workers/conninfo.js +0 -8
- package/dist/cjs/adapter/cloudflare-workers/index.js +0 -7
- package/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +0 -8
- package/dist/cjs/adapter/cloudflare-workers/serve-static.js +0 -29
- package/dist/cjs/adapter/cloudflare-workers/utils.js +0 -23
- package/dist/cjs/adapter/cloudflare-workers/websocket.js +0 -34
- package/dist/cjs/adapter/deno/conninfo.js +0 -18
- package/dist/cjs/adapter/deno/deno.d.js +0 -0
- package/dist/cjs/adapter/deno/index.js +0 -10
- package/dist/cjs/adapter/deno/serve-static.js +0 -36
- package/dist/cjs/adapter/deno/ssg.js +0 -31
- package/dist/cjs/adapter/deno/websocket.js +0 -33
- package/dist/cjs/adapter/lambda-edge/conninfo.js +0 -8
- package/dist/cjs/adapter/lambda-edge/handler.js +0 -116
- package/dist/cjs/adapter/lambda-edge/index.js +0 -5
- package/dist/cjs/adapter/netlify/conninfo.js +0 -25
- package/dist/cjs/adapter/netlify/handler.js +0 -12
- package/dist/cjs/adapter/netlify/index.js +0 -5
- package/dist/cjs/adapter/netlify/mod.js +0 -5
- package/dist/cjs/adapter/service-worker/handler.js +0 -17
- package/dist/cjs/adapter/service-worker/index.js +0 -27
- package/dist/cjs/adapter/service-worker/types.js +0 -0
- package/dist/cjs/adapter/vercel/conninfo.js +0 -8
- package/dist/cjs/adapter/vercel/handler.js +0 -10
- package/dist/cjs/adapter/vercel/index.js +0 -5
- package/dist/cjs/client/client.js +0 -145
- package/dist/cjs/client/fetch-result-please.js +0 -67
- package/dist/cjs/client/index.js +0 -7
- package/dist/cjs/client/types.js +0 -0
- package/dist/cjs/client/utils.js +0 -70
- package/dist/cjs/compose.js +0 -51
- package/dist/cjs/context.js +0 -383
- package/dist/cjs/helper/accepts/accepts.js +0 -54
- package/dist/cjs/helper/accepts/index.js +0 -3
- package/dist/cjs/helper/adapter/index.js +0 -41
- package/dist/cjs/helper/conninfo/index.js +0 -0
- package/dist/cjs/helper/conninfo/types.js +0 -0
- package/dist/cjs/helper/cookie/index.js +0 -89
- package/dist/cjs/helper/css/common.js +0 -194
- package/dist/cjs/helper/css/index.js +0 -142
- package/dist/cjs/helper/dev/index.js +0 -53
- package/dist/cjs/helper/factory/index.js +0 -33
- package/dist/cjs/helper/html/index.js +0 -34
- package/dist/cjs/helper/proxy/index.js +0 -122
- package/dist/cjs/helper/route/index.js +0 -128
- package/dist/cjs/helper/ssg/index.js +0 -19
- package/dist/cjs/helper/ssg/middleware.js +0 -65
- package/dist/cjs/helper/ssg/plugins.js +0 -68
- package/dist/cjs/helper/ssg/ssg.js +0 -220
- package/dist/cjs/helper/ssg/utils.js +0 -70
- package/dist/cjs/helper/streaming/index.js +0 -8
- package/dist/cjs/helper/streaming/sse.js +0 -59
- package/dist/cjs/helper/streaming/stream.js +0 -26
- package/dist/cjs/helper/streaming/text.js +0 -12
- package/dist/cjs/helper/streaming/utils.js +0 -16
- package/dist/cjs/helper/testing/index.js +0 -18
- package/dist/cjs/helper/websocket/index.js +0 -56
- package/dist/cjs/hono-base.js +0 -351
- package/dist/cjs/hono.js +0 -29
- package/dist/cjs/http-exception.js +0 -56
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/jsx/base.js +0 -266
- package/dist/cjs/jsx/children.js +0 -19
- package/dist/cjs/jsx/components.js +0 -147
- package/dist/cjs/jsx/constants.js +0 -15
- package/dist/cjs/jsx/context.js +0 -170
- package/dist/cjs/jsx/dom/client.js +0 -56
- package/dist/cjs/jsx/dom/components.js +0 -26
- package/dist/cjs/jsx/dom/context.js +0 -43
- package/dist/cjs/jsx/dom/css.js +0 -153
- package/dist/cjs/jsx/dom/hooks/index.js +0 -65
- package/dist/cjs/jsx/dom/index.js +0 -122
- package/dist/cjs/jsx/dom/intrinsic-element/components.js +0 -306
- package/dist/cjs/jsx/dom/jsx-dev-runtime.js +0 -17
- package/dist/cjs/jsx/dom/jsx-runtime.js +0 -5
- package/dist/cjs/jsx/dom/render.js +0 -525
- package/dist/cjs/jsx/dom/server.js +0 -44
- package/dist/cjs/jsx/dom/utils.js +0 -9
- package/dist/cjs/jsx/hooks/index.js +0 -280
- package/dist/cjs/jsx/index.js +0 -89
- package/dist/cjs/jsx/intrinsic-element/common.js +0 -27
- package/dist/cjs/jsx/intrinsic-element/components.js +0 -138
- package/dist/cjs/jsx/intrinsic-elements.js +0 -0
- package/dist/cjs/jsx/jsx-dev-runtime.js +0 -16
- package/dist/cjs/jsx/jsx-runtime.js +0 -37
- package/dist/cjs/jsx/streaming.js +0 -135
- package/dist/cjs/jsx/types.js +0 -0
- package/dist/cjs/jsx/utils.js +0 -116
- package/dist/cjs/middleware/basic-auth/index.js +0 -100
- package/dist/cjs/middleware/bearer-auth/index.js +0 -97
- package/dist/cjs/middleware/body-limit/index.js +0 -69
- package/dist/cjs/middleware/cache/index.js +0 -173
- package/dist/cjs/middleware/combine/index.js +0 -141
- package/dist/cjs/middleware/compress/index.js +0 -82
- package/dist/cjs/middleware/context-storage/index.js +0 -55
- package/dist/cjs/middleware/cors/index.js +0 -109
- package/dist/cjs/middleware/csrf/index.js +0 -106
- package/dist/cjs/middleware/etag/digest.js +0 -62
- package/dist/cjs/middleware/etag/index.js +0 -79
- package/dist/cjs/middleware/ip-restriction/index.js +0 -168
- package/dist/cjs/middleware/jsx-renderer/index.js +0 -104
- package/dist/cjs/middleware/jwk/index.js +0 -3
- package/dist/cjs/middleware/jwk/jwk.js +0 -122
- package/dist/cjs/middleware/jwt/index.js +0 -9
- package/dist/cjs/middleware/jwt/jwt.js +0 -124
- package/dist/cjs/middleware/language/index.js +0 -7
- package/dist/cjs/middleware/language/language.js +0 -208
- package/dist/cjs/middleware/logger/index.js +0 -51
- package/dist/cjs/middleware/method-not-allowed/index.js +0 -84
- package/dist/cjs/middleware/method-override/index.js +0 -105
- package/dist/cjs/middleware/mount/index.js +0 -71
- package/dist/cjs/middleware/powered-by/index.js +0 -25
- package/dist/cjs/middleware/pretty-json/index.js +0 -41
- package/dist/cjs/middleware/request-id/index.js +0 -3
- package/dist/cjs/middleware/request-id/request-id.js +0 -35
- package/dist/cjs/middleware/secure-headers/index.js +0 -4
- package/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -0
- package/dist/cjs/middleware/secure-headers/secure-headers.js +0 -166
- package/dist/cjs/middleware/serve-static/index.js +0 -62
- package/dist/cjs/middleware/serve-static/path.js +0 -17
- package/dist/cjs/middleware/timeout/index.js +0 -42
- package/dist/cjs/middleware/timing/index.js +0 -7
- package/dist/cjs/middleware/timing/timing.js +0 -189
- package/dist/cjs/middleware/trailing-slash/index.js +0 -89
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/preset/quick.js +0 -19
- package/dist/cjs/preset/tiny.js +0 -16
- package/dist/cjs/request/constants.js +0 -5
- package/dist/cjs/request.js +0 -337
- package/dist/cjs/router/linear-router/index.js +0 -3
- package/dist/cjs/router/linear-router/router.js +0 -97
- package/dist/cjs/router/pattern-router/index.js +0 -3
- package/dist/cjs/router/pattern-router/router.js +0 -42
- package/dist/cjs/router/reg-exp-router/index.js +0 -7
- package/dist/cjs/router/reg-exp-router/matcher.js +0 -21
- package/dist/cjs/router/reg-exp-router/node.js +0 -96
- package/dist/cjs/router/reg-exp-router/prepared-router.js +0 -97
- package/dist/cjs/router/reg-exp-router/router.js +0 -102
- package/dist/cjs/router/reg-exp-router/trie.js +0 -74
- package/dist/cjs/router/smart-router/index.js +0 -3
- package/dist/cjs/router/smart-router/router.js +0 -50
- package/dist/cjs/router/trie-router/index.js +0 -3
- package/dist/cjs/router/trie-router/node.js +0 -135
- package/dist/cjs/router/trie-router/router.js +0 -16
- package/dist/cjs/router/utils.js +0 -5
- package/dist/cjs/router.js +0 -40
- package/dist/cjs/types.js +0 -5
- package/dist/cjs/utils/accept.js +0 -194
- package/dist/cjs/utils/basic-auth.js +0 -21
- package/dist/cjs/utils/body.js +0 -97
- package/dist/cjs/utils/buffer.js +0 -55
- package/dist/cjs/utils/color.js +0 -39
- package/dist/cjs/utils/compress.js +0 -12
- package/dist/cjs/utils/concurrent.js +0 -31
- package/dist/cjs/utils/constants.js +0 -8
- package/dist/cjs/utils/cookie.js +0 -129
- package/dist/cjs/utils/crypto.js +0 -38
- package/dist/cjs/utils/encode.js +0 -37
- package/dist/cjs/utils/filepath.js +0 -27
- package/dist/cjs/utils/handler.js +0 -14
- package/dist/cjs/utils/headers.js +0 -0
- package/dist/cjs/utils/html.js +0 -109
- package/dist/cjs/utils/http-status.js +0 -0
- package/dist/cjs/utils/ipaddr.js +0 -247
- package/dist/cjs/utils/jwt/index.js +0 -15
- package/dist/cjs/utils/jwt/jwa.js +0 -25
- package/dist/cjs/utils/jwt/jws.js +0 -135
- package/dist/cjs/utils/jwt/jwt.js +0 -136
- package/dist/cjs/utils/jwt/types.js +0 -124
- package/dist/cjs/utils/jwt/utf8.js +0 -11
- package/dist/cjs/utils/mime.js +0 -80
- package/dist/cjs/utils/stream.js +0 -89
- package/dist/cjs/utils/types.js +0 -0
- package/dist/cjs/utils/url.js +0 -215
- package/dist/cjs/validator/index.js +0 -3
- package/dist/cjs/validator/utils.js +0 -0
- package/dist/cjs/validator/validator.js +0 -65
- package/dist/types/adapter/aws-lambda/conninfo.d.ts +0 -30
- package/dist/types/adapter/aws-lambda/handler.d.ts +0 -230
- package/dist/types/adapter/aws-lambda/index.d.ts +0 -4
- package/dist/types/adapter/aws-lambda/types.d.ts +0 -183
- package/dist/types/adapter/bun/conninfo.d.ts +0 -10
- package/dist/types/adapter/bun/index.d.ts +0 -6
- package/dist/types/adapter/bun/serve-static.d.ts +0 -8
- package/dist/types/adapter/bun/server.d.ts +0 -11
- package/dist/types/adapter/bun/ssg.d.ts +0 -17
- package/dist/types/adapter/bun/websocket.d.ts +0 -54
- package/dist/types/adapter/cloudflare-pages/conninfo.d.ts +0 -24
- package/dist/types/adapter/cloudflare-pages/handler.d.ts +0 -45
- package/dist/types/adapter/cloudflare-pages/index.d.ts +0 -3
- package/dist/types/adapter/cloudflare-workers/conninfo.d.ts +0 -7
- package/dist/types/adapter/cloudflare-workers/index.d.ts +0 -4
- package/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +0 -7
- package/dist/types/adapter/cloudflare-workers/serve-static.d.ts +0 -21
- package/dist/types/adapter/cloudflare-workers/utils.d.ts +0 -13
- package/dist/types/adapter/cloudflare-workers/websocket.d.ts +0 -7
- package/dist/types/adapter/deno/conninfo.d.ts +0 -10
- package/dist/types/adapter/deno/deno.d.ts +0 -1
- package/dist/types/adapter/deno/index.d.ts +0 -5
- package/dist/types/adapter/deno/serve-static.d.ts +0 -8
- package/dist/types/adapter/deno/ssg.d.ts +0 -17
- package/dist/types/adapter/deno/websocket.d.ts +0 -7
- package/dist/types/adapter/lambda-edge/conninfo.d.ts +0 -7
- package/dist/types/adapter/lambda-edge/handler.d.ts +0 -113
- package/dist/types/adapter/lambda-edge/index.d.ts +0 -3
- package/dist/types/adapter/netlify/conninfo.d.ts +0 -24
- package/dist/types/adapter/netlify/handler.d.ts +0 -7
- package/dist/types/adapter/netlify/index.d.ts +0 -3
- package/dist/types/adapter/netlify/mod.d.ts +0 -3
- package/dist/types/adapter/service-worker/handler.d.ts +0 -18
- package/dist/types/adapter/service-worker/index.d.ts +0 -26
- package/dist/types/adapter/service-worker/types.d.ts +0 -17
- package/dist/types/adapter/vercel/conninfo.d.ts +0 -7
- package/dist/types/adapter/vercel/handler.d.ts +0 -7
- package/dist/types/adapter/vercel/index.d.ts +0 -3
- package/dist/types/package.json +0 -3
- package/dist/types/utils/buffer.d.ts +0 -19
- package/dist/types/utils/color.d.ts +0 -23
- package/dist/{types/client → client}/client.d.ts +0 -0
- package/dist/{types/client → client}/fetch-result-please.d.ts +0 -0
- package/dist/{types/client → client}/index.d.ts +0 -0
- package/dist/{types/client → client}/types.d.ts +1 -1
- package/dist/{types/client → client}/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/accepts/accepts.d.ts +0 -0
- package/dist/{types/helper → helper}/accepts/index.d.ts +0 -0
- package/dist/{types/helper → helper}/adapter/index.d.ts +0 -0
- package/dist/{types/helper → helper}/conninfo/index.d.ts +0 -0
- package/dist/{types/helper → helper}/conninfo/types.d.ts +0 -0
- package/dist/{types/helper → helper}/cookie/index.d.ts +0 -0
- package/dist/{types/helper → helper}/css/common.d.ts +0 -0
- package/dist/{types/helper → helper}/css/index.d.ts +0 -0
- package/dist/{types/helper → helper}/dev/index.d.ts +0 -0
- package/dist/{types/helper → helper}/html/index.d.ts +0 -0
- package/dist/{types/helper → helper}/proxy/index.d.ts +0 -0
- package/dist/{types/helper → helper}/route/index.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/index.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/plugins.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/index.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/sse.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/stream.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/text.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/testing/index.d.ts +0 -0
- package/dist/{types/helper → helper}/websocket/index.d.ts +0 -0
- package/dist/{types/http-exception.d.ts → http-exception.d.ts} +0 -0
- package/dist/{types/index.d.ts → index.d.ts} +0 -0
- package/dist/{types/jsx → jsx}/base.d.ts +0 -0
- package/dist/{types/jsx → jsx}/children.d.ts +0 -0
- package/dist/{types/jsx → jsx}/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/constants.d.ts +0 -0
- package/dist/{types/jsx → jsx}/context.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/client.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/context.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/css.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/hooks/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/intrinsic-element/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/jsx-dev-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/jsx-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/render.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/server.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/utils.d.ts +0 -0
- package/dist/{types/jsx → jsx}/hooks/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-element/common.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-element/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-elements.d.ts +0 -0
- package/dist/{types/jsx → jsx}/jsx-dev-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/jsx-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/streaming.d.ts +0 -0
- package/dist/{types/jsx → jsx}/types.d.ts +0 -0
- package/dist/{types/jsx → jsx}/utils.d.ts +0 -0
- package/dist/{types/middleware → middleware}/body-limit/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/cache/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/combine/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/compress/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/context-storage/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/cors/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/csrf/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/etag/digest.d.ts +0 -0
- package/dist/{types/middleware → middleware}/etag/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/ip-restriction/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jsx-renderer/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwk/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwk/jwk.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwt/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwt/jwt.d.ts +0 -0
- package/dist/{types/middleware → middleware}/language/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/language/language.d.ts +0 -0
- package/dist/{types/middleware → middleware}/logger/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/method-not-allowed/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/method-override/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/mount/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/powered-by/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/pretty-json/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/request-id/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/request-id/request-id.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/permissions-policy.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/secure-headers.d.ts +0 -0
- package/dist/{types/middleware → middleware}/serve-static/path.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timeout/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timing/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timing/timing.d.ts +0 -0
- package/dist/{types/middleware → middleware}/trailing-slash/index.d.ts +0 -0
- package/dist/{types/request → request}/constants.d.ts +0 -0
- package/dist/{types/router → router}/linear-router/index.d.ts +0 -0
- package/dist/{types/router → router}/linear-router/router.d.ts +0 -0
- package/dist/{types/router → router}/pattern-router/index.d.ts +0 -0
- package/dist/{types/router → router}/pattern-router/router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/index.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/matcher.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/node.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/prepared-router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/trie.d.ts +0 -0
- package/dist/{types/router → router}/smart-router/index.d.ts +0 -0
- package/dist/{types/router → router}/smart-router/router.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/index.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/node.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/router.d.ts +0 -0
- package/dist/{types/router → router}/utils.d.ts +0 -0
- package/dist/{types/router.d.ts → router.d.ts} +0 -0
- package/dist/{types/types.d.ts → types.d.ts} +1 -1
- /package/dist/{types/utils → utils}/accept.d.ts +0 -0
- /package/dist/{types/utils → utils}/basic-auth.d.ts +0 -0
- /package/dist/{types/utils → utils}/body.d.ts +0 -0
- /package/dist/{types/utils → utils}/compress.d.ts +0 -0
- /package/dist/{types/utils → utils}/concurrent.d.ts +0 -0
- /package/dist/{types/utils → utils}/constants.d.ts +0 -0
- /package/dist/{types/utils → utils}/cookie.d.ts +0 -0
- /package/dist/{types/utils → utils}/crypto.d.ts +0 -0
- /package/dist/{types/utils → utils}/encode.d.ts +0 -0
- /package/dist/{types/utils → utils}/filepath.d.ts +0 -0
- /package/dist/{types/utils → utils}/handler.d.ts +0 -0
- /package/dist/{types/utils → utils}/headers.d.ts +0 -0
- /package/dist/{types/utils → utils}/html.d.ts +0 -0
- /package/dist/{types/utils → utils}/ipaddr.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/index.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jwa.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jws.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jwt.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/types.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/utf8.d.ts +0 -0
- /package/dist/{types/utils → utils}/mime.d.ts +0 -0
- /package/dist/{types/utils → utils}/stream.d.ts +0 -0
- /package/dist/{types/utils → utils}/types.d.ts +0 -0
- /package/dist/{types/validator → validator}/index.d.ts +0 -0
- /package/dist/{types/validator → validator}/utils.d.ts +0 -0
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_request_constants = require("../../request/constants.js");
|
|
3
|
-
const require_utils_url = require("../../utils/url.js");
|
|
4
|
-
//#region src/helper/route/index.ts
|
|
5
|
-
/**
|
|
6
|
-
* Get matched routes in the handler
|
|
7
|
-
*
|
|
8
|
-
* @param {Context} c - The context object
|
|
9
|
-
* @returns An array of matched routes
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { matchedRoutes } from 'hono/route'
|
|
14
|
-
*
|
|
15
|
-
* app.use('*', async function logger(c, next) {
|
|
16
|
-
* await next()
|
|
17
|
-
* matchedRoutes(c).forEach(({ handler, method, path }, i) => {
|
|
18
|
-
* const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
|
|
19
|
-
* console.log(
|
|
20
|
-
* method,
|
|
21
|
-
* ' ',
|
|
22
|
-
* path,
|
|
23
|
-
* ' '.repeat(Math.max(10 - path.length, 0)),
|
|
24
|
-
* name,
|
|
25
|
-
* i === c.req.routeIndex ? '<- respond from here' : ''
|
|
26
|
-
* )
|
|
27
|
-
* })
|
|
28
|
-
* })
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
const matchedRoutes = (c) => c.req[require_request_constants.GET_MATCH_RESULT][0].map(([[, route]]) => route);
|
|
32
|
-
/**
|
|
33
|
-
* Get the route path registered within the handler
|
|
34
|
-
*
|
|
35
|
-
* @param {Context} c - The context object
|
|
36
|
-
* @param {number} index - The index of the route from which to retrieve the path, similar to Array.prototype.at(), where a negative number is the index counted from the end of the matching route. Defaults to the current route index.
|
|
37
|
-
* @returns The route path registered within the handler
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { routePath } from 'hono/route'
|
|
42
|
-
*
|
|
43
|
-
* app.use('*', (c, next) => {
|
|
44
|
-
* console.log(routePath(c)) // '*'
|
|
45
|
-
* console.log(routePath(c, -1)) // '/posts/:id'
|
|
46
|
-
* return next()
|
|
47
|
-
* })
|
|
48
|
-
*
|
|
49
|
-
* app.get('/posts/:id', (c) => {
|
|
50
|
-
* return c.text(routePath(c)) // '/posts/:id'
|
|
51
|
-
* })
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
const routePath = (c, index) => matchedRoutes(c).at(index ?? c.req.routeIndex)?.path ?? "";
|
|
55
|
-
/**
|
|
56
|
-
* Get the basePath of the as-is route specified by routing.
|
|
57
|
-
*
|
|
58
|
-
* @param {Context} c - The context object
|
|
59
|
-
* @param {number} index - The index of the route from which to retrieve the path, similar to Array.prototype.at(), where a negative number is the index counted from the end of the matching route. Defaults to the current route index.
|
|
60
|
-
* @returns The basePath of the as-is route specified by routing.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* import { baseRoutePath } from 'hono/route'
|
|
65
|
-
*
|
|
66
|
-
* const app = new Hono()
|
|
67
|
-
*
|
|
68
|
-
* const subApp = new Hono()
|
|
69
|
-
* subApp.get('/posts/:id', (c) => {
|
|
70
|
-
* return c.text(baseRoutePath(c)) // '/:sub'
|
|
71
|
-
* })
|
|
72
|
-
*
|
|
73
|
-
* app.route('/:sub', subApp)
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
const baseRoutePath = (c, index) => matchedRoutes(c).at(index ?? c.req.routeIndex)?.basePath ?? "";
|
|
77
|
-
/**
|
|
78
|
-
* Get the basePath with embedded parameters
|
|
79
|
-
*
|
|
80
|
-
* @param {Context} c - The context object
|
|
81
|
-
* @param {number} index - The index of the route from which to retrieve the path, similar to Array.prototype.at(), where a negative number is the index counted from the end of the matching route. Defaults to the current route index.
|
|
82
|
-
* @returns The basePath with embedded parameters.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* import { basePath } from 'hono/route'
|
|
87
|
-
*
|
|
88
|
-
* const app = new Hono()
|
|
89
|
-
*
|
|
90
|
-
* const subApp = new Hono()
|
|
91
|
-
* subApp.get('/posts/:id', (c) => {
|
|
92
|
-
* return c.text(basePath(c)) // '/requested-sub-app-path'
|
|
93
|
-
* })
|
|
94
|
-
*
|
|
95
|
-
* app.route('/:sub', subApp)
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
const basePathCacheMap = /* @__PURE__ */ new WeakMap();
|
|
99
|
-
const basePath = (c, index) => {
|
|
100
|
-
index ??= c.req.routeIndex;
|
|
101
|
-
const cache = basePathCacheMap.get(c) || [];
|
|
102
|
-
if (typeof cache[index] === "string") return cache[index];
|
|
103
|
-
let result;
|
|
104
|
-
const rp = baseRoutePath(c, index);
|
|
105
|
-
if (!/[:*]/.test(rp)) result = rp;
|
|
106
|
-
else {
|
|
107
|
-
const paths = require_utils_url.splitRoutingPath(rp);
|
|
108
|
-
const reqPath = c.req.path;
|
|
109
|
-
let basePathLength = 0;
|
|
110
|
-
for (let i = 0, len = paths.length; i < len; i++) {
|
|
111
|
-
const pattern = require_utils_url.getPattern(paths[i], paths[i + 1]);
|
|
112
|
-
if (pattern) {
|
|
113
|
-
const re = pattern[2] === true || pattern === "*" ? /[^\/]+/ : pattern[2];
|
|
114
|
-
basePathLength += reqPath.substring(basePathLength + 1).match(re)?.[0].length || 0;
|
|
115
|
-
} else basePathLength += paths[i].length;
|
|
116
|
-
basePathLength += 1;
|
|
117
|
-
}
|
|
118
|
-
result = reqPath.substring(0, basePathLength);
|
|
119
|
-
}
|
|
120
|
-
cache[index] = result;
|
|
121
|
-
basePathCacheMap.set(c, cache);
|
|
122
|
-
return result;
|
|
123
|
-
};
|
|
124
|
-
//#endregion
|
|
125
|
-
exports.basePath = basePath;
|
|
126
|
-
exports.baseRoutePath = baseRoutePath;
|
|
127
|
-
exports.matchedRoutes = matchedRoutes;
|
|
128
|
-
exports.routePath = routePath;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_helper_ssg_middleware = require("./middleware.js");
|
|
3
|
-
const require_helper_ssg_plugins = require("./plugins.js");
|
|
4
|
-
const require_helper_ssg_ssg = require("./ssg.js");
|
|
5
|
-
exports.DEFAULT_OUTPUT_DIR = require_helper_ssg_ssg.DEFAULT_OUTPUT_DIR;
|
|
6
|
-
exports.X_HONO_DISABLE_SSG_HEADER_KEY = require_helper_ssg_middleware.X_HONO_DISABLE_SSG_HEADER_KEY;
|
|
7
|
-
exports.combineAfterGenerateHooks = require_helper_ssg_ssg.combineAfterGenerateHooks;
|
|
8
|
-
exports.combineAfterResponseHooks = require_helper_ssg_ssg.combineAfterResponseHooks;
|
|
9
|
-
exports.combineBeforeRequestHooks = require_helper_ssg_ssg.combineBeforeRequestHooks;
|
|
10
|
-
exports.defaultExtensionMap = require_helper_ssg_ssg.defaultExtensionMap;
|
|
11
|
-
exports.defaultPlugin = require_helper_ssg_plugins.defaultPlugin;
|
|
12
|
-
exports.disableSSG = require_helper_ssg_middleware.disableSSG;
|
|
13
|
-
exports.fetchRoutesContent = require_helper_ssg_ssg.fetchRoutesContent;
|
|
14
|
-
exports.isSSGContext = require_helper_ssg_middleware.isSSGContext;
|
|
15
|
-
exports.onlySSG = require_helper_ssg_middleware.onlySSG;
|
|
16
|
-
exports.redirectPlugin = require_helper_ssg_plugins.redirectPlugin;
|
|
17
|
-
exports.saveContentToFile = require_helper_ssg_ssg.saveContentToFile;
|
|
18
|
-
exports.ssgParams = require_helper_ssg_middleware.ssgParams;
|
|
19
|
-
exports.toSSG = require_helper_ssg_ssg.toSSG;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_helper_ssg_utils = require("./utils.js");
|
|
3
|
-
//#region src/helper/ssg/middleware.ts
|
|
4
|
-
const SSG_CONTEXT = "HONO_SSG_CONTEXT";
|
|
5
|
-
const X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated
|
|
8
|
-
* Use `X_HONO_DISABLE_SSG_HEADER_KEY` instead.
|
|
9
|
-
* This constant will be removed in the next minor version.
|
|
10
|
-
*/
|
|
11
|
-
const SSG_DISABLED_RESPONSE = (() => {
|
|
12
|
-
try {
|
|
13
|
-
return new Response("SSG is disabled", {
|
|
14
|
-
status: 404,
|
|
15
|
-
headers: { [X_HONO_DISABLE_SSG_HEADER_KEY]: "true" }
|
|
16
|
-
});
|
|
17
|
-
} catch {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
})();
|
|
21
|
-
/**
|
|
22
|
-
* Define SSG Route
|
|
23
|
-
*/
|
|
24
|
-
const ssgParams = (params) => async (c, next) => {
|
|
25
|
-
if (require_helper_ssg_utils.isDynamicRoute(c.req.path)) {
|
|
26
|
-
c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
|
|
27
|
-
return c.notFound();
|
|
28
|
-
}
|
|
29
|
-
await next();
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* @experimental
|
|
33
|
-
* `isSSGContext` is an experimental feature.
|
|
34
|
-
* The API might be changed.
|
|
35
|
-
*/
|
|
36
|
-
const isSSGContext = (c) => !!c.env?.[SSG_CONTEXT];
|
|
37
|
-
/**
|
|
38
|
-
* @experimental
|
|
39
|
-
* `disableSSG` is an experimental feature.
|
|
40
|
-
* The API might be changed.
|
|
41
|
-
*/
|
|
42
|
-
const disableSSG = () => async function disableSSG(c, next) {
|
|
43
|
-
if (isSSGContext(c)) {
|
|
44
|
-
c.header(X_HONO_DISABLE_SSG_HEADER_KEY, "true");
|
|
45
|
-
return c.notFound();
|
|
46
|
-
}
|
|
47
|
-
await next();
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* @experimental
|
|
51
|
-
* `onlySSG` is an experimental feature.
|
|
52
|
-
* The API might be changed.
|
|
53
|
-
*/
|
|
54
|
-
const onlySSG = () => async function onlySSG(c, next) {
|
|
55
|
-
if (!isSSGContext(c)) return c.notFound();
|
|
56
|
-
await next();
|
|
57
|
-
};
|
|
58
|
-
//#endregion
|
|
59
|
-
exports.SSG_CONTEXT = SSG_CONTEXT;
|
|
60
|
-
exports.SSG_DISABLED_RESPONSE = SSG_DISABLED_RESPONSE;
|
|
61
|
-
exports.X_HONO_DISABLE_SSG_HEADER_KEY = X_HONO_DISABLE_SSG_HEADER_KEY;
|
|
62
|
-
exports.disableSSG = disableSSG;
|
|
63
|
-
exports.isSSGContext = isSSGContext;
|
|
64
|
-
exports.onlySSG = onlySSG;
|
|
65
|
-
exports.ssgParams = ssgParams;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_helper_html_index = require("../html/index.js");
|
|
3
|
-
//#region src/helper/ssg/plugins.ts
|
|
4
|
-
/**
|
|
5
|
-
* The default plugin that defines the recommended behavior.
|
|
6
|
-
*
|
|
7
|
-
* @experimental
|
|
8
|
-
* `defaultPlugin` is an experimental feature.
|
|
9
|
-
* The API might be changed.
|
|
10
|
-
*/
|
|
11
|
-
const defaultPlugin = () => {
|
|
12
|
-
return { afterResponseHook: (res) => {
|
|
13
|
-
if (res.status !== 200) return false;
|
|
14
|
-
return res;
|
|
15
|
-
} };
|
|
16
|
-
};
|
|
17
|
-
const REDIRECT_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
18
|
-
301,
|
|
19
|
-
302,
|
|
20
|
-
303,
|
|
21
|
-
307,
|
|
22
|
-
308
|
|
23
|
-
]);
|
|
24
|
-
const generateRedirectHtml = (location) => {
|
|
25
|
-
return require_helper_html_index.html`<!DOCTYPE html>
|
|
26
|
-
<title>Redirecting to: ${location}</title>
|
|
27
|
-
<meta http-equiv="refresh" content="0;url=${location}" />
|
|
28
|
-
<meta name="robots" content="noindex" />
|
|
29
|
-
<link rel="canonical" href="${location}" />
|
|
30
|
-
<body>
|
|
31
|
-
<a href="${location}">Redirecting to <code>${location}</code></a>
|
|
32
|
-
</body>
|
|
33
|
-
`.toString().replace(/\n/g, "");
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The redirect plugin that generates HTML redirect pages for HTTP redirect responses for status codes 301, 302, 303, 307 and 308.
|
|
37
|
-
*
|
|
38
|
-
* When used with `defaultPlugin`, place `redirectPlugin` before it, because `defaultPlugin` skips non-200 responses.
|
|
39
|
-
*
|
|
40
|
-
* ```ts
|
|
41
|
-
* // ✅ Will work as expected
|
|
42
|
-
* toSSG(app, fs, { plugins: [redirectPlugin(), defaultPlugin()] })
|
|
43
|
-
*
|
|
44
|
-
* // ❌ Will not work as expected
|
|
45
|
-
* toSSG(app, fs, { plugins: [defaultPlugin(), redirectPlugin()] })
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @experimental
|
|
49
|
-
* `redirectPlugin` is an experimental feature.
|
|
50
|
-
* The API might be changed.
|
|
51
|
-
*/
|
|
52
|
-
const redirectPlugin = () => {
|
|
53
|
-
return { afterResponseHook: (res) => {
|
|
54
|
-
if (REDIRECT_STATUS_CODES.has(res.status)) {
|
|
55
|
-
const location = res.headers.get("Location");
|
|
56
|
-
if (!location) return false;
|
|
57
|
-
const htmlBody = generateRedirectHtml(location);
|
|
58
|
-
return new Response(htmlBody, {
|
|
59
|
-
status: 200,
|
|
60
|
-
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return res;
|
|
64
|
-
} };
|
|
65
|
-
};
|
|
66
|
-
//#endregion
|
|
67
|
-
exports.defaultPlugin = defaultPlugin;
|
|
68
|
-
exports.redirectPlugin = redirectPlugin;
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_client_utils = require("../../client/utils.js");
|
|
3
|
-
const require_utils_concurrent = require("../../utils/concurrent.js");
|
|
4
|
-
const require_utils_mime = require("../../utils/mime.js");
|
|
5
|
-
const require_helper_ssg_utils = require("./utils.js");
|
|
6
|
-
const require_helper_ssg_middleware = require("./middleware.js");
|
|
7
|
-
const require_helper_ssg_plugins = require("./plugins.js");
|
|
8
|
-
//#region src/helper/ssg/ssg.ts
|
|
9
|
-
const DEFAULT_CONCURRENCY = 2;
|
|
10
|
-
const DEFAULT_CONTENT_TYPE = "text/plain";
|
|
11
|
-
const DEFAULT_OUTPUT_DIR = "./static";
|
|
12
|
-
const generateFilePath = (routePath, outDir, mimeType, extensionMap) => {
|
|
13
|
-
const extension = determineExtension(mimeType, extensionMap);
|
|
14
|
-
let filePath;
|
|
15
|
-
if (routePath.endsWith(`.${extension}`)) filePath = require_helper_ssg_utils.joinPaths(outDir, routePath);
|
|
16
|
-
else if (routePath === "/") filePath = require_helper_ssg_utils.joinPaths(outDir, `index.${extension}`);
|
|
17
|
-
else if (routePath.endsWith("/")) filePath = require_helper_ssg_utils.joinPaths(outDir, routePath, `index.${extension}`);
|
|
18
|
-
else filePath = require_helper_ssg_utils.joinPaths(outDir, `${routePath}.${extension}`);
|
|
19
|
-
require_helper_ssg_utils.ensureWithinOutDir(outDir, filePath);
|
|
20
|
-
return filePath;
|
|
21
|
-
};
|
|
22
|
-
const parseResponseContent = async (response) => {
|
|
23
|
-
const contentType = response.headers.get("Content-Type");
|
|
24
|
-
try {
|
|
25
|
-
if (contentType?.includes("text") || contentType?.includes("json")) return await response.text();
|
|
26
|
-
else return await response.arrayBuffer();
|
|
27
|
-
} catch (error) {
|
|
28
|
-
throw new Error(`Error processing response: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const defaultExtensionMap = {
|
|
32
|
-
"text/html": "html",
|
|
33
|
-
"text/xml": "xml",
|
|
34
|
-
"application/xml": "xml",
|
|
35
|
-
"application/atom+xml": "xml",
|
|
36
|
-
"application/rss+xml": "xml",
|
|
37
|
-
"application/yaml": "yaml"
|
|
38
|
-
};
|
|
39
|
-
const determineExtension = (mimeType, userExtensionMap) => {
|
|
40
|
-
const extensionMap = userExtensionMap || defaultExtensionMap;
|
|
41
|
-
if (mimeType in extensionMap) return extensionMap[mimeType];
|
|
42
|
-
return require_utils_mime.getExtension(mimeType) || "html";
|
|
43
|
-
};
|
|
44
|
-
const combineBeforeRequestHooks = (hooks) => {
|
|
45
|
-
if (!Array.isArray(hooks)) return hooks;
|
|
46
|
-
return async (req) => {
|
|
47
|
-
let currentReq = req;
|
|
48
|
-
for (const hook of hooks) {
|
|
49
|
-
const result = await hook(currentReq);
|
|
50
|
-
if (result === false) return false;
|
|
51
|
-
if (result instanceof Request) currentReq = result;
|
|
52
|
-
}
|
|
53
|
-
return currentReq;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const combineAfterResponseHooks = (hooks) => {
|
|
57
|
-
if (!Array.isArray(hooks)) return hooks;
|
|
58
|
-
return async (res) => {
|
|
59
|
-
let currentRes = res;
|
|
60
|
-
for (const hook of hooks) {
|
|
61
|
-
const result = await hook(currentRes);
|
|
62
|
-
if (result === false) return false;
|
|
63
|
-
if (result instanceof Response) currentRes = result;
|
|
64
|
-
}
|
|
65
|
-
return currentRes;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
const combineAfterGenerateHooks = (hooks, fsModule, options) => {
|
|
69
|
-
if (!Array.isArray(hooks)) return hooks;
|
|
70
|
-
return async (result) => {
|
|
71
|
-
for (const hook of hooks) await hook(result, fsModule, options);
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* @experimental
|
|
76
|
-
* `fetchRoutesContent` is an experimental feature.
|
|
77
|
-
* The API might be changed.
|
|
78
|
-
*/
|
|
79
|
-
const fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, concurrency) {
|
|
80
|
-
const baseURL = "http://localhost";
|
|
81
|
-
const pool = require_utils_concurrent.createPool({ concurrency });
|
|
82
|
-
for (const route of require_helper_ssg_utils.filterStaticGenerateRoutes(app)) {
|
|
83
|
-
const thisRouteBaseURL = new URL(route.path, baseURL).toString();
|
|
84
|
-
let forGetInfoURLRequest = new Request(thisRouteBaseURL);
|
|
85
|
-
yield new Promise(async (resolveGetInfo, rejectGetInfo) => {
|
|
86
|
-
try {
|
|
87
|
-
if (beforeRequestHook) {
|
|
88
|
-
const maybeRequest = await beforeRequestHook(forGetInfoURLRequest);
|
|
89
|
-
if (!maybeRequest) {
|
|
90
|
-
resolveGetInfo(void 0);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
forGetInfoURLRequest = maybeRequest;
|
|
94
|
-
}
|
|
95
|
-
await pool.run(() => app.fetch(forGetInfoURLRequest, { [require_helper_ssg_middleware.SSG_CONTEXT]: true }));
|
|
96
|
-
if (!forGetInfoURLRequest.ssgParams) {
|
|
97
|
-
if (require_helper_ssg_utils.isDynamicRoute(route.path)) {
|
|
98
|
-
resolveGetInfo(void 0);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
forGetInfoURLRequest.ssgParams = [{}];
|
|
102
|
-
}
|
|
103
|
-
const requestInit = {
|
|
104
|
-
method: forGetInfoURLRequest.method,
|
|
105
|
-
headers: forGetInfoURLRequest.headers
|
|
106
|
-
};
|
|
107
|
-
resolveGetInfo((function* () {
|
|
108
|
-
for (const param of forGetInfoURLRequest.ssgParams) yield new Promise(async (resolveReq, rejectReq) => {
|
|
109
|
-
try {
|
|
110
|
-
const replacedUrlParam = require_client_utils.replaceUrlParam(route.path, param);
|
|
111
|
-
let response = await pool.run(() => app.request(replacedUrlParam, requestInit, { [require_helper_ssg_middleware.SSG_CONTEXT]: true }));
|
|
112
|
-
if (response.headers.get("x-hono-disable-ssg")) {
|
|
113
|
-
resolveReq(void 0);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (afterResponseHook) {
|
|
117
|
-
const maybeResponse = await afterResponseHook(response);
|
|
118
|
-
if (!maybeResponse) {
|
|
119
|
-
resolveReq(void 0);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
response = maybeResponse;
|
|
123
|
-
}
|
|
124
|
-
resolveReq({
|
|
125
|
-
routePath: replacedUrlParam,
|
|
126
|
-
mimeType: response.headers.get("Content-Type")?.split(";")[0] || DEFAULT_CONTENT_TYPE,
|
|
127
|
-
content: await parseResponseContent(response)
|
|
128
|
-
});
|
|
129
|
-
} catch (error) {
|
|
130
|
-
rejectReq(error);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
})());
|
|
134
|
-
} catch (error) {
|
|
135
|
-
rejectGetInfo(error);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* @experimental
|
|
142
|
-
* `saveContentToFile` is an experimental feature.
|
|
143
|
-
* The API might be changed.
|
|
144
|
-
*/
|
|
145
|
-
const createdDirs = /* @__PURE__ */ new Set();
|
|
146
|
-
const saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
147
|
-
const awaitedData = await data;
|
|
148
|
-
if (!awaitedData) return;
|
|
149
|
-
const { routePath, content, mimeType } = awaitedData;
|
|
150
|
-
const filePath = generateFilePath(routePath, outDir, mimeType, extensionMap);
|
|
151
|
-
const dirPath = require_helper_ssg_utils.dirname(filePath);
|
|
152
|
-
if (dirPath !== "" && !createdDirs.has(dirPath)) {
|
|
153
|
-
await fsModule.mkdir(dirPath, { recursive: true });
|
|
154
|
-
createdDirs.add(dirPath);
|
|
155
|
-
}
|
|
156
|
-
if (typeof content === "string") await fsModule.writeFile(filePath, content);
|
|
157
|
-
else if (content instanceof ArrayBuffer) await fsModule.writeFile(filePath, new Uint8Array(content));
|
|
158
|
-
return filePath;
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* @experimental
|
|
162
|
-
* `toSSG` is an experimental feature.
|
|
163
|
-
* The API might be changed.
|
|
164
|
-
*/
|
|
165
|
-
const toSSG = async (app, fs, options) => {
|
|
166
|
-
let result;
|
|
167
|
-
const getInfoPromises = [];
|
|
168
|
-
const savePromises = [];
|
|
169
|
-
const plugins = options?.plugins || [require_helper_ssg_plugins.defaultPlugin()];
|
|
170
|
-
const beforeRequestHooks = [];
|
|
171
|
-
const afterResponseHooks = [];
|
|
172
|
-
const afterGenerateHooks = [];
|
|
173
|
-
if (options?.beforeRequestHook) beforeRequestHooks.push(...Array.isArray(options.beforeRequestHook) ? options.beforeRequestHook : [options.beforeRequestHook]);
|
|
174
|
-
if (options?.afterResponseHook) afterResponseHooks.push(...Array.isArray(options.afterResponseHook) ? options.afterResponseHook : [options.afterResponseHook]);
|
|
175
|
-
if (options?.afterGenerateHook) afterGenerateHooks.push(...Array.isArray(options.afterGenerateHook) ? options.afterGenerateHook : [options.afterGenerateHook]);
|
|
176
|
-
for (const plugin of plugins) {
|
|
177
|
-
if (plugin.beforeRequestHook) beforeRequestHooks.push(...Array.isArray(plugin.beforeRequestHook) ? plugin.beforeRequestHook : [plugin.beforeRequestHook]);
|
|
178
|
-
if (plugin.afterResponseHook) afterResponseHooks.push(...Array.isArray(plugin.afterResponseHook) ? plugin.afterResponseHook : [plugin.afterResponseHook]);
|
|
179
|
-
if (plugin.afterGenerateHook) afterGenerateHooks.push(...Array.isArray(plugin.afterGenerateHook) ? plugin.afterGenerateHook : [plugin.afterGenerateHook]);
|
|
180
|
-
}
|
|
181
|
-
try {
|
|
182
|
-
const outputDir = options?.dir ?? "./static";
|
|
183
|
-
const concurrency = options?.concurrency ?? DEFAULT_CONCURRENCY;
|
|
184
|
-
const combinedBeforeRequestHook = combineBeforeRequestHooks(beforeRequestHooks.length > 0 ? beforeRequestHooks : [(req) => req]);
|
|
185
|
-
const combinedAfterResponseHook = combineAfterResponseHooks(afterResponseHooks.length > 0 ? afterResponseHooks : [(req) => req]);
|
|
186
|
-
const getInfoGen = fetchRoutesContent(app, combinedBeforeRequestHook, combinedAfterResponseHook, concurrency);
|
|
187
|
-
for (const getInfo of getInfoGen) getInfoPromises.push(getInfo.then((getContentGen) => {
|
|
188
|
-
if (!getContentGen) return;
|
|
189
|
-
for (const content of getContentGen) savePromises.push(saveContentToFile(content, fs, outputDir, options?.extensionMap).catch((e) => e));
|
|
190
|
-
}));
|
|
191
|
-
await Promise.all(getInfoPromises);
|
|
192
|
-
const files = [];
|
|
193
|
-
for (const savePromise of savePromises) {
|
|
194
|
-
const fileOrError = await savePromise;
|
|
195
|
-
if (typeof fileOrError === "string") files.push(fileOrError);
|
|
196
|
-
else if (fileOrError) throw fileOrError;
|
|
197
|
-
}
|
|
198
|
-
result = {
|
|
199
|
-
success: true,
|
|
200
|
-
files
|
|
201
|
-
};
|
|
202
|
-
} catch (error) {
|
|
203
|
-
result = {
|
|
204
|
-
success: false,
|
|
205
|
-
files: [],
|
|
206
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
if (afterGenerateHooks.length > 0) await combineAfterGenerateHooks(afterGenerateHooks, fs, options)(result, fs, options);
|
|
210
|
-
return result;
|
|
211
|
-
};
|
|
212
|
-
//#endregion
|
|
213
|
-
exports.DEFAULT_OUTPUT_DIR = DEFAULT_OUTPUT_DIR;
|
|
214
|
-
exports.combineAfterGenerateHooks = combineAfterGenerateHooks;
|
|
215
|
-
exports.combineAfterResponseHooks = combineAfterResponseHooks;
|
|
216
|
-
exports.combineBeforeRequestHooks = combineBeforeRequestHooks;
|
|
217
|
-
exports.defaultExtensionMap = defaultExtensionMap;
|
|
218
|
-
exports.fetchRoutesContent = fetchRoutesContent;
|
|
219
|
-
exports.saveContentToFile = saveContentToFile;
|
|
220
|
-
exports.toSSG = toSSG;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../router.js");
|
|
3
|
-
const require_utils_handler = require("../../utils/handler.js");
|
|
4
|
-
//#region src/helper/ssg/utils.ts
|
|
5
|
-
/**
|
|
6
|
-
* Get dirname
|
|
7
|
-
* @param path File Path
|
|
8
|
-
* @returns Parent dir path
|
|
9
|
-
*/
|
|
10
|
-
const dirname = (path) => {
|
|
11
|
-
return path.split(/[\/\\]/).slice(0, -1).join("/");
|
|
12
|
-
};
|
|
13
|
-
const normalizePath = (path) => {
|
|
14
|
-
return path.replace(/(\\)/g, "/").replace(/\/$/g, "");
|
|
15
|
-
};
|
|
16
|
-
const getUncRoot = (path) => {
|
|
17
|
-
const uncRoot = path.replace(/\\/g, "/").match(/^\/\/([^/]+)\/([^/]+)/);
|
|
18
|
-
if (uncRoot) return `${uncRoot[1].toLowerCase()}/${uncRoot[2].toLowerCase()}`;
|
|
19
|
-
};
|
|
20
|
-
const handleParent = (resultPaths) => {
|
|
21
|
-
if (resultPaths.length === 0 || resultPaths[resultPaths.length - 1] === "..") resultPaths.push("..");
|
|
22
|
-
else resultPaths.pop();
|
|
23
|
-
};
|
|
24
|
-
const handleNonDot = (path, resultPaths) => {
|
|
25
|
-
path = path.replace(/^\.(?!.)/, "");
|
|
26
|
-
if (path !== "") resultPaths.push(path);
|
|
27
|
-
};
|
|
28
|
-
const handleSegments = (paths, resultPaths) => {
|
|
29
|
-
for (const path of paths) if (path === "..") handleParent(resultPaths);
|
|
30
|
-
else handleNonDot(path, resultPaths);
|
|
31
|
-
};
|
|
32
|
-
const joinPaths = (...paths) => {
|
|
33
|
-
const hasUncPrefix = getUncRoot(paths[0]) !== void 0;
|
|
34
|
-
paths = paths.map(normalizePath);
|
|
35
|
-
const resultPaths = [];
|
|
36
|
-
handleSegments(paths.join("/").split("/"), resultPaths);
|
|
37
|
-
return (hasUncPrefix ? "//" : paths[0][0] === "/" ? "/" : "") + resultPaths.join("/");
|
|
38
|
-
};
|
|
39
|
-
const filterStaticGenerateRoutes = (hono) => {
|
|
40
|
-
return hono.routes.reduce((acc, { method, handler, path }) => {
|
|
41
|
-
const targetHandler = require_utils_handler.findTargetHandler(handler);
|
|
42
|
-
if (["GET", "ALL"].includes(method) && !require_utils_handler.isMiddleware(targetHandler)) acc.push({ path });
|
|
43
|
-
return acc;
|
|
44
|
-
}, []);
|
|
45
|
-
};
|
|
46
|
-
const isDynamicRoute = (path) => {
|
|
47
|
-
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
48
|
-
};
|
|
49
|
-
const toSegments = (path) => path === "" ? [] : path.split("/");
|
|
50
|
-
const getPathRoot = (path) => {
|
|
51
|
-
const normalizedPath = path.replace(/\\/g, "/");
|
|
52
|
-
const uncRoot = getUncRoot(normalizedPath);
|
|
53
|
-
if (uncRoot) return `unc:${uncRoot}`;
|
|
54
|
-
const driveRoot = normalizedPath.match(/^([A-Za-z]):/);
|
|
55
|
-
if (driveRoot) return `${normalizedPath[2] === "/" ? "drive-absolute" : "drive-relative"}:${driveRoot[1].toLowerCase()}`;
|
|
56
|
-
return normalizedPath.startsWith("/") ? "absolute" : "relative";
|
|
57
|
-
};
|
|
58
|
-
const ensureWithinOutDir = (outDir, filePath) => {
|
|
59
|
-
const outDirSegments = toSegments(joinPaths(outDir));
|
|
60
|
-
const filePathSegments = toSegments(joinPaths(filePath));
|
|
61
|
-
const hasMismatchedPathRoot = getPathRoot(outDir) !== getPathRoot(filePath);
|
|
62
|
-
const climbsAboveOutDir = filePathSegments[outDirSegments.length] === "..";
|
|
63
|
-
if (hasMismatchedPathRoot || filePathSegments.length <= outDirSegments.length || !outDirSegments.every((segment, i) => segment === filePathSegments[i]) || climbsAboveOutDir) throw new Error(`Path traversal detected: "${filePath}" is outside the output directory`);
|
|
64
|
-
};
|
|
65
|
-
//#endregion
|
|
66
|
-
exports.dirname = dirname;
|
|
67
|
-
exports.ensureWithinOutDir = ensureWithinOutDir;
|
|
68
|
-
exports.filterStaticGenerateRoutes = filterStaticGenerateRoutes;
|
|
69
|
-
exports.isDynamicRoute = isDynamicRoute;
|
|
70
|
-
exports.joinPaths = joinPaths;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_helper_streaming_stream = require("./stream.js");
|
|
3
|
-
const require_helper_streaming_sse = require("./sse.js");
|
|
4
|
-
const require_helper_streaming_text = require("./text.js");
|
|
5
|
-
exports.SSEStreamingApi = require_helper_streaming_sse.SSEStreamingApi;
|
|
6
|
-
exports.stream = require_helper_streaming_stream.stream;
|
|
7
|
-
exports.streamSSE = require_helper_streaming_sse.streamSSE;
|
|
8
|
-
exports.streamText = require_helper_streaming_text.streamText;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils_html = require("../../utils/html.js");
|
|
3
|
-
const require_utils_stream = require("../../utils/stream.js");
|
|
4
|
-
const require_helper_streaming_utils = require("./utils.js");
|
|
5
|
-
//#region src/helper/streaming/sse.ts
|
|
6
|
-
var SSEStreamingApi = class extends require_utils_stream.StreamingApi {
|
|
7
|
-
constructor(writable, readable) {
|
|
8
|
-
super(writable, readable);
|
|
9
|
-
}
|
|
10
|
-
async writeSSE(message) {
|
|
11
|
-
const dataLines = (await require_utils_html.resolveCallback(message.data, require_utils_html.HtmlEscapedCallbackPhase.Stringify, false, {})).split(/\r\n|\r|\n/).map((line) => {
|
|
12
|
-
return `data: ${line}`;
|
|
13
|
-
}).join("\n");
|
|
14
|
-
for (const key of ["event", "id"]) {
|
|
15
|
-
const value = message[key];
|
|
16
|
-
if (value && /[\r\n]/.test(value)) throw new Error(`${key} must not contain "\\r" or "\\n"`);
|
|
17
|
-
}
|
|
18
|
-
const sseData = [
|
|
19
|
-
message.event && `event: ${message.event}`,
|
|
20
|
-
dataLines,
|
|
21
|
-
message.id !== void 0 && `id: ${message.id}`,
|
|
22
|
-
message.retry !== void 0 && `retry: ${message.retry}`
|
|
23
|
-
].filter(Boolean).join("\n") + "\n\n";
|
|
24
|
-
await this.write(sseData);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const run = async (stream, cb, onError) => {
|
|
28
|
-
try {
|
|
29
|
-
await cb(stream);
|
|
30
|
-
} catch (e) {
|
|
31
|
-
if (e instanceof Error && onError) {
|
|
32
|
-
await onError(e, stream);
|
|
33
|
-
await stream.writeSSE({
|
|
34
|
-
event: "error",
|
|
35
|
-
data: e.message
|
|
36
|
-
});
|
|
37
|
-
} else console.error(e);
|
|
38
|
-
} finally {
|
|
39
|
-
stream.close();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const contextStash = /* @__PURE__ */ new WeakMap();
|
|
43
|
-
const streamSSE = (c, cb, onError) => {
|
|
44
|
-
const { readable, writable } = new TransformStream();
|
|
45
|
-
const stream = new SSEStreamingApi(writable, readable);
|
|
46
|
-
if (require_helper_streaming_utils.isOldBunVersion()) c.req.raw.signal.addEventListener("abort", () => {
|
|
47
|
-
if (!stream.closed) stream.abort();
|
|
48
|
-
});
|
|
49
|
-
contextStash.set(stream.responseReadable, c);
|
|
50
|
-
c.header("Transfer-Encoding", "chunked");
|
|
51
|
-
c.header("Content-Type", "text/event-stream");
|
|
52
|
-
c.header("Cache-Control", "no-cache");
|
|
53
|
-
c.header("Connection", "keep-alive");
|
|
54
|
-
run(stream, cb, onError);
|
|
55
|
-
return c.newResponse(stream.responseReadable);
|
|
56
|
-
};
|
|
57
|
-
//#endregion
|
|
58
|
-
exports.SSEStreamingApi = SSEStreamingApi;
|
|
59
|
-
exports.streamSSE = streamSSE;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils_stream = require("../../utils/stream.js");
|
|
3
|
-
const require_helper_streaming_utils = require("./utils.js");
|
|
4
|
-
//#region src/helper/streaming/stream.ts
|
|
5
|
-
const contextStash = /* @__PURE__ */ new WeakMap();
|
|
6
|
-
const stream = (c, cb, onError) => {
|
|
7
|
-
const { readable, writable } = new TransformStream();
|
|
8
|
-
const stream = new require_utils_stream.StreamingApi(writable, readable);
|
|
9
|
-
if (require_helper_streaming_utils.isOldBunVersion()) c.req.raw.signal.addEventListener("abort", () => {
|
|
10
|
-
if (!stream.closed) stream.abort();
|
|
11
|
-
});
|
|
12
|
-
contextStash.set(stream.responseReadable, c);
|
|
13
|
-
(async () => {
|
|
14
|
-
try {
|
|
15
|
-
await cb(stream);
|
|
16
|
-
} catch (e) {
|
|
17
|
-
if (e === void 0) {} else if (e instanceof Error && onError) await onError(e, stream);
|
|
18
|
-
else console.error(e);
|
|
19
|
-
} finally {
|
|
20
|
-
stream.close();
|
|
21
|
-
}
|
|
22
|
-
})();
|
|
23
|
-
return c.newResponse(stream.responseReadable);
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
26
|
-
exports.stream = stream;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_context = require("../../context.js");
|
|
3
|
-
const require_helper_streaming_stream = require("./stream.js");
|
|
4
|
-
//#region src/helper/streaming/text.ts
|
|
5
|
-
const streamText = (c, cb, onError) => {
|
|
6
|
-
c.header("Content-Type", require_context.TEXT_PLAIN);
|
|
7
|
-
c.header("X-Content-Type-Options", "nosniff");
|
|
8
|
-
c.header("Transfer-Encoding", "chunked");
|
|
9
|
-
return require_helper_streaming_stream.stream(c, cb, onError);
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
12
|
-
exports.streamText = streamText;
|