@discordjs/rest 3.0.0-dev.1753660955-593369dbb → 3.0.0-dev.1753876898-c3dc58169
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.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -4
- package/dist/index.mjs.map +1 -1
- package/dist/strategies/undiciRequest.js +15 -1
- package/dist/strategies/undiciRequest.js.map +1 -1
- package/dist/strategies/undiciRequest.mjs +16 -2
- package/dist/strategies/undiciRequest.mjs.map +1 -1
- 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 +3 -3
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ __name(getDefaultStrategy, "getDefaultStrategy");
|
|
|
19
19
|
import { STATUS_CODES } from "http";
|
|
20
20
|
import { URLSearchParams as URLSearchParams2 } from "url";
|
|
21
21
|
import { types } from "util";
|
|
22
|
-
import { request, Headers } from "undici";
|
|
22
|
+
import { request, Headers, FormData as UndiciFormData } from "undici";
|
|
23
23
|
async function makeRequest(url, init) {
|
|
24
24
|
const options = {
|
|
25
25
|
...init,
|
|
@@ -62,8 +62,10 @@ async function resolveBody(body) {
|
|
|
62
62
|
return new Uint8Array(body.buffer);
|
|
63
63
|
} else if (body instanceof Blob) {
|
|
64
64
|
return new Uint8Array(await body.arrayBuffer());
|
|
65
|
-
} else if (body instanceof
|
|
65
|
+
} else if (body instanceof UndiciFormData) {
|
|
66
66
|
return body;
|
|
67
|
+
} else if (body instanceof FormData) {
|
|
68
|
+
return globalToUndiciFormData(body);
|
|
67
69
|
} else if (body[Symbol.iterator]) {
|
|
68
70
|
const chunks = [...body];
|
|
69
71
|
return Buffer.concat(chunks);
|
|
@@ -77,6 +79,18 @@ async function resolveBody(body) {
|
|
|
77
79
|
throw new TypeError(`Unable to resolve body.`);
|
|
78
80
|
}
|
|
79
81
|
__name(resolveBody, "resolveBody");
|
|
82
|
+
function globalToUndiciFormData(fd) {
|
|
83
|
+
const clone = new UndiciFormData();
|
|
84
|
+
for (const [name, value] of fd.entries()) {
|
|
85
|
+
if (typeof value === "string") {
|
|
86
|
+
clone.append(name, value);
|
|
87
|
+
} else {
|
|
88
|
+
clone.append(name, value, value.name);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return clone;
|
|
92
|
+
}
|
|
93
|
+
__name(globalToUndiciFormData, "globalToUndiciFormData");
|
|
80
94
|
|
|
81
95
|
// src/lib/CDN.ts
|
|
82
96
|
import { CDNRoutes } from "discord-api-types/v10";
|
|
@@ -84,7 +98,7 @@ import { CDNRoutes } from "discord-api-types/v10";
|
|
|
84
98
|
// src/lib/utils/constants.ts
|
|
85
99
|
import { getUserAgentAppendix } from "@discordjs/util";
|
|
86
100
|
import { APIVersion } from "discord-api-types/v10";
|
|
87
|
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.
|
|
101
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.1753876898-c3dc58169)`;
|
|
88
102
|
var DefaultUserAgentAppendix = getUserAgentAppendix();
|
|
89
103
|
var DefaultRestOptions = {
|
|
90
104
|
agent: null,
|
|
@@ -1429,7 +1443,7 @@ var REST = class _REST extends AsyncEventEmitter {
|
|
|
1429
1443
|
};
|
|
1430
1444
|
|
|
1431
1445
|
// src/shared.ts
|
|
1432
|
-
var version = "3.0.0-dev.
|
|
1446
|
+
var version = "3.0.0-dev.1753876898-c3dc58169";
|
|
1433
1447
|
|
|
1434
1448
|
// src/index.ts
|
|
1435
1449
|
setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? fetch : makeRequest);
|