Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/js/internal/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,5 @@ export default {
kHandle: Symbol("kHandle"),
kAutoDestroyed: Symbol("kAutoDestroyed"),
kWeakHandler: Symbol("kWeak"),
kGetNativeReadableProto: Symbol("kGetNativeReadableProto"),
kEmptyObject,
};
131 changes: 0 additions & 131 deletions src/js/node/child_process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1926,137 +1926,6 @@ function genericNodeError(message, errorProperties) {
return err;
}

// const messages = new Map();

// Utility function for registering the error codes. Only used here. Exported
// *only* to allow for testing.
// function E(sym, val, def) {
// messages.set(sym, val);
// def = makeNodeErrorWithCode(def, sym);
// errorCodes[sym] = def;
// }

// function makeNodeErrorWithCode(Base, key) {
// return function NodeError(...args) {
// // const limit = Error.stackTraceLimit;
// // if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
// const error = new Base();
// // Reset the limit and setting the name property.
// // if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
// const message = getMessage(key, args);
// error.message = message;
// // captureLargerStackTrace(error);
// error.code = key;
// return error;
// };
// }

// function getMessage(key, args) {
// const msgFn = messages.get(key);
// if (args.length !== msgFn.length)
// throw new Error(
// `Invalid number of args for error message ${key}. Got ${args.length}, expected ${msgFn.length}.`
// );
// return msgFn(...args);
// }

// E(
// "ERR_INVALID_ARG_TYPE",
// (name, expected, actual) => {
// assert(typeof name === "string", "'name' must be a string");
// if (!$isJSArray(expected)) {
// expected = [expected];
// }

// let msg = "The ";
// if (StringPrototypeEndsWith(name, " argument")) {
// // For cases like 'first argument'
// msg += `${name} `;
// } else {
// const type = StringPrototypeIncludes(name, ".") ? "property" : "argument";
// msg += `"${name}" ${type} `;
// }
// msg += "must be ";

// const types = [];
// const instances = [];
// const other = [];

// for (const value of expected) {
// assert(
// typeof value === "string",
// "All expected entries have to be of type string"
// );
// if (ArrayPrototypeIncludes.$call(kTypes, value)) {
// ArrayPrototypePush(types, StringPrototypeToLowerCase(value));
// } else if (RegExpPrototypeExec(classRegExp, value) !== null) {
// ArrayPrototypePush(instances, value);
// } else {
// assert(
// value !== "object",
// 'The value "object" should be written as "Object"'
// );
// ArrayPrototypePush(other, value);
// }
// }

// // Special handle `object` in case other instances are allowed to outline
// // the differences between each other.
// if (instances.length > 0) {
// const pos = ArrayPrototypeIndexOf(types, "object");
// if (pos !== -1) {
// ArrayPrototypeSplice.$call(types, pos, 1);
// $arrayPush(instances, "Object");
// }
// }

// if (types.length > 0) {
// if (types.length > 2) {
// const last = ArrayPrototypePop(types);
// msg += `one of type ${ArrayPrototypeJoin(types, ", ")}, or ${last}`;
// } else if (types.length === 2) {
// msg += `one of type ${types[0]} or ${types[1]}`;
// } else {
// msg += `of type ${types[0]}`;
// }
// if (instances.length > 0 || other.length > 0) msg += " or ";
// }

// if (instances.length > 0) {
// if (instances.length > 2) {
// const last = ArrayPrototypePop(instances);
// msg += `an instance of ${ArrayPrototypeJoin(
// instances,
// ", "
// )}, or ${last}`;
// } else {
// msg += `an instance of ${instances[0]}`;
// if (instances.length === 2) {
// msg += ` or ${instances[1]}`;
// }
// }
// if (other.length > 0) msg += " or ";
// }

// if (other.length > 0) {
// if (other.length > 2) {
// const last = ArrayPrototypePop(other);
// msg += `one of ${ArrayPrototypeJoin.$call(other, ", ")}, or ${last}`;
// } else if (other.length === 2) {
// msg += `one of ${other[0]} or ${other[1]}`;
// } else {
// if (StringPrototypeToLowerCase(other[0]) !== other[0]) msg += "an ";
// msg += `${other[0]}`;
// }
// }

// msg += `. Received ${determineSpecificType(actual)}`;

// return msg;
// },
// TypeError
// );

