repocairn 0.1.3 → 0.1.4
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 +6 -0
- package/dist/graphify-source.d.ts +17 -0
- package/dist/graphify-source.js +87 -0
- package/dist/graphify-source.js.map +1 -0
- package/dist/index-command.js +3 -1
- package/dist/index-command.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/indexer.d.ts +1 -0
- package/dist/indexer.js +1 -1
- package/dist/indexer.js.map +1 -1
- package/dist/signals.d.ts +13 -0
- package/dist/signals.js +84 -0
- package/dist/signals.js.map +1 -0
- package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/eventsource-parser/dist/index.cjs +2 -2
- package/node_modules/eventsource-parser/dist/index.cjs.map +1 -1
- package/node_modules/eventsource-parser/dist/index.js +2 -2
- package/node_modules/eventsource-parser/dist/index.js.map +1 -1
- package/node_modules/eventsource-parser/package.json +1 -1
- package/node_modules/eventsource-parser/src/parse.ts +4 -2
- package/node_modules/express-rate-limit/dist/index.cjs +6 -1
- package/node_modules/express-rate-limit/dist/index.mjs +6 -1
- package/node_modules/express-rate-limit/package.json +6 -6
- package/node_modules/fast-uri/index.js +37 -1
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/security.test.js +136 -0
- package/node_modules/hono/dist/cjs/client/client.js +3 -3
- package/node_modules/hono/dist/cjs/client/utils.js +1 -1
- package/node_modules/hono/dist/cjs/context.js +32 -13
- package/node_modules/hono/dist/cjs/helper/proxy/index.js +4 -0
- package/node_modules/hono/dist/cjs/hono-base.js +3 -2
- package/node_modules/hono/dist/cjs/jsx/base.js +27 -23
- package/node_modules/hono/dist/cjs/jsx/hooks/index.js +16 -13
- package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +17 -14
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +6 -3
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/language/language.js +10 -6
- package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +90 -0
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/cjs/request.js +6 -8
- package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +44 -68
- package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/cjs/router.js +1 -1
- package/node_modules/hono/dist/cjs/utils/cookie.js +3 -2
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/cjs/utils/stream.js +5 -2
- package/node_modules/hono/dist/cjs/utils/url.js +9 -9
- package/node_modules/hono/dist/client/client.js +3 -3
- package/node_modules/hono/dist/client/utils.js +1 -1
- package/node_modules/hono/dist/context.js +32 -13
- package/node_modules/hono/dist/helper/proxy/index.js +4 -0
- package/node_modules/hono/dist/hono-base.js +3 -2
- package/node_modules/hono/dist/jsx/base.js +27 -23
- package/node_modules/hono/dist/jsx/hooks/index.js +16 -13
- package/node_modules/hono/dist/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/middleware/cors/index.js +17 -14
- package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/middleware/etag/index.js +6 -3
- package/node_modules/hono/dist/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/middleware/language/language.js +10 -6
- package/node_modules/hono/dist/middleware/method-not-allowed/index.js +68 -0
- package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/request.js +7 -9
- package/node_modules/hono/dist/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/router/trie-router/node.js +44 -68
- package/node_modules/hono/dist/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/router.js +1 -1
- package/node_modules/hono/dist/types/client/types.d.ts +1 -1
- package/node_modules/hono/dist/types/context.d.ts +4 -0
- package/node_modules/hono/dist/types/hono-base.d.ts +4 -3
- package/node_modules/hono/dist/types/jsx/base.d.ts +4 -2
- package/node_modules/hono/dist/types/jsx/dom/index.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/server.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +8 -6
- package/node_modules/hono/dist/types/jsx/index.d.ts +5 -5
- package/node_modules/hono/dist/types/middleware/cache/index.d.ts +6 -4
- package/node_modules/hono/dist/types/middleware/cors/index.d.ts +1 -1
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +2 -2
- package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +49 -0
- package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +1 -1
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +2 -1
- package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
- package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
- package/node_modules/hono/dist/types/router.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/headers.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
- package/node_modules/hono/dist/utils/cookie.js +4 -3
- package/node_modules/hono/dist/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/utils/stream.js +5 -2
- package/node_modules/hono/dist/utils/url.js +7 -8
- package/node_modules/hono/package.json +10 -3
- package/node_modules/ip-address/README.md +163 -149
- package/node_modules/ip-address/dist/address-error.d.ts +11 -0
- package/node_modules/ip-address/dist/address-error.js.map +1 -1
- package/node_modules/ip-address/dist/common.d.ts +6 -0
- package/node_modules/ip-address/dist/common.js +17 -1
- package/node_modules/ip-address/dist/common.js.map +1 -1
- package/node_modules/ip-address/dist/ipv4.d.ts +22 -6
- package/node_modules/ip-address/dist/ipv4.js +25 -18
- package/node_modules/ip-address/dist/ipv4.js.map +1 -1
- package/node_modules/ip-address/dist/ipv6.d.ts +19 -5
- package/node_modules/ip-address/dist/ipv6.js +61 -33
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/package.json +5 -3
- package/node_modules/jose/README.md +13 -13
- package/node_modules/jose/dist/types/index.d.ts +6 -5
- package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +8 -19
- package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +8 -19
- package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +18 -13
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +21 -21
- package/node_modules/jose/dist/types/jwk/embedded.d.ts +8 -12
- package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +0 -15
- package/node_modules/jose/dist/types/jwks/local.d.ts +12 -21
- package/node_modules/jose/dist/types/jwks/remote.d.ts +34 -165
- package/node_modules/jose/dist/types/jws/compact/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jws/compact/verify.d.ts +17 -13
- package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +17 -13
- package/node_modules/jose/dist/types/jws/general/sign.d.ts +16 -17
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +18 -15
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +11 -34
- package/node_modules/jose/dist/types/jwt/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +4 -13
- package/node_modules/jose/dist/types/jwt/verify.d.ts +14 -13
- package/node_modules/jose/dist/types/key/export.d.ts +0 -14
- package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +7 -14
- package/node_modules/jose/dist/types/key/generate_secret.d.ts +16 -14
- package/node_modules/jose/dist/types/key/import.d.ts +18 -28
- package/node_modules/jose/dist/types/types.d.ts +243 -224
- package/node_modules/jose/dist/types/util/base64url.d.ts +11 -4
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -9
- package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +0 -8
- package/node_modules/jose/dist/types/util/errors.d.ts +128 -121
- package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +4 -22
- package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +5 -153
- package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +16 -111
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +23 -3
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +70 -82
- package/node_modules/jose/dist/webapi/jwk/embedded.js +5 -3
- package/node_modules/jose/dist/webapi/jwks/local.js +32 -73
- package/node_modules/jose/dist/webapi/jwks/remote.js +19 -28
- package/node_modules/jose/dist/webapi/jws/compact/sign.js +5 -2
- package/node_modules/jose/dist/webapi/jws/compact/verify.js +4 -16
- package/node_modules/jose/dist/webapi/jws/flattened/sign.js +7 -65
- package/node_modules/jose/dist/webapi/jws/flattened/verify.js +3 -89
- package/node_modules/jose/dist/webapi/jws/general/sign.js +19 -15
- package/node_modules/jose/dist/webapi/jws/general/verify.js +29 -9
- package/node_modules/jose/dist/webapi/jwt/decrypt.js +5 -5
- package/node_modules/jose/dist/webapi/jwt/sign.js +2 -3
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +4 -3
- package/node_modules/jose/dist/webapi/jwt/verify.js +6 -6
- package/node_modules/jose/dist/webapi/key/export.js +37 -4
- package/node_modules/jose/dist/webapi/key/generate_key_pair.js +33 -82
- package/node_modules/jose/dist/webapi/key/generate_secret.js +2 -2
- package/node_modules/jose/dist/webapi/key/import.js +8 -8
- package/node_modules/jose/dist/webapi/lib/asn1.js +53 -122
- package/node_modules/jose/dist/webapi/lib/buffer_utils.js +1 -0
- package/node_modules/jose/dist/webapi/lib/content_encryption.js +34 -109
- package/node_modules/jose/dist/webapi/lib/crypto_key.js +18 -126
- package/node_modules/jose/dist/webapi/lib/helpers.js +23 -0
- package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +0 -1
- package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +107 -0
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +186 -0
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +114 -0
- package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +8 -98
- package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +73 -0
- package/node_modules/jose/dist/webapi/lib/jws_sign.js +74 -0
- package/node_modules/jose/dist/webapi/lib/jws_verify.js +107 -0
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +68 -109
- package/node_modules/jose/dist/webapi/lib/key.js +132 -0
- package/node_modules/jose/dist/webapi/lib/key_algorithm.js +10 -0
- package/node_modules/jose/dist/webapi/lib/key_descriptor.js +7 -0
- package/node_modules/jose/dist/webapi/lib/key_management.js +162 -92
- package/node_modules/jose/dist/webapi/lib/options.js +48 -0
- package/node_modules/jose/dist/webapi/lib/signing.js +14 -56
- package/node_modules/jose/dist/webapi/lib/type_checks.js +13 -18
- package/node_modules/jose/dist/webapi/util/base64url.js +13 -4
- package/node_modules/jose/dist/webapi/util/decode_jwt.js +2 -2
- package/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -15
- package/node_modules/jose/dist/webapi/util/errors.js +1 -1
- package/node_modules/jose/package.json +2 -4
- package/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/package.json +5 -3
- package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +0 -15
- package/node_modules/jose/dist/webapi/lib/aeskw.js +0 -25
- package/node_modules/jose/dist/webapi/lib/check_key_type.js +0 -122
- package/node_modules/jose/dist/webapi/lib/ecdhes.js +0 -52
- package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +0 -34
- package/node_modules/jose/dist/webapi/lib/normalize_key.js +0 -166
- package/node_modules/jose/dist/webapi/lib/pbes2kw.js +0 -42
- package/node_modules/jose/dist/webapi/lib/rsaes.js +0 -24
- package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +0 -10
- package/node_modules/jose/dist/webapi/lib/validate_crit.js +0 -33
|
@@ -24,12 +24,20 @@ var import_node = require("./node");
|
|
|
24
24
|
class Trie {
|
|
25
25
|
#context = { varIndex: 0 };
|
|
26
26
|
#root = new import_node.Node();
|
|
27
|
-
|
|
27
|
+
#index = 0;
|
|
28
|
+
// dynamic path -> [handler index, param assoc]; static paths are not registered
|
|
29
|
+
paths = /* @__PURE__ */ Object.create(null);
|
|
30
|
+
insert(path, isStatic) {
|
|
31
|
+
if (isStatic) {
|
|
32
|
+
this.#root.insert(path.split(""), 0, [], this.#context, true);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
28
35
|
const paramAssoc = [];
|
|
29
36
|
const groups = [];
|
|
37
|
+
let markedPath = path;
|
|
30
38
|
for (let i = 0; ; ) {
|
|
31
39
|
let replaced = false;
|
|
32
|
-
|
|
40
|
+
markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
|
|
33
41
|
const mark = `@\\${i}`;
|
|
34
42
|
groups[i] = [mark, m];
|
|
35
43
|
i++;
|
|
@@ -40,7 +48,7 @@ class Trie {
|
|
|
40
48
|
break;
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
|
-
const tokens =
|
|
51
|
+
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
44
52
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
45
53
|
const [mark] = groups[i];
|
|
46
54
|
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
@@ -50,8 +58,8 @@ class Trie {
|
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
|
-
this.#root.insert(tokens, index, paramAssoc, this.#context,
|
|
54
|
-
|
|
61
|
+
this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
|
|
62
|
+
this.paths[path] = [this.#index++, paramAssoc];
|
|
55
63
|
}
|
|
56
64
|
buildRegExp() {
|
|
57
65
|
let regexp = this.#root.buildRegExpStr();
|
|
@@ -23,76 +23,51 @@ module.exports = __toCommonJS(node_exports);
|
|
|
23
23
|
var import_router = require("../../router");
|
|
24
24
|
var import_url = require("../../utils/url");
|
|
25
25
|
const emptyParams = /* @__PURE__ */ Object.create(null);
|
|
26
|
-
|
|
27
|
-
for (const _ in children) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
};
|
|
26
|
+
let order = 0;
|
|
32
27
|
class Node {
|
|
33
|
-
#methods;
|
|
34
|
-
#children;
|
|
35
|
-
#patterns;
|
|
36
|
-
#
|
|
28
|
+
#methods = [];
|
|
29
|
+
#children = /* @__PURE__ */ Object.create(null);
|
|
30
|
+
#patterns = [];
|
|
31
|
+
#pattern;
|
|
37
32
|
#params = emptyParams;
|
|
38
|
-
constructor(method, handler, children) {
|
|
39
|
-
this.#children = children || /* @__PURE__ */ Object.create(null);
|
|
40
|
-
this.#methods = [];
|
|
41
|
-
if (method && handler) {
|
|
42
|
-
const m = /* @__PURE__ */ Object.create(null);
|
|
43
|
-
m[method] = { handler, possibleKeys: [], score: 0 };
|
|
44
|
-
this.#methods = [m];
|
|
45
|
-
}
|
|
46
|
-
this.#patterns = [];
|
|
47
|
-
}
|
|
48
33
|
insert(method, path, handler) {
|
|
49
|
-
this.#order = ++this.#order;
|
|
50
34
|
let curNode = this;
|
|
51
35
|
const parts = (0, import_url.splitRoutingPath)(path);
|
|
52
|
-
const possibleKeys =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const nextP = parts[i
|
|
56
|
-
const pattern = (0, import_url.getPattern)(p, nextP);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
continue;
|
|
36
|
+
const possibleKeys = /* @__PURE__ */ new Set();
|
|
37
|
+
let i = 0;
|
|
38
|
+
for (const p of parts) {
|
|
39
|
+
const nextP = parts[++i];
|
|
40
|
+
const pattern = (0, import_url.getPattern)(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
|
|
41
|
+
const isParam = Array.isArray(pattern);
|
|
42
|
+
const key = isParam ? pattern[0] : pattern || p;
|
|
43
|
+
const child = curNode.#children[key] ||= new Node();
|
|
44
|
+
if (pattern && !child.#pattern) {
|
|
45
|
+
child.#pattern = pattern;
|
|
46
|
+
curNode.#patterns.push(child);
|
|
64
47
|
}
|
|
65
|
-
curNode
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
possibleKeys.push(pattern[1]);
|
|
48
|
+
curNode = child;
|
|
49
|
+
if (isParam) {
|
|
50
|
+
possibleKeys.add(pattern[1]);
|
|
69
51
|
}
|
|
70
|
-
curNode = curNode.#children[key];
|
|
71
52
|
}
|
|
72
53
|
curNode.#methods.push({
|
|
73
54
|
[method]: {
|
|
74
55
|
handler,
|
|
75
|
-
possibleKeys: possibleKeys
|
|
76
|
-
score:
|
|
56
|
+
possibleKeys: [...possibleKeys],
|
|
57
|
+
score: ++order
|
|
77
58
|
}
|
|
78
59
|
});
|
|
79
|
-
return curNode;
|
|
80
60
|
}
|
|
81
61
|
#pushHandlerSets(handlerSets, node, method, nodeParams, params) {
|
|
82
62
|
for (let i = 0, len = node.#methods.length; i < len; i++) {
|
|
83
63
|
const m = node.#methods[i];
|
|
84
64
|
const handlerSet = m[method] || m[import_router.METHOD_NAME_ALL];
|
|
85
|
-
|
|
86
|
-
if (handlerSet !== void 0) {
|
|
65
|
+
if (handlerSet) {
|
|
87
66
|
handlerSet.params = /* @__PURE__ */ Object.create(null);
|
|
88
67
|
handlerSets.push(handlerSet);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const processed = processedSet[handlerSet.score];
|
|
93
|
-
handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
|
|
94
|
-
processedSet[handlerSet.score] = true;
|
|
95
|
-
}
|
|
68
|
+
for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
|
|
69
|
+
const key = handlerSet.possibleKeys[i2];
|
|
70
|
+
handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
|
|
96
71
|
}
|
|
97
72
|
}
|
|
98
73
|
}
|
|
@@ -124,33 +99,33 @@ class Node {
|
|
|
124
99
|
tempNodes.push(nextNode);
|
|
125
100
|
}
|
|
126
101
|
}
|
|
127
|
-
for (
|
|
128
|
-
const pattern =
|
|
102
|
+
for (const child of node.#patterns) {
|
|
103
|
+
const pattern = child.#pattern;
|
|
129
104
|
const params = node.#params === emptyParams ? {} : { ...node.#params };
|
|
130
|
-
if (pattern === "
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
if (typeof pattern === "string") {
|
|
106
|
+
if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
|
|
107
|
+
this.#pushHandlerSets(handlerSets, child, method, node.#params);
|
|
108
|
+
if (pattern === "*") {
|
|
109
|
+
child.#params = params;
|
|
110
|
+
tempNodes.push(child);
|
|
111
|
+
}
|
|
136
112
|
}
|
|
137
113
|
continue;
|
|
138
114
|
}
|
|
139
|
-
const [
|
|
140
|
-
if (!part &&
|
|
115
|
+
const [, name, matcher] = pattern;
|
|
116
|
+
if (!part && matcher === true) {
|
|
141
117
|
continue;
|
|
142
118
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
partOffsets = new Array(len);
|
|
119
|
+
if (matcher !== true) {
|
|
120
|
+
if (!partOffsets) {
|
|
121
|
+
partOffsets = [];
|
|
147
122
|
let offset = path[0] === "/" ? 1 : 0;
|
|
148
123
|
for (let p = 0; p < len; p++) {
|
|
149
124
|
partOffsets[p] = offset;
|
|
150
125
|
offset += parts[p].length + 1;
|
|
151
126
|
}
|
|
152
127
|
}
|
|
153
|
-
const restPathString = path.
|
|
128
|
+
const restPathString = path.slice(partOffsets[i]);
|
|
154
129
|
const m = matcher.exec(restPathString);
|
|
155
130
|
if (m) {
|
|
156
131
|
params[name] = m[0];
|
|
@@ -164,11 +139,12 @@ class Node {
|
|
|
164
139
|
params
|
|
165
140
|
);
|
|
166
141
|
}
|
|
167
|
-
|
|
142
|
+
for (const _ in child.#children) {
|
|
168
143
|
child.#params = params;
|
|
169
|
-
const componentCount = m[0].match(/\//)?.length ?? 0;
|
|
144
|
+
const componentCount = m[0].match(/\//g)?.length ?? 0;
|
|
170
145
|
const targetCurNodes = curNodesQueue[componentCount] ||= [];
|
|
171
146
|
targetCurNodes.push(child);
|
|
147
|
+
break;
|
|
172
148
|
}
|
|
173
149
|
continue;
|
|
174
150
|
}
|
|
@@ -196,7 +172,7 @@ class Node {
|
|
|
196
172
|
const shifted = curNodesQueue.shift();
|
|
197
173
|
curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
|
|
198
174
|
}
|
|
199
|
-
if (handlerSets
|
|
175
|
+
if (handlerSets[1]) {
|
|
200
176
|
handlerSets.sort((a, b) => {
|
|
201
177
|
return a.score - b.score;
|
|
202
178
|
});
|
|
@@ -24,19 +24,11 @@ var import_url = require("../../utils/url");
|
|
|
24
24
|
var import_node = require("./node");
|
|
25
25
|
class TrieRouter {
|
|
26
26
|
name = "TrieRouter";
|
|
27
|
-
#node;
|
|
28
|
-
constructor() {
|
|
29
|
-
this.#node = new import_node.Node();
|
|
30
|
-
}
|
|
27
|
+
#node = new import_node.Node();
|
|
31
28
|
add(method, path, handler) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
for (let i = 0, len = results.length; i < len; i++) {
|
|
35
|
-
this.#node.insert(method, results[i], handler);
|
|
36
|
-
}
|
|
37
|
-
return;
|
|
29
|
+
for (const result of (0, import_url.checkOptionalParameter)(path) || [path]) {
|
|
30
|
+
this.#node.insert(method, result, handler);
|
|
38
31
|
}
|
|
39
|
-
this.#node.insert(method, path, handler);
|
|
40
32
|
}
|
|
41
33
|
match(method, path) {
|
|
42
34
|
return this.#node.search(method, path);
|
|
@@ -26,7 +26,7 @@ __export(router_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(router_exports);
|
|
27
27
|
const METHOD_NAME_ALL = "ALL";
|
|
28
28
|
const METHOD_NAME_ALL_LOWERCASE = "all";
|
|
29
|
-
const METHODS = ["get", "post", "put", "delete", "options", "patch"];
|
|
29
|
+
const METHODS = ["get", "post", "put", "delete", "options", "patch", "query"];
|
|
30
30
|
const MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
31
31
|
class UnsupportedPathError extends Error {
|
|
32
32
|
}
|
|
@@ -47,6 +47,7 @@ const verifySignature = async (base64Signature, value, secret) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
|
|
50
|
+
const relaxedCookieNameRegEx = /^[!#-:<>-[\]-~]+$/;
|
|
50
51
|
const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
|
|
51
52
|
const trimCookieWhitespace = (value) => {
|
|
52
53
|
let start = 0;
|
|
@@ -79,7 +80,7 @@ const parse = (cookie, name) => {
|
|
|
79
80
|
continue;
|
|
80
81
|
}
|
|
81
82
|
const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos));
|
|
82
|
-
if (name && name !== cookieName || !
|
|
83
|
+
if (name && name !== cookieName || !relaxedCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) {
|
|
83
84
|
continue;
|
|
84
85
|
}
|
|
85
86
|
let cookieValue = trimCookieWhitespace(pairStr.substring(valueStartPos + 1));
|
|
@@ -87,7 +88,7 @@ const parse = (cookie, name) => {
|
|
|
87
88
|
cookieValue = cookieValue.slice(1, -1);
|
|
88
89
|
}
|
|
89
90
|
if (validCookieValueRegEx.test(cookieValue)) {
|
|
90
|
-
parsedCookie[cookieName] =
|
|
91
|
+
parsedCookie[cookieName] = (0, import_url.tryDecodeURIComponent)(cookieValue);
|
|
91
92
|
if (name) {
|
|
92
93
|
break;
|
|
93
94
|
}
|
|
@@ -30,12 +30,14 @@ __export(ipaddr_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(ipaddr_exports);
|
|
31
31
|
const expandIPv6 = (ipV6) => {
|
|
32
32
|
const sections = ipV6.split(":");
|
|
33
|
-
|
|
33
|
+
const lastSection = sections.at(-1);
|
|
34
|
+
if (IPV4_REGEX.test(lastSection)) {
|
|
35
|
+
const octets = lastSection.split(".").map(Number);
|
|
34
36
|
sections.splice(
|
|
35
37
|
-1,
|
|
36
38
|
1,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
(octets[0] << 8 | octets[1]).toString(16),
|
|
40
|
+
(octets[2] << 8 | octets[3]).toString(16)
|
|
39
41
|
);
|
|
40
42
|
}
|
|
41
43
|
for (let i = 0; i < sections.length; i++) {
|
|
@@ -80,8 +80,11 @@ class StreamingApi {
|
|
|
80
80
|
}
|
|
81
81
|
async pipe(body) {
|
|
82
82
|
this.writer.releaseLock();
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
try {
|
|
84
|
+
await body.pipeTo(this.writable, { preventClose: true, preventAbort: true });
|
|
85
|
+
} finally {
|
|
86
|
+
this.writer = this.writable.getWriter();
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
onAbort(listener) {
|
|
87
90
|
this.abortSubscribers.push(listener);
|
|
@@ -29,7 +29,8 @@ __export(url_exports, {
|
|
|
29
29
|
splitPath: () => splitPath,
|
|
30
30
|
splitRoutingPath: () => splitRoutingPath,
|
|
31
31
|
tryDecode: () => tryDecode,
|
|
32
|
-
tryDecodeURI: () => tryDecodeURI
|
|
32
|
+
tryDecodeURI: () => tryDecodeURI,
|
|
33
|
+
tryDecodeURIComponent: () => tryDecodeURIComponent
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(url_exports);
|
|
35
36
|
const splitPath = (path) => {
|
|
@@ -141,13 +142,13 @@ const checkOptionalParameter = (path) => {
|
|
|
141
142
|
if (segment !== "" && !/\:/.test(segment)) {
|
|
142
143
|
basePath += "/" + segment;
|
|
143
144
|
} else if (/\:/.test(segment)) {
|
|
144
|
-
if (
|
|
145
|
+
if (segment.charCodeAt(segment.length - 1) === 63) {
|
|
145
146
|
if (results.length === 0 && basePath === "") {
|
|
146
147
|
results.push("/");
|
|
147
148
|
} else {
|
|
148
149
|
results.push(basePath);
|
|
149
150
|
}
|
|
150
|
-
const optionalSegment = segment.
|
|
151
|
+
const optionalSegment = segment.slice(0, -1);
|
|
151
152
|
basePath += "/" + optionalSegment;
|
|
152
153
|
results.push(basePath);
|
|
153
154
|
} else {
|
|
@@ -157,18 +158,16 @@ const checkOptionalParameter = (path) => {
|
|
|
157
158
|
});
|
|
158
159
|
return results.filter((v, i, a) => a.indexOf(v) === i);
|
|
159
160
|
};
|
|
161
|
+
const tryDecodeURIComponent = (str) => str.indexOf("%") !== -1 ? tryDecode(str, decodeURIComponent_) : str;
|
|
160
162
|
const _decodeURI = (value) => {
|
|
161
|
-
if (!/[%+]/.test(value)) {
|
|
162
|
-
return value;
|
|
163
|
-
}
|
|
164
163
|
if (value.indexOf("+") !== -1) {
|
|
165
164
|
value = value.replace(/\+/g, " ");
|
|
166
165
|
}
|
|
167
|
-
return
|
|
166
|
+
return tryDecodeURIComponent(value);
|
|
168
167
|
};
|
|
169
168
|
const _getQueryParam = (url, key, multiple) => {
|
|
170
169
|
let encoded;
|
|
171
|
-
if (!multiple && key &&
|
|
170
|
+
if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
|
|
172
171
|
let keyIndex2 = url.indexOf("?", 8);
|
|
173
172
|
if (keyIndex2 === -1) {
|
|
174
173
|
return void 0;
|
|
@@ -252,5 +251,6 @@ const decodeURIComponent_ = decodeURIComponent;
|
|
|
252
251
|
splitPath,
|
|
253
252
|
splitRoutingPath,
|
|
254
253
|
tryDecode,
|
|
255
|
-
tryDecodeURI
|
|
254
|
+
tryDecodeURI,
|
|
255
|
+
tryDecodeURIComponent
|
|
256
256
|
});
|
|
@@ -60,7 +60,7 @@ var ClientRequestImpl = class {
|
|
|
60
60
|
}
|
|
61
61
|
this.rBody = form;
|
|
62
62
|
}
|
|
63
|
-
if (args.json) {
|
|
63
|
+
if (args.json !== void 0) {
|
|
64
64
|
this.rBody = JSON.stringify(args.json);
|
|
65
65
|
this.cType = "application/json";
|
|
66
66
|
}
|
|
@@ -76,9 +76,9 @@ var ClientRequestImpl = class {
|
|
|
76
76
|
if (args?.cookie) {
|
|
77
77
|
const cookies = [];
|
|
78
78
|
for (const [key, value] of Object.entries(args.cookie)) {
|
|
79
|
-
cookies.push(serialize(key, value
|
|
79
|
+
cookies.push(serialize(key, value));
|
|
80
80
|
}
|
|
81
|
-
headerValues["Cookie"] = cookies.join("
|
|
81
|
+
headerValues["Cookie"] = cookies.join("; ");
|
|
82
82
|
}
|
|
83
83
|
if (this.cType) {
|
|
84
84
|
headerValues["Content-Type"] = this.cType;
|
|
@@ -9,7 +9,7 @@ var mergePath = (base, path) => {
|
|
|
9
9
|
var replaceUrlParam = (urlString, params) => {
|
|
10
10
|
for (const [k, v] of Object.entries(params)) {
|
|
11
11
|
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
12
|
-
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
12
|
+
urlString = urlString.replace(reg, () => v ? `/${v}` : "");
|
|
13
13
|
}
|
|
14
14
|
return urlString;
|
|
15
15
|
};
|
|
@@ -202,6 +202,10 @@ var Context = class {
|
|
|
202
202
|
* c.header('X-Message', 'Hello!')
|
|
203
203
|
* c.header('Content-Type', 'text/plain')
|
|
204
204
|
*
|
|
205
|
+
* // Append multiple headers using the append option (e.g. Vary)
|
|
206
|
+
* c.header('Vary', 'Accept-Encoding', { append: true })
|
|
207
|
+
* c.header('Vary', 'User-Agent', { append: true })
|
|
208
|
+
*
|
|
205
209
|
* return c.body('Thank you for coming')
|
|
206
210
|
* })
|
|
207
211
|
* ```
|
|
@@ -273,11 +277,11 @@ var Context = class {
|
|
|
273
277
|
return Object.fromEntries(this.#var);
|
|
274
278
|
}
|
|
275
279
|
#newResponse(data, arg, headers) {
|
|
276
|
-
|
|
277
|
-
if (typeof arg === "object" &&
|
|
278
|
-
|
|
279
|
-
for (const [key, value] of
|
|
280
|
-
if (key
|
|
280
|
+
let responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders;
|
|
281
|
+
if (typeof arg === "object" && arg.headers) {
|
|
282
|
+
responseHeaders ??= new Headers();
|
|
283
|
+
for (const [key, value] of new Headers(arg.headers)) {
|
|
284
|
+
if (key === "set-cookie") {
|
|
281
285
|
responseHeaders.append(key, value);
|
|
282
286
|
} else {
|
|
283
287
|
responseHeaders.set(key, value);
|
|
@@ -285,19 +289,34 @@ var Context = class {
|
|
|
285
289
|
}
|
|
286
290
|
}
|
|
287
291
|
if (headers) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
292
|
+
if (!responseHeaders) {
|
|
293
|
+
let count = 0;
|
|
294
|
+
for (const k in headers) {
|
|
295
|
+
if (++count > 1 || typeof headers[k] !== "string") {
|
|
296
|
+
responseHeaders = new Headers();
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (responseHeaders) {
|
|
302
|
+
for (const k in headers) {
|
|
303
|
+
const v = headers[k];
|
|
304
|
+
if (typeof v === "string") {
|
|
305
|
+
responseHeaders.set(k, v);
|
|
306
|
+
} else {
|
|
307
|
+
responseHeaders.delete(k);
|
|
308
|
+
for (const v2 of v) {
|
|
309
|
+
responseHeaders.append(k, v2);
|
|
310
|
+
}
|
|
295
311
|
}
|
|
296
312
|
}
|
|
297
313
|
}
|
|
298
314
|
}
|
|
299
315
|
const status = typeof arg === "number" ? arg : arg?.status ?? this.#status;
|
|
300
|
-
return createResponseInstance(data, {
|
|
316
|
+
return createResponseInstance(data, {
|
|
317
|
+
status,
|
|
318
|
+
headers: responseHeaders ?? headers
|
|
319
|
+
});
|
|
301
320
|
}
|
|
302
321
|
newResponse = (...args) => this.#newResponse(...args);
|
|
303
322
|
/**
|
|
@@ -71,6 +71,10 @@ var proxy = async (input, proxyInit) => {
|
|
|
71
71
|
req.headers.delete("accept-encoding");
|
|
72
72
|
const res = await (customFetch || fetch)(req);
|
|
73
73
|
const resHeaders = new Headers(res.headers);
|
|
74
|
+
const connectionValue = resHeaders.get("connection");
|
|
75
|
+
if (connectionValue) {
|
|
76
|
+
connectionValue.split(",").map((h) => h.trim()).filter((h) => ALLOWED_TOKEN_PATTERN.test(h)).forEach((h) => resHeaders.delete(h));
|
|
77
|
+
}
|
|
74
78
|
hopByHopHeaders.forEach((header) => {
|
|
75
79
|
resHeaders.delete(header);
|
|
76
80
|
});
|
|
@@ -22,6 +22,7 @@ var Hono = class _Hono {
|
|
|
22
22
|
delete;
|
|
23
23
|
options;
|
|
24
24
|
patch;
|
|
25
|
+
query;
|
|
25
26
|
all;
|
|
26
27
|
on;
|
|
27
28
|
use;
|
|
@@ -321,8 +322,8 @@ var Hono = class _Hono {
|
|
|
321
322
|
* @see {@link https://hono.dev/docs/api/hono#fetch}
|
|
322
323
|
*
|
|
323
324
|
* @param {Request} request - request Object of request
|
|
324
|
-
* @param {Env}
|
|
325
|
-
* @param {ExecutionContext} - context of execution
|
|
325
|
+
* @param {Env} env - env Object
|
|
326
|
+
* @param {ExecutionContext} executionCtx - context of execution
|
|
326
327
|
* @returns {Response | Promise<Response>} response of request
|
|
327
328
|
*
|
|
328
329
|
*/
|
|
@@ -69,6 +69,18 @@ var booleanAttributes = [
|
|
|
69
69
|
"reversed",
|
|
70
70
|
"selected"
|
|
71
71
|
];
|
|
72
|
+
var resolveFunctionComponentResult = (result, suspendedContext) => result.then((resolved) => {
|
|
73
|
+
if (!Array.isArray(resolved) && !(resolved instanceof JSXNode)) {
|
|
74
|
+
return resolved;
|
|
75
|
+
}
|
|
76
|
+
const children = Array.isArray(resolved) ? resolved : [resolved];
|
|
77
|
+
const render = () => {
|
|
78
|
+
const buffer = [""];
|
|
79
|
+
childrenToStringToBuffer(children, buffer);
|
|
80
|
+
return buffer.length === 1 ? raw(buffer[0], buffer.callbacks) : stringBufferToString(buffer, buffer.callbacks);
|
|
81
|
+
};
|
|
82
|
+
return suspendedContext ? suspendedContext(render) : runWithRenderContext(render);
|
|
83
|
+
});
|
|
72
84
|
var childrenToStringToBuffer = (children, buffer) => {
|
|
73
85
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
74
86
|
const child = children[i];
|
|
@@ -78,9 +90,17 @@ var childrenToStringToBuffer = (children, buffer) => {
|
|
|
78
90
|
continue;
|
|
79
91
|
} else if (child instanceof JSXNode) {
|
|
80
92
|
child.toStringToBuffer(buffer);
|
|
81
|
-
} else if (typeof child === "number"
|
|
93
|
+
} else if (typeof child === "number") {
|
|
94
|
+
;
|
|
95
|
+
buffer[0] += child;
|
|
96
|
+
} else if (child.isEscaped) {
|
|
82
97
|
;
|
|
83
98
|
buffer[0] += child;
|
|
99
|
+
const callbacks = child.callbacks;
|
|
100
|
+
if (callbacks) {
|
|
101
|
+
buffer.callbacks ||= [];
|
|
102
|
+
buffer.callbacks.push(...callbacks);
|
|
103
|
+
}
|
|
84
104
|
} else if (child instanceof Promise) {
|
|
85
105
|
buffer.unshift("", child);
|
|
86
106
|
} else {
|
|
@@ -94,7 +114,6 @@ var JSXNode = class {
|
|
|
94
114
|
key;
|
|
95
115
|
children;
|
|
96
116
|
isEscaped = true;
|
|
97
|
-
suspendedContext;
|
|
98
117
|
constructor(tag, props, children) {
|
|
99
118
|
if (typeof tag !== "function" && !isValidTagName(tag)) {
|
|
100
119
|
throw new Error(`Invalid JSX tag name: ${tag}`);
|
|
@@ -117,7 +136,7 @@ var JSXNode = class {
|
|
|
117
136
|
this.toStringToBuffer(buffer);
|
|
118
137
|
return buffer.length === 1 ? "callbacks" in buffer ? resolveCallbackSync(raw(buffer[0], buffer.callbacks)).toString() : buffer[0] : stringBufferToString(buffer, buffer.callbacks);
|
|
119
138
|
};
|
|
120
|
-
return
|
|
139
|
+
return runWithRenderContext(render);
|
|
121
140
|
}
|
|
122
141
|
toStringToBuffer(buffer) {
|
|
123
142
|
const tag = this.tag;
|
|
@@ -191,21 +210,14 @@ var JSXFunctionNode = class extends JSXNode {
|
|
|
191
210
|
return;
|
|
192
211
|
} else if (res instanceof Promise) {
|
|
193
212
|
if (globalContexts.length === 0) {
|
|
194
|
-
buffer.unshift("", res);
|
|
213
|
+
buffer.unshift("", resolveFunctionComponentResult(res));
|
|
195
214
|
} else {
|
|
196
|
-
|
|
197
|
-
buffer.unshift(
|
|
198
|
-
"",
|
|
199
|
-
res.then((childRes) => {
|
|
200
|
-
if (childRes instanceof JSXNode) {
|
|
201
|
-
childRes.suspendedContext = suspendedContext;
|
|
202
|
-
}
|
|
203
|
-
return childRes;
|
|
204
|
-
})
|
|
205
|
-
);
|
|
215
|
+
buffer.unshift("", resolveFunctionComponentResult(res, captureRenderContext()));
|
|
206
216
|
}
|
|
207
217
|
} else if (res instanceof JSXNode) {
|
|
208
218
|
res.toStringToBuffer(buffer);
|
|
219
|
+
} else if (Array.isArray(res)) {
|
|
220
|
+
childrenToStringToBuffer(res, buffer);
|
|
209
221
|
} else if (typeof res === "number" || res.isEscaped) {
|
|
210
222
|
buffer[0] += res;
|
|
211
223
|
if (res.callbacks) {
|
|
@@ -284,15 +296,7 @@ var shallowEqual = (a, b) => {
|
|
|
284
296
|
return true;
|
|
285
297
|
};
|
|
286
298
|
var memo = (component, propsAreEqual = shallowEqual) => {
|
|
287
|
-
|
|
288
|
-
let prevProps = void 0;
|
|
289
|
-
const wrapper = ((props) => {
|
|
290
|
-
if (prevProps && !propsAreEqual(prevProps, props)) {
|
|
291
|
-
computed = null;
|
|
292
|
-
}
|
|
293
|
-
prevProps = props;
|
|
294
|
-
return computed ||= component(props);
|
|
295
|
-
});
|
|
299
|
+
const wrapper = ((props) => component(props));
|
|
296
300
|
wrapper[DOM_MEMO] = propsAreEqual;
|
|
297
301
|
wrapper[DOM_RENDERER] = component;
|
|
298
302
|
return wrapper;
|
|
@@ -222,7 +222,7 @@ var useCallback = (callback, deps) => {
|
|
|
222
222
|
}
|
|
223
223
|
return callback;
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
function useRef(initialValue) {
|
|
226
226
|
const buildData = buildDataStack.at(-1);
|
|
227
227
|
if (!buildData) {
|
|
228
228
|
return { current: initialValue };
|
|
@@ -231,7 +231,7 @@ var useRef = (initialValue) => {
|
|
|
231
231
|
const refArray = node[DOM_STASH][1][STASH_REF] ||= [];
|
|
232
232
|
const hookIndex = node[DOM_STASH][0]++;
|
|
233
233
|
return refArray[hookIndex] ||= { current: initialValue };
|
|
234
|
-
}
|
|
234
|
+
}
|
|
235
235
|
var use = (promise) => {
|
|
236
236
|
const cachedRes = resolvedPromiseValueMap.get(promise);
|
|
237
237
|
if (cachedRes) {
|
|
@@ -289,19 +289,22 @@ var useSyncExternalStore = (subscribe, getSnapshot, getServerSnapshot) => {
|
|
|
289
289
|
}
|
|
290
290
|
return getServerSnapshot();
|
|
291
291
|
}
|
|
292
|
-
const
|
|
293
|
-
const [
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
const snapshot = buildData[0][4] && getServerSnapshot ? getServerSnapshot() : getSnapshot();
|
|
293
|
+
const [, setVersion] = useState(0);
|
|
294
|
+
const latestSnapshot = useRef([snapshot, getSnapshot]);
|
|
295
|
+
latestSnapshot.current = [snapshot, getSnapshot];
|
|
296
|
+
const unsubscribeRef = useRef(null);
|
|
296
297
|
useEffect(() => {
|
|
297
|
-
|
|
298
|
-
|
|
298
|
+
const update2 = () => setVersion((version) => version + 1);
|
|
299
|
+
unsubscribeRef.current?.();
|
|
300
|
+
unsubscribeRef.current = subscribe(update2);
|
|
301
|
+
const [snapshot2, getSnapshot2] = latestSnapshot.current;
|
|
302
|
+
if (!Object.is(snapshot2, getSnapshot2())) {
|
|
303
|
+
update2();
|
|
299
304
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}, []);
|
|
304
|
-
return state;
|
|
305
|
+
}, [subscribe]);
|
|
306
|
+
useEffect(() => () => unsubscribeRef.current?.(), []);
|
|
307
|
+
return snapshot;
|
|
305
308
|
};
|
|
306
309
|
export {
|
|
307
310
|
STASH_EFFECT,
|
|
@@ -78,7 +78,7 @@ var documentMetadataTag = (tag, children, props, sort) => {
|
|
|
78
78
|
const string = new JSXNode(tag, restProps, toArray(children || [])).toString();
|
|
79
79
|
if (string instanceof Promise) {
|
|
80
80
|
return string.then(
|
|
81
|
-
(resString) => raw(
|
|
81
|
+
(resString) => raw(resString, [
|
|
82
82
|
...resString.callbacks || [],
|
|
83
83
|
insertIntoHead(tag, resString, restProps, precedence)
|
|
84
84
|
])
|