summaryrefslogtreecommitdiff
path: root/cli/bench/testdata/npm/hono/dist/utils
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-08-19 15:54:54 +0530
committerGitHub <noreply@github.com>2022-08-19 15:54:54 +0530
commit25a109d9ea27ad3a76fdce14bba283e953af9bce (patch)
tree68f0280065c9df4be8fa325ba82693879b4b46cd /cli/bench/testdata/npm/hono/dist/utils
parent9e576dff7c39cfd510c60ba92aa0d1c15fd24a6b (diff)
chore(bench): add flash router benchmarks (#15495)
Diffstat (limited to 'cli/bench/testdata/npm/hono/dist/utils')
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/body.d.ts2
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/body.js31
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/buffer.d.ts3
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/buffer.js39
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/cloudflare.d.ts6
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/cloudflare.js39
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/cookie.d.ts13
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/cookie.js40
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/crypto.d.ts10
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/crypto.js53
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/encode.d.ts7
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/encode.js80
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/filepath.d.ts7
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/filepath.js25
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/html.d.ts6
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/html.js38
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/http-status.d.ts2
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/http-status.js50
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/jwt/index.d.ts1
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/jwt/index.js27
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/jwt/jwt.d.ts7
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/jwt/jwt.js101
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/jwt/types.d.ts25
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/jwt/types.js49
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/mime.d.ts1
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/mime.js92
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/url.d.ts6
-rw-r--r--cli/bench/testdata/npm/hono/dist/utils/url.js83
28 files changed, 843 insertions, 0 deletions
diff --git a/cli/bench/testdata/npm/hono/dist/utils/body.d.ts b/cli/bench/testdata/npm/hono/dist/utils/body.d.ts
new file mode 100644
index 000000000..87407539c
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/body.d.ts
@@ -0,0 +1,2 @@
+export declare type Body = string | object | Record<string, string | File> | ArrayBuffer;
+export declare const parseBody: (r: Request | Response) => Promise<Body>;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/body.js b/cli/bench/testdata/npm/hono/dist/utils/body.js
new file mode 100644
index 000000000..5deeca1cd
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/body.js
@@ -0,0 +1,31 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.parseBody = void 0;
+const parseBody = async (r) => {
+ const contentType = r.headers.get('Content-Type') || '';
+ if (contentType.includes('application/json')) {
+ let body = {};
+ try {
+ body = await r.json();
+ }
+ catch { } // Do nothing
+ return body;
+ }
+ else if (contentType.includes('application/text')) {
+ return await r.text();
+ }
+ else if (contentType.startsWith('text')) {
+ return await r.text();
+ }
+ else if (contentType.includes('form')) {
+ const form = {};
+ const data = [...(await r.formData())].reduce((acc, cur) => {
+ acc[cur[0]] = cur[1];
+ return acc;
+ }, form);
+ return data;
+ }
+ const arrayBuffer = await r.arrayBuffer();
+ return arrayBuffer;
+};
+exports.parseBody = parseBody;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/buffer.d.ts b/cli/bench/testdata/npm/hono/dist/utils/buffer.d.ts
new file mode 100644
index 000000000..f30e3f9d4
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/buffer.d.ts
@@ -0,0 +1,3 @@
+export declare const equal: (a: ArrayBuffer, b: ArrayBuffer) => boolean;
+export declare const timingSafeEqual: (a: string | object | boolean, b: string | object | boolean, hashFunction?: Function) => Promise<boolean>;
+export declare const bufferToString: (buffer: ArrayBuffer) => string;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/buffer.js b/cli/bench/testdata/npm/hono/dist/utils/buffer.js
new file mode 100644
index 000000000..58ee6f9ae
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/buffer.js
@@ -0,0 +1,39 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.bufferToString = exports.timingSafeEqual = exports.equal = void 0;
+const crypto_1 = require("./crypto");
+const equal = (a, b) => {
+ if (a === b) {
+ return true;
+ }
+ if (a.byteLength !== b.byteLength) {
+ return false;
+ }
+ const va = new DataView(a);
+ const vb = new DataView(b);
+ let i = va.byteLength;
+ while (i--) {
+ if (va.getUint8(i) !== vb.getUint8(i)) {
+ return false;
+ }
+ }
+ return true;
+};
+exports.equal = equal;
+const timingSafeEqual = async (a, b, hashFunction) => {
+ if (!hashFunction) {
+ hashFunction = crypto_1.sha256;
+ }
+ const sa = await hashFunction(a);
+ const sb = await hashFunction(b);
+ return sa === sb && a === b;
+};
+exports.timingSafeEqual = timingSafeEqual;
+const bufferToString = (buffer) => {
+ if (buffer instanceof ArrayBuffer) {
+ const enc = new TextDecoder('utf-8');
+ return enc.decode(buffer);
+ }
+ return buffer;
+};
+exports.bufferToString = bufferToString;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/cloudflare.d.ts b/cli/bench/testdata/npm/hono/dist/utils/cloudflare.d.ts
new file mode 100644
index 000000000..abdc25a5b
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/cloudflare.d.ts
@@ -0,0 +1,6 @@
+/// <reference types="@cloudflare/workers-types" />
+export declare type KVAssetOptions = {
+ manifest?: object | string;
+ namespace?: KVNamespace;
+};
+export declare const getContentFromKVAsset: (path: string, options?: KVAssetOptions) => Promise<ArrayBuffer | null>;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/cloudflare.js b/cli/bench/testdata/npm/hono/dist/utils/cloudflare.js
new file mode 100644
index 000000000..4ba9a7e52
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/cloudflare.js
@@ -0,0 +1,39 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getContentFromKVAsset = void 0;
+const getContentFromKVAsset = async (path, options) => {
+ let ASSET_MANIFEST = {};
+ if (options && options.manifest) {
+ if (typeof options.manifest === 'string') {
+ ASSET_MANIFEST = JSON.parse(options.manifest);
+ }
+ else {
+ ASSET_MANIFEST = options.manifest;
+ }
+ }
+ else {
+ if (typeof __STATIC_CONTENT_MANIFEST === 'string') {
+ ASSET_MANIFEST = JSON.parse(__STATIC_CONTENT_MANIFEST);
+ }
+ else {
+ ASSET_MANIFEST = __STATIC_CONTENT_MANIFEST;
+ }
+ }
+ let ASSET_NAMESPACE;
+ if (options && options.namespace) {
+ ASSET_NAMESPACE = options.namespace;
+ }
+ else {
+ ASSET_NAMESPACE = __STATIC_CONTENT;
+ }
+ const key = ASSET_MANIFEST[path] || path;
+ if (!key) {
+ return null;
+ }
+ let content = await ASSET_NAMESPACE.get(key, { type: 'arrayBuffer' });
+ if (content) {
+ content = content;
+ }
+ return content;
+};
+exports.getContentFromKVAsset = getContentFromKVAsset;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/cookie.d.ts b/cli/bench/testdata/npm/hono/dist/utils/cookie.d.ts
new file mode 100644
index 000000000..d467efde5
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/cookie.d.ts
@@ -0,0 +1,13 @@
+export declare type Cookie = Record<string, string>;
+export declare type CookieOptions = {
+ domain?: string;
+ expires?: Date;
+ httpOnly?: boolean;
+ maxAge?: number;
+ path?: string;
+ secure?: boolean;
+ signed?: boolean;
+ sameSite?: 'Strict' | 'Lax' | 'None';
+};
+export declare const parse: (cookie: string) => Cookie;
+export declare const serialize: (name: string, value: string, opt?: CookieOptions) => string;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/cookie.js b/cli/bench/testdata/npm/hono/dist/utils/cookie.js
new file mode 100644
index 000000000..13a18602f
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/cookie.js
@@ -0,0 +1,40 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.serialize = exports.parse = void 0;
+const parse = (cookie) => {
+ const pairs = cookie.split(/;\s*/g);
+ const parsedCookie = {};
+ for (let i = 0, len = pairs.length; i < len; i++) {
+ const pair = pairs[i].split(/\s*=\s*([^\s]+)/);
+ parsedCookie[pair[0]] = decodeURIComponent(pair[1]);
+ }
+ return parsedCookie;
+};
+exports.parse = parse;
+const serialize = (name, value, opt = {}) => {
+ value = encodeURIComponent(value);
+ let cookie = `${name}=${value}`;
+ if (opt.maxAge) {
+ cookie += `; Max-Age=${Math.floor(opt.maxAge)}`;
+ }
+ if (opt.domain) {
+ cookie += '; Domain=' + opt.domain;
+ }
+ if (opt.path) {
+ cookie += '; Path=' + opt.path;
+ }
+ if (opt.expires) {
+ cookie += '; Expires=' + opt.expires.toUTCString();
+ }
+ if (opt.httpOnly) {
+ cookie += '; HttpOnly';
+ }
+ if (opt.secure) {
+ cookie += '; Secure';
+ }
+ if (opt.sameSite) {
+ cookie += `; SameSite=${opt.sameSite}`;
+ }
+ return cookie;
+};
+exports.serialize = serialize;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/crypto.d.ts b/cli/bench/testdata/npm/hono/dist/utils/crypto.d.ts
new file mode 100644
index 000000000..540afb399
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/crypto.d.ts
@@ -0,0 +1,10 @@
+declare type Algorithm = {
+ name: string;
+ alias: string;
+};
+declare type Data = string | boolean | number | object | ArrayBufferView | ArrayBuffer | ReadableStream;
+export declare const sha256: (data: Data) => Promise<string | null>;
+export declare const sha1: (data: Data) => Promise<string | null>;
+export declare const md5: (data: Data) => Promise<string | null>;
+export declare const createHash: (data: Data, algorithm: Algorithm) => Promise<string | null>;
+export {};
diff --git a/cli/bench/testdata/npm/hono/dist/utils/crypto.js b/cli/bench/testdata/npm/hono/dist/utils/crypto.js
new file mode 100644
index 000000000..0d259ae1c
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/crypto.js
@@ -0,0 +1,53 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.createHash = exports.md5 = exports.sha1 = exports.sha256 = void 0;
+const sha256 = async (data) => {
+ const algorithm = { name: 'SHA-256', alias: 'sha256' };
+ const hash = await (0, exports.createHash)(data, algorithm);
+ return hash;
+};
+exports.sha256 = sha256;
+const sha1 = async (data) => {
+ const algorithm = { name: 'SHA-1', alias: 'sha1' };
+ const hash = await (0, exports.createHash)(data, algorithm);
+ return hash;
+};
+exports.sha1 = sha1;
+const md5 = async (data) => {
+ const algorithm = { name: 'MD5', alias: 'md5' };
+ const hash = await (0, exports.createHash)(data, algorithm);
+ return hash;
+};
+exports.md5 = md5;
+const createHash = async (data, algorithm) => {
+ let sourceBuffer;
+ if (data instanceof ReadableStream) {
+ let body = '';
+ const reader = data.getReader();
+ await reader?.read().then(async (chuck) => {
+ const value = await (0, exports.createHash)(chuck.value || '', algorithm);
+ body += value;
+ });
+ return body;
+ }
+ if (ArrayBuffer.isView(data) || data instanceof ArrayBuffer) {
+ sourceBuffer = data;
+ }
+ else {
+ if (typeof data === 'object') {
+ data = JSON.stringify(data);
+ }
+ sourceBuffer = new TextEncoder().encode(String(data));
+ }
+ if (crypto && crypto.subtle) {
+ const buffer = await crypto.subtle.digest({
+ name: algorithm.name,
+ }, sourceBuffer);
+ const hash = Array.prototype.map
+ .call(new Uint8Array(buffer), (x) => ('00' + x.toString(16)).slice(-2))
+ .join('');
+ return hash;
+ }
+ return null;
+};
+exports.createHash = createHash;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/encode.d.ts b/cli/bench/testdata/npm/hono/dist/utils/encode.d.ts
new file mode 100644
index 000000000..e1db501e0
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/encode.d.ts
@@ -0,0 +1,7 @@
+export declare const encodeBase64: (str: string) => string;
+export declare const decodeBase64: (str: string) => string;
+export declare const encodeBase64URL: (str: string) => string;
+export declare const decodeBase64URL: (str: string) => string;
+export declare const utf8ToUint8Array: (str: string) => Uint8Array;
+export declare const arrayBufferToBase64: (buf: ArrayBuffer) => Promise<string>;
+export declare const arrayBufferToBase64URL: (buf: ArrayBuffer) => Promise<string>;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/encode.js b/cli/bench/testdata/npm/hono/dist/utils/encode.js
new file mode 100644
index 000000000..46e61c079
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/encode.js
@@ -0,0 +1,80 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.arrayBufferToBase64URL = exports.arrayBufferToBase64 = exports.utf8ToUint8Array = exports.decodeBase64URL = exports.encodeBase64URL = exports.decodeBase64 = exports.encodeBase64 = void 0;
+const encodeBase64 = (str) => {
+ if (str === null) {
+ throw new TypeError('1st argument of "encodeBase64" should not be null.');
+ }
+ try {
+ const encoder = new TextEncoder();
+ const bytes = encoder.encode(str);
+ return btoa(String.fromCharCode(...bytes));
+ }
+ catch { }
+ try {
+ return Buffer.from(str).toString('base64');
+ }
+ catch (e) {
+ console.error('If you want to do "encodeBase64", polyfill "buffer" module.');
+ throw e;
+ }
+};
+exports.encodeBase64 = encodeBase64;
+const decodeBase64 = (str) => {
+ if (str === null) {
+ throw new TypeError('1st argument of "decodeBase64" should not be null.');
+ }
+ try {
+ const text = atob(str);
+ const bytes = new Uint8Array(text.split('').map((c) => c.charCodeAt(0)));
+ const decoder = new TextDecoder();
+ return decoder.decode(bytes);
+ }
+ catch { }
+ try {
+ return Buffer.from(str, 'base64').toString();
+ }
+ catch (e) {
+ console.error('If you want to do "decodeBase64", polyfill "buffer" module.');
+ throw e;
+ }
+};
+exports.decodeBase64 = decodeBase64;
+const encodeBase64URL = (str) => {
+ return (0, exports.encodeBase64)(str).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
+};
+exports.encodeBase64URL = encodeBase64URL;
+const decodeBase64URL = (str) => {
+ const pad = (s) => {
+ const diff = s.length % 4;
+ if (diff === 2) {
+ return `${s}==`;
+ }
+ if (diff === 3) {
+ return `${s}=`;
+ }
+ return s;
+ };
+ return (0, exports.decodeBase64)(pad(str).replace(/-/g, '+').replace('_', '/'));
+};
+exports.decodeBase64URL = decodeBase64URL;
+const utf8ToUint8Array = (str) => {
+ const encoder = new TextEncoder();
+ return encoder.encode(str);
+};
+exports.utf8ToUint8Array = utf8ToUint8Array;
+const arrayBufferToBase64 = async (buf) => {
+ if (typeof btoa === 'function') {
+ return btoa(String.fromCharCode(...new Uint8Array(buf)));
+ }
+ try {
+ return Buffer.from(String.fromCharCode(...new Uint8Array(buf))).toString('base64');
+ }
+ catch (e) { }
+ return '';
+};
+exports.arrayBufferToBase64 = arrayBufferToBase64;
+const arrayBufferToBase64URL = async (buf) => {
+ return (await (0, exports.arrayBufferToBase64)(buf)).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
+};
+exports.arrayBufferToBase64URL = arrayBufferToBase64URL;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/filepath.d.ts b/cli/bench/testdata/npm/hono/dist/utils/filepath.d.ts
new file mode 100644
index 000000000..99453d5d6
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/filepath.d.ts
@@ -0,0 +1,7 @@
+declare type FilePathOptions = {
+ filename: string;
+ root?: string;
+ defaultDocument?: string;
+};
+export declare const getFilePath: (options: FilePathOptions) => string;
+export {};
diff --git a/cli/bench/testdata/npm/hono/dist/utils/filepath.js b/cli/bench/testdata/npm/hono/dist/utils/filepath.js
new file mode 100644
index 000000000..43451a9cc
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/filepath.js
@@ -0,0 +1,25 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getFilePath = void 0;
+const getFilePath = (options) => {
+ let filename = options.filename;
+ let root = options.root || '';
+ const defaultDocument = options.defaultDocument || 'index.html';
+ if (filename.endsWith('/')) {
+ // /top/ => /top/index.html
+ filename = filename.concat(defaultDocument);
+ }
+ else if (!filename.match(/\.[a-zA-Z0-9]+$/)) {
+ // /top => /top/index.html
+ filename = filename.concat('/' + defaultDocument);
+ }
+ // /foo.html => foo.html
+ filename = filename.replace(/^\.?\//, '');
+ // assets/ => assets
+ root = root.replace(/\/$/, '');
+ // ./assets/foo.html => assets/foo.html
+ let path = root ? root + '/' + filename : filename;
+ path = path.replace(/^\.?\//, '');
+ return path;
+};
+exports.getFilePath = getFilePath;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/html.d.ts b/cli/bench/testdata/npm/hono/dist/utils/html.d.ts
new file mode 100644
index 000000000..d8d5cd4e7
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/html.d.ts
@@ -0,0 +1,6 @@
+export declare type HtmlEscaped = {
+ isEscaped: true;
+};
+export declare type HtmlEscapedString = string & HtmlEscaped;
+export declare type StringBuffer = [string];
+export declare const escapeToBuffer: (str: string, buffer: StringBuffer) => void;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/html.js b/cli/bench/testdata/npm/hono/dist/utils/html.js
new file mode 100644
index 000000000..920739092
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/html.js
@@ -0,0 +1,38 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.escapeToBuffer = void 0;
+// The `escapeToBuffer` implementation is based on code from the MIT licensed `react-dom` package.
+// https://github.com/facebook/react/blob/main/packages/react-dom/src/server/escapeTextForBrowser.js
+const escapeRe = /[&<>"]/;
+const escapeToBuffer = (str, buffer) => {
+ const match = str.search(escapeRe);
+ if (match === -1) {
+ buffer[0] += str;
+ return;
+ }
+ let escape;
+ let index;
+ let lastIndex = 0;
+ for (index = match; index < str.length; index++) {
+ switch (str.charCodeAt(index)) {
+ case 34: // "
+ escape = '&quot;';
+ break;
+ case 38: // &
+ escape = '&amp;';
+ break;
+ case 60: // <
+ escape = '&lt;';
+ break;
+ case 62: // >
+ escape = '&gt;';
+ break;
+ default:
+ continue;
+ }
+ buffer[0] += str.substring(lastIndex, index) + escape;
+ lastIndex = index + 1;
+ }
+ buffer[0] += str.substring(lastIndex, index);
+};
+exports.escapeToBuffer = escapeToBuffer;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/http-status.d.ts b/cli/bench/testdata/npm/hono/dist/utils/http-status.d.ts
new file mode 100644
index 000000000..5002ec0ba
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/http-status.d.ts
@@ -0,0 +1,2 @@
+export declare const getStatusText: (statusCode: StatusCode) => string;
+export declare type StatusCode = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 444 | 449 | 450 | 451 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 598 | 599;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/http-status.js b/cli/bench/testdata/npm/hono/dist/utils/http-status.js
new file mode 100644
index 000000000..295d3f1ec
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/http-status.js
@@ -0,0 +1,50 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getStatusText = void 0;
+const getStatusText = (statusCode) => {
+ const text = statuses[statusCode];
+ return text;
+};
+exports.getStatusText = getStatusText;
+const statuses = {
+ 100: 'Continue',
+ 101: 'Switching Protocols',
+ 102: 'Processing',
+ 103: 'Early Hints',
+ 200: 'OK',
+ 201: 'Created',
+ 202: 'Accepted',
+ 204: 'No Content',
+ 206: 'Partial Content',
+ 301: 'Moved Permanently',
+ 302: 'Moved Temporarily',
+ 303: 'See Other',
+ 304: 'Not Modified',
+ 307: 'Temporary Redirect',
+ 308: 'Permanent Redirect',
+ 400: 'Bad Request',
+ 401: 'Unauthorized',
+ 402: 'Payment Required',
+ 403: 'Forbidden',
+ 404: 'Not Found',
+ 405: 'Not Allowed',
+ 406: 'Not Acceptable',
+ 408: 'Request Time-out',
+ 409: 'Conflict',
+ 410: 'Gone',
+ 411: 'Length Required',
+ 412: 'Precondition Failed',
+ 413: 'Request Entity Too Large',
+ 414: 'Request-URI Too Large',
+ 415: 'Unsupported Media Type',
+ 416: 'Requested Range Not Satisfiable',
+ 421: 'Misdirected Request',
+ 429: 'Too Many Requests',
+ 500: 'Internal Server Error',
+ 501: 'Not Implemented',
+ 502: 'Bad Gateway',
+ 503: 'Service Temporarily Unavailable',
+ 504: 'Gateway Time-out',
+ 505: 'HTTP Version Not Supported',
+ 507: 'Insufficient Storage',
+};
diff --git a/cli/bench/testdata/npm/hono/dist/utils/jwt/index.d.ts b/cli/bench/testdata/npm/hono/dist/utils/jwt/index.d.ts
new file mode 100644
index 000000000..8581a525a
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/jwt/index.d.ts
@@ -0,0 +1 @@
+export * as Jwt from './jwt';
diff --git a/cli/bench/testdata/npm/hono/dist/utils/jwt/index.js b/cli/bench/testdata/npm/hono/dist/utils/jwt/index.js
new file mode 100644
index 000000000..221dba30c
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/jwt/index.js
@@ -0,0 +1,27 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Jwt = void 0;
+exports.Jwt = __importStar(require("./jwt"));
diff --git a/cli/bench/testdata/npm/hono/dist/utils/jwt/jwt.d.ts b/cli/bench/testdata/npm/hono/dist/utils/jwt/jwt.d.ts
new file mode 100644
index 000000000..46aba49e5
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/jwt/jwt.d.ts
@@ -0,0 +1,7 @@
+import { AlgorithmTypes } from './types';
+export declare const sign: (payload: unknown, secret: string, alg?: AlgorithmTypes) => Promise<string>;
+export declare const verify: (token: string, secret: string, alg?: AlgorithmTypes) => Promise<boolean>;
+export declare const decode: (token: string) => {
+ header: any;
+ payload: any;
+};
diff --git a/cli/bench/testdata/npm/hono/dist/utils/jwt/jwt.js b/cli/bench/testdata/npm/hono/dist/utils/jwt/jwt.js
new file mode 100644
index 000000000..73a3f2df4
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/jwt/jwt.js
@@ -0,0 +1,101 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.decode = exports.verify = exports.sign = void 0;
+const encode_1 = require("../../utils/encode");
+const types_1 = require("./types");
+const types_2 = require("./types");
+var CryptoKeyFormat;
+(function (CryptoKeyFormat) {
+ CryptoKeyFormat["RAW"] = "raw";
+ CryptoKeyFormat["PKCS8"] = "pkcs8";
+ CryptoKeyFormat["SPKI"] = "spki";
+ CryptoKeyFormat["JWK"] = "jwk";
+})(CryptoKeyFormat || (CryptoKeyFormat = {}));
+var CryptoKeyUsage;
+(function (CryptoKeyUsage) {
+ CryptoKeyUsage["Ecrypt"] = "encrypt";
+ CryptoKeyUsage["Decrypt"] = "decrypt";
+ CryptoKeyUsage["Sign"] = "sign";
+ CryptoKeyUsage["Verify"] = "verify";
+ CryptoKeyUsage["Deriverkey"] = "deriveKey";
+ CryptoKeyUsage["DeriveBits"] = "deriveBits";
+ CryptoKeyUsage["WrapKey"] = "wrapKey";
+ CryptoKeyUsage["UnwrapKey"] = "unwrapKey";
+})(CryptoKeyUsage || (CryptoKeyUsage = {}));
+const param = (name) => {
+ switch (name.toUpperCase()) {
+ case 'HS256':
+ return {
+ name: 'HMAC',
+ hash: {
+ name: 'SHA-256',
+ },
+ };
+ case 'HS384':
+ return {
+ name: 'HMAC',
+ hash: {
+ name: 'SHA-384',
+ },
+ };
+ case 'HS512':
+ return {
+ name: 'HMAC',
+ hash: {
+ name: 'SHA-512',
+ },
+ };
+ default:
+ throw new types_2.JwtAlgorithmNotImplemented(name);
+ }
+};
+const signing = async (data, secret, alg = types_1.AlgorithmTypes.HS256) => {
+ if (!crypto.subtle || !crypto.subtle.importKey) {
+ throw new Error('`crypto.subtle.importKey` is undefined. JWT auth middleware requires it.');
+ }
+ const cryptoKey = await crypto.subtle.importKey(CryptoKeyFormat.RAW, (0, encode_1.utf8ToUint8Array)(secret), param(alg), false, [CryptoKeyUsage.Sign]);
+ return await crypto.subtle.sign(param(alg), cryptoKey, (0, encode_1.utf8ToUint8Array)(data));
+};
+const sign = async (payload, secret, alg = types_1.AlgorithmTypes.HS256) => {
+ const encodedPayload = await (0, encode_1.encodeBase64URL)(JSON.stringify(payload));
+ const encodedHeader = await (0, encode_1.encodeBase64URL)(JSON.stringify({ alg, typ: 'JWT' }));
+ const partialToken = `${encodedHeader}.${encodedPayload}`;
+ const signature = await (0, encode_1.arrayBufferToBase64URL)(await signing(partialToken, secret, alg));
+ return `${partialToken}.${signature}`;
+};
+exports.sign = sign;
+const verify = async (token, secret, alg = types_1.AlgorithmTypes.HS256) => {
+ const tokenParts = token.split('.');
+ if (tokenParts.length !== 3) {
+ throw new types_2.JwtTokenInvalid(token);
+ }
+ const { payload } = (0, exports.decode)(token);
+ if (payload.nbf && payload.nbf > Math.floor(Date.now() / 1000)) {
+ throw new types_2.JwtTokenNotBefore(token);
+ }
+ if (payload.exp && payload.exp <= Math.floor(Date.now() / 1000)) {
+ throw new types_2.JwtTokenExpired(token);
+ }
+ const signature = await (0, encode_1.arrayBufferToBase64URL)(await signing(tokenParts.slice(0, 2).join('.'), secret, alg));
+ if (signature !== tokenParts[2]) {
+ throw new types_2.JwtTokenSignatureMismatched(token);
+ }
+ return true;
+};
+exports.verify = verify;
+// eslint-disable-next-line
+const decode = (token) => {
+ try {
+ const [h, p] = token.split('.');
+ const header = JSON.parse((0, encode_1.decodeBase64URL)(h));
+ const payload = JSON.parse((0, encode_1.decodeBase64URL)(p));
+ return {
+ header,
+ payload,
+ };
+ }
+ catch (e) {
+ throw new types_2.JwtTokenInvalid(token);
+ }
+};
+exports.decode = decode;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/jwt/types.d.ts b/cli/bench/testdata/npm/hono/dist/utils/jwt/types.d.ts
new file mode 100644
index 000000000..b3c8f3f17
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/jwt/types.d.ts
@@ -0,0 +1,25 @@
+export declare class JwtAlgorithmNotImplemented extends Error {
+ constructor(token: string);
+}
+/**
+ * Export for backward compatibility
+ * @deprecated Use JwtAlgorithmNotImplemented instead
+**/
+export declare const JwtAlorithmNotImplemented: typeof JwtAlgorithmNotImplemented;
+export declare class JwtTokenInvalid extends Error {
+ constructor(token: string);
+}
+export declare class JwtTokenNotBefore extends Error {
+ constructor(token: string);
+}
+export declare class JwtTokenExpired extends Error {
+ constructor(token: string);
+}
+export declare class JwtTokenSignatureMismatched extends Error {
+ constructor(token: string);
+}
+export declare enum AlgorithmTypes {
+ HS256 = "HS256",
+ HS384 = "HS384",
+ HS512 = "HS512"
+}
diff --git a/cli/bench/testdata/npm/hono/dist/utils/jwt/types.js b/cli/bench/testdata/npm/hono/dist/utils/jwt/types.js
new file mode 100644
index 000000000..638bdbe6e
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/jwt/types.js
@@ -0,0 +1,49 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.AlgorithmTypes = exports.JwtTokenSignatureMismatched = exports.JwtTokenExpired = exports.JwtTokenNotBefore = exports.JwtTokenInvalid = exports.JwtAlorithmNotImplemented = exports.JwtAlgorithmNotImplemented = void 0;
+class JwtAlgorithmNotImplemented extends Error {
+ constructor(token) {
+ super(`invalid JWT token: ${token}`);
+ this.name = 'JwtAlgorithmNotImplemented';
+ }
+}
+exports.JwtAlgorithmNotImplemented = JwtAlgorithmNotImplemented;
+/**
+ * Export for backward compatibility
+ * @deprecated Use JwtAlgorithmNotImplemented instead
+**/
+exports.JwtAlorithmNotImplemented = JwtAlgorithmNotImplemented;
+class JwtTokenInvalid extends Error {
+ constructor(token) {
+ super(`invalid JWT token: ${token}`);
+ this.name = 'JwtTokenInvalid';
+ }
+}
+exports.JwtTokenInvalid = JwtTokenInvalid;
+class JwtTokenNotBefore extends Error {
+ constructor(token) {
+ super(`token (${token}) is being used before it's valid`);
+ this.name = 'JwtTokenNotBefore';
+ }
+}
+exports.JwtTokenNotBefore = JwtTokenNotBefore;
+class JwtTokenExpired extends Error {
+ constructor(token) {
+ super(`token (${token}) expired`);
+ this.name = 'JwtTokenExpired';
+ }
+}
+exports.JwtTokenExpired = JwtTokenExpired;
+class JwtTokenSignatureMismatched extends Error {
+ constructor(token) {
+ super(`token(${token}) signature mismatched`);
+ this.name = 'JwtTokenSignatureMismatched';
+ }
+}
+exports.JwtTokenSignatureMismatched = JwtTokenSignatureMismatched;
+var AlgorithmTypes;
+(function (AlgorithmTypes) {
+ AlgorithmTypes["HS256"] = "HS256";
+ AlgorithmTypes["HS384"] = "HS384";
+ AlgorithmTypes["HS512"] = "HS512";
+})(AlgorithmTypes = exports.AlgorithmTypes || (exports.AlgorithmTypes = {}));
diff --git a/cli/bench/testdata/npm/hono/dist/utils/mime.d.ts b/cli/bench/testdata/npm/hono/dist/utils/mime.d.ts
new file mode 100644
index 000000000..83e4db22e
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/mime.d.ts
@@ -0,0 +1 @@
+export declare const getMimeType: (filename: string) => string | undefined;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/mime.js b/cli/bench/testdata/npm/hono/dist/utils/mime.js
new file mode 100644
index 000000000..18aa76d52
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/mime.js
@@ -0,0 +1,92 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getMimeType = void 0;
+const getMimeType = (filename) => {
+ const regexp = /\.([a-zA-Z0-9]+?)$/;
+ const match = filename.match(regexp);
+ if (!match)
+ return;
+ let mimeType = mimes[match[1]];
+ if ((mimeType && mimeType.startsWith('text')) || mimeType === 'application/json') {
+ mimeType += '; charset=utf-8';
+ }
+ return mimeType;
+};
+exports.getMimeType = getMimeType;
+const mimes = {
+ aac: 'audio/aac',
+ abw: 'application/x-abiword',
+ arc: 'application/x-freearc',
+ avi: 'video/x-msvideo',
+ azw: 'application/vnd.amazon.ebook',
+ bin: 'application/octet-stream',
+ bmp: 'image/bmp',
+ bz: 'application/x-bzip',
+ bz2: 'application/x-bzip2',
+ csh: 'application/x-csh',
+ css: 'text/css',
+ csv: 'text/csv',
+ doc: 'application/msword',
+ docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ eot: 'application/vnd.ms-fontobject',
+ epub: 'application/epub+zip',
+ gz: 'application/gzip',
+ gif: 'image/gif',
+ htm: 'text/html',
+ html: 'text/html',
+ ico: 'image/x-icon',
+ ics: 'text/calendar',
+ jar: 'application/java-archive',
+ jpeg: 'image/jpeg',
+ jpg: 'image/jpeg',
+ js: 'text/javascript',
+ json: 'application/json',
+ jsonld: 'application/ld+json',
+ map: 'application/json',
+ mid: 'audio/x-midi',
+ midi: 'audio/x-midi',
+ mjs: 'text/javascript',
+ mp3: 'audio/mpeg',
+ mpeg: 'video/mpeg',
+ mpkg: 'application/vnd.apple.installer+xml',
+ odp: 'application/vnd.oasis.opendocument.presentation',
+ ods: 'application/vnd.oasis.opendocument.spreadsheet',
+ odt: 'application/vnd.oasis.opendocument.text',
+ oga: 'audio/ogg',
+ ogv: 'video/ogg',
+ ogx: 'application/ogg',
+ opus: 'audio/opus',
+ otf: 'font/otf',
+ png: 'image/png',
+ pdf: 'application/pdf',
+ php: 'application/php',
+ ppt: 'application/vnd.ms-powerpoint',
+ pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ rar: 'application/vnd.rar',
+ rtf: 'application/rtf',
+ sh: 'application/x-sh',
+ svg: 'image/svg+xml',
+ swf: 'application/x-shockwave-flash',
+ tar: 'application/x-tar',
+ tif: 'image/tiff',
+ tiff: 'image/tiff',
+ ts: 'video/mp2t',
+ ttf: 'font/ttf',
+ txt: 'text/plain',
+ vsd: 'application/vnd.visio',
+ wav: 'audio/wav',
+ weba: 'audio/webm',
+ webm: 'video/webm',
+ webp: 'image/webp',
+ woff: 'font/woff',
+ woff2: 'font/woff2',
+ xhtml: 'application/xhtml+xml',
+ xls: 'application/vnd.ms-excel',
+ xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ xml: 'application/xml',
+ xul: 'application/vnd.mozilla.xul+xml',
+ zip: 'application/zip',
+ '3gp': 'video/3gpp',
+ '3g2': 'video/3gpp2',
+ '7z': 'application/x-7z-compressed',
+};
diff --git a/cli/bench/testdata/npm/hono/dist/utils/url.d.ts b/cli/bench/testdata/npm/hono/dist/utils/url.d.ts
new file mode 100644
index 000000000..16e077f04
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/url.d.ts
@@ -0,0 +1,6 @@
+export declare type Pattern = readonly [string, string, RegExp | true] | '*';
+export declare const splitPath: (path: string) => string[];
+export declare const getPattern: (label: string) => Pattern | null;
+export declare const getPathFromURL: (url: string, strict?: boolean) => string;
+export declare const isAbsoluteURL: (url: string) => boolean;
+export declare const mergePath: (...paths: string[]) => string;
diff --git a/cli/bench/testdata/npm/hono/dist/utils/url.js b/cli/bench/testdata/npm/hono/dist/utils/url.js
new file mode 100644
index 000000000..0e8fc33a3
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/utils/url.js
@@ -0,0 +1,83 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.mergePath = exports.isAbsoluteURL = exports.getPathFromURL = exports.getPattern = exports.splitPath = void 0;
+const URL_REGEXP = /^https?:\/\/[a-zA-Z0-9\-\.:]+(\/?[^?#]*)/;
+const splitPath = (path) => {
+ const paths = path.split(/\//); // faster than path.split('/')
+ if (paths[0] === '') {
+ paths.shift();
+ }
+ return paths;
+};
+exports.splitPath = splitPath;
+const patternCache = {};
+const getPattern = (label) => {
+ // * => wildcard
+ // :id{[0-9]+} => ([0-9]+)
+ // :id => (.+)
+ //const name = ''
+ if (label === '*') {
+ return '*';
+ }
+ const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
+ if (match) {
+ if (!patternCache[label]) {
+ if (match[2]) {
+ patternCache[label] = [label, match[1], new RegExp('^' + match[2] + '$')];
+ }
+ else {
+ patternCache[label] = [label, match[1], true];
+ }
+ }
+ return patternCache[label];
+ }
+ return null;
+};
+exports.getPattern = getPattern;
+const getPathFromURL = (url, strict = true) => {
+ const queryIndex = url.indexOf('?');
+ const result = url.substring(url.indexOf('/', 8), queryIndex === -1 ? url.length : queryIndex);
+ // if strict routing is false => `/hello/hey/` and `/hello/hey` are treated the same
+ // default is true
+ if (strict === false && result.endsWith('/')) {
+ return result.slice(0, -1);
+ }
+ return result;
+};
+exports.getPathFromURL = getPathFromURL;
+const isAbsoluteURL = (url) => {
+ const match = url.match(URL_REGEXP);
+ if (match) {
+ return true;
+ }
+ return false;
+};
+exports.isAbsoluteURL = isAbsoluteURL;
+const mergePath = (...paths) => {
+ let p = '';
+ let endsWithSlash = false;
+ for (let path of paths) {
+ /* ['/hey/','/say'] => ['/hey', '/say'] */
+ if (p.endsWith('/')) {
+ p = p.slice(0, -1);
+ endsWithSlash = true;
+ }
+ /* ['/hey','say'] => ['/hey', '/say'] */
+ if (!path.startsWith('/')) {
+ path = `/${path}`;
+ }
+ /* ['/hey/', '/'] => `/hey/` */
+ if (path === '/' && endsWithSlash) {
+ p = `${p}/`;
+ }
+ else if (path !== '/') {
+ p = `${p}${path}`;
+ }
+ /* ['/', '/'] => `/` */
+ if (path === '/' && p === '') {
+ p = '/';
+ }
+ }
+ return p;
+};
+exports.mergePath = mergePath;