@satorijs/satori
Advanced tools
Comparing version 2.2.3 to 2.3.0
/// <reference types="ws" /> | ||
/// <reference types="node" /> | ||
/// <reference types="koa__router" /> | ||
import { Agent } from 'agent-base'; | ||
import { Context, Schema } from '@satorijs/core'; | ||
@@ -10,5 +9,2 @@ import { MaybeArray } from 'cosmokit'; | ||
import KoaRouter from '@koa/router'; | ||
type CreateAgent = (opts: string) => Agent; | ||
export function register(protocols: string[], callback: CreateAgent): void; | ||
export function getAgent(url: string): Agent; | ||
export interface ListenOptions { | ||
@@ -15,0 +11,0 @@ host?: string; |
@@ -35,5 +35,3 @@ var __create = Object.create; | ||
Router: () => Router, | ||
WebSocketLayer: () => WebSocketLayer, | ||
getAgent: () => getAgent, | ||
register: () => register | ||
WebSocketLayer: () => WebSocketLayer | ||
}); | ||
@@ -111,3 +109,3 @@ module.exports = __toCommonJS(src_exports); | ||
return new import_ws.WebSocket(url, { | ||
agent: getAgent(this.config.proxyAgent), | ||
agent: this.agent(this.config.proxyAgent), | ||
handshakeTimeout: this.config.timeout, | ||
@@ -124,4 +122,4 @@ ...options, | ||
const options = _prepare.call(this); | ||
options.httpAgent = getAgent(this.config.proxyAgent); | ||
options.httpsAgent = getAgent(this.config.proxyAgent); | ||
options.httpAgent = this.agent(this.config.proxyAgent); | ||
options.httpsAgent = this.agent(this.config.proxyAgent); | ||
return options; | ||
@@ -133,23 +131,5 @@ }, "prepare"); | ||
}).description("请求设置")); | ||
var agents = /* @__PURE__ */ Object.create(null); | ||
var proxies = /* @__PURE__ */ Object.create(null); | ||
function register(protocols, callback) { | ||
for (const protocol of protocols) { | ||
proxies[protocol] = callback; | ||
} | ||
} | ||
__name(register, "register"); | ||
register(["http"], import_http_proxy_agent.default); | ||
register(["https"], import_https_proxy_agent.default); | ||
register(["socks", "socks4", "socks4a", "socks5", "socks5h"], import_socks_proxy_agent.default); | ||
function getAgent(url) { | ||
if (!url) | ||
return; | ||
if (agents[url]) | ||
return agents[url]; | ||
const { protocol } = new URL(url); | ||
const callback = proxies[protocol.slice(0, -1)]; | ||
return agents[url] || (agents[url] = callback(url)); | ||
} | ||
__name(getAgent, "getAgent"); | ||
import_core.Quester.defineAgent(["http"], import_http_proxy_agent.default); | ||
import_core.Quester.defineAgent(["https"], import_https_proxy_agent.default); | ||
import_core.Quester.defineAgent(["socks", "socks4", "socks4a", "socks5", "socks5h"], import_socks_proxy_agent.default); | ||
@@ -272,6 +252,4 @@ // satori/packages/satori/src/router.ts | ||
Router, | ||
WebSocketLayer, | ||
getAgent, | ||
register | ||
WebSocketLayer | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@satorijs/satori", | ||
"description": "Core components of Satorijs", | ||
"version": "2.2.3", | ||
"version": "2.3.0", | ||
"main": "lib/index.js", | ||
@@ -35,7 +35,6 @@ "typings": "lib/index.d.ts", | ||
"@koa/router": "^10.1.1", | ||
"@satorijs/core": "2.2.3", | ||
"@satorijs/core": "2.3.0", | ||
"@types/koa": "*", | ||
"@types/koa__router": "*", | ||
"@types/ws": "^8.5.4", | ||
"agent-base": "^6.0.2", | ||
"file-type": "^16.5.4", | ||
@@ -42,0 +41,0 @@ "koa": "^2.14.1", |
Sorry, the diff of this file is not supported yet
14
36760
432
+ Added@satorijs/core@2.3.0(transitive)
- Removedagent-base@^6.0.2
- Removed@satorijs/core@2.2.3(transitive)
Updated@satorijs/core@2.3.0