acrylblends 0.8.1 → 0.9.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/dist/index.d.ts +2 -0
- package/dist/index.js +83 -7
- package/dist/index.js.map +1 -1
- package/lib/audit-BXnYsLge.d.ts +58 -0
- package/lib/cell-ChU41DZD.d.ts +32 -0
- package/lib/client-modules-CLvWOjbd.js +267 -0
- package/lib/connection-ZLEso7XL.d.ts +25 -0
- package/lib/conninfo.d.ts +1 -23
- package/lib/cordis/db-sqlite.d.ts +56 -0
- package/lib/cordis/db-sqlite.js +58 -0
- package/lib/cordis/db.d.ts +8 -0
- package/lib/cordis/db.js +1 -0
- package/lib/cordis/door.d.ts +159 -0
- package/lib/cordis/door.js +757 -0
- package/lib/cordis/inspect.d.ts +77 -0
- package/lib/cordis/inspect.js +149 -0
- package/lib/cordis/kv-db.d.ts +16 -0
- package/lib/cordis/kv-db.js +18 -0
- package/lib/cordis/kv-json.d.ts +16 -0
- package/lib/cordis/kv-json.js +44 -0
- package/lib/cordis/kv.d.ts +8 -0
- package/lib/cordis/kv.js +1 -0
- package/lib/cordis/node-server.d.ts +45 -0
- package/lib/cordis/node-server.js +93 -0
- package/lib/cordis/router-http.d.ts +56 -0
- package/lib/cordis/router-http.js +117 -0
- package/lib/cordis/router.d.ts +8 -0
- package/lib/cordis/router.js +7 -0
- package/lib/cordis/state/react.d.ts +6 -0
- package/lib/cordis/state/react.js +11 -0
- package/lib/cordis/state.d.ts +33 -0
- package/lib/cordis/state.js +163 -0
- package/lib/core-CaY8XDZ6.js +19 -0
- package/lib/database-DBHdwefi.d.ts +44 -0
- package/lib/db/conformance.d.ts +11 -0
- package/lib/db/conformance.js +267 -0
- package/lib/db/sqlite.d.ts +1 -1
- package/lib/db/sqlite.js +1 -196
- package/lib/db.d.ts +2 -1
- package/lib/{src-0hI7M7cN.js → deprecated-BP4fPt38.js} +0 -17
- package/lib/door/host.d.ts +24 -0
- package/lib/door/host.js +2 -0
- package/lib/door/page.d.ts +105 -0
- package/lib/door/page.js +1030 -0
- package/lib/door/protocol.d.ts +2 -0
- package/lib/door/protocol.js +197 -0
- package/lib/error-t4N2js2I.d.ts +8 -0
- package/lib/etag-DaKMOjty.js +135 -0
- package/lib/etag.js +1 -134
- package/lib/helpers-CvTauQT5.js +5 -0
- package/lib/http-exception-kpGJkmpi.d.ts +57 -0
- package/lib/http-exception.d.ts +1 -56
- package/lib/{index-BLTYsyc1.d.ts → index-BnGgRKTv.d.ts} +3 -39
- package/lib/index-BqVQkTnu.d.ts +98 -0
- package/lib/index-Dmst2QCQ.d.ts +44 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/jwk-LkzeoaU8.js +117 -0
- package/lib/jwk.js +1 -116
- package/lib/jwt-CskdhEW9.js +115 -0
- package/lib/jwt.js +2 -114
- package/lib/kv/conformance.d.ts +13 -0
- package/lib/kv/conformance.js +301 -0
- package/lib/kv/db.d.ts +2 -2
- package/lib/kv/json.d.ts +1 -1
- package/lib/kv-9f-AlRKN.d.ts +39 -0
- package/lib/kv.d.ts +2 -1
- package/lib/language-D9a4zqvn.js +198 -0
- package/lib/language.js +1 -197
- package/lib/middleware-CPQ8himN.js +12 -0
- package/lib/node-server/serve-static.d.ts +0 -1
- package/lib/node-server/serve-static.js +1 -1
- package/lib/node-server.d.ts +1 -7
- package/lib/node-server.js +3 -1586
- package/lib/open-CMhnJODn.js +197 -0
- package/lib/protocol-BizVt4J6.d.ts +144 -0
- package/lib/request-id-CKVvHOO1.js +34 -0
- package/lib/request-id.js +1 -33
- package/lib/secure-headers-mP3j6Hm6.js +163 -0
- package/lib/secure-headers.js +1 -162
- package/lib/{serve-static-B849HlX2.js → serve-static-3uo_9rjF.js} +1 -4
- package/lib/server-DvgMGtzo.js +1323 -0
- package/lib/snapshot-text-D3NspDyT.js +338 -0
- package/lib/src-CwABFr6r.js +328 -0
- package/lib/timeout.d.ts +1 -1
- package/lib/timing-Cky7C1Jf.js +183 -0
- package/lib/timing.js +1 -182
- package/package.json +89 -1
- package/plugins/acryl-db/plugin.json +6 -1
- package/plugins/acryl-db-sqlite/plugin.json +4 -0
- package/plugins/acryl-db-sqlite/src/facade/node.ts +1 -1
- package/plugins/acryl-db-sqlite/src/index.ts +2 -2
- package/plugins/acryl-db-sqlite/src/open.ts +2 -2
- package/plugins/acryl-door/plugin.json +4 -1
- package/plugins/acryl-door/src/host/http.ts +2 -2
- package/plugins/acryl-door/src/host/mcp-routes.ts +1 -1
- package/plugins/acryl-door/src/host/operator-routes.ts +1 -1
- package/plugins/acryl-door/src/host/page-routes.ts +3 -3
- package/plugins/acryl-door/src/index.ts +2 -2
- package/plugins/acryl-inspect/plugin.json +4 -1
- package/plugins/acryl-inspect/src/service.ts +2 -2
- package/plugins/acryl-kv/plugin.json +6 -1
- package/plugins/acryl-kv-db/plugin.json +4 -0
- package/plugins/acryl-kv-db/src/index.ts +1 -1
- package/plugins/acryl-kv-db/src/open.ts +3 -3
- package/plugins/acryl-kv-json/plugin.json +4 -0
- package/plugins/acryl-kv-json/src/index.ts +1 -1
- package/plugins/acryl-kv-json/src/open.ts +2 -2
- package/plugins/acryl-node-server/plugin.json +5 -1
- package/plugins/acryl-node-server/src/adapter/conninfo.ts +1 -1
- package/plugins/acryl-node-server/src/adapter/early-hints.ts +1 -1
- package/plugins/acryl-node-server/src/adapter/serve-static.ts +2 -2
- package/plugins/acryl-node-server/src/adapter/websocket.ts +2 -2
- package/plugins/acryl-node-server/src/client-modules.ts +2 -2
- package/plugins/acryl-node-server/src/index.ts +1 -1
- package/plugins/acryl-router/plugin.json +11 -1
- package/plugins/acryl-router/src/connection.d.ts +25 -0
- package/plugins/acryl-router/src/core/app-base.d.ts +215 -0
- package/plugins/acryl-router/src/core/app.d.ts +19 -0
- package/plugins/acryl-router/src/core/client/client.d.ts +4 -0
- package/plugins/acryl-router/src/core/client/fetch-result-please.d.ts +35 -0
- package/plugins/acryl-router/src/core/client/index.d.ts +7 -0
- package/plugins/acryl-router/src/core/client/types.d.ts +229 -0
- package/plugins/acryl-router/src/core/client/utils.d.ts +18 -0
- package/plugins/acryl-router/src/core/compose.d.ts +14 -0
- package/plugins/acryl-router/src/core/context.d.ts +443 -0
- package/plugins/acryl-router/src/core/helper/accepts/accepts.d.ts +30 -0
- package/plugins/acryl-router/src/core/helper/accepts/index.d.ts +5 -0
- package/plugins/acryl-router/src/core/helper/conninfo/index.d.ts +5 -0
- package/plugins/acryl-router/src/core/helper/conninfo/types.d.ts +36 -0
- package/plugins/acryl-router/src/core/helper/cookie/index.d.ts +25 -0
- package/plugins/acryl-router/src/core/helper/css/common.d.ts +59 -0
- package/plugins/acryl-router/src/core/helper/css/index.d.ts +80 -0
- package/plugins/acryl-router/src/core/helper/dev/index.d.ts +20 -0
- package/plugins/acryl-router/src/core/helper/factory/index.d.ts +82 -0
- package/plugins/acryl-router/src/core/helper/html/index.d.ts +8 -0
- package/plugins/acryl-router/src/core/helper/proxy/index.d.ts +73 -0
- package/plugins/acryl-router/src/core/helper/route/index.d.ts +75 -0
- package/plugins/acryl-router/src/core/helper/ssg/index.d.ts +7 -0
- package/plugins/acryl-router/src/core/helper/ssg/middleware.d.ts +44 -0
- package/plugins/acryl-router/src/core/helper/ssg/plugins.d.ts +27 -0
- package/plugins/acryl-router/src/core/helper/ssg/ssg.d.ts +91 -0
- package/plugins/acryl-router/src/core/helper/ssg/utils.d.ts +16 -0
- package/plugins/acryl-router/src/core/helper/streaming/index.d.ts +8 -0
- package/plugins/acryl-router/src/core/helper/streaming/sse.d.ts +13 -0
- package/plugins/acryl-router/src/core/helper/streaming/stream.d.ts +3 -0
- package/plugins/acryl-router/src/core/helper/streaming/text.d.ts +3 -0
- package/plugins/acryl-router/src/core/helper/streaming/utils.d.ts +1 -0
- package/plugins/acryl-router/src/core/helper/testing/index.d.ts +13 -0
- package/plugins/acryl-router/src/core/helper/websocket/index.d.ts +70 -0
- package/plugins/acryl-router/src/core/http-exception.d.ts +58 -0
- package/plugins/acryl-router/src/core/index.d.ts +37 -0
- package/plugins/acryl-router/src/core/jsx/base.d.ts +61 -0
- package/plugins/acryl-router/src/core/jsx/children.d.ts +9 -0
- package/plugins/acryl-router/src/core/jsx/components.d.ts +15 -0
- package/plugins/acryl-router/src/core/jsx/constants.d.ts +6 -0
- package/plugins/acryl-router/src/core/jsx/context.d.ts +51 -0
- package/plugins/acryl-router/src/core/jsx/dom/components.d.ts +10 -0
- package/plugins/acryl-router/src/core/jsx/dom/context.d.ts +3 -0
- package/plugins/acryl-router/src/core/jsx/dom/css.d.ts +83 -0
- package/plugins/acryl-router/src/core/jsx/dom/hooks/index.d.ts +39 -0
- package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.d.ts +16 -0
- package/plugins/acryl-router/src/core/jsx/dom/jsx-dev-runtime.d.ts +8 -0
- package/plugins/acryl-router/src/core/jsx/dom/jsx-runtime.d.ts +7 -0
- package/plugins/acryl-router/src/core/jsx/dom/render.d.ts +73 -0
- package/plugins/acryl-router/src/core/jsx/dom/utils.d.ts +1 -0
- package/plugins/acryl-router/src/core/jsx/hooks/index.d.ts +47 -0
- package/plugins/acryl-router/src/core/jsx/index.d.ts +76 -0
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/common.d.ts +6 -0
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.d.ts +13 -0
- package/plugins/acryl-router/src/core/jsx/intrinsic-elements.d.ts +735 -0
- package/plugins/acryl-router/src/core/jsx/streaming.d.ts +36 -0
- package/plugins/acryl-router/src/core/jsx/types.d.ts +36 -0
- package/plugins/acryl-router/src/core/jsx/utils.d.ts +4 -0
- package/plugins/acryl-router/src/core/request/constants.d.ts +1 -0
- package/plugins/acryl-router/src/core/request.d.ts +306 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/index.d.ts +6 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/matcher.d.ts +7 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/node.d.ts +13 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.d.ts +17 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.d.ts +11 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/trie.d.ts +8 -0
- package/plugins/acryl-router/src/core/router/smart-router/index.d.ts +5 -0
- package/plugins/acryl-router/src/core/router/smart-router/router.d.ts +11 -0
- package/plugins/acryl-router/src/core/router/trie-router/index.d.ts +5 -0
- package/plugins/acryl-router/src/core/router/trie-router/node.d.ts +6 -0
- package/plugins/acryl-router/src/core/router/trie-router/router.d.ts +7 -0
- package/plugins/acryl-router/src/core/router/utils.d.ts +1 -0
- package/plugins/acryl-router/src/core/router.d.ts +97 -0
- package/plugins/acryl-router/src/core/types.d.ts +573 -0
- package/plugins/acryl-router/src/core/utils/accept.d.ts +6 -0
- package/plugins/acryl-router/src/core/utils/body.d.ts +79 -0
- package/plugins/acryl-router/src/core/utils/buffer.d.ts +17 -0
- package/plugins/acryl-router/src/core/utils/color.d.ts +21 -0
- package/plugins/acryl-router/src/core/utils/concurrent.d.ts +11 -0
- package/plugins/acryl-router/src/core/utils/constants.d.ts +4 -0
- package/plugins/acryl-router/src/core/utils/cookie.d.ts +41 -0
- package/plugins/acryl-router/src/core/utils/crypto.d.ts +15 -0
- package/plugins/acryl-router/src/core/utils/handler.d.ts +6 -0
- package/plugins/acryl-router/src/core/utils/headers.d.ts +8 -0
- package/plugins/acryl-router/src/core/utils/html.d.ts +44 -0
- package/plugins/acryl-router/src/core/utils/http-status.d.ts +32 -0
- package/plugins/acryl-router/src/core/utils/mime.d.ts +70 -0
- package/plugins/acryl-router/src/core/utils/stream.d.ts +31 -0
- package/plugins/acryl-router/src/core/utils/types.d.ts +128 -0
- package/plugins/acryl-router/src/core/utils/url.d.ts +44 -0
- package/plugins/acryl-router/src/core/validator/index.d.ts +7 -0
- package/plugins/acryl-router/src/core/validator/utils.d.ts +29 -0
- package/plugins/acryl-router/src/core/validator/validator.d.ts +16 -0
- package/plugins/acryl-router/src/helpers/index.d.ts +17 -0
- package/plugins/acryl-router/src/helpers/schema-validator.d.ts +54 -0
- package/plugins/acryl-router-http/plugin.json +4 -1
- package/plugins/acryl-router-http/src/index.ts +1 -1
- package/plugins/acryl-state/plugin.json +5 -1
- package/plugins/acryl-state/src/service.ts +3 -3
- package/plugins/tsconfig.json +32 -20
- package/docs/framework/UPSTREAM.md +0 -3
- package/docs/framework/upstream.json +0 -9
- package/lib/index-D4FAsBZu.d.ts +0 -85
- package/plugins/acryl-db/upstream.json +0 -18
- package/plugins/acryl-db-sqlite/upstream.json +0 -21
- package/plugins/acryl-door/upstream.json +0 -28
- package/plugins/acryl-inspect/upstream.json +0 -18
- package/plugins/acryl-kv/upstream.json +0 -18
- package/plugins/acryl-kv-db/upstream.json +0 -21
- package/plugins/acryl-kv-json/upstream.json +0 -22
- package/plugins/acryl-node-server/upstream.json +0 -21
- package/plugins/acryl-router/upstream.json +0 -20
- package/plugins/acryl-router-http/upstream.json +0 -22
- package/plugins/acryl-state/NOTICE +0 -30
- package/plugins/acryl-state/upstream.json +0 -22
- package/plugins/desktop/upstream.json +0 -12
- package/plugins/desktop-web/upstream.json +0 -12
- package/templates/todo/upstream.json +0 -12
- /package/lib/{index-CTy4N7ng.d.ts → deprecated-CTy4N7ng.d.ts} +0 -0
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* code point in the end, whatever collation the database sorts with.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type { Db } from '
|
|
12
|
-
import { checkKey, codePoints, compareKeys, decodeValue, encodeValue, type Kv, runChange } from '
|
|
11
|
+
import type { Db } from 'acryl-db'
|
|
12
|
+
import { checkKey, codePoints, compareKeys, decodeValue, encodeValue, type Kv, runChange } from 'acryl-kv'
|
|
13
13
|
|
|
14
|
-
export type { Kv } from '
|
|
14
|
+
export type { Kv } from 'acryl-kv'
|
|
15
15
|
|
|
16
16
|
export interface KvOnDbOptions {
|
|
17
17
|
/** The table that holds the documents. Defaults to `kv`; a plain SQL identifier. */
|
|
@@ -10,7 +10,7 @@ import { dirname, isAbsolute, join, resolve } from 'node:path'
|
|
|
10
10
|
import { fileURLToPath } from 'node:url'
|
|
11
11
|
import type { Context } from '@deepseek-ai/cordis'
|
|
12
12
|
import z from '@deepseek-ai/schemastery'
|
|
13
|
-
import { KV_SERVICE } from '
|
|
13
|
+
import { KV_SERVICE } from 'acryl-kv'
|
|
14
14
|
import { openKv } from './open.ts'
|
|
15
15
|
|
|
16
16
|
export { openKv, type OpenKvOptions } from './open.ts'
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
import { mkdir, open, readdir, readFile, rename, rm } from 'node:fs/promises'
|
|
15
15
|
import { basename, dirname, join, resolve } from 'node:path'
|
|
16
|
-
import { checkKey, compareKeys, decodeValue, encodeValue, type Kv, type KvOpened, runChange } from '
|
|
16
|
+
import { checkKey, compareKeys, decodeValue, encodeValue, type Kv, type KvOpened, runChange } from 'acryl-kv'
|
|
17
17
|
|
|
18
|
-
export type { Kv, KvOpened } from '
|
|
18
|
+
export type { Kv, KvOpened } from 'acryl-kv'
|
|
19
19
|
|
|
20
20
|
export interface OpenKvOptions {
|
|
21
21
|
/** The JSON file; its folder is created if missing. */
|
|
@@ -9,5 +9,9 @@
|
|
|
9
9
|
"@deepseek-ai/schemastery": "3.18.4"
|
|
10
10
|
},
|
|
11
11
|
"mount": "root.plugin(router); root.plugin(nodeServer, { port: 3000, hostname: '127.0.0.1', scan: 20 }); ctx.nodeServer.url",
|
|
12
|
-
"omit": ["**/*.test.*", "**/*.case.ts"]
|
|
12
|
+
"omit": ["**/*.test.*", "**/*.case.ts"],
|
|
13
|
+
"entries": {
|
|
14
|
+
"": "src/index.ts",
|
|
15
|
+
"/client-modules": "src/client-modules.ts"
|
|
16
|
+
}
|
|
13
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Context, Env, MiddlewareHandler } from '
|
|
2
|
-
import { getMimeType } from '
|
|
1
|
+
import type { Context, Env, MiddlewareHandler } from 'acryl-router'
|
|
2
|
+
import { getMimeType } from 'acryl-router/helpers'
|
|
3
3
|
import type { Stats } from 'node:fs'
|
|
4
4
|
import { createReadStream, statSync, existsSync } from 'node:fs'
|
|
5
5
|
import { join } from 'node:path'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UpgradeWebSocket, WSContext } from '
|
|
2
|
-
import { defineWebSocketHelper } from '
|
|
1
|
+
import type { UpgradeWebSocket, WSContext } from 'acryl-router/helpers'
|
|
2
|
+
import { defineWebSocketHelper } from 'acryl-router/helpers'
|
|
3
3
|
import type { IncomingMessage } from 'node:http'
|
|
4
4
|
import { STATUS_CODES } from 'node:http'
|
|
5
5
|
import type { Duplex } from 'node:stream'
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
import { copyFileSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs'
|
|
13
13
|
import { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
14
14
|
import { fileURLToPath } from 'node:url'
|
|
15
|
-
import { Acryl } from '
|
|
16
|
-
import { basePath } from '
|
|
15
|
+
import { Acryl } from 'acryl-router'
|
|
16
|
+
import { basePath } from 'acryl-router/helpers'
|
|
17
17
|
import { MissingTypeScriptError, compileModule } from './transpile.ts'
|
|
18
18
|
|
|
19
19
|
/** The folder the three browser files are served from, below the app's mount. A source folder of this name is not served. */
|
|
@@ -14,7 +14,7 @@ import type { Server } from 'node:http'
|
|
|
14
14
|
import type { AddressInfo } from 'node:net'
|
|
15
15
|
import { Context, Service } from '@deepseek-ai/cordis'
|
|
16
16
|
import z from '@deepseek-ai/schemastery'
|
|
17
|
-
import type {} from '
|
|
17
|
+
import type {} from 'acryl-router'
|
|
18
18
|
import { Request as AdapterRequest } from './adapter/request.ts'
|
|
19
19
|
import { createAdaptorServer } from './adapter/server.ts'
|
|
20
20
|
|
|
@@ -9,5 +9,15 @@
|
|
|
9
9
|
"@deepseek-ai/schemastery": "3.18.4"
|
|
10
10
|
},
|
|
11
11
|
"mount": "root.plugin(router); then in your own plugin: inject: ['router'] and ctx.router.get('/path', (c) => c.json({ ok: true }))",
|
|
12
|
-
"omit": ["**/*.test.*", "**/*.case.ts"]
|
|
12
|
+
"omit": ["**/*.test.*", "**/*.case.ts"],
|
|
13
|
+
"entries": {
|
|
14
|
+
"": "src/index.ts",
|
|
15
|
+
"/middleware": "src/middleware/index.ts",
|
|
16
|
+
"/helpers": "src/helpers/index.ts",
|
|
17
|
+
"/client": "src/client.ts",
|
|
18
|
+
"/jsx": "src/core/jsx/index.ts",
|
|
19
|
+
"/jsx/jsx-runtime": "src/core/jsx/jsx-runtime.ts",
|
|
20
|
+
"/jsx/jsx-dev-runtime": "src/core/jsx/jsx-dev-runtime.ts",
|
|
21
|
+
"/jsx/streaming": "src/core/jsx/streaming.ts"
|
|
22
|
+
}
|
|
13
23
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport facts: who is on the other end of the socket and which local port it reached. The caller of `router.fetch` supplies them
|
|
3
|
+
* (an HTTP adapter passes the socket's peer address and real port); they travel in `c.env.connection`, beside the request and never in a header.
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from './core/context.ts';
|
|
6
|
+
import type { GetConnInfo } from './core/helper/conninfo/types.ts';
|
|
7
|
+
/** An in-process caller (the terminal UI, a test) passes nothing, so a handler that needs a trusted peer must refuse an empty one. */
|
|
8
|
+
export interface ConnectionInfo {
|
|
9
|
+
/** The peer address of the socket, when the request came over one (for example `127.0.0.1`). */
|
|
10
|
+
readonly remoteAddress?: string | undefined;
|
|
11
|
+
/** The local port the socket is connected to, the real one a `Host` header should be checked against. */
|
|
12
|
+
readonly localPort?: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** What the router puts in `c.env`. */
|
|
15
|
+
export interface RouterBindings {
|
|
16
|
+
readonly connection: ConnectionInfo;
|
|
17
|
+
}
|
|
18
|
+
/** The `Env` of an `Acryl` that wants `c.env.connection` typed: `new Acryl<RouterEnv>()`. */
|
|
19
|
+
export interface RouterEnv {
|
|
20
|
+
Bindings: RouterBindings;
|
|
21
|
+
}
|
|
22
|
+
/** The transport facts of this request; empty for an in-process call or an `Acryl` run outside the router. */
|
|
23
|
+
export declare function connectionOf(c: Context): ConnectionInfo;
|
|
24
|
+
/** The peer in the core's conninfo shape, for middleware written against it (for example `ipRestriction`). */
|
|
25
|
+
export declare const getConnInfo: GetConnInfo;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* This module is the base module for the Acryl object.
|
|
4
|
+
*/
|
|
5
|
+
import { Context } from './context.ts';
|
|
6
|
+
import type { ExecutionContext } from './context.ts';
|
|
7
|
+
import type { Router } from './router.ts';
|
|
8
|
+
import type { Env, ErrorHandler, H, HandlerInterface, MergePath, MergeSchemaPath, MiddlewareHandlerInterface, NotFoundHandler, OnHandlerInterface, RouterRoute, Schema } from './types.ts';
|
|
9
|
+
type GetPath<E extends Env> = (request: Request, options?: {
|
|
10
|
+
env?: E['Bindings'];
|
|
11
|
+
}) => string;
|
|
12
|
+
export type AcrylOptions<E extends Env> = {
|
|
13
|
+
/**
|
|
14
|
+
* `router` option specifies which router to use.
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const app = new Acryl({ router: new RegExpRouter() })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
router?: Router<[H, RouterRoute]>;
|
|
23
|
+
} & ({
|
|
24
|
+
/**
|
|
25
|
+
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
|
|
26
|
+
*
|
|
27
|
+
*
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
strict?: true;
|
|
31
|
+
/**
|
|
32
|
+
* `getPath` can handle the host header value.
|
|
33
|
+
*
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const app = new Acryl({
|
|
38
|
+
* getPath: (req) =>
|
|
39
|
+
* '/' + req.headers.get('host') + req.url.replace(/^https?:\/\/[^/]+(\/[^?]*)/, '$1'),
|
|
40
|
+
* })
|
|
41
|
+
*
|
|
42
|
+
* app.get('/www1.example.com/hello', () => c.text('hello www1'))
|
|
43
|
+
*
|
|
44
|
+
* // A following request will match the route:
|
|
45
|
+
* // new Request('http://www1.example.com/hello', {
|
|
46
|
+
* // headers: { host: 'www1.example.com' },
|
|
47
|
+
* // })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
getPath?: GetPath<E>;
|
|
51
|
+
} | {
|
|
52
|
+
/**
|
|
53
|
+
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
|
|
54
|
+
* When `strict` is `false`, `getPath` is not used.
|
|
55
|
+
*
|
|
56
|
+
*
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
strict: false;
|
|
60
|
+
getPath?: never;
|
|
61
|
+
});
|
|
62
|
+
type MountOptionHandler = (c: Context) => unknown;
|
|
63
|
+
type MountReplaceRequest = (originalRequest: Request) => Request;
|
|
64
|
+
type MountOptions = MountOptionHandler | {
|
|
65
|
+
optionHandler?: MountOptionHandler;
|
|
66
|
+
replaceRequest?: MountReplaceRequest | false;
|
|
67
|
+
};
|
|
68
|
+
declare class Acryl<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/', CurrentPath extends string = BasePath> {
|
|
69
|
+
#private;
|
|
70
|
+
get: HandlerInterface<E, 'get', S, BasePath, CurrentPath>;
|
|
71
|
+
post: HandlerInterface<E, 'post', S, BasePath, CurrentPath>;
|
|
72
|
+
put: HandlerInterface<E, 'put', S, BasePath, CurrentPath>;
|
|
73
|
+
delete: HandlerInterface<E, 'delete', S, BasePath, CurrentPath>;
|
|
74
|
+
options: HandlerInterface<E, 'options', S, BasePath, CurrentPath>;
|
|
75
|
+
patch: HandlerInterface<E, 'patch', S, BasePath, CurrentPath>;
|
|
76
|
+
query: HandlerInterface<E, 'query', S, BasePath, CurrentPath>;
|
|
77
|
+
all: HandlerInterface<E, 'all', S, BasePath, CurrentPath>;
|
|
78
|
+
on: OnHandlerInterface<E, S, BasePath>;
|
|
79
|
+
use: MiddlewareHandlerInterface<E, S, BasePath>;
|
|
80
|
+
router: Router<[H, RouterRoute]>;
|
|
81
|
+
readonly getPath: GetPath<E>;
|
|
82
|
+
private _basePath;
|
|
83
|
+
routes: RouterRoute[];
|
|
84
|
+
constructor(options?: AcrylOptions<E>);
|
|
85
|
+
private errorHandler;
|
|
86
|
+
/**
|
|
87
|
+
* `.route()` allows grouping other Acryl instance in routes.
|
|
88
|
+
*
|
|
89
|
+
*
|
|
90
|
+
* @param {string} path - base Path
|
|
91
|
+
* @param {Acryl} app - other Acryl instance
|
|
92
|
+
* @returns {Acryl} routed Acryl instance
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const app = new Acryl()
|
|
97
|
+
* const app2 = new Acryl()
|
|
98
|
+
*
|
|
99
|
+
* app2.get("/user", (c) => c.text("user"))
|
|
100
|
+
* app.route("/api", app2) // GET /api/user
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string, SubCurrentPath extends string>(path: SubPath, app: Acryl<SubEnv, SubSchema, SubBasePath, SubCurrentPath>): Acryl<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> | S, BasePath, CurrentPath>;
|
|
104
|
+
/**
|
|
105
|
+
* `.basePath()` allows base paths to be specified.
|
|
106
|
+
*
|
|
107
|
+
*
|
|
108
|
+
* @param {string} path - base Path
|
|
109
|
+
* @returns {Acryl} changed Acryl instance
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const api = new Acryl().basePath('/api')
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
basePath<SubPath extends string>(path: SubPath): Acryl<E, S, MergePath<BasePath, SubPath>, MergePath<BasePath, SubPath>>;
|
|
117
|
+
/**
|
|
118
|
+
* `.onError()` handles an error and returns a customized Response.
|
|
119
|
+
*
|
|
120
|
+
*
|
|
121
|
+
* @param {ErrorHandler} handler - request Handler for error
|
|
122
|
+
* @returns {Acryl} changed Acryl instance
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* app.onError((err, c) => {
|
|
127
|
+
* console.error(`${err}`)
|
|
128
|
+
* return c.text('Custom Error Message', 500)
|
|
129
|
+
* })
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
onError: (handler: ErrorHandler<E>) => Acryl<E, S, BasePath, CurrentPath>;
|
|
133
|
+
/**
|
|
134
|
+
* `.notFound()` allows you to customize a Not Found Response.
|
|
135
|
+
*
|
|
136
|
+
*
|
|
137
|
+
* @param {NotFoundHandler} handler - request handler for not-found
|
|
138
|
+
* @returns {Acryl} changed Acryl instance
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* app.notFound((c) => {
|
|
143
|
+
* return c.text('Custom 404 Message', 404)
|
|
144
|
+
* })
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
notFound: (handler: NotFoundHandler<E>) => Acryl<E, S, BasePath, CurrentPath>;
|
|
148
|
+
/**
|
|
149
|
+
* `.mount()` allows you to mount applications built with other frameworks into your Acryl application.
|
|
150
|
+
*
|
|
151
|
+
* @deprecated Use `mount()` from `acryl-router/mount` instead. `.mount()` will be removed in v5.
|
|
152
|
+
*
|
|
153
|
+
*
|
|
154
|
+
* @param {string} path - base Path
|
|
155
|
+
* @param {Function} applicationHandler - other Request Handler
|
|
156
|
+
* @param {MountOptions} [options] - options of `.mount()`
|
|
157
|
+
* @returns {Acryl} mounted Acryl instance
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* import { Router as IttyRouter } from 'itty-router'
|
|
162
|
+
* import { Acryl } from 'acrylblends'
|
|
163
|
+
* // Create itty-router application
|
|
164
|
+
* const ittyRouter = IttyRouter()
|
|
165
|
+
* // GET /itty-router/hello
|
|
166
|
+
* ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
|
|
167
|
+
*
|
|
168
|
+
* const app = new Acryl()
|
|
169
|
+
* app.mount('/itty-router', ittyRouter.handle)
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const app = new Acryl()
|
|
175
|
+
* // Send the request to another application without modification.
|
|
176
|
+
* app.mount('/app', anotherApp, {
|
|
177
|
+
* replaceRequest: (req) => req,
|
|
178
|
+
* })
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Acryl<E, S, BasePath, CurrentPath>;
|
|
182
|
+
/**
|
|
183
|
+
* `.fetch()` will be entry point of your app.
|
|
184
|
+
*
|
|
185
|
+
*
|
|
186
|
+
* @param {Request} request - request Object of request
|
|
187
|
+
* @param {Env} env - env Object
|
|
188
|
+
* @param {ExecutionContext} executionCtx - context of execution
|
|
189
|
+
* @returns {Response | Promise<Response>} response of request
|
|
190
|
+
*
|
|
191
|
+
*/
|
|
192
|
+
fetch: (request: Request, env?: E['Bindings'] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
|
|
193
|
+
/**
|
|
194
|
+
* `.request()` is a useful method for testing.
|
|
195
|
+
* You can pass a URL or pathname to send a GET request.
|
|
196
|
+
* app will return a Response object.
|
|
197
|
+
* ```ts
|
|
198
|
+
* test('GET /hello is ok', async () => {
|
|
199
|
+
* const res = await app.request('/hello')
|
|
200
|
+
* expect(res.status).toBe(200)
|
|
201
|
+
* })
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
request: (input: Request | string | URL, requestInit?: RequestInit, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
|
|
205
|
+
/**
|
|
206
|
+
* `.fire()` automatically adds a global fetch event listener.
|
|
207
|
+
* This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
|
|
208
|
+
* @deprecated
|
|
209
|
+
* ACRYL ships no service-worker adapter: mount the app with `ctx.router.route(path, app)` and serve it through an ACRYL adapter instead.
|
|
210
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
|
|
211
|
+
* @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
|
|
212
|
+
*/
|
|
213
|
+
fire: () => void;
|
|
214
|
+
}
|
|
215
|
+
export { Acryl as AcrylBase };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AcrylBase } from './app-base.ts';
|
|
2
|
+
import type { AcrylOptions } from './app-base.ts';
|
|
3
|
+
import type { BlankEnv, BlankSchema, Env, Schema } from './types.ts';
|
|
4
|
+
/**
|
|
5
|
+
* The Acryl class extends the functionality of the AcrylBase class.
|
|
6
|
+
* It sets up routing and allows for custom options to be passed.
|
|
7
|
+
*
|
|
8
|
+
* @template E - The environment type.
|
|
9
|
+
* @template S - The schema type.
|
|
10
|
+
* @template BasePath - The base path type.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Acryl<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = '/'> extends AcrylBase<E, S, BasePath> {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of the Acryl class.
|
|
15
|
+
*
|
|
16
|
+
* @param options - Optional configuration options for the Acryl instance.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options?: AcrylOptions<E>);
|
|
19
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Acryl } from '../app.ts';
|
|
2
|
+
import type { UnionToIntersection } from '../utils/types.ts';
|
|
3
|
+
import type { Client, ClientRequestOptions } from './types.ts';
|
|
4
|
+
export declare const hc: <T extends Acryl<any, any, any>, Prefix extends string = string>(baseUrl: Prefix, options?: ClientRequestOptions) => UnionToIntersection<Client<T, Prefix>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description This file is a modified version of `fetch-result-please` (`ofetch`), minimalized and adapted to Acryl's custom needs.
|
|
3
|
+
*
|
|
4
|
+
* @link https://www.npmjs.com/package/fetch-result-please
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Smartly parses and return the consumable result from a fetch `Response`.
|
|
8
|
+
*
|
|
9
|
+
* Throwing a structured error if the response is not `ok`. ({@link DetailedError})
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchRP(fetchRes: Response | Promise<Response>): Promise<any>;
|
|
12
|
+
export declare class DetailedError extends Error {
|
|
13
|
+
/**
|
|
14
|
+
* Additional `message` that will be logged AND returned to client
|
|
15
|
+
*/
|
|
16
|
+
detail?: any;
|
|
17
|
+
/**
|
|
18
|
+
* Additional `code` that will be logged AND returned to client
|
|
19
|
+
*/
|
|
20
|
+
code?: any;
|
|
21
|
+
/**
|
|
22
|
+
* Additional value that will be logged AND NOT returned to client
|
|
23
|
+
*/
|
|
24
|
+
log?: any;
|
|
25
|
+
/**
|
|
26
|
+
* Optionally set the status code to return, in a web server context
|
|
27
|
+
*/
|
|
28
|
+
statusCode?: any;
|
|
29
|
+
constructor(message: string, options?: {
|
|
30
|
+
detail?: any;
|
|
31
|
+
code?: any;
|
|
32
|
+
statusCode?: number;
|
|
33
|
+
log?: any;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* The HTTP Client for Acryl.
|
|
4
|
+
*/
|
|
5
|
+
export { hc } from './client.ts';
|
|
6
|
+
export { parseResponse, DetailedError } from './utils.ts';
|
|
7
|
+
export type { InferResponseType, InferRequestType, Fetch, ClientRequestOptions, ClientRequest, ClientResponse, ApplyGlobalResponse, PickResponseByStatusCode, } from './types.ts';
|