@discordjs/rest 3.0.0-pr-11005.1765454364-f3f6d34e7 → 3.0.0-pr-10758.1765463096-d081e1706
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/index.d.mts +4 -25
- package/dist/index.d.ts +4 -25
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -7
- package/dist/index.mjs.map +1 -1
- package/dist/strategies/undiciRequest.js +9 -4
- package/dist/strategies/undiciRequest.js.map +1 -1
- package/dist/strategies/undiciRequest.mjs +9 -4
- package/dist/strategies/undiciRequest.mjs.map +1 -1
- package/dist/web.d.mts +4 -25
- package/dist/web.d.ts +4 -25
- package/dist/web.js +2 -2
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +2 -2
- package/dist/web.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
|
@@ -16,15 +16,20 @@ function getDefaultStrategy() {
|
|
|
16
16
|
__name(getDefaultStrategy, "getDefaultStrategy");
|
|
17
17
|
|
|
18
18
|
// src/strategies/undiciRequest.ts
|
|
19
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
19
20
|
import { STATUS_CODES } from "http";
|
|
20
|
-
import { URLSearchParams as URLSearchParams2 } from "url";
|
|
21
21
|
import { types } from "util";
|
|
22
|
-
import { request, Headers, FormData as UndiciFormData } from "undici";
|
|
22
|
+
import { request, Headers, FormData as UndiciFormData, Agent } from "undici";
|
|
23
|
+
var localAgent = null;
|
|
23
24
|
async function makeRequest(url, init) {
|
|
24
25
|
const options = {
|
|
25
26
|
...init,
|
|
26
27
|
body: await resolveBody(init.body)
|
|
27
28
|
};
|
|
29
|
+
if (!options.dispatcher) {
|
|
30
|
+
localAgent ??= new Agent();
|
|
31
|
+
options.dispatcher = localAgent;
|
|
32
|
+
}
|
|
28
33
|
const res = await request(url, options);
|
|
29
34
|
return {
|
|
30
35
|
body: res.body,
|
|
@@ -56,7 +61,7 @@ async function resolveBody(body) {
|
|
|
56
61
|
return body;
|
|
57
62
|
} else if (types.isArrayBuffer(body)) {
|
|
58
63
|
return new Uint8Array(body);
|
|
59
|
-
} else if (body instanceof
|
|
64
|
+
} else if (body instanceof URLSearchParams) {
|
|
60
65
|
return body.toString();
|
|
61
66
|
} else if (body instanceof DataView) {
|
|
62
67
|
return new Uint8Array(body.buffer);
|
|
@@ -68,13 +73,13 @@ async function resolveBody(body) {
|
|
|
68
73
|
return globalToUndiciFormData(body);
|
|
69
74
|
} else if (body[Symbol.iterator]) {
|
|
70
75
|
const chunks = [...body];
|
|
71
|
-
return
|
|
76
|
+
return Buffer2.concat(chunks);
|
|
72
77
|
} else if (body[Symbol.asyncIterator]) {
|
|
73
78
|
const chunks = [];
|
|
74
79
|
for await (const chunk of body) {
|
|
75
80
|
chunks.push(chunk);
|
|
76
81
|
}
|
|
77
|
-
return
|
|
82
|
+
return Buffer2.concat(chunks);
|
|
78
83
|
}
|
|
79
84
|
throw new TypeError(`Unable to resolve body.`);
|
|
80
85
|
}
|
|
@@ -98,7 +103,7 @@ import { CDNRoutes } from "discord-api-types/v10";
|
|
|
98
103
|
// src/lib/utils/constants.ts
|
|
99
104
|
import { getUserAgentAppendix } from "@discordjs/util";
|
|
100
105
|
import { APIVersion } from "discord-api-types/v10";
|
|
101
|
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-pr-
|
|
106
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-pr-10758.1765463096-d081e1706)`;
|
|
102
107
|
var DefaultUserAgentAppendix = getUserAgentAppendix();
|
|
103
108
|
var DefaultRestOptions = {
|
|
104
109
|
agent: null,
|
|
@@ -1499,7 +1504,7 @@ var REST = class _REST extends AsyncEventEmitter {
|
|
|
1499
1504
|
};
|
|
1500
1505
|
|
|
1501
1506
|
// src/shared.ts
|
|
1502
|
-
var version = "3.0.0-pr-
|
|
1507
|
+
var version = "3.0.0-pr-10758.1765463096-d081e1706";
|
|
1503
1508
|
|
|
1504
1509
|
// src/index.ts
|
|
1505
1510
|
setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? fetch : makeRequest);
|