function ERR_UNKNOWN_SIGNAL(name) {
const err = new TypeError(`Unknown signal: ${name}`);
err.code = "ERR_UNKNOWN_SIGNAL";
Expand Down
16 changes: 1 addition & 15 deletions src/js/node/http2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
* Modifications were made to the original code.
*/
const { isTypedArray } = require("node:util/types");
const { hideFromStack, throwNotImplemented } = require("internal/shared");
const { hideFromStack } = require("internal/shared");
const { STATUS_CODES } = require("internal/http");
const { kTimeout, getTimerDuration } = require("internal/timers");
const tls = require("node:tls");
const net = require("node:net");
const fs = require("node:fs");
const { $data } = require("node:fs/promises");
const FileHandle = $data.FileHandle;
const bunTLSConnectOptions = Symbol.for("::buntlsconnectoptions::");
const bunSocketServerOptions = Symbol.for("::bunnetserveroptions::");
const kInfoHeaders = Symbol("sent-info-headers");
const kStrictSingleValueFields = Symbol("strictSingleValueFields");
Expand Down Expand Up @@ -76,7 +75,6 @@ const { Duplex } = Stream;
const { SafeArrayIterator, SafeSet } = require("internal/primordials");
const { promisify } = require("internal/promisify");

const RegExpPrototypeExec = RegExp.prototype.exec;
const ObjectAssign = Object.assign;
const ArrayIsArray = Array.isArray;
const ObjectKeys = Object.keys;
Expand All @@ -87,23 +85,11 @@ const StringPrototypeToLowerCase = String.prototype.toLowerCase;
const StringPrototypeIncludes = String.prototype.includes;
const StringPrototypeStartsWith = String.prototype.startsWith;
const ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty;
const DatePrototypeToUTCString = Date.prototype.toUTCString;
const DatePrototypeGetMilliseconds = Date.prototype.getMilliseconds;

const H2FrameParser = $rust("h2_frame_parser.rs", "H2FrameParserConstructor");
const _nativeAssertSettings = $newRustFunction("h2_frame_parser.rs", "jsAssertSettings", 1);
const { upgradeRawSocketToH2 } = require("node:_http2_upgrade");

const kSettingNames = {
headerTableSize: 0x1,
enablePush: 0x2,
maxConcurrentStreams: 0x3,
initialWindowSize: 0x4,
maxFrameSize: 0x5,
maxHeaderListSize: 0x6,
enableConnectProtocol: 0x8,
};

const kSettingIds: Record<number, string> = {
0x1: "headerTableSize",
0x2: "enablePush",
Expand Down
24 changes: 0 additions & 24 deletions src/js/node/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,30 +893,6 @@ Url.prototype.parseHost = function parseHost() {
if (host) this.hostname = host;
};

// function fileURLToPath(...args) {
// // Since we use WTF::URL::fileSystemPath directly in Bun.fileURLToPath, we don't get invalid windows
// // path checking. We patch this in to `node:url` for compatibility. Note that
// // this behavior is missing from WATWG URL.
// if (process.platform === "win32") {
// var url: string;
// if ($isObject(args[0]) && args[0] instanceof Url) {
// url = (args[0] as { href: string }).href;
// } else if (typeof args[0] === "string") {
// url = args[0];
// } else {
// throw $ERR_INVALID_ARG_TYPE("url", ["string", "URL"], args[0]);
// }

// for (var i = 0; i < url.length; i++) {
// if (url.charCodeAt(i) === Char.PERCENT && (i + 1) < url.length) {
// switch (url.charCodeAt(i + 1)) {
// break;
// }
// }
// }
// return Bun.fileURLToPath.$call(args);
// }

/**
* Add new characters as needed from
* [here](https://github.com/nodejs/node/blob/main/lib/internal/constants.js).
Expand Down
20 changes: 0 additions & 20 deletions src/jsc/bindings/BunPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,11 @@ static JSC::EncodedJSValue jsFunctionAppendOnLoadPluginGlobal(JSC::JSGlobalObjec
return jsFunctionAppendOnLoadPluginBody(globalObject, callframe, target, plugins, global->bunVM(), callback);
}

JSC_DEFINE_HOST_FUNCTION(jsFunctionAppendOnLoadPluginNode, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
return jsFunctionAppendOnLoadPluginGlobal(globalObject, callframe, BunPluginTargetNode);
}

JSC_DEFINE_HOST_FUNCTION(jsFunctionAppendOnLoadPluginBun, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
return jsFunctionAppendOnLoadPluginGlobal(globalObject, callframe, BunPluginTargetBun);
}

JSC_DEFINE_HOST_FUNCTION(jsFunctionAppendOnLoadPluginBrowser, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
return jsFunctionAppendOnLoadPluginGlobal(globalObject, callframe, BunPluginTargetBrowser);
}

JSC_DEFINE_HOST_FUNCTION(jsFunctionAppendOnResolvePluginNode, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
return jsFunctionAppendOnResolvePluginGlobal(globalObject, callframe, BunPluginTargetNode);
}

JSC_DEFINE_HOST_FUNCTION(jsFunctionAppendOnResolvePluginBun, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
return jsFunctionAppendOnResolvePluginGlobal(globalObject, callframe, BunPluginTargetBun);
Expand All @@ -274,11 +259,6 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionAppendVirtualModule, (JSC::JSGlobalObject * g
return jsFunctionAppendVirtualModulePluginBody(globalObject, callframe);
}

JSC_DEFINE_HOST_FUNCTION(jsFunctionAppendOnResolvePluginBrowser, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
return jsFunctionAppendOnResolvePluginGlobal(globalObject, callframe, BunPluginTargetBrowser);
}

/// `Bun.plugin()`
static inline JSC::EncodedJSValue setupBunPlugin(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe, BunPluginTarget target)
{
Expand Down
11 changes: 0 additions & 11 deletions src/jsc/bindings/BunProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,6 @@ static void dispatchExitInternal(JSC::JSGlobalObject* globalObject, Process* pro
emitter.emit(event, arguments);
}

JSC_DEFINE_CUSTOM_SETTER(Process_defaultSetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName propertyName))
{
auto& vm = JSC::getVM(globalObject);

JSC::JSObject* thisObject = dynamicDowncast<JSC::JSObject>(JSValue::decode(thisValue));
if (value)
thisObject->putDirect(vm, propertyName, JSValue::decode(value), 0);

return true;
}

extern "C" bool Bun__resolveEmbeddedNodeFile(void*, BunString*);
#if OS(WINDOWS)
extern "C" HMODULE Bun__LoadLibraryBunString(BunString*);
Expand Down
5 changes: 0 additions & 5 deletions src/jsc/bindings/ErrorStackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,3 @@ String functionName(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, const
return functionName;
}
}

extern "C" void Bun__errorInstance__finalize(void* bunErrorData)
{
UNUSED_PARAM(bunErrorData);
}
18 changes: 0 additions & 18 deletions src/jsc/bindings/FormatStackTraceForJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,6 @@ static JSValue formatStackTraceToJSValue(JSC::VM& vm, Zig::GlobalObject* globalO
return stackStringValue;
}

static JSValue formatStackTraceToJSValueWithoutPrepareStackTrace(JSC::VM& vm, Zig::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* errorObject, JSC::JSArray* callSites)
{
JSValue prepareStackTrace = {};
if (lexicalGlobalObject->inherits<Zig::GlobalObject>()) {
if (auto prepare = globalObject->m_errorConstructorPrepareStackTraceValue.get()) {
prepareStackTrace = prepare;
}
} else {
auto scope = DECLARE_TOP_EXCEPTION_SCOPE(vm);

auto* errorConstructor = lexicalGlobalObject->m_errorStructure.constructor(globalObject);
prepareStackTrace = errorConstructor->getIfPropertyExists(lexicalGlobalObject, JSC::Identifier::fromString(vm, "prepareStackTrace"_s));
CLEAR_IF_EXCEPTION(scope);
}

return formatStackTraceToJSValue(vm, globalObject, lexicalGlobalObject, errorObject, callSites, prepareStackTrace);
}

WTF::String formatStackTrace(
JSC::VM& vm,
Zig::GlobalObject* globalObject,
Expand Down
16 changes: 0 additions & 16 deletions src/jsc/bindings/napi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,17 +1137,6 @@ extern "C" napi_status napi_create_reference(napi_env env, napi_value value,
NAPI_RETURN_SUCCESS(env);
}

extern "C" void napi_set_ref(NapiRef* ref, JSC::EncodedJSValue val_)
{
NAPI_LOG_CURRENT_FUNCTION;
JSC::JSValue val = JSC::JSValue::decode(val_);
if (val) {
ref->strongRef.set(JSC::getVM(&*ref->globalObject), val);
} else {
ref->strongRef.clear();
}
}

extern "C" napi_status napi_add_finalizer(napi_env env, napi_value js_object,
void* native_object,
napi_finalize finalize_cb,
Expand Down Expand Up @@ -3330,11 +3319,6 @@ extern "C" bool NapiEnv__hasPendingException(napi_env env)
return scope.exception() != nullptr;
}

extern "C" uint32_t napi_internal_get_version(napi_env env)
{
return env->napiModule().nm_version;
}

extern "C" JSGlobalObject* NapiEnv__globalObject(napi_env env)
{
return env->globalObject();
Expand Down
6 changes: 0 additions & 6 deletions src/jsc/bindings/node/crypto/CryptoUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,6 @@ JSValue createCryptoError(JSC::JSGlobalObject* globalObject, ThrowScope& scope,
return errorObject;
}

extern "C" EncodedJSValue Bun__NodeCrypto__createCryptoError(JSC::JSGlobalObject* globalObject, uint32_t err, const char* message)
{
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
return JSValue::encode(createCryptoError(globalObject, scope, err, message));
}

void throwCryptoError(JSC::JSGlobalObject* globalObject, ThrowScope& scope, uint32_t err, const char* message)
{
JSValue errorObject = createCryptoError(globalObject, scope, err, message);
Expand Down
35 changes: 0 additions & 35 deletions src/jsc/bindings/webcore/BroadcastChannelIdentifier.h

This file was deleted.

Loading
Loading