@discordjs/rest 3.0.0-move-client-init.1761650119-a4c0a246f → 3.0.0-pr-11006.1765450224-e636950b2
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 +12 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -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 +3 -2
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +3 -2
- package/dist/web.mjs.map +1 -1
- package/package.json +16 -16
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-
|
|
106
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-pr-11006.1765450224-e636950b2)`;
|
|
102
107
|
var DefaultUserAgentAppendix = getUserAgentAppendix();
|
|
103
108
|
var DefaultRestOptions = {
|
|
104
109
|
agent: null,
|
|
@@ -1215,6 +1220,7 @@ var REST = class _REST extends AsyncEventEmitter {
|
|
|
1215
1220
|
handlerTimer;
|
|
1216
1221
|
options;
|
|
1217
1222
|
constructor(options = {}) {
|
|
1223
|
+
console.log("even rest got something new \u203C\uFE0F \u{1F5E3}\uFE0F \u{1F525}");
|
|
1218
1224
|
super();
|
|
1219
1225
|
this.cdn = new CDN(options);
|
|
1220
1226
|
this.options = { ...DefaultRestOptions, ...options };
|
|
@@ -1499,7 +1505,7 @@ var REST = class _REST extends AsyncEventEmitter {
|
|
|
1499
1505
|
};
|
|
1500
1506
|
|
|
1501
1507
|
// src/shared.ts
|
|
1502
|
-
var version = "3.0.0-
|
|
1508
|
+
var version = "3.0.0-pr-11006.1765450224-e636950b2";
|
|
1503
1509
|
|
|
1504
1510
|
// src/index.ts
|
|
1505
1511
|
setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? fetch : makeRequest);
|