@kevisual/router 0.0.38 → 0.0.40

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/router.js CHANGED
@@ -78,11 +78,8 @@ class CustomError extends Error {
78
78
  * @param err
79
79
  * @returns
80
80
  */
81
- static isError(err) {
82
- if (err instanceof CustomError || err?.code) {
83
- return true;
84
- }
85
- return false;
81
+ static isError(error) {
82
+ return error instanceof CustomError || (typeof error === 'object' && error !== null && 'code' in error);
86
83
  }
87
84
  parse(e) {
88
85
  if (e) {
@@ -906,370 +903,243 @@ const handleServer = async (req, res) => {
906
903
  return data;
907
904
  };
908
905
 
909
- function getDefaultExportFromCjs (x) {
910
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
906
+ /**
907
+ * RegExp to match cookie-name in RFC 6265 sec 4.1.1
908
+ * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
909
+ * which has been replaced by the token definition in RFC 7230 appendix B.
910
+ *
911
+ * cookie-name = token
912
+ * token = 1*tchar
913
+ * tchar = "!" / "#" / "$" / "%" / "&" / "'" /
914
+ * "*" / "+" / "-" / "." / "^" / "_" /
915
+ * "`" / "|" / "~" / DIGIT / ALPHA
916
+ *
917
+ * Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191
918
+ * Allow same range as cookie value, except `=`, which delimits end of name.
919
+ */
920
+ const cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
921
+ /**
922
+ * RegExp to match cookie-value in RFC 6265 sec 4.1.1
923
+ *
924
+ * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
925
+ * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
926
+ * ; US-ASCII characters excluding CTLs,
927
+ * ; whitespace DQUOTE, comma, semicolon,
928
+ * ; and backslash
929
+ *
930
+ * Allowing more characters: https://github.com/jshttp/cookie/issues/191
931
+ * Comma, backslash, and DQUOTE are not part of the parsing algorithm.
932
+ */
933
+ const cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
934
+ /**
935
+ * RegExp to match domain-value in RFC 6265 sec 4.1.1
936
+ *
937
+ * domain-value = <subdomain>
938
+ * ; defined in [RFC1034], Section 3.5, as
939
+ * ; enhanced by [RFC1123], Section 2.1
940
+ * <subdomain> = <label> | <subdomain> "." <label>
941
+ * <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
942
+ * Labels must be 63 characters or less.
943
+ * 'let-dig' not 'letter' in the first char, per RFC1123
944
+ * <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
945
+ * <let-dig-hyp> = <let-dig> | "-"
946
+ * <let-dig> = <letter> | <digit>
947
+ * <letter> = any one of the 52 alphabetic characters A through Z in
948
+ * upper case and a through z in lower case
949
+ * <digit> = any one of the ten digits 0 through 9
950
+ *
951
+ * Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
952
+ *
953
+ * > (Note that a leading %x2E ("."), if present, is ignored even though that
954
+ * character is not permitted, but a trailing %x2E ("."), if present, will
955
+ * cause the user agent to ignore the attribute.)
956
+ */
957
+ const domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
958
+ /**
959
+ * RegExp to match path-value in RFC 6265 sec 4.1.1
960
+ *
961
+ * path-value = <any CHAR except CTLs or ";">
962
+ * CHAR = %x01-7F
963
+ * ; defined in RFC 5234 appendix B.1
964
+ */
965
+ const pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
966
+ const __toString = Object.prototype.toString;
967
+ const NullObject = /* @__PURE__ */ (() => {
968
+ const C = function () { };
969
+ C.prototype = Object.create(null);
970
+ return C;
971
+ })();
972
+ /**
973
+ * Parse a `Cookie` header.
974
+ *
975
+ * Parse the given cookie header string into an object
976
+ * The object has the various cookies as keys(names) => values
977
+ */
978
+ function parseCookie(str, options) {
979
+ const obj = new NullObject();
980
+ const len = str.length;
981
+ // RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
982
+ if (len < 2)
983
+ return obj;
984
+ const dec = decode$1;
985
+ let index = 0;
986
+ do {
987
+ const eqIdx = eqIndex(str, index, len);
988
+ if (eqIdx === -1)
989
+ break; // No more cookie pairs.
990
+ const endIdx = endIndex(str, index, len);
991
+ if (eqIdx > endIdx) {
992
+ // backtrack on prior semicolon
993
+ index = str.lastIndexOf(";", eqIdx - 1) + 1;
994
+ continue;
995
+ }
996
+ const key = valueSlice(str, index, eqIdx);
997
+ // only assign once
998
+ if (obj[key] === undefined) {
999
+ obj[key] = dec(valueSlice(str, eqIdx + 1, endIdx));
1000
+ }
1001
+ index = endIdx + 1;
1002
+ } while (index < len);
1003
+ return obj;
911
1004
  }
912
-
913
- var dist = {};
914
-
915
- var hasRequiredDist;
916
-
917
- function requireDist () {
918
- if (hasRequiredDist) return dist;
919
- hasRequiredDist = 1;
920
- Object.defineProperty(dist, "__esModule", { value: true });
921
- dist.parseCookie = parseCookie;
922
- dist.parse = parseCookie;
923
- dist.stringifyCookie = stringifyCookie;
924
- dist.stringifySetCookie = stringifySetCookie;
925
- dist.serialize = stringifySetCookie;
926
- dist.parseSetCookie = parseSetCookie;
927
- dist.stringifySetCookie = stringifySetCookie;
928
- dist.serialize = stringifySetCookie;
929
- /**
930
- * RegExp to match cookie-name in RFC 6265 sec 4.1.1
931
- * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
932
- * which has been replaced by the token definition in RFC 7230 appendix B.
933
- *
934
- * cookie-name = token
935
- * token = 1*tchar
936
- * tchar = "!" / "#" / "$" / "%" / "&" / "'" /
937
- * "*" / "+" / "-" / "." / "^" / "_" /
938
- * "`" / "|" / "~" / DIGIT / ALPHA
939
- *
940
- * Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191
941
- * Allow same range as cookie value, except `=`, which delimits end of name.
942
- */
943
- const cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
944
- /**
945
- * RegExp to match cookie-value in RFC 6265 sec 4.1.1
946
- *
947
- * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
948
- * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
949
- * ; US-ASCII characters excluding CTLs,
950
- * ; whitespace DQUOTE, comma, semicolon,
951
- * ; and backslash
952
- *
953
- * Allowing more characters: https://github.com/jshttp/cookie/issues/191
954
- * Comma, backslash, and DQUOTE are not part of the parsing algorithm.
955
- */
956
- const cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
957
- /**
958
- * RegExp to match domain-value in RFC 6265 sec 4.1.1
959
- *
960
- * domain-value = <subdomain>
961
- * ; defined in [RFC1034], Section 3.5, as
962
- * ; enhanced by [RFC1123], Section 2.1
963
- * <subdomain> = <label> | <subdomain> "." <label>
964
- * <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
965
- * Labels must be 63 characters or less.
966
- * 'let-dig' not 'letter' in the first char, per RFC1123
967
- * <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
968
- * <let-dig-hyp> = <let-dig> | "-"
969
- * <let-dig> = <letter> | <digit>
970
- * <letter> = any one of the 52 alphabetic characters A through Z in
971
- * upper case and a through z in lower case
972
- * <digit> = any one of the ten digits 0 through 9
973
- *
974
- * Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
975
- *
976
- * > (Note that a leading %x2E ("."), if present, is ignored even though that
977
- * character is not permitted, but a trailing %x2E ("."), if present, will
978
- * cause the user agent to ignore the attribute.)
979
- */
980
- const domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
981
- /**
982
- * RegExp to match path-value in RFC 6265 sec 4.1.1
983
- *
984
- * path-value = <any CHAR except CTLs or ";">
985
- * CHAR = %x01-7F
986
- * ; defined in RFC 5234 appendix B.1
987
- */
988
- const pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
989
- /**
990
- * RegExp to match max-age-value in RFC 6265 sec 5.6.2
991
- */
992
- const maxAgeRegExp = /^-?\d+$/;
993
- const __toString = Object.prototype.toString;
994
- const NullObject = /* @__PURE__ */ (() => {
995
- const C = function () { };
996
- C.prototype = Object.create(null);
997
- return C;
998
- })();
999
- /**
1000
- * Parse a `Cookie` header.
1001
- *
1002
- * Parse the given cookie header string into an object
1003
- * The object has the various cookies as keys(names) => values
1004
- */
1005
- function parseCookie(str, options) {
1006
- const obj = new NullObject();
1007
- const len = str.length;
1008
- // RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
1009
- if (len < 2)
1010
- return obj;
1011
- const dec = options?.decode || decode;
1012
- let index = 0;
1013
- do {
1014
- const eqIdx = eqIndex(str, index, len);
1015
- if (eqIdx === -1)
1016
- break; // No more cookie pairs.
1017
- const endIdx = endIndex(str, index, len);
1018
- if (eqIdx > endIdx) {
1019
- // backtrack on prior semicolon
1020
- index = str.lastIndexOf(";", eqIdx - 1) + 1;
1021
- continue;
1022
- }
1023
- const key = valueSlice(str, index, eqIdx);
1024
- // only assign once
1025
- if (obj[key] === undefined) {
1026
- obj[key] = dec(valueSlice(str, eqIdx + 1, endIdx));
1027
- }
1028
- index = endIdx + 1;
1029
- } while (index < len);
1030
- return obj;
1031
- }
1032
- /**
1033
- * Stringifies an object into an HTTP `Cookie` header.
1034
- */
1035
- function stringifyCookie(cookie, options) {
1036
- const enc = options?.encode || encodeURIComponent;
1037
- const cookieStrings = [];
1038
- for (const name of Object.keys(cookie)) {
1039
- const val = cookie[name];
1040
- if (val === undefined)
1041
- continue;
1042
- if (!cookieNameRegExp.test(name)) {
1043
- throw new TypeError(`cookie name is invalid: ${name}`);
1044
- }
1045
- const value = enc(val);
1046
- if (!cookieValueRegExp.test(value)) {
1047
- throw new TypeError(`cookie val is invalid: ${val}`);
1048
- }
1049
- cookieStrings.push(`${name}=${value}`);
1050
- }
1051
- return cookieStrings.join("; ");
1052
- }
1053
- function stringifySetCookie(_name, _val, _opts) {
1054
- const cookie = typeof _name === "object"
1055
- ? _name
1056
- : { ..._opts, name: _name, value: String(_val) };
1057
- const options = typeof _val === "object" ? _val : _opts;
1058
- const enc = options?.encode || encodeURIComponent;
1059
- if (!cookieNameRegExp.test(cookie.name)) {
1060
- throw new TypeError(`argument name is invalid: ${cookie.name}`);
1061
- }
1062
- const value = cookie.value ? enc(cookie.value) : "";
1063
- if (!cookieValueRegExp.test(value)) {
1064
- throw new TypeError(`argument val is invalid: ${cookie.value}`);
1065
- }
1066
- let str = cookie.name + "=" + value;
1067
- if (cookie.maxAge !== undefined) {
1068
- if (!Number.isInteger(cookie.maxAge)) {
1069
- throw new TypeError(`option maxAge is invalid: ${cookie.maxAge}`);
1070
- }
1071
- str += "; Max-Age=" + cookie.maxAge;
1072
- }
1073
- if (cookie.domain) {
1074
- if (!domainValueRegExp.test(cookie.domain)) {
1075
- throw new TypeError(`option domain is invalid: ${cookie.domain}`);
1076
- }
1077
- str += "; Domain=" + cookie.domain;
1078
- }
1079
- if (cookie.path) {
1080
- if (!pathValueRegExp.test(cookie.path)) {
1081
- throw new TypeError(`option path is invalid: ${cookie.path}`);
1082
- }
1083
- str += "; Path=" + cookie.path;
1084
- }
1085
- if (cookie.expires) {
1086
- if (!isDate(cookie.expires) || !Number.isFinite(cookie.expires.valueOf())) {
1087
- throw new TypeError(`option expires is invalid: ${cookie.expires}`);
1088
- }
1089
- str += "; Expires=" + cookie.expires.toUTCString();
1090
- }
1091
- if (cookie.httpOnly) {
1092
- str += "; HttpOnly";
1093
- }
1094
- if (cookie.secure) {
1095
- str += "; Secure";
1096
- }
1097
- if (cookie.partitioned) {
1098
- str += "; Partitioned";
1099
- }
1100
- if (cookie.priority) {
1101
- const priority = typeof cookie.priority === "string"
1102
- ? cookie.priority.toLowerCase()
1103
- : undefined;
1104
- switch (priority) {
1105
- case "low":
1106
- str += "; Priority=Low";
1107
- break;
1108
- case "medium":
1109
- str += "; Priority=Medium";
1110
- break;
1111
- case "high":
1112
- str += "; Priority=High";
1113
- break;
1114
- default:
1115
- throw new TypeError(`option priority is invalid: ${cookie.priority}`);
1116
- }
1117
- }
1118
- if (cookie.sameSite) {
1119
- const sameSite = typeof cookie.sameSite === "string"
1120
- ? cookie.sameSite.toLowerCase()
1121
- : cookie.sameSite;
1122
- switch (sameSite) {
1123
- case true:
1124
- case "strict":
1125
- str += "; SameSite=Strict";
1126
- break;
1127
- case "lax":
1128
- str += "; SameSite=Lax";
1129
- break;
1130
- case "none":
1131
- str += "; SameSite=None";
1132
- break;
1133
- default:
1134
- throw new TypeError(`option sameSite is invalid: ${cookie.sameSite}`);
1135
- }
1136
- }
1137
- return str;
1138
- }
1139
- /**
1140
- * Deserialize a `Set-Cookie` header into an object.
1141
- *
1142
- * deserialize('foo=bar; httpOnly')
1143
- * => { name: 'foo', value: 'bar', httpOnly: true }
1144
- */
1145
- function parseSetCookie(str, options) {
1146
- const dec = options?.decode || decode;
1147
- const len = str.length;
1148
- const endIdx = endIndex(str, 0, len);
1149
- const eqIdx = eqIndex(str, 0, endIdx);
1150
- const setCookie = eqIdx === -1
1151
- ? { name: "", value: dec(valueSlice(str, 0, endIdx)) }
1152
- : {
1153
- name: valueSlice(str, 0, eqIdx),
1154
- value: dec(valueSlice(str, eqIdx + 1, endIdx)),
1155
- };
1156
- let index = endIdx + 1;
1157
- while (index < len) {
1158
- const endIdx = endIndex(str, index, len);
1159
- const eqIdx = eqIndex(str, index, endIdx);
1160
- const attr = eqIdx === -1
1161
- ? valueSlice(str, index, endIdx)
1162
- : valueSlice(str, index, eqIdx);
1163
- const val = eqIdx === -1 ? undefined : valueSlice(str, eqIdx + 1, endIdx);
1164
- switch (attr.toLowerCase()) {
1165
- case "httponly":
1166
- setCookie.httpOnly = true;
1167
- break;
1168
- case "secure":
1169
- setCookie.secure = true;
1170
- break;
1171
- case "partitioned":
1172
- setCookie.partitioned = true;
1173
- break;
1174
- case "domain":
1175
- setCookie.domain = val;
1176
- break;
1177
- case "path":
1178
- setCookie.path = val;
1179
- break;
1180
- case "max-age":
1181
- if (val && maxAgeRegExp.test(val))
1182
- setCookie.maxAge = Number(val);
1183
- break;
1184
- case "expires":
1185
- if (!val)
1186
- break;
1187
- const date = new Date(val);
1188
- if (Number.isFinite(date.valueOf()))
1189
- setCookie.expires = date;
1190
- break;
1191
- case "priority":
1192
- if (!val)
1193
- break;
1194
- const priority = val.toLowerCase();
1195
- if (priority === "low" ||
1196
- priority === "medium" ||
1197
- priority === "high") {
1198
- setCookie.priority = priority;
1199
- }
1200
- break;
1201
- case "samesite":
1202
- if (!val)
1203
- break;
1204
- const sameSite = val.toLowerCase();
1205
- if (sameSite === "lax" ||
1206
- sameSite === "strict" ||
1207
- sameSite === "none") {
1208
- setCookie.sameSite = sameSite;
1209
- }
1210
- break;
1211
- }
1212
- index = endIdx + 1;
1213
- }
1214
- return setCookie;
1215
- }
1216
- /**
1217
- * Find the `;` character between `min` and `len` in str.
1218
- */
1219
- function endIndex(str, min, len) {
1220
- const index = str.indexOf(";", min);
1221
- return index === -1 ? len : index;
1222
- }
1223
- /**
1224
- * Find the `=` character between `min` and `max` in str.
1225
- */
1226
- function eqIndex(str, min, max) {
1227
- const index = str.indexOf("=", min);
1228
- return index < max ? index : -1;
1229
- }
1230
- /**
1231
- * Slice out a value between startPod to max.
1232
- */
1233
- function valueSlice(str, min, max) {
1234
- let start = min;
1235
- let end = max;
1236
- do {
1237
- const code = str.charCodeAt(start);
1238
- if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
1239
- break;
1240
- } while (++start < end);
1241
- while (end > start) {
1242
- const code = str.charCodeAt(end - 1);
1243
- if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
1244
- break;
1245
- end--;
1246
- }
1247
- return str.slice(start, end);
1248
- }
1249
- /**
1250
- * URL-decode string value. Optimized to skip native call when no %.
1251
- */
1252
- function decode(str) {
1253
- if (str.indexOf("%") === -1)
1254
- return str;
1255
- try {
1256
- return decodeURIComponent(str);
1257
- }
1258
- catch (e) {
1259
- return str;
1260
- }
1261
- }
1262
- /**
1263
- * Determine if value is a Date.
1264
- */
1265
- function isDate(val) {
1266
- return __toString.call(val) === "[object Date]";
1267
- }
1268
-
1269
- return dist;
1005
+ function stringifySetCookie(_name, _val, _opts) {
1006
+ const cookie = typeof _name === "object"
1007
+ ? _name
1008
+ : { ..._opts, name: _name, value: String(_val) };
1009
+ const options = typeof _val === "object" ? _val : _opts;
1010
+ const enc = options?.encode || encodeURIComponent;
1011
+ if (!cookieNameRegExp.test(cookie.name)) {
1012
+ throw new TypeError(`argument name is invalid: ${cookie.name}`);
1013
+ }
1014
+ const value = cookie.value ? enc(cookie.value) : "";
1015
+ if (!cookieValueRegExp.test(value)) {
1016
+ throw new TypeError(`argument val is invalid: ${cookie.value}`);
1017
+ }
1018
+ let str = cookie.name + "=" + value;
1019
+ if (cookie.maxAge !== undefined) {
1020
+ if (!Number.isInteger(cookie.maxAge)) {
1021
+ throw new TypeError(`option maxAge is invalid: ${cookie.maxAge}`);
1022
+ }
1023
+ str += "; Max-Age=" + cookie.maxAge;
1024
+ }
1025
+ if (cookie.domain) {
1026
+ if (!domainValueRegExp.test(cookie.domain)) {
1027
+ throw new TypeError(`option domain is invalid: ${cookie.domain}`);
1028
+ }
1029
+ str += "; Domain=" + cookie.domain;
1030
+ }
1031
+ if (cookie.path) {
1032
+ if (!pathValueRegExp.test(cookie.path)) {
1033
+ throw new TypeError(`option path is invalid: ${cookie.path}`);
1034
+ }
1035
+ str += "; Path=" + cookie.path;
1036
+ }
1037
+ if (cookie.expires) {
1038
+ if (!isDate(cookie.expires) || !Number.isFinite(cookie.expires.valueOf())) {
1039
+ throw new TypeError(`option expires is invalid: ${cookie.expires}`);
1040
+ }
1041
+ str += "; Expires=" + cookie.expires.toUTCString();
1042
+ }
1043
+ if (cookie.httpOnly) {
1044
+ str += "; HttpOnly";
1045
+ }
1046
+ if (cookie.secure) {
1047
+ str += "; Secure";
1048
+ }
1049
+ if (cookie.partitioned) {
1050
+ str += "; Partitioned";
1051
+ }
1052
+ if (cookie.priority) {
1053
+ const priority = typeof cookie.priority === "string"
1054
+ ? cookie.priority.toLowerCase()
1055
+ : undefined;
1056
+ switch (priority) {
1057
+ case "low":
1058
+ str += "; Priority=Low";
1059
+ break;
1060
+ case "medium":
1061
+ str += "; Priority=Medium";
1062
+ break;
1063
+ case "high":
1064
+ str += "; Priority=High";
1065
+ break;
1066
+ default:
1067
+ throw new TypeError(`option priority is invalid: ${cookie.priority}`);
1068
+ }
1069
+ }
1070
+ if (cookie.sameSite) {
1071
+ const sameSite = typeof cookie.sameSite === "string"
1072
+ ? cookie.sameSite.toLowerCase()
1073
+ : cookie.sameSite;
1074
+ switch (sameSite) {
1075
+ case true:
1076
+ case "strict":
1077
+ str += "; SameSite=Strict";
1078
+ break;
1079
+ case "lax":
1080
+ str += "; SameSite=Lax";
1081
+ break;
1082
+ case "none":
1083
+ str += "; SameSite=None";
1084
+ break;
1085
+ default:
1086
+ throw new TypeError(`option sameSite is invalid: ${cookie.sameSite}`);
1087
+ }
1088
+ }
1089
+ return str;
1090
+ }
1091
+ /**
1092
+ * Find the `;` character between `min` and `len` in str.
1093
+ */
1094
+ function endIndex(str, min, len) {
1095
+ const index = str.indexOf(";", min);
1096
+ return index === -1 ? len : index;
1097
+ }
1098
+ /**
1099
+ * Find the `=` character between `min` and `max` in str.
1100
+ */
1101
+ function eqIndex(str, min, max) {
1102
+ const index = str.indexOf("=", min);
1103
+ return index < max ? index : -1;
1104
+ }
1105
+ /**
1106
+ * Slice out a value between startPod to max.
1107
+ */
1108
+ function valueSlice(str, min, max) {
1109
+ let start = min;
1110
+ let end = max;
1111
+ do {
1112
+ const code = str.charCodeAt(start);
1113
+ if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
1114
+ break;
1115
+ } while (++start < end);
1116
+ while (end > start) {
1117
+ const code = str.charCodeAt(end - 1);
1118
+ if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
1119
+ break;
1120
+ end--;
1121
+ }
1122
+ return str.slice(start, end);
1123
+ }
1124
+ /**
1125
+ * URL-decode string value. Optimized to skip native call when no %.
1126
+ */
1127
+ function decode$1(str) {
1128
+ if (str.indexOf("%") === -1)
1129
+ return str;
1130
+ try {
1131
+ return decodeURIComponent(str);
1132
+ }
1133
+ catch (e) {
1134
+ return str;
1135
+ }
1136
+ }
1137
+ /**
1138
+ * Determine if value is a Date.
1139
+ */
1140
+ function isDate(val) {
1141
+ return __toString.call(val) === "[object Date]";
1270
1142
  }
1271
-
1272
- var distExports = /*@__PURE__*/ requireDist();
1273
1143
 
1274
1144
  // 实现函数
1275
1145
  function createHandleCtx(req, res) {
@@ -1280,7 +1150,7 @@ function createHandleCtx(req, res) {
1280
1150
  // 扩展 res.cookie 方法
1281
1151
  const cookieFn = (name, value, options = {}, end = true) => {
1282
1152
  // 序列化新的 Cookie
1283
- const serializedCookie = distExports.serialize(name, value, options);
1153
+ const serializedCookie = stringifySetCookie(name, value, options);
1284
1154
  cookies.push(serializedCookie); // 将新的 Cookie 添加到数组
1285
1155
  if (end) {
1286
1156
  // 如果设置了 end 参数,则立即设置到响应头
@@ -1288,7 +1158,7 @@ function createHandleCtx(req, res) {
1288
1158
  }
1289
1159
  };
1290
1160
  // 解析请求中的现有 Cookie
1291
- const parsedCookies = distExports.parse(req.headers.cookie || '');
1161
+ const parsedCookies = parseCookie(req.headers.cookie || '');
1292
1162
  handReq.cookies = parsedCookies;
1293
1163
  handRes.cookie = cookieFn;
1294
1164
  // 返回扩展的上下文
@@ -5725,6 +5595,10 @@ const createSchema = (rule) => {
5725
5595
  }
5726
5596
  };
5727
5597
 
5598
+ function getDefaultExportFromCjs (x) {
5599
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5600
+ }
5601
+
5728
5602
  var constants;
5729
5603
  var hasRequiredConstants;
5730
5604