aboutsummaryrefslogtreecommitdiff
path: root/src/js/thirdparty
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/thirdparty')
-rw-r--r--src/js/thirdparty/depd.js118
-rw-r--r--src/js/thirdparty/undici.js76
-rw-r--r--src/js/thirdparty/ws.js2
3 files changed, 84 insertions, 112 deletions
diff --git a/src/js/thirdparty/depd.js b/src/js/thirdparty/depd.js
index f69f4312e..2da8901bc 100644
--- a/src/js/thirdparty/depd.js
+++ b/src/js/thirdparty/depd.js
@@ -1,89 +1,35 @@
-// Hardcoded module "depd"
-// TODO: remove this module from being bundled into bun
-// This is a temporary workaround for a CommonJS <> ESM interop issue.
-
-/*!
- * depd
- * Copyright(c) 2015 Douglas Christopher Wilson
- * MIT Licensed
- */
-
-var __create = Object.create;
-var __defProp = Object.defineProperty;
-var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
-var __getOwnPropNames = Object.getOwnPropertyNames;
-var __getProtoOf = Object.getPrototypeOf;
-var __hasOwnProp = Object.prototype.hasOwnProperty;
-var __commonJS = (cb, mod) =>
- function __require() {
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
- };
-var __copyProps = (to, from, except, desc) => {
- if ((from && typeof from === "object") || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, {
- get: () => from[key],
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
- });
+function depd2(namespace) {
+ if (!namespace) {
+ throw new TypeError("argument namespace is required");
+ }
+ function deprecate(message) {}
+ deprecate._file = void 0;
+ deprecate._ignored = true;
+ deprecate._namespace = namespace;
+ deprecate._traced = false;
+ deprecate._warned = /* @__PURE__ */ Object.create(null);
+ deprecate.function = wrapfunction;
+ deprecate.property = wrapproperty;
+ return deprecate;
+}
+function wrapfunction(fn, message) {
+ if (typeof fn !== "function") {
+ throw new TypeError("argument fn must be a function");
+ }
+ return fn;
+}
+function wrapproperty(obj, prop, message) {
+ if (!obj || (typeof obj !== "object" && typeof obj !== "function")) {
+ throw new TypeError("argument obj must be object");
+ }
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
+ if (!descriptor) {
+ throw new TypeError("must call property on owner object");
+ }
+ if (!descriptor.configurable) {
+ throw new TypeError("property must be configurable");
}
- return to;
-};
-var __toESM = (mod, isNodeMode, target) => (
- (target = mod != null ? __create(__getProtoOf(mod)) : {}),
- __copyProps(
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
- mod,
- )
-);
-
-// node_modules/depd/lib/browser/index.js
-var require_browser = __commonJS({
- "node_modules/depd/lib/browser/index.js"(exports, module) {
- "use strict";
- module.exports = depd2;
- function depd2(namespace) {
- if (!namespace) {
- throw new TypeError("argument namespace is required");
- }
- function deprecate(message) {}
- deprecate._file = void 0;
- deprecate._ignored = true;
- deprecate._namespace = namespace;
- deprecate._traced = false;
- deprecate._warned = /* @__PURE__ */ Object.create(null);
- deprecate.function = wrapfunction;
- deprecate.property = wrapproperty;
- return deprecate;
- }
- function wrapfunction(fn, message) {
- if (typeof fn !== "function") {
- throw new TypeError("argument fn must be a function");
- }
- return fn;
- }
- function wrapproperty(obj, prop, message) {
- if (!obj || (typeof obj !== "object" && typeof obj !== "function")) {
- throw new TypeError("argument obj must be object");
- }
- var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
- if (!descriptor) {
- throw new TypeError("must call property on owner object");
- }
- if (!descriptor.configurable) {
- throw new TypeError("property must be configurable");
- }
- }
- },
-});
-
-// bundle.js
-var import_depd = __toESM(require_browser());
-var bundle_default = import_depd.default;
-
-function depd(...args) {
- return args.length ? bundle_default(...args) : bundle_default;
}
-depd[Symbol.for("CommonJS")] = true; // TODO: this requires hacky default export
-export default depd;
+export default depd2;
+depd2[Symbol.for("CommonJS")] = 0;
diff --git a/src/js/thirdparty/undici.js b/src/js/thirdparty/undici.js
index cf3968b58..579e33d1d 100644
--- a/src/js/thirdparty/undici.js
+++ b/src/js/thirdparty/undici.js
@@ -1,27 +1,27 @@
-// const { Object } = import.meta.primordials;
-const { EventEmitter } = import.meta.require("events");
-const {
- Readable,
- [Symbol.for("::bunternal::")]: { _ReadableFromWeb },
-} = import.meta.require("node:stream");
+const { Object } = globalThis[Symbol.for("Bun.lazy")]("primordials");
+import { EventEmitter } from "events";
+import NodeStreamModule from "node:stream";
+import { Readable } from "node:stream";
+
+const { _ReadableFromWebForUndici: ReadableFromWeb } = NodeStreamModule[Symbol.for("::bunternal::")];
const ObjectCreate = Object.create;
const kEmptyObject = ObjectCreate(null);
-export var fetch = Bun.fetch;
-export var Response = globalThis.Response;
-export var Headers = globalThis.Headers;
-export var Request = globalThis.Request;
-export var URLSearchParams = globalThis.URLSearchParams;
-export var URL = globalThis.URL;
-export class File extends Blob {}
-export class FileReader extends EventTarget {
+var fetch = Bun.fetch;
+var Response = globalThis.Response;
+var Headers = globalThis.Headers;
+var Request = globalThis.Request;
+var URLSearchParams = globalThis.URLSearchParams;
+var URL = globalThis.URL;
+class File extends Blob {}
+class FileReader extends EventTarget {
constructor() {
throw new Error("Not implemented yet!");
}
}
-export var FormData = globalThis.FormData;
+var FormData = globalThis.FormData;
function notImplemented() {
throw new Error("Not implemented in bun");
}
@@ -45,7 +45,7 @@ function notImplemented() {
* @typedef {import('events').EventEmitter} EventEmitter
*/
-class BodyReadable extends _ReadableFromWeb {
+class BodyReadable extends ReadableFromWeb {
#response;
#bodyUsed;
@@ -127,7 +127,7 @@ class BodyReadable extends _ReadableFromWeb {
* context: Object<string, *>;
* }}
*/
-export async function request(
+async function request(
url,
options = {
method: "GET",
@@ -228,36 +228,36 @@ export async function request(
return { statusCode, headers: headers.toJSON(), body, trailers, opaque: kEmptyObject, context: kEmptyObject };
}
-export function stream() {
+function stream() {
throw new Error("Not implemented in bun");
}
-export function pipeline() {
+function pipeline() {
throw new Error("Not implemented in bun");
}
-export function connect() {
+function connect() {
throw new Error("Not implemented in bun");
}
-export function upgrade() {
+function upgrade() {
throw new Error("Not implemented in bun");
}
-export class MockClient {
+class MockClient {
constructor() {
throw new Error("Not implemented in bun");
}
}
-export class MockPool {
+class MockPool {
constructor() {
throw new Error("Not implemented in bun");
}
}
-export class MockAgent {
+class MockAgent {
constructor() {
throw new Error("Not implemented in bun");
}
}
-export function mockErrors() {
+function mockErrors() {
throw new Error("Not implemented in bun");
}
@@ -329,3 +329,29 @@ export default {
Undici,
[Symbol.for("CommonJS")]: 0,
};
+
+export {
+ fetch,
+ Response,
+ Headers,
+ Request,
+ URLSearchParams,
+ URL,
+ File,
+ FileReader,
+ FormData,
+ request,
+ stream,
+ pipeline,
+ connect,
+ upgrade,
+ MockClient,
+ MockPool,
+ MockAgent,
+ mockErrors,
+ Dispatcher,
+ Pool,
+ BalancedPool,
+ Client,
+ Agent,
+};
diff --git a/src/js/thirdparty/ws.js b/src/js/thirdparty/ws.js
index 3af650764..5b27c5b50 100644
--- a/src/js/thirdparty/ws.js
+++ b/src/js/thirdparty/ws.js
@@ -3,7 +3,7 @@
// this just wraps WebSocket to look like an EventEmitter
// without actually using an EventEmitter polyfill
-import EventEmitter from "events";
+import { EventEmitter } from "events";
import http from "http";
const kBunInternals = Symbol.for("::bunternal::");