hono 2.3.2 → 2.4.1
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/cjs/compose.js +82 -66
- package/dist/cjs/context.js +159 -144
- package/dist/cjs/hono.js +173 -150
- package/dist/cjs/index.js +31 -11
- package/dist/cjs/middleware/basic-auth/index.js +70 -39
- package/dist/cjs/middleware/bearer-auth/index.js +69 -51
- package/dist/cjs/middleware/cache/index.js +49 -28
- package/dist/cjs/middleware/compress/index.js +39 -16
- package/dist/cjs/middleware/cors/index.js +89 -71
- package/dist/cjs/middleware/etag/index.js +46 -24
- package/dist/cjs/middleware/html/index.js +50 -30
- package/dist/cjs/middleware/jsx/index.js +178 -166
- package/dist/cjs/middleware/jsx/jsx-dev-runtime.js +33 -7
- package/dist/cjs/middleware/jsx/jsx-runtime.js +32 -6
- package/dist/cjs/middleware/jwt/index.js +74 -54
- package/dist/cjs/middleware/logger/index.js +59 -38
- package/dist/cjs/middleware/powered-by/index.js +30 -7
- package/dist/cjs/middleware/pretty-json/index.js +31 -8
- package/dist/cjs/middleware/serve-static/bun.js +56 -38
- package/dist/cjs/middleware/serve-static/index.js +27 -4
- package/dist/cjs/middleware/serve-static/module.js +42 -0
- package/dist/cjs/middleware/serve-static/serve-static.js +58 -39
- package/dist/cjs/middleware/validator/index.js +27 -4
- package/dist/cjs/middleware/validator/middleware.js +125 -91
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/request.js +129 -116
- package/dist/cjs/router/reg-exp-router/index.js +27 -4
- package/dist/cjs/router/reg-exp-router/node.js +108 -97
- package/dist/cjs/router/reg-exp-router/router.js +158 -141
- package/dist/cjs/router/reg-exp-router/trie.js +55 -39
- package/dist/cjs/router/smart-router/index.js +27 -4
- package/dist/cjs/router/smart-router/router.js +70 -49
- package/dist/cjs/router/static-router/index.js +27 -4
- package/dist/cjs/router/static-router/router.js +78 -64
- package/dist/cjs/router/trie-router/index.js +27 -4
- package/dist/cjs/router/trie-router/node.js +167 -159
- package/dist/cjs/router/trie-router/router.js +43 -20
- package/dist/cjs/router.js +35 -6
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/utils/body.js +36 -15
- package/dist/cjs/utils/buffer.js +56 -31
- package/dist/cjs/utils/cloudflare.js +53 -34
- package/dist/cjs/utils/cookie.js +59 -35
- package/dist/cjs/utils/crypto.js +69 -43
- package/dist/cjs/utils/encode.js +92 -65
- package/dist/cjs/utils/filepath.js +39 -22
- package/dist/cjs/utils/html.js +54 -33
- package/dist/cjs/utils/http-status.js +68 -45
- package/dist/cjs/utils/json.js +91 -76
- package/dist/cjs/utils/jwt/index.js +32 -25
- package/dist/cjs/utils/jwt/jwt.js +124 -93
- package/dist/cjs/utils/jwt/types.js +65 -38
- package/dist/cjs/utils/mime.js +110 -87
- package/dist/cjs/utils/object.js +53 -35
- package/dist/cjs/utils/types.js +15 -1
- package/dist/cjs/utils/url.js +89 -78
- package/dist/cjs/validator/rule.js +78 -64
- package/dist/cjs/validator/sanitizer.js +28 -4
- package/dist/cjs/validator/schema.js +15 -1
- package/dist/cjs/validator/validator.js +405 -386
- package/dist/compose.d.ts +1 -1
- package/dist/compose.js +61 -64
- package/dist/context.d.ts +4 -4
- package/dist/context.js +139 -143
- package/dist/hono.d.ts +1 -17
- package/dist/hono.js +153 -149
- package/dist/index.d.ts +3 -1
- package/dist/index.js +9 -9
- package/dist/middleware/basic-auth/index.d.ts +1 -1
- package/dist/middleware/basic-auth/index.js +52 -40
- package/dist/middleware/bearer-auth/index.d.ts +1 -1
- package/dist/middleware/bearer-auth/index.js +48 -49
- package/dist/middleware/cache/index.d.ts +1 -1
- package/dist/middleware/cache/index.js +28 -26
- package/dist/middleware/compress/index.d.ts +1 -1
- package/dist/middleware/compress/index.js +18 -14
- package/dist/middleware/cors/index.d.ts +1 -1
- package/dist/middleware/cors/index.js +68 -69
- package/dist/middleware/etag/index.d.ts +1 -1
- package/dist/middleware/etag/index.js +25 -22
- package/dist/middleware/html/index.js +29 -28
- package/dist/middleware/jsx/index.js +164 -172
- package/dist/middleware/jsx/jsx-dev-runtime.d.ts +1 -0
- package/dist/middleware/jsx/jsx-dev-runtime.js +11 -5
- package/dist/middleware/jsx/jsx-runtime.d.ts +1 -1
- package/dist/middleware/jsx/jsx-runtime.js +8 -2
- package/dist/middleware/jwt/index.d.ts +1 -1
- package/dist/middleware/jwt/index.js +53 -52
- package/dist/middleware/logger/index.d.ts +1 -1
- package/dist/middleware/logger/index.js +35 -39
- package/dist/middleware/powered-by/index.d.ts +1 -1
- package/dist/middleware/powered-by/index.js +9 -5
- package/dist/middleware/pretty-json/index.d.ts +1 -1
- package/dist/middleware/pretty-json/index.js +10 -6
- package/dist/middleware/serve-static/bun.d.ts +1 -1
- package/dist/middleware/serve-static/bun.js +35 -36
- package/dist/middleware/serve-static/index.js +5 -1
- package/dist/middleware/serve-static/{module.d.mts → module.d.ts} +1 -1
- package/dist/middleware/serve-static/module.js +13 -0
- package/dist/middleware/serve-static/serve-static.d.ts +1 -1
- package/dist/middleware/serve-static/serve-static.js +36 -36
- package/dist/middleware/validator/index.js +5 -2
- package/dist/middleware/validator/middleware.d.ts +1 -1
- package/dist/middleware/validator/middleware.js +104 -89
- package/dist/request.js +108 -114
- package/dist/router/reg-exp-router/index.js +5 -1
- package/dist/router/reg-exp-router/node.js +87 -96
- package/dist/router/reg-exp-router/router.js +140 -142
- package/dist/router/reg-exp-router/trie.js +35 -38
- package/dist/router/smart-router/index.js +5 -1
- package/dist/router/smart-router/router.js +50 -48
- package/dist/router/static-router/index.js +5 -1
- package/dist/router/static-router/router.js +58 -63
- package/dist/router/trie-router/index.js +5 -1
- package/dist/router/trie-router/node.js +147 -158
- package/dist/router/trie-router/router.js +23 -19
- package/dist/router.js +12 -5
- package/dist/types.d.ts +22 -0
- package/dist/types.js +0 -0
- package/dist/utils/body.js +15 -13
- package/dist/utils/buffer.js +35 -29
- package/dist/utils/cloudflare.js +32 -32
- package/dist/utils/cookie.js +38 -33
- package/dist/utils/crypto.js +48 -41
- package/dist/utils/encode.js +70 -62
- package/dist/utils/filepath.js +18 -20
- package/dist/utils/html.js +34 -32
- package/dist/utils/http-status.js +48 -44
- package/dist/utils/json.js +71 -75
- package/dist/utils/jwt/index.js +5 -1
- package/dist/utils/jwt/jwt.js +95 -90
- package/dist/utils/jwt/types.js +47 -41
- package/dist/utils/mime.js +90 -86
- package/dist/utils/object.js +31 -32
- package/dist/utils/types.js +0 -1
- package/dist/utils/url.js +69 -77
- package/dist/validator/rule.js +56 -62
- package/dist/validator/sanitizer.js +6 -2
- package/dist/validator/schema.js +0 -1
- package/dist/validator/validator.d.ts +5 -4
- package/dist/validator/validator.js +393 -393
- package/package.json +14 -8
- package/dist/middleware/serve-static/module.mjs +0 -13
|
@@ -1,49 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
AlgorithmTypes: () => AlgorithmTypes,
|
|
22
|
+
JwtAlgorithmNotImplemented: () => JwtAlgorithmNotImplemented,
|
|
23
|
+
JwtAlorithmNotImplemented: () => JwtAlorithmNotImplemented,
|
|
24
|
+
JwtTokenExpired: () => JwtTokenExpired,
|
|
25
|
+
JwtTokenInvalid: () => JwtTokenInvalid,
|
|
26
|
+
JwtTokenNotBefore: () => JwtTokenNotBefore,
|
|
27
|
+
JwtTokenSignatureMismatched: () => JwtTokenSignatureMismatched
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(types_exports);
|
|
4
30
|
class JwtAlgorithmNotImplemented extends Error {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
31
|
+
constructor(token) {
|
|
32
|
+
super(`invalid JWT token: ${token}`);
|
|
33
|
+
this.name = "JwtAlgorithmNotImplemented";
|
|
34
|
+
}
|
|
9
35
|
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Export for backward compatibility
|
|
13
|
-
* @deprecated Use JwtAlgorithmNotImplemented instead
|
|
14
|
-
**/
|
|
15
|
-
exports.JwtAlorithmNotImplemented = JwtAlgorithmNotImplemented;
|
|
36
|
+
const JwtAlorithmNotImplemented = JwtAlgorithmNotImplemented;
|
|
16
37
|
class JwtTokenInvalid extends Error {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
38
|
+
constructor(token) {
|
|
39
|
+
super(`invalid JWT token: ${token}`);
|
|
40
|
+
this.name = "JwtTokenInvalid";
|
|
41
|
+
}
|
|
21
42
|
}
|
|
22
|
-
exports.JwtTokenInvalid = JwtTokenInvalid;
|
|
23
43
|
class JwtTokenNotBefore extends Error {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
constructor(token) {
|
|
45
|
+
super(`token (${token}) is being used before it's valid`);
|
|
46
|
+
this.name = "JwtTokenNotBefore";
|
|
47
|
+
}
|
|
28
48
|
}
|
|
29
|
-
exports.JwtTokenNotBefore = JwtTokenNotBefore;
|
|
30
49
|
class JwtTokenExpired extends Error {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
50
|
+
constructor(token) {
|
|
51
|
+
super(`token (${token}) expired`);
|
|
52
|
+
this.name = "JwtTokenExpired";
|
|
53
|
+
}
|
|
35
54
|
}
|
|
36
|
-
exports.JwtTokenExpired = JwtTokenExpired;
|
|
37
55
|
class JwtTokenSignatureMismatched extends Error {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
constructor(token) {
|
|
57
|
+
super(`token(${token}) signature mismatched`);
|
|
58
|
+
this.name = "JwtTokenSignatureMismatched";
|
|
59
|
+
}
|
|
42
60
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
var AlgorithmTypes = /* @__PURE__ */ ((AlgorithmTypes2) => {
|
|
62
|
+
AlgorithmTypes2["HS256"] = "HS256";
|
|
63
|
+
AlgorithmTypes2["HS384"] = "HS384";
|
|
64
|
+
AlgorithmTypes2["HS512"] = "HS512";
|
|
65
|
+
return AlgorithmTypes2;
|
|
66
|
+
})(AlgorithmTypes || {});
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
AlgorithmTypes,
|
|
70
|
+
JwtAlgorithmNotImplemented,
|
|
71
|
+
JwtAlorithmNotImplemented,
|
|
72
|
+
JwtTokenExpired,
|
|
73
|
+
JwtTokenInvalid,
|
|
74
|
+
JwtTokenNotBefore,
|
|
75
|
+
JwtTokenSignatureMismatched
|
|
76
|
+
});
|
package/dist/cjs/utils/mime.js
CHANGED
|
@@ -1,92 +1,115 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var mime_exports = {};
|
|
20
|
+
__export(mime_exports, {
|
|
21
|
+
getMimeType: () => getMimeType
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(mime_exports);
|
|
4
24
|
const getMimeType = (filename) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
const regexp = /\.([a-zA-Z0-9]+?)$/;
|
|
26
|
+
const match = filename.match(regexp);
|
|
27
|
+
if (!match)
|
|
28
|
+
return;
|
|
29
|
+
let mimeType = mimes[match[1]];
|
|
30
|
+
if (mimeType && mimeType.startsWith("text") || mimeType === "application/json") {
|
|
31
|
+
mimeType += "; charset=utf-8";
|
|
32
|
+
}
|
|
33
|
+
return mimeType;
|
|
14
34
|
};
|
|
15
|
-
exports.getMimeType = getMimeType;
|
|
16
35
|
const mimes = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
36
|
+
aac: "audio/aac",
|
|
37
|
+
abw: "application/x-abiword",
|
|
38
|
+
arc: "application/x-freearc",
|
|
39
|
+
avi: "video/x-msvideo",
|
|
40
|
+
azw: "application/vnd.amazon.ebook",
|
|
41
|
+
bin: "application/octet-stream",
|
|
42
|
+
bmp: "image/bmp",
|
|
43
|
+
bz: "application/x-bzip",
|
|
44
|
+
bz2: "application/x-bzip2",
|
|
45
|
+
csh: "application/x-csh",
|
|
46
|
+
css: "text/css",
|
|
47
|
+
csv: "text/csv",
|
|
48
|
+
doc: "application/msword",
|
|
49
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
50
|
+
eot: "application/vnd.ms-fontobject",
|
|
51
|
+
epub: "application/epub+zip",
|
|
52
|
+
gz: "application/gzip",
|
|
53
|
+
gif: "image/gif",
|
|
54
|
+
htm: "text/html",
|
|
55
|
+
html: "text/html",
|
|
56
|
+
ico: "image/x-icon",
|
|
57
|
+
ics: "text/calendar",
|
|
58
|
+
jar: "application/java-archive",
|
|
59
|
+
jpeg: "image/jpeg",
|
|
60
|
+
jpg: "image/jpeg",
|
|
61
|
+
js: "text/javascript",
|
|
62
|
+
json: "application/json",
|
|
63
|
+
jsonld: "application/ld+json",
|
|
64
|
+
map: "application/json",
|
|
65
|
+
mid: "audio/x-midi",
|
|
66
|
+
midi: "audio/x-midi",
|
|
67
|
+
mjs: "text/javascript",
|
|
68
|
+
mp3: "audio/mpeg",
|
|
69
|
+
mpeg: "video/mpeg",
|
|
70
|
+
mpkg: "application/vnd.apple.installer+xml",
|
|
71
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
|
72
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
73
|
+
odt: "application/vnd.oasis.opendocument.text",
|
|
74
|
+
oga: "audio/ogg",
|
|
75
|
+
ogv: "video/ogg",
|
|
76
|
+
ogx: "application/ogg",
|
|
77
|
+
opus: "audio/opus",
|
|
78
|
+
otf: "font/otf",
|
|
79
|
+
png: "image/png",
|
|
80
|
+
pdf: "application/pdf",
|
|
81
|
+
php: "application/php",
|
|
82
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
83
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
84
|
+
rar: "application/vnd.rar",
|
|
85
|
+
rtf: "application/rtf",
|
|
86
|
+
sh: "application/x-sh",
|
|
87
|
+
svg: "image/svg+xml",
|
|
88
|
+
swf: "application/x-shockwave-flash",
|
|
89
|
+
tar: "application/x-tar",
|
|
90
|
+
tif: "image/tiff",
|
|
91
|
+
tiff: "image/tiff",
|
|
92
|
+
ts: "video/mp2t",
|
|
93
|
+
ttf: "font/ttf",
|
|
94
|
+
txt: "text/plain",
|
|
95
|
+
vsd: "application/vnd.visio",
|
|
96
|
+
wav: "audio/wav",
|
|
97
|
+
weba: "audio/webm",
|
|
98
|
+
webm: "video/webm",
|
|
99
|
+
webp: "image/webp",
|
|
100
|
+
woff: "font/woff",
|
|
101
|
+
woff2: "font/woff2",
|
|
102
|
+
xhtml: "application/xhtml+xml",
|
|
103
|
+
xls: "application/vnd.ms-excel",
|
|
104
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
105
|
+
xml: "application/xml",
|
|
106
|
+
xul: "application/vnd.mozilla.xul+xml",
|
|
107
|
+
zip: "application/zip",
|
|
108
|
+
"3gp": "video/3gpp",
|
|
109
|
+
"3g2": "video/3gpp2",
|
|
110
|
+
"7z": "application/x-7z-compressed"
|
|
92
111
|
};
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
getMimeType
|
|
115
|
+
});
|
package/dist/cjs/utils/object.js
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var object_exports = {};
|
|
20
|
+
__export(object_exports, {
|
|
21
|
+
isObject: () => isObject,
|
|
22
|
+
mergeObjects: () => mergeObjects
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(object_exports);
|
|
25
|
+
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
7
26
|
const mergeObjects = (target, source) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
outArr[i] = srcArr[i];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
Object.assign(merged, { [key]: outArr });
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
Object.assign(merged, { [key]: source[key] });
|
|
35
|
-
}
|
|
27
|
+
const merged = Object.assign({}, target);
|
|
28
|
+
if (isObject(target) && isObject(source)) {
|
|
29
|
+
for (const key of Object.keys(source)) {
|
|
30
|
+
if (isObject(source[key])) {
|
|
31
|
+
if (target[key] === void 0)
|
|
32
|
+
Object.assign(merged, { [key]: source[key] });
|
|
33
|
+
else
|
|
34
|
+
merged[key] = mergeObjects(target[key], source[key]);
|
|
35
|
+
} else if (Array.isArray(source[key]) && Array.isArray(target[key])) {
|
|
36
|
+
const srcArr = source[key];
|
|
37
|
+
const tgtArr = target[key];
|
|
38
|
+
const outArr = [];
|
|
39
|
+
for (let i = 0; i < srcArr.length; i += 1) {
|
|
40
|
+
if (isObject(srcArr[i]) && isObject(tgtArr[i])) {
|
|
41
|
+
outArr[i] = mergeObjects(tgtArr[i], srcArr[i]);
|
|
42
|
+
} else {
|
|
43
|
+
outArr[i] = srcArr[i];
|
|
44
|
+
}
|
|
36
45
|
}
|
|
46
|
+
Object.assign(merged, { [key]: outArr });
|
|
47
|
+
} else {
|
|
48
|
+
Object.assign(merged, { [key]: source[key] });
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
|
-
|
|
51
|
+
}
|
|
52
|
+
return merged;
|
|
39
53
|
};
|
|
40
|
-
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
isObject,
|
|
57
|
+
mergeObjects
|
|
58
|
+
});
|
package/dist/cjs/utils/types.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/cjs/utils/url.js
CHANGED
|
@@ -1,94 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var url_exports = {};
|
|
20
|
+
__export(url_exports, {
|
|
21
|
+
checkOptionalParameter: () => checkOptionalParameter,
|
|
22
|
+
getPathFromURL: () => getPathFromURL,
|
|
23
|
+
getPattern: () => getPattern,
|
|
24
|
+
getQueryStringFromURL: () => getQueryStringFromURL,
|
|
25
|
+
mergePath: () => mergePath,
|
|
26
|
+
splitPath: () => splitPath
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(url_exports);
|
|
4
29
|
const splitPath = (path) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
30
|
+
const paths = path.split(/\//);
|
|
31
|
+
if (paths[0] === "") {
|
|
32
|
+
paths.shift();
|
|
33
|
+
}
|
|
34
|
+
return paths;
|
|
10
35
|
};
|
|
11
|
-
exports.splitPath = splitPath;
|
|
12
36
|
const patternCache = {};
|
|
13
37
|
const getPattern = (label) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
38
|
+
if (label === "*") {
|
|
39
|
+
return "*";
|
|
40
|
+
}
|
|
41
|
+
const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
42
|
+
if (match) {
|
|
43
|
+
if (!patternCache[label]) {
|
|
44
|
+
if (match[2]) {
|
|
45
|
+
patternCache[label] = [label, match[1], new RegExp("^" + match[2] + "$")];
|
|
46
|
+
} else {
|
|
47
|
+
patternCache[label] = [label, match[1], true];
|
|
48
|
+
}
|
|
20
49
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (match[2]) {
|
|
25
|
-
patternCache[label] = [label, match[1], new RegExp('^' + match[2] + '$')];
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
patternCache[label] = [label, match[1], true];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return patternCache[label];
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
50
|
+
return patternCache[label];
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
34
53
|
};
|
|
35
|
-
exports.getPattern = getPattern;
|
|
36
54
|
const getPathFromURL = (url, strict = true) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
55
|
+
const queryIndex = url.indexOf("?");
|
|
56
|
+
const result = url.substring(url.indexOf("/", 8), queryIndex === -1 ? url.length : queryIndex);
|
|
57
|
+
if (strict === false && result.endsWith("/")) {
|
|
58
|
+
return result.slice(0, -1);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
45
61
|
};
|
|
46
|
-
exports.getPathFromURL = getPathFromURL;
|
|
47
62
|
const getQueryStringFromURL = (url) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
const queryIndex = url.indexOf("?");
|
|
64
|
+
const result = queryIndex !== -1 ? url.substring(queryIndex) : "";
|
|
65
|
+
return result;
|
|
51
66
|
};
|
|
52
|
-
exports.getQueryStringFromURL = getQueryStringFromURL;
|
|
53
67
|
const mergePath = (...paths) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
p = `${p}/`;
|
|
69
|
-
}
|
|
70
|
-
else if (path !== '/') {
|
|
71
|
-
p = `${p}${path}`;
|
|
72
|
-
}
|
|
73
|
-
/* ['/', '/'] => `/` */
|
|
74
|
-
if (path === '/' && p === '') {
|
|
75
|
-
p = '/';
|
|
76
|
-
}
|
|
68
|
+
let p = "";
|
|
69
|
+
let endsWithSlash = false;
|
|
70
|
+
for (let path of paths) {
|
|
71
|
+
if (p.endsWith("/")) {
|
|
72
|
+
p = p.slice(0, -1);
|
|
73
|
+
endsWithSlash = true;
|
|
74
|
+
}
|
|
75
|
+
if (!path.startsWith("/")) {
|
|
76
|
+
path = `/${path}`;
|
|
77
|
+
}
|
|
78
|
+
if (path === "/" && endsWithSlash) {
|
|
79
|
+
p = `${p}/`;
|
|
80
|
+
} else if (path !== "/") {
|
|
81
|
+
p = `${p}${path}`;
|
|
77
82
|
}
|
|
78
|
-
|
|
83
|
+
if (path === "/" && p === "") {
|
|
84
|
+
p = "/";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return p;
|
|
79
88
|
};
|
|
80
|
-
exports.mergePath = mergePath;
|
|
81
89
|
const checkOptionalParameter = (path) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (!match)
|
|
89
|
-
return null;
|
|
90
|
-
const base = match[1];
|
|
91
|
-
const optional = base + match[2];
|
|
92
|
-
return [base, optional];
|
|
90
|
+
const match = path.match(/(^.+)(\/\:[^\/]+)\?$/);
|
|
91
|
+
if (!match)
|
|
92
|
+
return null;
|
|
93
|
+
const base = match[1];
|
|
94
|
+
const optional = base + match[2];
|
|
95
|
+
return [base, optional];
|
|
93
96
|
};
|
|
94
|
-
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
checkOptionalParameter,
|
|
100
|
+
getPathFromURL,
|
|
101
|
+
getPattern,
|
|
102
|
+
getQueryStringFromURL,
|
|
103
|
+
mergePath,
|
|
104
|
+
splitPath
|
|
105
|
+
});
|