mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-13 09:32:12 +00:00
refactor(node): Replace undici dependency with built-in fetch (#1045)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { fetch } from 'undici';
|
||||
import { gunzip } from 'zlib';
|
||||
import { dirname, resolve } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
12
package-lock.json
generated
12
package-lock.json
generated
@@ -13,8 +13,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.0.0",
|
||||
"jintr": "^3.3.1",
|
||||
"undici": "^6.21.3"
|
||||
"jintr": "^3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.9.0",
|
||||
@@ -5033,15 +5032,6 @@
|
||||
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "6.21.3",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz",
|
||||
"integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
||||
|
||||
@@ -103,8 +103,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.0.0",
|
||||
"jintr": "^3.3.1",
|
||||
"undici": "^6.21.3"
|
||||
"jintr": "^3.3.1"
|
||||
},
|
||||
"overrides": {
|
||||
"typescript": "^5.0.0"
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
// Node.js Platform Support
|
||||
import { ReadableStream } from 'stream/web';
|
||||
import {
|
||||
fetch as defaultFetch,
|
||||
Request,
|
||||
Response,
|
||||
Headers,
|
||||
FormData,
|
||||
File
|
||||
} from 'undici';
|
||||
import type { ICache } from '../types/Cache.js';
|
||||
import { Platform } from '../utils/Utils.js';
|
||||
import crypto from 'crypto';
|
||||
import type { FetchFunction } from '../types/PlatformShim.js';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import fs from 'fs/promises';
|
||||
@@ -105,12 +96,12 @@ Platform.load({
|
||||
return crypto.randomUUID();
|
||||
},
|
||||
eval: evaluate,
|
||||
fetch: defaultFetch as unknown as FetchFunction,
|
||||
Request: Request as unknown as typeof globalThis.Request,
|
||||
Response: Response as unknown as typeof globalThis.Response,
|
||||
Headers: Headers as unknown as typeof globalThis.Headers,
|
||||
FormData: FormData as unknown as typeof globalThis.FormData,
|
||||
File: File as unknown as typeof globalThis.File,
|
||||
fetch: globalThis.fetch,
|
||||
Request: globalThis.Request,
|
||||
Response: globalThis.Response,
|
||||
Headers: globalThis.Headers,
|
||||
FormData: globalThis.FormData,
|
||||
File: globalThis.File,
|
||||
ReadableStream: ReadableStream as unknown as typeof globalThis.ReadableStream,
|
||||
CustomEvent: CustomEvent as unknown as typeof globalThis.CustomEvent
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user