@hyperttp/core 2.0.0 → 2.0.2
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/Core/HyperCore.d.ts +13 -6
- package/Core/HyperCore.d.ts.map +1 -1
- package/Core/HyperCore.js +1 -1
- package/Core/HyperCore.js.map +3 -3
- package/README.md +3 -3
- package/defaultConfig.d.ts +0 -5
- package/defaultConfig.d.ts.map +1 -1
- package/defaultConfig.js +1 -1
- package/defaultConfig.js.map +2 -2
- package/package.json +3 -3
- package/protocols/manager.d.ts +6 -0
- package/protocols/manager.d.ts.map +1 -1
- package/protocols/manager.js +1 -1
- package/protocols/manager.js.map +3 -3
- package/protocols/rest/index.d.ts +2 -1
- package/protocols/rest/index.d.ts.map +1 -1
- package/protocols/rest/index.js.map +2 -2
- package/protocols/rest/receiver.d.ts +5 -0
- package/protocols/rest/receiver.d.ts.map +1 -1
- package/protocols/rest/receiver.js +1 -1
- package/protocols/rest/receiver.js.map +3 -3
- package/protocols/rest/sender.d.ts +0 -7
- package/protocols/rest/sender.d.ts.map +1 -1
- package/protocols/rest/sender.js +1 -1
- package/protocols/rest/sender.js.map +3 -3
- package/protocols/rest/type.d.ts +51 -9
- package/protocols/rest/type.d.ts.map +1 -1
- package/protocols/rest/utils.d.ts +3 -0
- package/protocols/rest/utils.d.ts.map +1 -0
- package/protocols/rest/utils.js +2 -0
- package/protocols/rest/utils.js.map +7 -0
- package/rest.d.ts +1 -1
- package/rest.d.ts.map +1 -1
- package/transports/fetch.d.ts +20 -1
- package/transports/fetch.d.ts.map +1 -1
- package/transports/fetch.js +1 -1
- package/transports/fetch.js.map +3 -3
- package/transports/manager.d.ts +18 -3
- package/transports/manager.d.ts.map +1 -1
- package/transports/manager.js +1 -1
- package/transports/manager.js.map +3 -3
- package/utils/errors.d.ts +12 -4
- package/utils/errors.d.ts.map +1 -1
- package/utils/errors.js.map +2 -2
- package/utils/modules.d.ts +3 -0
- package/utils/modules.d.ts.map +1 -0
- package/utils/modules.js +2 -0
- package/utils/modules.js.map +7 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/transports/manager.ts"],
|
|
4
|
-
"sourcesContent": ["import type { HyperTransport, SenderProtocol } from \"@hyperttp/types\";\nimport { FetchTransport, type FetchTransportOptions } from \"./fetch.js\";\n\ndeclare const Bun: unknown;\ndeclare const Deno: unknown;\n\nexport type Runtime = \"bun\" | \"node\" | \"deno\" | \"browser\";\n\n/**\n * @ru Опции разрешения транспорта. `customTransport` имеет приоритет над автовыбором.\n * @en Transport resolution options. `customTransport` takes priority over auto-selection.\n */\nexport interface ResolveTransportOptions {\n customTransport?: HyperTransport;\n [key: string]: unknown;\n}\n\nexport const CURRENT_RUNTIME: Runtime = (() => {\n if (typeof Bun !== \"undefined\") return \"bun\";\n if (typeof Deno !== \"undefined\") return \"deno\";\n if (typeof process !== \"undefined\" && process.versions?.node) return \"node\";\n return \"browser\";\n})();\n\ntype TransportDef = {\n readonly runtime: readonly Runtime[];\n readonly pkg: string;\n readonly export: string;\n
|
|
5
|
-
"mappings": "aACA,OAAS,kBAAAA,MAAkD,
|
|
6
|
-
"names": ["FetchTransport", "
|
|
4
|
+
"sourcesContent": ["import type { HyperTransport, LogLevel, SenderProtocol } from \"@hyperttp/types\";\nimport { FetchTransport, type FetchTransportOptions } from \"./fetch.js\";\nimport { dynamicImport, isModuleNotFoundError } from \"../utils/modules.js\";\n\ndeclare const Bun: unknown;\ndeclare const Deno: unknown;\n\nexport type Runtime = \"bun\" | \"node\" | \"deno\" | \"browser\";\n\n/**\n * @ru Опции разрешения транспорта. `customTransport` имеет приоритет над автовыбором.\n * @en Transport resolution options. `customTransport` takes priority over auto-selection.\n */\nexport interface ResolveTransportOptions {\n customTransport?: HyperTransport;\n logger?: (level: LogLevel, message: string, meta?: unknown) => void;\n verbose?: boolean;\n [key: string]: unknown;\n}\n\nexport const CURRENT_RUNTIME: Runtime = (() => {\n if (typeof Bun !== \"undefined\") return \"bun\";\n if (typeof Deno !== \"undefined\") return \"deno\";\n if (typeof process !== \"undefined\" && process.versions?.node) return \"node\";\n return \"browser\";\n})();\n\ntype TransportDef = {\n readonly runtime: readonly Runtime[];\n readonly pkg: string;\n readonly export: string;\n};\n\nconst TRANSPORT_DEFS: readonly TransportDef[] = [\n { runtime: [\"bun\"], pkg: \"@hyperttp/transport-bun\", export: \"BunTransport\" },\n { runtime: [\"node\"], pkg: \"@hyperttp/transport-undici\", export: \"UndiciTransport\" },\n { runtime: [\"deno\"], pkg: \"@hyperttp/transport-deno\", export: \"DenoTransport\" },\n];\n\nconst CANDIDATES = TRANSPORT_DEFS.filter((t) => t.runtime.includes(CURRENT_RUNTIME));\n\nconst transportCache = new Map<string, HyperTransport>();\nconst transportResolutions = new Map<string, Promise<HyperTransport>>();\n\nfunction supportsProtocol(transport: HyperTransport, protocol: SenderProtocol): boolean {\n return typeof transport.supports === \"function\"\n ? transport.supports(protocol)\n : (transport.protocols?.includes(protocol) ?? true);\n}\n\nasync function disposeUnusedTransport(transport: HyperTransport): Promise<void> {\n if (typeof transport.destroy === \"function\") {\n await transport.destroy();\n } else if (typeof transport.close === \"function\") {\n await transport.close();\n }\n}\n\nasync function createTransport(\n protocol: SenderProtocol,\n config?: ResolveTransportOptions,\n): Promise<HyperTransport> {\n for (let i = 0; i < CANDIDATES.length; i++) {\n const t = CANDIDATES[i]!;\n try {\n const mod = await dynamicImport(t.pkg);\n const candidate = (mod[t.export] ?? mod.default) as\n | { new (opts?: unknown): HyperTransport }\n | undefined;\n if (typeof candidate !== \"function\") continue;\n\n const instance = new candidate(config ?? {});\n if (!supportsProtocol(instance, protocol)) {\n await disposeUnusedTransport(instance);\n continue;\n }\n\n return instance;\n } catch (err) {\n if (!isModuleNotFoundError(err)) throw err;\n }\n }\n\n const message = `[HyperCore] Fast transport (e.g. @hyperttp/transport-undici) unavailable for runtime \"${CURRENT_RUNTIME}\". Falling back to slow FetchTransport.`;\n if (config?.logger) {\n config.logger(\"warn\", message);\n } else if (config?.verbose) {\n console.warn(message);\n }\n\n const fetchTransport = new FetchTransport(config as unknown as FetchTransportOptions);\n if (supportsProtocol(fetchTransport, protocol)) return fetchTransport;\n\n await disposeUnusedTransport(fetchTransport);\n throw new Error(\n `[HyperCore] No transport available for protocol \"${protocol}\" in runtime \"${CURRENT_RUNTIME}\".`,\n );\n}\n\n/**\n * @ru Разрешает оптимальный транспорт для указанного протокола и текущей среды.\n * Кастомный транспорт из конфигурации имеет приоритет над автовыбором.\n * @en Resolves optimal transport for the given protocol and current runtime.\n * A custom transport from the config takes priority over auto-selection.\n */\nexport async function resolveTransport(\n protocol: SenderProtocol = \"rest\",\n config?: ResolveTransportOptions,\n): Promise<HyperTransport> {\n if (config?.customTransport) {\n if (!supportsProtocol(config.customTransport, protocol)) {\n throw new Error(`[HyperCore] Custom transport does not support protocol \"${protocol}\".`);\n }\n return config.customTransport;\n }\n\n const cached = transportCache.get(protocol);\n if (cached) return cached;\n\n const pending = transportResolutions.get(protocol);\n if (pending) return pending;\n\n const resolution = createTransport(protocol, config)\n .then((transport) => {\n transportCache.set(protocol, transport);\n return transport;\n })\n .finally(() => {\n transportResolutions.delete(protocol);\n });\n\n transportResolutions.set(protocol, resolution);\n return resolution;\n}\n\n/**\n * @ru Синхронно возвращает транспорт из кэша без создания Promise.\n * @en Synchronously returns a cached transport without creating a Promise.\n * @param protocol - Протокол, для которого запрашивается транспорт. @en Protocol whose transport is requested.\n * @returns Кэшированный транспорт или `undefined`. @en Cached transport or `undefined`.\n */\nexport function getCachedTransport(protocol: SenderProtocol = \"rest\"): HyperTransport | undefined {\n return transportCache.get(protocol);\n}\n\n/**\n * @ru Удаляет все записи кэша, ссылающиеся на указанный транспорт.\n * @en Removes every cache entry that references the given transport.\n * @param transport - Экземпляр транспорта для удаления из кэша. @en Transport instance to evict from the cache.\n */\nexport function evictCachedTransport(transport: HyperTransport): void {\n for (const [protocol, cached] of transportCache) {\n if (cached === transport) {\n transportCache.delete(protocol);\n }\n }\n}\n\n/**\n * @ru Очищает кэш транспортов и ожидающих их разрешений. Не закрывает уже\n * созданные экземпляры транспорта.\n * @en Clears cached transports and pending resolutions. It does not close\n * already-created transport instances.\n */\nexport function resetCachedTransport(): void {\n transportCache.clear();\n transportResolutions.clear();\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["FetchTransport", "dynamicImport", "isModuleNotFoundError", "TRANSPORT_DEFS", "CANDIDATES", "transportCache", "transportResolutions", "supportsProtocol", "transport", "protocol", "disposeUnusedTransport", "createTransport", "config", "i", "t", "mod", "candidate", "instance", "err", "message", "fetchTransport", "cached", "pending", "resolution"]
|
|
7
7
|
}
|
package/utils/errors.d.ts
CHANGED
|
@@ -9,8 +9,14 @@ export declare class HyperClientError extends Error {
|
|
|
9
9
|
url?: string | undefined;
|
|
10
10
|
method?: string | undefined;
|
|
11
11
|
/**
|
|
12
|
-
* @ru Создает
|
|
13
|
-
* @en Creates a
|
|
12
|
+
* @ru Создает ошибку Hyperttp с дополнительным сетевым контекстом.
|
|
13
|
+
* @en Creates a Hyperttp error with optional network context.
|
|
14
|
+
* @param message - Человекочитаемое описание ошибки. @en Human-readable error description.
|
|
15
|
+
* @param code - Машиночитаемый код ошибки. @en Machine-readable error code.
|
|
16
|
+
* @param statusCode - Связанный HTTP-статус, если есть. @en Associated HTTP status, when available.
|
|
17
|
+
* @param originalError - Исходная ошибка как `cause`. @en Original error exposed as `cause`.
|
|
18
|
+
* @param url - URL, связанный с ошибкой. @en URL associated with the error.
|
|
19
|
+
* @param method - HTTP-метод, связанный с ошибкой. @en HTTP method associated with the error.
|
|
14
20
|
*/
|
|
15
21
|
constructor(message: string, code?: string, statusCode?: number | undefined, originalError?: Error | undefined, url?: string | undefined, method?: string | undefined);
|
|
16
22
|
/**
|
|
@@ -25,8 +31,10 @@ export declare class HyperClientError extends Error {
|
|
|
25
31
|
*/
|
|
26
32
|
export declare class TimeoutError extends HyperClientError {
|
|
27
33
|
/**
|
|
28
|
-
* @ru Создает
|
|
29
|
-
* @en Creates a
|
|
34
|
+
* @ru Создает ошибку таймаута для указанного URL.
|
|
35
|
+
* @en Creates a timeout error for the given URL.
|
|
36
|
+
* @param url - URL запроса с истекшим таймаутом. @en URL of the timed-out request.
|
|
37
|
+
* @param timeout - Лимит времени в миллисекундах. @en Time limit in milliseconds.
|
|
30
38
|
*/
|
|
31
39
|
constructor(url: string, timeout: number);
|
|
32
40
|
/**
|
package/utils/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAahC,IAAI,EAAE,MAAM;IACZ,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,KAAK;IACrB,GAAG,CAAC,EAAE,MAAM;IACZ,MAAM,CAAC,EAAE,MAAM;IAhBxB;;;;;;;;;OASG;IACH,YACE,OAAO,EAAE,MAAM,EACR,IAAI,GAAE,MAAsB,EAC5B,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,KAAK,YAAA,EACrB,GAAG,CAAC,EAAE,MAAM,YAAA,EACZ,MAAM,CAAC,EAAE,MAAM,YAAA,EAKvB;IAED;;;OAGG;IACH,OAAc,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,gBAAgB,CAKtE;CACF;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IAChD;;;;;OAKG;IACH,YAAY,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIvC;IAED;;;OAGG;IACH,OAAc,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,YAAY,CAE9D;CACF"}
|
package/utils/errors.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/errors.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @ru Базовый класс ошибок клиента Hyperttp, агрегирующий контекст неудачного сетевого запроса.\n * @en Base error class for the Hyperttp client, providing explicit layout context for failed requests.\n */\nexport class HyperClientError extends Error {\n /**\n * @ru Создает
|
|
5
|
-
"mappings": "aAIM,aAAO,yBAAyB,KAAK,
|
|
4
|
+
"sourcesContent": ["/**\n * @ru Базовый класс ошибок клиента Hyperttp, агрегирующий контекст неудачного сетевого запроса.\n * @en Base error class for the Hyperttp client, providing explicit layout context for failed requests.\n */\nexport class HyperClientError extends Error {\n /**\n * @ru Создает ошибку Hyperttp с дополнительным сетевым контекстом.\n * @en Creates a Hyperttp error with optional network context.\n * @param message - Человекочитаемое описание ошибки. @en Human-readable error description.\n * @param code - Машиночитаемый код ошибки. @en Machine-readable error code.\n * @param statusCode - Связанный HTTP-статус, если есть. @en Associated HTTP status, when available.\n * @param originalError - Исходная ошибка как `cause`. @en Original error exposed as `cause`.\n * @param url - URL, связанный с ошибкой. @en URL associated with the error.\n * @param method - HTTP-метод, связанный с ошибкой. @en HTTP method associated with the error.\n */\n constructor(\n message: string,\n public code: string = \"HYPER_ERROR\",\n public statusCode?: number,\n public originalError?: Error,\n public url?: string,\n public method?: string,\n ) {\n super(message, originalError ? { cause: originalError } : undefined);\n this.name = \"HyperClientError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /**\n * @ru Проверяет, является ли ошибка экземпляром HttpClientError (безопасно для разрозненных бандлов).\n * @en Checks if an error is an HttpClientError instance (bundle boundary safe).\n */\n public static isHyperClientError(err: unknown): err is HyperClientError {\n return (\n err instanceof HyperClientError ||\n (err instanceof Error && (err as any).code === \"HYPER_ERROR\")\n );\n }\n}\n\n/**\n * @ru Ошибка, возникающая при превышении лимита времени ожидания ответа от сервера.\n * @en Error thrown when a network request exceeds its allocated execution timeout threshold.\n */\nexport class TimeoutError extends HyperClientError {\n /**\n * @ru Создает ошибку таймаута для указанного URL.\n * @en Creates a timeout error for the given URL.\n * @param url - URL запроса с истекшим таймаутом. @en URL of the timed-out request.\n * @param timeout - Лимит времени в миллисекундах. @en Time limit in milliseconds.\n */\n constructor(url: string, timeout: number) {\n super(`Timeout after ${timeout}ms`, \"TIMEOUT\", 408, undefined, url);\n this.name = \"TimeoutError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /**\n * @ru Проверяет, является ли ошибка экземпляром TimeoutError.\n * @en Checks if an error is a TimeoutError instance.\n */\n public static isTimeoutError(err: unknown): err is TimeoutError {\n return err instanceof TimeoutError || (err instanceof Error && (err as any).code === \"TIMEOUT\");\n }\n}\n"],
|
|
5
|
+
"mappings": "aAIM,aAAO,yBAAyB,KAAK,CAahC,KACA,WACA,cACA,IACA,OANT,YACEA,EACOC,EAAe,cACfC,EACAC,EACAC,EACAC,EAAe,CAEtB,MAAML,EAASG,EAAgB,CAAE,MAAOA,CAAa,EAAK,MAAS,YAN5DF,kBACAC,qBACAC,WACAC,cACAC,EAGP,KAAK,KAAO,mBACZ,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CAMO,OAAO,mBAAmBC,EAAY,CAC3C,OACEA,aAAe,kBACdA,aAAe,OAAUA,EAAY,OAAS,aAEnD,EAOI,aAAO,qBAAqB,gBAAgB,CAOhD,YAAYF,EAAaG,EAAe,CACtC,MAAM,iBAAiBA,CAAO,KAAM,UAAW,IAAK,OAAWH,CAAG,EAClE,KAAK,KAAO,eACZ,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CAMO,OAAO,eAAeE,EAAY,CACvC,OAAOA,aAAe,cAAiBA,aAAe,OAAUA,EAAY,OAAS,SACvF",
|
|
6
6
|
"names": ["message", "code", "statusCode", "originalError", "url", "method", "err", "timeout"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/utils/modules.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAW3D;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAGjF"}
|
package/utils/modules.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";export function isModuleNotFoundError(e){if(!e||typeof e!="object")return!1;const o=e;if(o.code==="ERR_MODULE_NOT_FOUND"||o.code==="MODULE_NOT_FOUND")return!0;const n=e instanceof Error?e.message:String(o.message??"");return n.includes("Cannot find module")||n.includes("Failed to resolve")||n.includes("Failed to load")}export async function dynamicImport(e){return import(e)}
|
|
2
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/modules.ts"],
|
|
4
|
+
"sourcesContent": ["export function isModuleNotFoundError(err: unknown): boolean {\n if (!err || typeof err !== \"object\") return false;\n const e = err as Record<string, unknown>;\n if (e.code === \"ERR_MODULE_NOT_FOUND\" || e.code === \"MODULE_NOT_FOUND\") return true;\n\n const message = err instanceof Error ? err.message : String(e.message ?? \"\");\n return (\n message.includes(\"Cannot find module\") ||\n message.includes(\"Failed to resolve\") ||\n message.includes(\"Failed to load\")\n );\n}\n\nexport async function dynamicImport(pkg: string): Promise<Record<string, unknown>> {\n /* @vite-ignore */\n return import(/* webpackIgnore: true */ pkg);\n}\n"],
|
|
5
|
+
"mappings": "aAAM,gBAAU,sBAAsBA,EAAY,CAChD,GAAI,CAACA,GAAO,OAAOA,GAAQ,SAAU,MAAO,GAC5C,MAAMC,EAAID,EACV,GAAIC,EAAE,OAAS,wBAA0BA,EAAE,OAAS,mBAAoB,MAAO,GAE/E,MAAMC,EAAUF,aAAe,MAAQA,EAAI,QAAU,OAAOC,EAAE,SAAW,EAAE,EAC3E,OACEC,EAAQ,SAAS,oBAAoB,GACrCA,EAAQ,SAAS,mBAAmB,GACpCA,EAAQ,SAAS,gBAAgB,CAErC,CAEA,sBAAsB,cAAcC,EAAW,CAE7C,OAAO,OAAiCA,EAC1C",
|
|
6
|
+
"names": ["err", "e", "message", "pkg"]
|
|
7
|
+
}
|