acrylblends 1.0.3 → 1.0.5
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/docs/framework/agents/index.md +6 -4
- package/docs/framework/workshop/README.md +3 -3
- package/docs/framework/workshop/facilitator.md +1 -0
- package/lib/accept-CNNHu4Cf.js +193 -0
- package/lib/{accepts-XBuZPVRI.js → accepts-Btq83xPd.js} +1 -1
- package/lib/accepts.js +1 -1
- package/lib/acryl-base.js +1 -331
- package/lib/adapter-CaZ6FZUU.js +37 -0
- package/lib/adapter.js +1 -36
- package/lib/{app-BM0rTCp7.js → app-CQcGWjrk.js} +4 -4
- package/lib/app-base-CpRMZL4v.js +332 -0
- package/lib/{audit-BXnYsLge.d.ts → audit-D5z9uwOP.d.ts} +14 -1
- package/lib/{base-NSN_SNv-.js → base-D_6kfOr-.js} +1 -1
- package/lib/basic-auth-C0HTRpXh.js +20 -0
- package/lib/basic-auth-DFLflXNe.js +95 -0
- package/lib/basic-auth.js +1 -94
- package/lib/bearer-auth-Cwxt-vgS.js +94 -0
- package/lib/bearer-auth.js +1 -93
- package/lib/body-D7f4e7w_.js +94 -0
- package/lib/body-limit-WmIjWRLt.js +66 -0
- package/lib/body-limit.js +1 -65
- package/lib/buffer-CkEOJCcY.js +51 -0
- package/lib/bun.js +3 -3
- package/lib/cache-B0bHH7s5.js +169 -0
- package/lib/cache.js +1 -168
- package/lib/{client-DDLXwhBo.js → client-BrMFnMEd.js} +1 -1
- package/lib/{client-modules-CLvWOjbd.js → client-modules-drj4mjhj.js} +4 -4
- package/lib/client.js +1 -1
- package/lib/color-COa3DplO.js +37 -0
- package/lib/combine-TWuGdcbC.js +137 -0
- package/lib/combine.js +1 -136
- package/lib/{components-cEW3ovK0.js → components-B2ka9Ax1.js} +4 -4
- package/lib/{components-JXVm45kK.js → components-PVXwaOaC.js} +2 -2
- package/lib/compress-BzWqsHF1.js +79 -0
- package/lib/compress-C-9vK4B2.d.ts +11 -0
- package/lib/compress-DCyrrQ5D.js +11 -0
- package/lib/compress.d.ts +1 -1
- package/lib/compress.js +2 -78
- package/lib/concurrent-DrF3d2c-.js +30 -0
- package/lib/conninfo-BCROmdnf.d.ts +11 -0
- package/lib/conninfo-CWJwieh4.js +19 -0
- package/lib/constants-CBSEudrb.js +7 -0
- package/lib/{context-DDO0cfuP.js → context-CkOh7Ygv.js} +2 -2
- package/lib/context-storage-iuPoI_CR.js +52 -0
- package/lib/context-storage.js +1 -51
- package/lib/cookie-B1LlkzOe.js +125 -0
- package/lib/cookie-BHIduy2T.js +82 -0
- package/lib/cookie.js +1 -81
- package/lib/cordis/db-sqlite.d.ts +1 -1
- package/lib/cordis/door.d.ts +17 -3
- package/lib/cordis/door.js +123 -16
- package/lib/cordis/inspect.js +4 -4
- package/lib/cordis/kv-db.d.ts +1 -1
- package/lib/cordis/kv-db.js +1 -1
- package/lib/cordis/kv-json.d.ts +1 -1
- package/lib/cordis/kv-json.js +1 -1
- package/lib/cordis/node-server.d.ts +1 -1
- package/lib/cordis/node-server.js +3 -116
- package/lib/cordis/router-http.d.ts +1 -1
- package/lib/cordis/router-http.js +2 -2
- package/lib/cordis/router.d.ts +1 -1
- package/lib/cordis/router.js +4 -4
- package/lib/cordis/state.js +7 -7
- package/lib/{core-CaY8XDZ6.js → core-BOu1jYua.js} +1 -1
- package/lib/cors-CbAQ-8qU.js +106 -0
- package/lib/cors.js +1 -105
- package/lib/crypto-iVP-N-tS.js +34 -0
- package/lib/csrf-DqqOZtgy.js +101 -0
- package/lib/csrf.js +1 -100
- package/lib/css-C5CPVMvM.js +134 -0
- package/lib/css.js +2 -133
- package/lib/db/sqlite.d.ts +1 -25
- package/lib/dev-CLgu-JRe.js +50 -0
- package/lib/dev.js +1 -49
- package/lib/dom-YjND9Jt3.js +74 -0
- package/lib/door/host.d.ts +2 -2
- package/lib/door/host.js +1 -1
- package/lib/door/page.d.ts +12 -1
- package/lib/door/page.js +22 -1
- package/lib/door/protocol.d.ts +2 -2
- package/lib/door/protocol.js +2 -197
- package/lib/encode-BhbNLrjp.js +33 -0
- package/lib/factory-CLdSf-xS.js +30 -0
- package/lib/factory.js +1 -29
- package/lib/handler-C0wZ0KwO.js +12 -0
- package/lib/helpers-BEjcdbgw.js +5 -0
- package/lib/{hooks-w72iLeFR.js → hooks-CfC07ri0.js} +1 -1
- package/lib/html-CgNa89xw.js +31 -0
- package/lib/html-DGExBFNg.js +103 -0
- package/lib/html.d.ts +2 -5
- package/lib/html.js +2 -30
- package/lib/http-exception-MjWkT89V.js +54 -0
- package/lib/http-exception.js +1 -53
- package/lib/{index-D4nVR3wu.d.ts → index-DMOtA-NJ.d.ts} +7 -1
- package/lib/index-dAzQsJG9.d.ts +6 -0
- package/lib/index.js +3 -3
- package/lib/ip-restriction-jKtKCRM_.js +166 -0
- package/lib/ip-restriction.js +1 -165
- package/lib/ipaddr-DCoIo528.js +238 -0
- package/lib/jsx/dom/client.js +1 -1
- package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
- package/lib/jsx/dom/jsx-runtime.js +2 -1
- package/lib/jsx/dom/server.js +3 -3
- package/lib/jsx/dom.js +5 -73
- package/lib/jsx/jsx-dev-runtime.d.ts +2 -5
- package/lib/jsx/jsx-dev-runtime.js +2 -13
- package/lib/jsx/jsx-runtime.d.ts +2 -2
- package/lib/jsx/jsx-runtime.js +4 -4
- package/lib/jsx/streaming.js +1 -1
- package/lib/jsx-CUQgttxU.js +47 -0
- package/lib/jsx-dev-runtime-B4WTyq8r.js +14 -0
- package/lib/{jsx-dev-runtime-CWLRA2F3.js → jsx-dev-runtime-BLfA-EhI.js} +2 -2
- package/lib/jsx-dev-runtime-CGt4kNYr.d.ts +6 -0
- package/lib/jsx-renderer-CfifM4hT.js +99 -0
- package/lib/jsx-renderer.js +1 -98
- package/lib/jsx-runtime-COCRWBJ9.js +2 -0
- package/lib/jsx.js +5 -46
- package/lib/{jwk-LkzeoaU8.js → jwk-CDPpYQpD.js} +3 -3
- package/lib/jwk.js +1 -1
- package/lib/{jwt-BGJBw5AF.js → jwt-BXoIA2fQ.js} +2 -2
- package/lib/{jwt-CskdhEW9.js → jwt-lyS4Q3mT.js} +3 -3
- package/lib/jwt.js +2 -2
- package/lib/kv/db.d.ts +1 -10
- package/lib/kv/db.js +1 -56
- package/lib/kv/json.d.ts +1 -9
- package/lib/kv/json.js +1 -223
- package/lib/{language-D9a4zqvn.js → language-DeGRtLJt.js} +2 -2
- package/lib/language.js +1 -1
- package/lib/{linear-router-C3FPib6h.js → linear-router-CmZn_JLV.js} +2 -2
- package/lib/logger-Ckxu8diz.js +54 -0
- package/lib/logger.js +1 -53
- package/lib/loopback-only-BbasoF7R.js +90 -0
- package/lib/loopback-only.js +1 -89
- package/lib/method-not-allowed-TO2_hnfl.js +82 -0
- package/lib/method-not-allowed.js +1 -81
- package/lib/method-override-DnZKfJbV.js +103 -0
- package/lib/method-override.js +1 -102
- package/lib/middleware-BfG_fp8P.js +12 -0
- package/lib/mime-BnScXkQn.js +77 -0
- package/lib/mount-QkK_3NtJ.js +67 -0
- package/lib/mount.js +1 -66
- package/lib/node-server/conninfo.d.ts +1 -10
- package/lib/node-server/conninfo.js +1 -18
- package/lib/node-server/register.js +25 -2
- package/lib/node-server/serve-static.d.ts +1 -17
- package/lib/node-server/serve-static.js +1 -1
- package/lib/node-server.d.ts +2 -2
- package/lib/node-server.js +4 -4
- package/lib/open-BqK4D2Wn.d.ts +11 -0
- package/lib/open-But9E2rL.js +57 -0
- package/lib/open-CULVJgOc.d.ts +12 -0
- package/lib/open-Dp4sxspc.js +224 -0
- package/lib/open-T7kgbO2O.d.ts +27 -0
- package/lib/{pattern-router-HZxjDGEQ.js → pattern-router-CJBecJBd.js} +1 -1
- package/lib/powered-by-CXQNjNIX.js +24 -0
- package/lib/powered-by.js +1 -23
- package/lib/pretty-json-CeC1yvYt.js +39 -0
- package/lib/pretty-json.js +1 -38
- package/lib/{protocol-BizVt4J6.d.ts → protocol-C37gPePD.d.ts} +9 -2
- package/lib/protocol-Dt0AZBOz.js +213 -0
- package/lib/proxy-C2w_mH7k.js +121 -0
- package/lib/proxy.js +1 -120
- package/lib/quick.js +4 -4
- package/lib/{reg-exp-router-DC1R3qoY.js → reg-exp-router-C_WV84eV.js} +2 -2
- package/lib/request-DvMgGtlW.js +323 -0
- package/lib/request.js +1 -322
- package/lib/route-D8m-a2I1.js +126 -0
- package/lib/route.js +1 -125
- package/lib/router/linear-router.js +1 -1
- package/lib/router/pattern-router.js +1 -1
- package/lib/router/reg-exp-router.js +1 -1
- package/lib/router/smart-router.js +1 -1
- package/lib/router/trie-router.js +1 -1
- package/lib/router-Be_o6nFu.js +35 -0
- package/lib/router.js +1 -34
- package/lib/schema-validator-EK3cUUCt.js +22 -0
- package/lib/schema-validator.js +1 -21
- package/lib/{secure-headers-mP3j6Hm6.js → secure-headers-C5ZOcXqk.js} +1 -1
- package/lib/secure-headers.js +1 -1
- package/lib/serve-static-B7sqnftW.d.ts +18 -0
- package/lib/{serve-static-3uo_9rjF.js → serve-static-C1Nkj_xB.js} +2 -2
- package/lib/{serve-static-Cp5adzGo.js → serve-static-EiJf1zkO.js} +4 -4
- package/lib/serve-static.js +1 -1
- package/lib/{smart-router-C5CZ5XSM.js → smart-router-BjxkDQCE.js} +1 -1
- package/lib/{snapshot-text-DmE0YfeZ.js → snapshot-text-Bbx43mN0.js} +57 -9
- package/lib/{src-2Z4mJg0x.js → src-BTBm4OPD.js} +22 -6
- package/lib/src-LX0E4ec4.js +117 -0
- package/lib/{ssg-BwjcA-Ge.js → ssg-BEl7MHqg.js} +5 -5
- package/lib/ssg.js +1 -1
- package/lib/stream-CzM_SHkq.js +88 -0
- package/lib/{streaming-DHST3Scg.js → streaming-BlDaph8U.js} +3 -3
- package/lib/streaming.js +1 -1
- package/lib/{test-websocket-D8WWqE5G.js → test-websocket-BLeEvybj.js} +2 -2
- package/lib/testing-BQx5T_UX.js +17 -0
- package/lib/testing.js +1 -16
- package/lib/timeout-FeqZ9A-0.js +42 -0
- package/lib/timeout.js +1 -41
- package/lib/tiny.js +2 -2
- package/lib/trailing-slash-DwTx-1sk.js +85 -0
- package/lib/trailing-slash.js +1 -84
- package/lib/{trie-router-CfFbapzL.js → trie-router-JydLKUa2.js} +2 -2
- package/lib/url-BPh4d6j-.js +197 -0
- package/lib/utils/accept.js +1 -192
- package/lib/utils/basic-auth.js +1 -19
- package/lib/utils/body.js +1 -93
- package/lib/utils/buffer.js +1 -50
- package/lib/utils/color.js +1 -36
- package/lib/utils/compress.d.ts +1 -10
- package/lib/utils/compress.js +1 -10
- package/lib/utils/concurrent.js +1 -29
- package/lib/utils/constants.js +1 -6
- package/lib/utils/cookie.js +1 -124
- package/lib/utils/crypto.js +1 -33
- package/lib/utils/encode.js +1 -32
- package/lib/utils/handler.js +1 -11
- package/lib/utils/html.js +1 -102
- package/lib/utils/ipaddr.js +1 -237
- package/lib/utils/jwt.js +1 -1
- package/lib/utils/mime.js +1 -76
- package/lib/utils/stream.js +1 -87
- package/lib/utils/url.js +1 -196
- package/lib/{validator-D84mq-dO.js → validator-Btiyt5VJ.js} +3 -3
- package/lib/validator.js +1 -1
- package/lib/websocket-DsyBIKVA.js +56 -0
- package/lib/ws.js +1 -55
- package/package.json +1 -1
- package/plugins/acryl-door/src/cli/acryl.ts +5 -3
- package/plugins/acryl-door/src/host/channel.ts +36 -0
- package/plugins/acryl-door/src/host/chat-tools.ts +2 -0
- package/plugins/acryl-door/src/host/door.ts +44 -5
- package/plugins/acryl-door/src/host/shim.ts +23 -0
- package/plugins/acryl-door/src/host/verbs.ts +4 -3
- package/plugins/acryl-door/src/index.ts +39 -3
- package/plugins/acryl-door/src/page/driver/driver.ts +22 -1
- package/plugins/acryl-door/src/page/protocol.ts +13 -2
- package/plugins/acryl-node-server/src/register.ts +29 -2
- package/plugins/acryl-router/src/service.ts +19 -1
- package/plugins/agent/model.ts +6 -1
- package/plugins/agent/tools.ts +12 -2
- package/plugins/agent-panel/client/describe.ts +44 -0
- package/plugins/agent-panel/client/main.ts +67 -35
- package/plugins/agent-panel/index.ts +137 -35
- package/plugins/desktop/attach.ts +72 -0
- package/plugins/desktop/main.ts +17 -4
- package/plugins/extensions/index.ts +3 -4
- package/plugins/extensions/stage.ts +33 -5
- package/plugins/openai/index.ts +1 -1
- package/shared/DEFAULTS.md +4 -0
- package/templates/agent/AGENTS.md +2 -0
- package/templates/agent/blend.yaml +4 -1
- package/templates/agent/src/app.ts +2 -0
- package/templates/agent/src/routes.ts +1 -1
- package/templates/agent/template.json +1 -0
- package/templates/agent/test/builder.test.ts +26 -21
- package/lib/helpers-CvTauQT5.js +0 -5
- package/lib/middleware-CPQ8himN.js +0 -12
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
//#region ../../plugins/acryl-router/src/core/utils/url.ts
|
|
2
|
+
const splitPath = (path) => {
|
|
3
|
+
const paths = path.split("/");
|
|
4
|
+
if (paths[0] === "") paths.shift();
|
|
5
|
+
return paths;
|
|
6
|
+
};
|
|
7
|
+
const splitRoutingPath = (routePath) => {
|
|
8
|
+
const { groups, path } = extractGroupsFromPath(routePath);
|
|
9
|
+
const paths = splitPath(path);
|
|
10
|
+
return replaceGroupMarks(paths, groups);
|
|
11
|
+
};
|
|
12
|
+
const extractGroupsFromPath = (path) => {
|
|
13
|
+
const groups = [];
|
|
14
|
+
path = path.replace(/\{[^}]+\}/g, (match, index) => {
|
|
15
|
+
const mark = `@${index}`;
|
|
16
|
+
groups.push([mark, match]);
|
|
17
|
+
return mark;
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
groups,
|
|
21
|
+
path
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const replaceGroupMarks = (paths, groups) => {
|
|
25
|
+
for (let i = groups.length - 1; i >= 0; i--) {
|
|
26
|
+
const [mark] = groups[i];
|
|
27
|
+
for (let j = paths.length - 1; j >= 0; j--) if (paths[j].includes(mark)) {
|
|
28
|
+
paths[j] = paths[j].replace(mark, groups[i][1]);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return paths;
|
|
33
|
+
};
|
|
34
|
+
const patternCache = {};
|
|
35
|
+
const getPattern = (label, next) => {
|
|
36
|
+
if (label === "*") return "*";
|
|
37
|
+
const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
38
|
+
if (match) {
|
|
39
|
+
const cacheKey = `${label}#${next}`;
|
|
40
|
+
if (!patternCache[cacheKey]) if (match[2]) patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [
|
|
41
|
+
cacheKey,
|
|
42
|
+
match[1],
|
|
43
|
+
new RegExp(`^${match[2]}(?=/${next})`)
|
|
44
|
+
] : [
|
|
45
|
+
label,
|
|
46
|
+
match[1],
|
|
47
|
+
new RegExp(`^${match[2]}$`)
|
|
48
|
+
];
|
|
49
|
+
else patternCache[cacheKey] = [
|
|
50
|
+
label,
|
|
51
|
+
match[1],
|
|
52
|
+
true
|
|
53
|
+
];
|
|
54
|
+
return patternCache[cacheKey];
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
const tryDecode = (str, decoder) => {
|
|
59
|
+
try {
|
|
60
|
+
return decoder(str);
|
|
61
|
+
} catch {
|
|
62
|
+
return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
|
|
63
|
+
try {
|
|
64
|
+
return decoder(match);
|
|
65
|
+
} catch {
|
|
66
|
+
return match;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Try to apply decodeURI() to given string.
|
|
73
|
+
* If it fails, skip invalid percent encoding or invalid UTF-8 sequences, and apply decodeURI() to the rest as much as possible.
|
|
74
|
+
* @param str The string to decode.
|
|
75
|
+
* @returns The decoded string that sometimes contains undecodable percent encoding.
|
|
76
|
+
* @example
|
|
77
|
+
* tryDecodeURI('Hello%20World') // 'Hello World'
|
|
78
|
+
* tryDecodeURI('Hello%20World/%A4%A2') // 'Hello World/%A4%A2'
|
|
79
|
+
*/
|
|
80
|
+
const tryDecodeURI = (str) => tryDecode(str, decodeURI);
|
|
81
|
+
const getPath = (request) => {
|
|
82
|
+
const url = request.url;
|
|
83
|
+
const start = url.indexOf("/", url.indexOf(":") + 4);
|
|
84
|
+
let i = start;
|
|
85
|
+
for (; i < url.length; i++) {
|
|
86
|
+
const charCode = url.charCodeAt(i);
|
|
87
|
+
if (charCode === 37) {
|
|
88
|
+
const queryIndex = url.indexOf("?", i);
|
|
89
|
+
const hashIndex = url.indexOf("#", i);
|
|
90
|
+
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
91
|
+
const path = url.slice(start, end);
|
|
92
|
+
return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
|
|
93
|
+
} else if (charCode === 63 || charCode === 35) break;
|
|
94
|
+
}
|
|
95
|
+
return url.slice(start, i);
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated
|
|
99
|
+
* Use the `URL` API instead.
|
|
100
|
+
*/
|
|
101
|
+
const getQueryStrings = (url) => {
|
|
102
|
+
const queryIndex = url.indexOf("?", 8);
|
|
103
|
+
if (queryIndex === -1) return "";
|
|
104
|
+
const hashIndex = url.indexOf("#", 8);
|
|
105
|
+
return hashIndex === -1 ? url.slice(queryIndex) : queryIndex < hashIndex ? url.slice(queryIndex, hashIndex) : "";
|
|
106
|
+
};
|
|
107
|
+
const getPathNoStrict = (request) => {
|
|
108
|
+
const result = getPath(request);
|
|
109
|
+
return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Merge paths.
|
|
113
|
+
* @param {string[]} ...paths - The paths to merge.
|
|
114
|
+
* @returns {string} The merged path.
|
|
115
|
+
* @example
|
|
116
|
+
* mergePath('/api', '/users') // '/api/users'
|
|
117
|
+
* mergePath('/api/', '/users') // '/api/users'
|
|
118
|
+
* mergePath('/api', '/') // '/api'
|
|
119
|
+
* mergePath('/api/', '/') // '/api/'
|
|
120
|
+
*/
|
|
121
|
+
const mergePath = (base, sub, ...rest) => {
|
|
122
|
+
if (rest.length) sub = mergePath(sub, ...rest);
|
|
123
|
+
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
124
|
+
};
|
|
125
|
+
const checkOptionalParameter = (path) => {
|
|
126
|
+
if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) return null;
|
|
127
|
+
const segments = path.split("/");
|
|
128
|
+
const results = [];
|
|
129
|
+
let basePath = "";
|
|
130
|
+
segments.forEach((segment) => {
|
|
131
|
+
if (segment !== "" && !/\:/.test(segment)) basePath += "/" + segment;
|
|
132
|
+
else if (/\:/.test(segment)) if (segment.charCodeAt(segment.length - 1) === 63) {
|
|
133
|
+
if (results.length === 0 && basePath === "") results.push("/");
|
|
134
|
+
else results.push(basePath);
|
|
135
|
+
const optionalSegment = segment.slice(0, -1);
|
|
136
|
+
basePath += "/" + optionalSegment;
|
|
137
|
+
results.push(basePath);
|
|
138
|
+
} else basePath += "/" + segment;
|
|
139
|
+
});
|
|
140
|
+
return results.filter((v, i, a) => a.indexOf(v) === i);
|
|
141
|
+
};
|
|
142
|
+
const tryDecodeURIComponent = (str) => str.indexOf("%") !== -1 ? tryDecode(str, decodeURIComponent_) : str;
|
|
143
|
+
const _decodeURI = (value) => {
|
|
144
|
+
if (value.indexOf("+") !== -1) value = value.replace(/\+/g, " ");
|
|
145
|
+
return tryDecodeURIComponent(value);
|
|
146
|
+
};
|
|
147
|
+
const _getQueryParam = (url, key, multiple) => {
|
|
148
|
+
const hashIndex = url.indexOf("#", 8);
|
|
149
|
+
if (hashIndex !== -1) url = url.slice(0, hashIndex);
|
|
150
|
+
let encoded;
|
|
151
|
+
if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
|
|
152
|
+
let keyIndex = url.indexOf("?", 8);
|
|
153
|
+
if (keyIndex === -1) return;
|
|
154
|
+
if (!url.startsWith(key, keyIndex + 1)) keyIndex = url.indexOf(`&${key}`, keyIndex + 1);
|
|
155
|
+
while (keyIndex !== -1) {
|
|
156
|
+
const trailingKeyCode = url.charCodeAt(keyIndex + key.length + 1);
|
|
157
|
+
if (trailingKeyCode === 61) {
|
|
158
|
+
const valueIndex = keyIndex + key.length + 2;
|
|
159
|
+
const endIndex = url.indexOf("&", valueIndex);
|
|
160
|
+
return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
|
|
161
|
+
} else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) return "";
|
|
162
|
+
keyIndex = url.indexOf(`&${key}`, keyIndex + 1);
|
|
163
|
+
}
|
|
164
|
+
encoded = /[%+]/.test(url);
|
|
165
|
+
if (!encoded) return;
|
|
166
|
+
}
|
|
167
|
+
const results = Object.create(null);
|
|
168
|
+
encoded ??= /[%+]/.test(url);
|
|
169
|
+
let keyIndex = url.indexOf("?", 8);
|
|
170
|
+
while (keyIndex !== -1) {
|
|
171
|
+
const nextKeyIndex = url.indexOf("&", keyIndex + 1);
|
|
172
|
+
let valueIndex = url.indexOf("=", keyIndex);
|
|
173
|
+
if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) valueIndex = -1;
|
|
174
|
+
let name = url.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex);
|
|
175
|
+
if (encoded) name = _decodeURI(name);
|
|
176
|
+
keyIndex = nextKeyIndex;
|
|
177
|
+
if (name === "") continue;
|
|
178
|
+
let value;
|
|
179
|
+
if (valueIndex === -1) value = "";
|
|
180
|
+
else {
|
|
181
|
+
value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);
|
|
182
|
+
if (encoded) value = _decodeURI(value);
|
|
183
|
+
}
|
|
184
|
+
if (multiple) {
|
|
185
|
+
if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
|
|
186
|
+
results[name].push(value);
|
|
187
|
+
} else results[name] ??= value;
|
|
188
|
+
}
|
|
189
|
+
return key ? results[key] : results;
|
|
190
|
+
};
|
|
191
|
+
const getQueryParam = _getQueryParam;
|
|
192
|
+
const getQueryParams = (url, key) => {
|
|
193
|
+
return _getQueryParam(url, key, true);
|
|
194
|
+
};
|
|
195
|
+
const decodeURIComponent_ = decodeURIComponent;
|
|
196
|
+
//#endregion
|
|
197
|
+
export { getPattern as a, getQueryStrings as c, splitRoutingPath as d, tryDecode as f, getPathNoStrict as i, mergePath as l, tryDecodeURIComponent as m, decodeURIComponent_ as n, getQueryParam as o, tryDecodeURI as p, getPath as r, getQueryParams as s, checkOptionalParameter as t, splitPath as u };
|
package/lib/utils/accept.js
CHANGED
|
@@ -1,193 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
const isWhitespace = (char) => char === 32 || char === 9 || char === 10 || char === 13;
|
|
3
|
-
const consumeWhitespace = (acceptHeader, startIndex) => {
|
|
4
|
-
while (startIndex < acceptHeader.length) {
|
|
5
|
-
if (!isWhitespace(acceptHeader.charCodeAt(startIndex))) break;
|
|
6
|
-
startIndex++;
|
|
7
|
-
}
|
|
8
|
-
return startIndex;
|
|
9
|
-
};
|
|
10
|
-
const ignoreTrailingWhitespace = (acceptHeader, startIndex) => {
|
|
11
|
-
while (startIndex > 0) {
|
|
12
|
-
if (!isWhitespace(acceptHeader.charCodeAt(startIndex - 1))) break;
|
|
13
|
-
startIndex--;
|
|
14
|
-
}
|
|
15
|
-
return startIndex;
|
|
16
|
-
};
|
|
17
|
-
const skipInvalidParam = (acceptHeader, startIndex) => {
|
|
18
|
-
while (startIndex < acceptHeader.length) {
|
|
19
|
-
const char = acceptHeader.charCodeAt(startIndex);
|
|
20
|
-
if (char === 59) return [startIndex + 1, true];
|
|
21
|
-
if (char === 44) return [startIndex + 1, false];
|
|
22
|
-
startIndex++;
|
|
23
|
-
}
|
|
24
|
-
return [startIndex, false];
|
|
25
|
-
};
|
|
26
|
-
const skipInvalidAcceptValue = (acceptHeader, startIndex) => {
|
|
27
|
-
let i = startIndex;
|
|
28
|
-
let inQuotes = false;
|
|
29
|
-
while (i < acceptHeader.length) {
|
|
30
|
-
const char = acceptHeader.charCodeAt(i);
|
|
31
|
-
if (inQuotes && char === 92) i++;
|
|
32
|
-
else if (char === 34) inQuotes = !inQuotes;
|
|
33
|
-
else if (!inQuotes && char === 44) return i + 1;
|
|
34
|
-
i++;
|
|
35
|
-
}
|
|
36
|
-
return i;
|
|
37
|
-
};
|
|
38
|
-
const getNextParam = (acceptHeader, startIndex) => {
|
|
39
|
-
startIndex = consumeWhitespace(acceptHeader, startIndex);
|
|
40
|
-
let i = startIndex;
|
|
41
|
-
let key;
|
|
42
|
-
let value;
|
|
43
|
-
let hasNext = false;
|
|
44
|
-
while (i < acceptHeader.length) {
|
|
45
|
-
const char = acceptHeader.charCodeAt(i);
|
|
46
|
-
if (char === 61) {
|
|
47
|
-
key = acceptHeader.slice(startIndex, ignoreTrailingWhitespace(acceptHeader, i));
|
|
48
|
-
i++;
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
if (char === 59) return [
|
|
52
|
-
i + 1,
|
|
53
|
-
void 0,
|
|
54
|
-
void 0,
|
|
55
|
-
true
|
|
56
|
-
];
|
|
57
|
-
if (char === 44) return [
|
|
58
|
-
i + 1,
|
|
59
|
-
void 0,
|
|
60
|
-
void 0,
|
|
61
|
-
false
|
|
62
|
-
];
|
|
63
|
-
i++;
|
|
64
|
-
}
|
|
65
|
-
if (key === void 0) return [
|
|
66
|
-
i,
|
|
67
|
-
void 0,
|
|
68
|
-
void 0,
|
|
69
|
-
false
|
|
70
|
-
];
|
|
71
|
-
i = consumeWhitespace(acceptHeader, i);
|
|
72
|
-
if (acceptHeader.charCodeAt(i) === 61) {
|
|
73
|
-
const skipResult = skipInvalidParam(acceptHeader, i + 1);
|
|
74
|
-
return [
|
|
75
|
-
skipResult[0],
|
|
76
|
-
key,
|
|
77
|
-
void 0,
|
|
78
|
-
skipResult[1]
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
let inQuotes = false;
|
|
82
|
-
const paramStartIndex = i;
|
|
83
|
-
while (i < acceptHeader.length) {
|
|
84
|
-
const char = acceptHeader.charCodeAt(i);
|
|
85
|
-
if (inQuotes && char === 92) i++;
|
|
86
|
-
else if (char === 34) {
|
|
87
|
-
if (inQuotes) {
|
|
88
|
-
let nextIndex = consumeWhitespace(acceptHeader, i + 1);
|
|
89
|
-
const nextChar = acceptHeader.charCodeAt(nextIndex);
|
|
90
|
-
if (nextIndex < acceptHeader.length && !(nextChar === 59 || nextChar === 44)) {
|
|
91
|
-
const skipResult = skipInvalidParam(acceptHeader, nextIndex);
|
|
92
|
-
return [
|
|
93
|
-
skipResult[0],
|
|
94
|
-
key,
|
|
95
|
-
void 0,
|
|
96
|
-
skipResult[1]
|
|
97
|
-
];
|
|
98
|
-
}
|
|
99
|
-
value = acceptHeader.slice(paramStartIndex + 1, i);
|
|
100
|
-
if (value.includes("\\")) value = value.replace(/\\(.)/g, "$1");
|
|
101
|
-
if (nextChar === 44) return [
|
|
102
|
-
nextIndex + 1,
|
|
103
|
-
key,
|
|
104
|
-
value,
|
|
105
|
-
false
|
|
106
|
-
];
|
|
107
|
-
if (nextChar === 59) {
|
|
108
|
-
hasNext = true;
|
|
109
|
-
nextIndex++;
|
|
110
|
-
}
|
|
111
|
-
i = nextIndex;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
inQuotes = true;
|
|
115
|
-
} else if (!inQuotes && (char === 59 || char === 44)) {
|
|
116
|
-
value = acceptHeader.slice(paramStartIndex, ignoreTrailingWhitespace(acceptHeader, i));
|
|
117
|
-
if (char === 59) hasNext = true;
|
|
118
|
-
i++;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
i++;
|
|
122
|
-
}
|
|
123
|
-
return [
|
|
124
|
-
i,
|
|
125
|
-
key,
|
|
126
|
-
value ?? acceptHeader.slice(paramStartIndex, ignoreTrailingWhitespace(acceptHeader, i)),
|
|
127
|
-
hasNext
|
|
128
|
-
];
|
|
129
|
-
};
|
|
130
|
-
const getNextAcceptValue = (acceptHeader, startIndex) => {
|
|
131
|
-
const accept = {
|
|
132
|
-
type: "",
|
|
133
|
-
params: Object.create(null),
|
|
134
|
-
q: 1
|
|
135
|
-
};
|
|
136
|
-
startIndex = consumeWhitespace(acceptHeader, startIndex);
|
|
137
|
-
let i = startIndex;
|
|
138
|
-
while (i < acceptHeader.length) {
|
|
139
|
-
const char = acceptHeader.charCodeAt(i);
|
|
140
|
-
if (char === 59 || char === 44) {
|
|
141
|
-
accept.type = acceptHeader.slice(startIndex, ignoreTrailingWhitespace(acceptHeader, i));
|
|
142
|
-
i++;
|
|
143
|
-
if (char === 44) return [i, accept.type ? accept : void 0];
|
|
144
|
-
if (!accept.type) return [skipInvalidAcceptValue(acceptHeader, i), void 0];
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
i++;
|
|
148
|
-
}
|
|
149
|
-
if (!accept.type) {
|
|
150
|
-
accept.type = acceptHeader.slice(startIndex, ignoreTrailingWhitespace(acceptHeader, acceptHeader.length));
|
|
151
|
-
return [acceptHeader.length, accept.type ? accept : void 0];
|
|
152
|
-
}
|
|
153
|
-
let param;
|
|
154
|
-
let value;
|
|
155
|
-
let hasNext;
|
|
156
|
-
while (i < acceptHeader.length) {
|
|
157
|
-
[i, param, value, hasNext] = getNextParam(acceptHeader, i);
|
|
158
|
-
if (param && value) accept.params[param] = value;
|
|
159
|
-
if (!hasNext) break;
|
|
160
|
-
}
|
|
161
|
-
return [i, accept];
|
|
162
|
-
};
|
|
163
|
-
const parseAccept = (acceptHeader) => {
|
|
164
|
-
if (!acceptHeader) return [];
|
|
165
|
-
const values = [];
|
|
166
|
-
let i = 0;
|
|
167
|
-
let accept;
|
|
168
|
-
let requiresSort = false;
|
|
169
|
-
let lastAccept;
|
|
170
|
-
while (i < acceptHeader.length) {
|
|
171
|
-
[i, accept] = getNextAcceptValue(acceptHeader, i);
|
|
172
|
-
if (accept) {
|
|
173
|
-
accept.q = parseQuality(accept.params.q ?? accept.params.Q);
|
|
174
|
-
values.push(accept);
|
|
175
|
-
if (lastAccept && lastAccept.q < accept.q) requiresSort = true;
|
|
176
|
-
lastAccept = accept;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (requiresSort) values.sort((a, b) => b.q - a.q);
|
|
180
|
-
return values;
|
|
181
|
-
};
|
|
182
|
-
const parseQuality = (qVal) => {
|
|
183
|
-
if (qVal === void 0) return 1;
|
|
184
|
-
if (qVal === "") return 1;
|
|
185
|
-
if (qVal === "NaN") return 0;
|
|
186
|
-
const num = Number(qVal);
|
|
187
|
-
if (Number.isNaN(num)) return 1;
|
|
188
|
-
if (num < 0) return 0;
|
|
189
|
-
if (num > 1) return 1;
|
|
190
|
-
return num;
|
|
191
|
-
};
|
|
192
|
-
//#endregion
|
|
1
|
+
import { t as parseAccept } from "../accept-CNNHu4Cf.js";
|
|
193
2
|
export { parseAccept };
|
package/lib/utils/basic-auth.js
CHANGED
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../plugins/acryl-router/src/core/utils/basic-auth.ts
|
|
3
|
-
const CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/;
|
|
4
|
-
const USER_PASS_REGEXP = /^([^:]*):(.*)$/;
|
|
5
|
-
const utf8Decoder = new TextDecoder();
|
|
6
|
-
const auth = (req) => {
|
|
7
|
-
const match = CREDENTIALS_REGEXP.exec(req.headers.get("Authorization") || "");
|
|
8
|
-
if (!match) return;
|
|
9
|
-
let userPass = void 0;
|
|
10
|
-
try {
|
|
11
|
-
userPass = USER_PASS_REGEXP.exec(utf8Decoder.decode(decodeBase64(match[1])));
|
|
12
|
-
} catch {}
|
|
13
|
-
if (!userPass) return;
|
|
14
|
-
return {
|
|
15
|
-
username: userPass[1],
|
|
16
|
-
password: userPass[2]
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
//#endregion
|
|
1
|
+
import { t as auth } from "../basic-auth-C0HTRpXh.js";
|
|
20
2
|
export { auth };
|
package/lib/utils/body.js
CHANGED
|
@@ -1,94 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../plugins/acryl-router/src/core/utils/body.ts
|
|
3
|
-
const MAX_NESTED_OBJECTS = 1e4;
|
|
4
|
-
const isRawRequest = (request) => "headers" in request;
|
|
5
|
-
const parseBody = async (request, options = Object.create(null)) => {
|
|
6
|
-
const { all = false, dot = false } = options;
|
|
7
|
-
const mediaType = (isRawRequest(request) ? request.headers : request.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
|
|
8
|
-
if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return parseFormData(request, {
|
|
9
|
-
all,
|
|
10
|
-
dot
|
|
11
|
-
});
|
|
12
|
-
return {};
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Parses form data from a request.
|
|
16
|
-
*
|
|
17
|
-
* @template T - The type of the parsed body data.
|
|
18
|
-
* @param {AcrylRequest | Request} request - The request object containing form data.
|
|
19
|
-
* @param {ParseBodyOptions} options - Options for parsing the form data.
|
|
20
|
-
* @returns {Promise<T>} The parsed body data.
|
|
21
|
-
*/
|
|
22
|
-
async function parseFormData(request, options) {
|
|
23
|
-
if (!isRawRequest(request) && request.bodyCache.formData) return convertFormDataToBodyData(await request.bodyCache.formData, options);
|
|
24
|
-
const headers = isRawRequest(request) ? request.headers : request.raw.headers;
|
|
25
|
-
const formDataPromise = bufferToFormData(await request.arrayBuffer(), headers.get("Content-Type") || "");
|
|
26
|
-
if (!isRawRequest(request)) request.bodyCache.formData = formDataPromise;
|
|
27
|
-
const formData = await formDataPromise;
|
|
28
|
-
if (formData) return convertFormDataToBodyData(formData, options);
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Converts form data to body data based on the provided options.
|
|
33
|
-
*
|
|
34
|
-
* @template T - The type of the parsed body data.
|
|
35
|
-
* @param {FormData} formData - The form data to convert.
|
|
36
|
-
* @param {ParseBodyOptions} options - Options for parsing the form data.
|
|
37
|
-
* @returns {T} The converted body data.
|
|
38
|
-
*/
|
|
39
|
-
function convertFormDataToBodyData(formData, options) {
|
|
40
|
-
const form = Object.create(null);
|
|
41
|
-
const nestingState = { count: 0 };
|
|
42
|
-
formData.forEach((value, key) => {
|
|
43
|
-
if (!(options.all || key.endsWith("[]"))) form[key] = value;
|
|
44
|
-
else handleParsingAllValues(form, key, value);
|
|
45
|
-
});
|
|
46
|
-
if (options.dot) Object.entries(form).forEach(([key, value]) => {
|
|
47
|
-
if (key.includes(".")) {
|
|
48
|
-
handleParsingNestedValues(form, key, value, nestingState);
|
|
49
|
-
delete form[key];
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return form;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Handles parsing all values for a given key, supporting multiple values as arrays.
|
|
56
|
-
*
|
|
57
|
-
* @param {BodyData} form - The form data object.
|
|
58
|
-
* @param {string} key - The key to parse.
|
|
59
|
-
* @param {FormDataEntryValue} value - The value to assign.
|
|
60
|
-
*/
|
|
61
|
-
const handleParsingAllValues = (form, key, value) => {
|
|
62
|
-
if (form[key] !== void 0) if (Array.isArray(form[key])) form[key].push(value);
|
|
63
|
-
else form[key] = [form[key], value];
|
|
64
|
-
else if (!key.endsWith("[]")) form[key] = value;
|
|
65
|
-
else form[key] = [value];
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Handles parsing nested values using dot notation keys.
|
|
69
|
-
*
|
|
70
|
-
* @param {BodyData} form - The form data object.
|
|
71
|
-
* @param {string} key - The dot notation key.
|
|
72
|
-
* @param {BodyDataValue} value - The value to assign.
|
|
73
|
-
*/
|
|
74
|
-
const handleParsingNestedValues = (form, key, value, state) => {
|
|
75
|
-
if (/(?:^|\.)__proto__\./.test(key)) return;
|
|
76
|
-
let nestedForm = form;
|
|
77
|
-
const keys = key.split(".", 34);
|
|
78
|
-
if (keys.length > 33) throwNestingLimitExceeded();
|
|
79
|
-
keys.forEach((key, index) => {
|
|
80
|
-
if (index === keys.length - 1) nestedForm[key] = value;
|
|
81
|
-
else {
|
|
82
|
-
if (!nestedForm[key] || typeof nestedForm[key] !== "object" || Array.isArray(nestedForm[key]) || nestedForm[key] instanceof File) {
|
|
83
|
-
if (state.count++ >= MAX_NESTED_OBJECTS) throwNestingLimitExceeded();
|
|
84
|
-
nestedForm[key] = Object.create(null);
|
|
85
|
-
}
|
|
86
|
-
nestedForm = nestedForm[key];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
const throwNestingLimitExceeded = () => {
|
|
91
|
-
throw new Error("Nesting limit exceeded");
|
|
92
|
-
};
|
|
93
|
-
//#endregion
|
|
1
|
+
import { t as parseBody } from "../body-D7f4e7w_.js";
|
|
94
2
|
export { parseBody };
|
package/lib/utils/buffer.js
CHANGED
|
@@ -1,51 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../plugins/acryl-router/src/core/utils/buffer.ts
|
|
3
|
-
/**
|
|
4
|
-
* @module
|
|
5
|
-
* Buffer utility.
|
|
6
|
-
*/
|
|
7
|
-
const equal = (a, b) => {
|
|
8
|
-
if (a === b) return true;
|
|
9
|
-
if (a.byteLength !== b.byteLength) return false;
|
|
10
|
-
const va = new DataView(a);
|
|
11
|
-
const vb = new DataView(b);
|
|
12
|
-
let i = va.byteLength;
|
|
13
|
-
while (i--) if (va.getUint8(i) !== vb.getUint8(i)) return false;
|
|
14
|
-
return true;
|
|
15
|
-
};
|
|
16
|
-
const constantTimeEqualString = (a, b) => {
|
|
17
|
-
const aLen = a.length;
|
|
18
|
-
const bLen = b.length;
|
|
19
|
-
const maxLen = Math.max(aLen, bLen);
|
|
20
|
-
let out = aLen ^ bLen;
|
|
21
|
-
for (let i = 0; i < maxLen; i++) {
|
|
22
|
-
const aChar = i < aLen ? a.charCodeAt(i) : 0;
|
|
23
|
-
const bChar = i < bLen ? b.charCodeAt(i) : 0;
|
|
24
|
-
out |= aChar ^ bChar;
|
|
25
|
-
}
|
|
26
|
-
return out === 0;
|
|
27
|
-
};
|
|
28
|
-
const timingSafeEqualString = async (a, b, hashFunction) => {
|
|
29
|
-
if (!hashFunction) hashFunction = sha256;
|
|
30
|
-
const [sa, sb] = await Promise.all([hashFunction(a), hashFunction(b)]);
|
|
31
|
-
if (sa == null || sb == null || typeof sa !== "string" || typeof sb !== "string") return false;
|
|
32
|
-
const hashEqual = constantTimeEqualString(sa, sb);
|
|
33
|
-
const originalEqual = constantTimeEqualString(a, b);
|
|
34
|
-
return hashEqual && originalEqual;
|
|
35
|
-
};
|
|
36
|
-
const timingSafeEqual = async (a, b, hashFunction) => {
|
|
37
|
-
if (typeof a === "string" && typeof b === "string") return timingSafeEqualString(a, b, hashFunction);
|
|
38
|
-
if (!hashFunction) hashFunction = sha256;
|
|
39
|
-
const [sa, sb] = await Promise.all([hashFunction(a), hashFunction(b)]);
|
|
40
|
-
if (!sa || !sb || typeof sa !== "string" || typeof sb !== "string") return false;
|
|
41
|
-
return timingSafeEqualString(sa, sb);
|
|
42
|
-
};
|
|
43
|
-
const bufferToString = (buffer) => {
|
|
44
|
-
if (buffer instanceof ArrayBuffer) return new TextDecoder("utf-8").decode(buffer);
|
|
45
|
-
return buffer;
|
|
46
|
-
};
|
|
47
|
-
const bufferToFormData = (arrayBuffer, contentType) => {
|
|
48
|
-
return new Response(arrayBuffer, { headers: { "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) } }).formData();
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
1
|
+
import { i as timingSafeEqual, n as bufferToString, r as equal, t as bufferToFormData } from "../buffer-CkEOJCcY.js";
|
|
51
2
|
export { bufferToFormData, bufferToString, equal, timingSafeEqual };
|
package/lib/utils/color.js
CHANGED
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* Color utility.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Get whether color change on terminal is enabled or disabled.
|
|
8
|
-
* If `NO_COLOR` environment variable is set, this function returns `false`.
|
|
9
|
-
* Unlike getColorEnabledAsync(), this cannot check Cloudflare environment variables.
|
|
10
|
-
* @see {@link https://no-color.org/}
|
|
11
|
-
*
|
|
12
|
-
* @returns {boolean}
|
|
13
|
-
*/
|
|
14
|
-
function getColorEnabled() {
|
|
15
|
-
const { process, Deno } = globalThis;
|
|
16
|
-
return !(typeof Deno?.noColor === "boolean" ? Deno.noColor : process !== void 0 ? "NO_COLOR" in process?.env : false);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get whether color change on terminal is enabled or disabled.
|
|
20
|
-
* If `NO_COLOR` environment variable is set, this function returns `false`.
|
|
21
|
-
* @see {@link https://no-color.org/}
|
|
22
|
-
*
|
|
23
|
-
* @returns {boolean}
|
|
24
|
-
*/
|
|
25
|
-
async function getColorEnabledAsync() {
|
|
26
|
-
const { navigator } = globalThis;
|
|
27
|
-
const cfWorkers = "cloudflare:workers";
|
|
28
|
-
return !(navigator !== void 0 && navigator.userAgent === "Cloudflare-Workers" ? await (async () => {
|
|
29
|
-
try {
|
|
30
|
-
return "NO_COLOR" in ((await import(cfWorkers)).env ?? {});
|
|
31
|
-
} catch {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
})() : !getColorEnabled());
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
1
|
+
import { n as getColorEnabledAsync, t as getColorEnabled } from "../color-COa3DplO.js";
|
|
37
2
|
export { getColorEnabled, getColorEnabledAsync };
|
package/lib/utils/compress.d.ts
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* Constants for compression.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Match for compressible content type.
|
|
8
|
-
*/
|
|
9
|
-
declare const COMPRESSIBLE_CONTENT_TYPE_REGEX: RegExp;
|
|
10
|
-
//#endregion
|
|
1
|
+
import { t as COMPRESSIBLE_CONTENT_TYPE_REGEX } from "../compress-C-9vK4B2.js";
|
|
11
2
|
export { COMPRESSIBLE_CONTENT_TYPE_REGEX };
|
package/lib/utils/compress.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* Constants for compression.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Match for compressible content type.
|
|
8
|
-
*/
|
|
9
|
-
const COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|msgpack|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|vnd\.msgpack|wasm|x-httpd-php|x-javascript|x-msgpack|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml|msgpack))(?:[;\s]|$)/i;
|
|
10
|
-
//#endregion
|
|
1
|
+
import { t as COMPRESSIBLE_CONTENT_TYPE_REGEX } from "../compress-DCyrrQ5D.js";
|
|
11
2
|
export { COMPRESSIBLE_CONTENT_TYPE_REGEX };
|
package/lib/utils/concurrent.js
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* Concurrent utility.
|
|
5
|
-
*/
|
|
6
|
-
const DEFAULT_CONCURRENCY = 1024;
|
|
7
|
-
const createPool = ({ concurrency, interval } = {}) => {
|
|
8
|
-
concurrency ||= DEFAULT_CONCURRENCY;
|
|
9
|
-
if (concurrency === Infinity) return { run: async (fn) => fn() };
|
|
10
|
-
const pool = /* @__PURE__ */ new Set();
|
|
11
|
-
const run = async (fn, promise, resolve) => {
|
|
12
|
-
if (pool.size >= concurrency) {
|
|
13
|
-
promise ||= new Promise((r) => resolve = r);
|
|
14
|
-
setTimeout(() => run(fn, promise, resolve));
|
|
15
|
-
return promise;
|
|
16
|
-
}
|
|
17
|
-
const marker = {};
|
|
18
|
-
pool.add(marker);
|
|
19
|
-
const result = await fn();
|
|
20
|
-
if (interval) setTimeout(() => pool.delete(marker), interval);
|
|
21
|
-
else pool.delete(marker);
|
|
22
|
-
if (resolve) {
|
|
23
|
-
resolve(result);
|
|
24
|
-
return promise;
|
|
25
|
-
} else return result;
|
|
26
|
-
};
|
|
27
|
-
return { run };
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
1
|
+
import { t as createPool } from "../concurrent-DrF3d2c-.js";
|
|
30
2
|
export { createPool };
|
package/lib/utils/constants.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Constant used to mark a composed handler.
|
|
4
|
-
*/
|
|
5
|
-
const COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
6
|
-
//#endregion
|
|
1
|
+
import { t as COMPOSED_HANDLER } from "../constants-CBSEudrb.js";
|
|
7
2
|
export { COMPOSED_HANDLER };
|