aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/bun-linux-aarch64.yml2
-rw-r--r--.github/workflows/bun-linux-build.yml4
-rw-r--r--.github/workflows/bun-mac-aarch64.yml16
-rw-r--r--.github/workflows/bun-mac-x64-baseline.yml16
-rw-r--r--.github/workflows/bun-mac-x64.yml16
-rw-r--r--Dockerfile2
-rwxr-xr-xbun.lockbbin73331 -> 73331 bytes
-rw-r--r--package.json2
m---------src/bun.js/WebKit0
-rw-r--r--src/bun.js/api/JSBundler.zig16
-rw-r--r--src/bun.js/api/JSTranspiler.zig2
-rw-r--r--src/bun.js/api/bun.zig2038
-rw-r--r--src/bun.js/api/bun/socket.zig16
-rw-r--r--src/bun.js/api/crypto.classes.ts43
-rw-r--r--src/bun.js/api/ffi.classes.ts23
-rw-r--r--src/bun.js/api/ffi.zig37
-rw-r--r--src/bun.js/api/filesystem_router.zig116
-rw-r--r--src/bun.js/api/server.classes.ts47
-rw-r--r--src/bun.js/api/server.zig191
-rw-r--r--src/bun.js/base.zig1639
-rw-r--r--src/bun.js/bindings/BunDebugger.cpp28
-rw-r--r--src/bun.js/bindings/BunInjectedScriptHost.cpp211
-rw-r--r--src/bun.js/bindings/BunInjectedScriptHost.h15
-rw-r--r--src/bun.js/bindings/BunObject+exports.h82
-rw-r--r--src/bun.js/bindings/BunObject.cpp706
-rw-r--r--src/bun.js/bindings/BunObject.h17
-rw-r--r--src/bun.js/bindings/BunObject.lut.h359
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h12
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h12
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h36
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h42
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp3525
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h330
-rw-r--r--src/bun.js/bindings/ZigGeneratedCode.cpp120
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp868
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.h10
-rw-r--r--src/bun.js/bindings/bindings.cpp3
-rw-r--r--src/bun.js/bindings/bindings.zig35
-rw-r--r--src/bun.js/bindings/exports.zig35
-rw-r--r--src/bun.js/bindings/generated_classes.zig649
-rw-r--r--src/bun.js/bindings/generated_classes_list.zig6
-rw-r--r--src/bun.js/bindings/headers.h2
-rw-r--r--src/bun.js/bindings/headers.zig2
-rw-r--r--src/bun.js/bindings/webcore/JSDOMFormData.cpp140
-rw-r--r--src/bun.js/bindings/webcore/JSDOMFormData.h2
-rw-r--r--src/bun.js/bindings/webcore/JSFetchHeaders.cpp114
-rw-r--r--src/bun.js/bindings/webcore/JSFetchHeaders.h2
-rw-r--r--src/bun.js/bindings/webcore/JSURLSearchParams.cpp21
-rw-r--r--src/bun.js/bindings/webcore/JSURLSearchParams.h2
-rw-r--r--src/bun.js/javascript.zig209
-rw-r--r--src/bun.js/node/types.zig13
-rw-r--r--src/bun.js/rare_data.zig2
-rw-r--r--src/bun.js/scripts/class-definitions.ts2
-rw-r--r--src/bun.js/scripts/generate-classes.ts52
-rw-r--r--src/bun.js/test/jest.zig32
-rw-r--r--src/bun.js/webcore.zig381
-rw-r--r--src/bun.js/webcore/blob.zig165
-rw-r--r--src/bun.js/webcore/body.zig5
-rw-r--r--src/bun.js/webcore/encoding.zig5
-rw-r--r--src/bun.js/webcore/request.zig5
-rw-r--r--src/bun.js/webcore/response.zig252
-rw-r--r--src/bun.js/webcore/streams.zig5
-rw-r--r--src/bun.zig5
-rw-r--r--src/http.zig548
-rw-r--r--src/js/_codegen/build-functions.ts2
-rw-r--r--src/js/bun/ffi.ts10
-rw-r--r--src/js/internal/debugger.ts48
-rw-r--r--src/js/out/InternalModuleRegistryConstants.h12
-rw-r--r--src/js_ast.zig2771
-rw-r--r--src/js_parser.zig136
-rw-r--r--src/jsc.zig8
-rw-r--r--src/router.zig8
72 files changed, 7324 insertions, 8964 deletions
diff --git a/.github/workflows/bun-linux-aarch64.yml b/.github/workflows/bun-linux-aarch64.yml
index d29fa0b7b..6d9126282 100644
--- a/.github/workflows/bun-linux-aarch64.yml
+++ b/.github/workflows/bun-linux-aarch64.yml
@@ -36,7 +36,7 @@ jobs:
arch: aarch64
build_arch: arm64
runner: linux-arm64
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-linux-arm64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-linux-arm64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-arm64-lto"
build_machine_arch: aarch64
diff --git a/.github/workflows/bun-linux-build.yml b/.github/workflows/bun-linux-build.yml
index 4f8b2981e..3b3d2efcd 100644
--- a/.github/workflows/bun-linux-build.yml
+++ b/.github/workflows/bun-linux-build.yml
@@ -46,7 +46,7 @@ jobs:
arch: x86_64
build_arch: amd64
runner: big-ubuntu
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-linux-amd64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
- cpu: nehalem
@@ -54,7 +54,7 @@ jobs:
arch: x86_64
build_arch: amd64
runner: big-ubuntu
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-linux-amd64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
diff --git a/.github/workflows/bun-mac-aarch64.yml b/.github/workflows/bun-mac-aarch64.yml
index 52258374e..53e15c4c7 100644
--- a/.github/workflows/bun-mac-aarch64.yml
+++ b/.github/workflows/bun-mac-aarch64.yml
@@ -117,7 +117,7 @@ jobs:
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: haswell
@@ -126,7 +126,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: nehalem
@@ -135,7 +135,7 @@ jobs:
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: haswell
@@ -144,7 +144,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: native
@@ -152,7 +152,7 @@ jobs:
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
artifact: bun-obj-darwin-aarch64
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-arm64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
dependencies: true
compile_obj: true
@@ -257,7 +257,7 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -265,14 +265,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: native
arch: aarch64
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
package: bun-darwin-aarch64
artifact: bun-obj-darwin-aarch64
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-arm64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
steps:
- uses: actions/checkout@v3
diff --git a/.github/workflows/bun-mac-x64-baseline.yml b/.github/workflows/bun-mac-x64-baseline.yml
index 049a96691..1b750ec7d 100644
--- a/.github/workflows/bun-mac-x64-baseline.yml
+++ b/.github/workflows/bun-mac-x64-baseline.yml
@@ -117,7 +117,7 @@ jobs:
obj: bun-obj-darwin-x64-baseline
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: haswell
@@ -126,7 +126,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: nehalem
@@ -135,7 +135,7 @@ jobs:
obj: bun-obj-darwin-x64-baseline
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: haswell
@@ -144,7 +144,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: native
@@ -152,7 +152,7 @@ jobs:
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -258,7 +258,7 @@ jobs:
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -266,14 +266,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: native
# arch: aarch64
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# package: bun-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
diff --git a/.github/workflows/bun-mac-x64.yml b/.github/workflows/bun-mac-x64.yml
index 4289c578f..a7a6773d0 100644
--- a/.github/workflows/bun-mac-x64.yml
+++ b/.github/workflows/bun-mac-x64.yml
@@ -117,7 +117,7 @@ jobs:
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: haswell
@@ -126,7 +126,7 @@ jobs:
obj: bun-obj-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: nehalem
@@ -135,7 +135,7 @@ jobs:
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: haswell
@@ -144,7 +144,7 @@ jobs:
obj: bun-obj-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: native
@@ -152,7 +152,7 @@ jobs:
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-arm64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -260,7 +260,7 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
@@ -268,14 +268,14 @@ jobs:
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
- webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-amd64-lto.tar.gz"
+ webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: native
# arch: aarch64
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# package: bun-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
- # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-2/bun-webkit-macos-arm64-lto.tar.gz"
+ # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-3/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
diff --git a/Dockerfile b/Dockerfile
index 9042ea802..8a0bd4414 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,7 +10,7 @@ ARG ARCH=x86_64
ARG BUILD_MACHINE_ARCH=x86_64
ARG TRIPLET=${ARCH}-linux-gnu
ARG BUILDARCH=amd64
-ARG WEBKIT_TAG=2023-aug3-2
+ARG WEBKIT_TAG=2023-aug3-3
ARG ZIG_TAG=jul1
ARG ZIG_VERSION="0.11.0-dev.4006+bf827d0b5"
ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH"
diff --git a/bun.lockb b/bun.lockb
index e8af27911..4ae392d58 100755
--- a/bun.lockb
+++ b/bun.lockb
Binary files differ
diff --git a/package.json b/package.json
index 9632fd7a4..87d21bed3 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
"@types/react": "^18.0.25",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
- "bun-webkit": "0.0.1-8259132d1e63749ef9942bd5beb7a2fd02dad82e"
+ "bun-webkit": "0.0.1-fc705595a2e10361a64f1dab56527d7b112e75c6"
},
"version": "0.0.0",
"prettier": "./.prettierrc.cjs"
diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit
-Subproject e84b7bbb14480f117099df22c299e6341c62f42
+Subproject fc705595a2e10361a64f1dab56527d7b112e75c
diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig
index 6a821f447..af1a55ce6 100644
--- a/src/bun.js/api/JSBundler.zig
+++ b/src/bun.js/api/JSBundler.zig
@@ -23,7 +23,7 @@ const JSError = Base.JSError;
const JSValue = bun.JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;
const strings = bun.strings;
-const NewClass = Base.NewClass;
+
const To = Base.To;
const Request = WebCore.Request;
const String = bun.String;
@@ -523,17 +523,11 @@ pub const JSBundler = struct {
}
pub fn buildFn(
- // this
- _: void,
globalThis: *JSC.JSGlobalObject,
- // function
- _: js.JSObjectRef,
- // thisObject
- _: js.JSObjectRef,
- arguments_: []const js.JSValueRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return build(globalThis, @as([]const JSC.JSValue, @ptrCast(arguments_))).asObjectRef();
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1);
+ return build(globalThis, arguments.slice());
}
pub const Resolve = struct {
diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig
index 9376eb964..c31354712 100644
--- a/src/bun.js/api/JSTranspiler.zig
+++ b/src/bun.js/api/JSTranspiler.zig
@@ -22,7 +22,7 @@ const JSError = Base.JSError;
const JSValue = bun.JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;
const strings = bun.strings;
-const NewClass = Base.NewClass;
+
const To = Base.To;
const Request = WebCore.Request;
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig
index 7685b8f80..e98151fb1 100644
--- a/src/bun.js/api/bun.zig
+++ b/src/bun.js/api/bun.zig
@@ -1,3 +1,158 @@
+/// How to add a new function or property to the Bun global
+///
+/// - Add a callback or property to the below struct
+/// - @export it in the appropriate place
+/// - Update "@begin bunObjectTable" in BunObject.cpp
+/// - Update "BunObject+exports.h"
+/// - Run "make dev"
+///
+pub const BunObject = struct {
+ // --- Callbacks ---
+ pub const DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump = dump_mimalloc;
+ pub const _Os = Bun._Os;
+ pub const _Path = Bun._Path;
+ pub const allocUnsafe = Bun.allocUnsafe;
+ pub const build = Bun.JSBundler.buildFn;
+ pub const connect = JSC.wrapStaticMethod(JSC.API.Listener, "connect", false);
+ pub const deflateSync = JSC.wrapStaticMethod(JSZlib, "deflateSync", true);
+ pub const file = WebCore.Blob.constructFile;
+ pub const fs = Bun.fs;
+ pub const gc = Bun.runGC;
+ pub const generateHeapSnapshot = Bun.generateHeapSnapshot;
+ pub const getImportedStyles = Bun.getImportedStyles;
+ pub const getPublicPath = Bun.getPublicPathJS;
+ pub const gunzipSync = JSC.wrapStaticMethod(JSZlib, "gunzipSync", true);
+ pub const gzipSync = JSC.wrapStaticMethod(JSZlib, "gzipSync", true);
+ pub const indexOfLine = Bun.indexOfLine;
+ pub const inflateSync = JSC.wrapStaticMethod(JSZlib, "inflateSync", true);
+ pub const inspect = Bun.inspect;
+ pub const jest = @import("../test/jest.zig").Jest.call;
+ pub const listen = JSC.wrapStaticMethod(JSC.API.Listener, "listen", false);
+ pub const mmap = Bun.mmapFile;
+ pub const nanoseconds = Bun.nanoseconds;
+ pub const openInEditor = Bun.openInEditor;
+ pub const registerMacro = Bun.registerMacro;
+ pub const resolve = Bun.resolve;
+ pub const resolveSync = Bun.resolveSync;
+ pub const serve = Bun.serve;
+ pub const sha = JSC.wrapStaticMethod(Crypto.SHA512_256, "hash_", true);
+ pub const shrink = Bun.shrink;
+ pub const sleepSync = Bun.sleepSync;
+ pub const spawn = JSC.wrapStaticMethod(JSC.Subprocess, "spawn", false);
+ pub const spawnSync = JSC.wrapStaticMethod(JSC.Subprocess, "spawnSync", false);
+ pub const which = Bun.which;
+ pub const write = JSC.WebCore.Blob.writeFile;
+ // --- Callbacks ---
+
+ // --- Getters ---
+ pub const CryptoHasher = Crypto.CryptoHasher.getter;
+ pub const FFI = Bun.FFIObject.getter;
+ pub const FileSystemRouter = Bun.getFileSystemRouter;
+ pub const MD4 = Crypto.MD4.getter;
+ pub const MD5 = Crypto.MD5.getter;
+ pub const SHA1 = Crypto.SHA1.getter;
+ pub const SHA224 = Crypto.SHA224.getter;
+ pub const SHA256 = Crypto.SHA256.getter;
+ pub const SHA384 = Crypto.SHA384.getter;
+ pub const SHA512 = Crypto.SHA512.getter;
+ pub const SHA512_256 = Crypto.SHA512_256.getter;
+ pub const TOML = Bun.getTOMLObject;
+ pub const Transpiler = Bun.getTranspilerConstructor;
+ pub const argv = Bun.getArgv;
+ pub const assetPrefix = Bun.getAssetPrefix;
+ pub const cwd = Bun.getCWD;
+ pub const enableANSIColors = Bun.enableANSIColors;
+ pub const hash = Bun.getHashObject;
+ pub const main = Bun.getMain;
+ pub const origin = Bun.getOrigin;
+ pub const stderr = Bun.getStderr;
+ pub const stdin = Bun.getStdin;
+ pub const stdout = Bun.getStdout;
+ pub const unsafe = Bun.getUnsafe;
+ // --- Getters ---
+
+ fn getterName(comptime baseName: anytype) [:0]const u8 {
+ return "BunObject_getter_" ++ baseName;
+ }
+
+ fn callbackName(comptime baseName: anytype) [:0]const u8 {
+ return "BunObject_callback_" ++ baseName;
+ }
+
+ pub fn exportAll() void {
+ if (!@inComptime()) {
+ @compileError("Must be comptime");
+ }
+
+ if (JSC.is_bindgen) {
+ return;
+ }
+
+ // --- Getters ---
+ @export(BunObject.CryptoHasher, .{ .name = getterName("CryptoHasher") });
+ @export(BunObject.FFI, .{ .name = getterName("FFI") });
+ @export(BunObject.FileSystemRouter, .{ .name = getterName("FileSystemRouter") });
+ @export(BunObject.MD4, .{ .name = getterName("MD4") });
+ @export(BunObject.MD5, .{ .name = getterName("MD5") });
+ @export(BunObject.SHA1, .{ .name = getterName("SHA1") });
+ @export(BunObject.SHA224, .{ .name = getterName("SHA224") });
+ @export(BunObject.SHA256, .{ .name = getterName("SHA256") });
+ @export(BunObject.SHA384, .{ .name = getterName("SHA384") });
+ @export(BunObject.SHA512, .{ .name = getterName("SHA512") });
+ @export(BunObject.SHA512_256, .{ .name = getterName("SHA512_256") });
+ @export(BunObject.TOML, .{ .name = getterName("TOML") });
+ @export(BunObject.Transpiler, .{ .name = getterName("Transpiler") });
+ @export(BunObject.argv, .{ .name = getterName("argv") });
+ @export(BunObject.assetPrefix, .{ .name = getterName("assetPrefix") });
+ @export(BunObject.cwd, .{ .name = getterName("cwd") });
+ @export(BunObject.enableANSIColors, .{ .name = getterName("enableANSIColors") });
+ @export(BunObject.hash, .{ .name = getterName("hash") });
+ @export(BunObject.main, .{ .name = getterName("main") });
+ @export(BunObject.origin, .{ .name = getterName("origin") });
+ @export(BunObject.stderr, .{ .name = getterName("stderr") });
+ @export(BunObject.stdin, .{ .name = getterName("stdin") });
+ @export(BunObject.stdout, .{ .name = getterName("stdout") });
+ @export(BunObject.unsafe, .{ .name = getterName("unsafe") });
+ // --- Getters --
+
+ // -- Callbacks --
+ @export(BunObject.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump, .{ .name = callbackName("DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump") });
+ @export(BunObject._Os, .{ .name = callbackName("_Os") });
+ @export(BunObject._Path, .{ .name = callbackName("_Path") });
+ @export(BunObject.allocUnsafe, .{ .name = callbackName("allocUnsafe") });
+ @export(BunObject.build, .{ .name = callbackName("build") });
+ @export(BunObject.connect, .{ .name = callbackName("connect") });
+ @export(BunObject.deflateSync, .{ .name = callbackName("deflateSync") });
+ @export(BunObject.file, .{ .name = callbackName("file") });
+ @export(BunObject.fs, .{ .name = callbackName("fs") });
+ @export(BunObject.gc, .{ .name = callbackName("gc") });
+ @export(BunObject.generateHeapSnapshot, .{ .name = callbackName("generateHeapSnapshot") });
+ @export(BunObject.getImportedStyles, .{ .name = callbackName("getImportedStyles") });
+ @export(BunObject.gunzipSync, .{ .name = callbackName("gunzipSync") });
+ @export(BunObject.gzipSync, .{ .name = callbackName("gzipSync") });
+ @export(BunObject.indexOfLine, .{ .name = callbackName("indexOfLine") });
+ @export(BunObject.inflateSync, .{ .name = callbackName("inflateSync") });
+ @export(BunObject.inspect, .{ .name = callbackName("inspect") });
+ @export(BunObject.jest, .{ .name = callbackName("jest") });
+ @export(BunObject.listen, .{ .name = callbackName("listen") });
+ @export(BunObject.mmap, .{ .name = callbackName("mmap") });
+ @export(BunObject.nanoseconds, .{ .name = callbackName("nanoseconds") });
+ @export(BunObject.openInEditor, .{ .name = callbackName("openInEditor") });
+ @export(BunObject.registerMacro, .{ .name = callbackName("registerMacro") });
+ @export(BunObject.resolve, .{ .name = callbackName("resolve") });
+ @export(BunObject.resolveSync, .{ .name = callbackName("resolveSync") });
+ @export(BunObject.serve, .{ .name = callbackName("serve") });
+ @export(BunObject.sha, .{ .name = callbackName("sha") });
+ @export(BunObject.shrink, .{ .name = callbackName("shrink") });
+ @export(BunObject.sleepSync, .{ .name = callbackName("sleepSync") });
+ @export(BunObject.spawn, .{ .name = callbackName("spawn") });
+ @export(BunObject.spawnSync, .{ .name = callbackName("spawnSync") });
+ @export(BunObject.which, .{ .name = callbackName("which") });
+ @export(BunObject.write, .{ .name = callbackName("write") });
+ // -- Callbacks --
+ }
+};
+
const Bun = @This();
const default_allocator = @import("root").bun.default_allocator;
const bun = @import("root").bun;
@@ -41,15 +196,14 @@ const Request = WebCore.Request;
const Response = WebCore.Response;
const Headers = WebCore.Headers;
const Fetch = WebCore.Fetch;
-const FetchEvent = WebCore.FetchEvent;
const js = @import("root").bun.JSC.C;
const JSC = @import("root").bun.JSC;
const JSError = @import("../base.zig").JSError;
-const d = @import("../base.zig").d;
+
const MarkedArrayBuffer = @import("../base.zig").MarkedArrayBuffer;
const getAllocator = @import("../base.zig").getAllocator;
const JSValue = @import("root").bun.JSC.JSValue;
-const NewClass = @import("../base.zig").NewClass;
+
const Microtask = @import("root").bun.JSC.Microtask;
const JSGlobalObject = @import("root").bun.JSC.JSGlobalObject;
const ExceptionValueRef = @import("root").bun.JSC.ExceptionValueRef;
@@ -131,22 +285,16 @@ pub fn getCSSImports() []ZigString {
}
pub fn which(
- // this
- _: void,
- globalThis: js.JSContextRef,
- // function
- _: js.JSObjectRef,
- // thisObject
- _: js.JSObjectRef,
- arguments_: []const js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef {
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+) callconv(.C) JSC.JSValue {
+ const arguments_ = callframe.arguments(2);
var path_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
- var arguments = JSC.Node.ArgumentsSlice.from(globalThis.bunVM(), arguments_);
+ var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
defer arguments.deinit();
const path_arg = arguments.nextEat() orelse {
- JSC.throwInvalidArguments("which: expected 1 argument, got 0", .{}, globalThis, exception);
- return JSC.JSValue.jsUndefined().asObjectRef();
+ globalThis.throw("which: expected 1 argument, got 0", .{});
+ return JSC.JSValue.jsUndefined();
};
var path_str: ZigString.Slice = ZigString.Slice.empty;
@@ -159,18 +307,18 @@ pub fn which(
}
if (path_arg.isEmptyOrUndefinedOrNull()) {
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
}
bin_str = path_arg.toSlice(globalThis, globalThis.bunVM().allocator);
if (bin_str.len >= bun.MAX_PATH_BYTES) {
- JSC.throwInvalidArguments("bin path is too long", .{}, globalThis, exception);
- return JSC.JSValue.jsUndefined().asObjectRef();
+ globalThis.throw("bin path is too long", .{});
+ return JSC.JSValue.jsUndefined();
}
if (bin_str.len == 0) {
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
}
path_str = ZigString.Slice.fromUTF8NeverFree(
@@ -198,32 +346,26 @@ pub fn which(
cwd_str.slice(),
bin_str.slice(),
)) |bin_path| {
- return ZigString.init(bin_path).withEncoding().toValueGC(globalThis).asObjectRef();
+ return ZigString.init(bin_path).withEncoding().toValueGC(globalThis);
}
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
}
pub fn inspect(
- // this
- _: void,
- ctx: js.JSContextRef,
- // function
- _: js.JSObjectRef,
- // thisObject
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(4).slice();
if (arguments.len == 0)
- return ZigString.Empty.toValue(ctx.ptr()).asObjectRef();
+ return bun.String.empty.toJSConst(globalThis);
for (arguments) |arg| {
- JSC.C.JSValueProtect(ctx, arg);
+ arg.protect();
}
defer {
for (arguments) |arg| {
- JSC.C.JSValueUnprotect(ctx, arg);
+ arg.unprotect();
}
}
@@ -235,18 +377,18 @@ pub fn inspect(
.quote_strings = true,
.ordered_properties = false,
};
- var value = JSC.JSValue.fromRef(arguments[0]);
+ const value = arguments[0];
if (arguments.len > 1) {
- var arg1: JSC.JSValue = JSC.JSValue.fromRef(arguments[1]);
+ const arg1 = arguments[1];
if (arg1.isObject()) {
- if (arg1.getTruthy(ctx, "depth")) |opt| {
+ if (arg1.getTruthy(globalThis, "depth")) |opt| {
if (opt.isInt32()) {
const arg = opt.toInt32();
if (arg < 0) {
- ctx.throwInvalidArguments("expected depth to be greater than or equal to 0, got {d}", .{arg});
- return null;
+ globalThis.throwInvalidArguments("expected depth to be greater than or equal to 0, got {d}", .{arg});
+ return .zero;
}
formatOptions.max_depth = @as(u16, @truncate(@as(u32, @intCast(@min(arg, std.math.maxInt(u16))))));
} else if (opt.isNumber()) {
@@ -254,26 +396,26 @@ pub fn inspect(
if (std.math.isInf(v)) {
formatOptions.max_depth = std.math.maxInt(u16);
} else {
- ctx.throwInvalidArguments("expected depth to be an integer, got {d}", .{v});
- return null;
+ globalThis.throwInvalidArguments("expected depth to be an integer, got {d}", .{v});
+ return .zero;
}
}
}
- if (arg1.getOptional(ctx, "colors", bool) catch return null) |opt| {
+ if (arg1.getOptional(globalThis, "colors", bool) catch return .zero) |opt| {
formatOptions.enable_colors = opt;
}
- if (arg1.getOptional(ctx, "sorted", bool) catch return null) |opt| {
+ if (arg1.getOptional(globalThis, "sorted", bool) catch return .zero) |opt| {
formatOptions.ordered_properties = opt;
}
} else {
// formatOptions.show_hidden = arg1.toBoolean();
if (arguments.len > 2) {
- var depthArg = JSC.JSValue.fromRef(arguments[1]);
+ var depthArg = arguments[1];
if (depthArg.isInt32()) {
const arg = depthArg.toInt32();
if (arg < 0) {
- ctx.throwInvalidArguments("expected depth to be greater than or equal to 0, got {d}", .{arg});
- return null;
+ globalThis.throwInvalidArguments("expected depth to be greater than or equal to 0, got {d}", .{arg});
+ return .zero;
}
formatOptions.max_depth = @as(u16, @truncate(@as(u32, @intCast(@min(arg, std.math.maxInt(u16))))));
} else if (depthArg.isNumber()) {
@@ -281,19 +423,19 @@ pub fn inspect(
if (std.math.isInf(v)) {
formatOptions.max_depth = std.math.maxInt(u16);
} else {
- ctx.throwInvalidArguments("expected depth to be an integer, got {d}", .{v});
- return null;
+ globalThis.throwInvalidArguments("expected depth to be an integer, got {d}", .{v});
+ return .zero;
}
}
if (arguments.len > 3) {
- formatOptions.enable_colors = JSC.JSValue.fromRef(arguments[2]).toBoolean();
+ formatOptions.enable_colors = arguments[2].toBoolean();
}
}
}
}
// very stable memory address
- var array = MutableString.init(getAllocator(ctx), 0) catch unreachable;
+ var array = MutableString.init(getAllocator(globalThis), 0) catch unreachable;
var buffered_writer_ = MutableString.BufferedWriter{ .context = &array };
var buffered_writer = &buffered_writer_;
@@ -303,7 +445,7 @@ pub fn inspect(
// when it's under 4096, we want to avoid the dynamic allocation
ZigConsoleClient.format(
.Debug,
- ctx.ptr(),
+ globalThis,
@as([*]const JSValue, @ptrCast(&value)),
1,
Writer,
@@ -312,390 +454,136 @@ pub fn inspect(
formatOptions,
);
buffered_writer.flush() catch {
- return JSC.C.JSValueMakeUndefined(ctx);
+ return .undefined;
};
// we are going to always clone to keep things simple for now
// the common case here will be stack-allocated, so it should be fine
var out = ZigString.init(array.toOwnedSliceLeaky()).withEncoding();
- const ret = out.toValueGC(ctx);
+ const ret = out.toValueGC(globalThis);
array.deinit();
- return ret.asObjectRef();
-
- // // when it's a small thing, rely on GC to manage the memory
- // if (writer.context.pos < 2048 and array.list.items.len == 0) {
- // var slice = writer.context.buffer[0..writer.context.pos];
- // if (slice.len == 0) {
- // return ZigString.Empty.toValue(ctx.ptr()).asObjectRef();
- // }
-
- // var zig_str =
- // return zig_str.toValueGC(ctx.ptr()).asObjectRef();
- // }
-
- // // when it's a big thing, we will manage it
- // {
- // writer.context.flush() catch {};
- // var slice =try writer.context.context.toOwnedSlice();
-
- // var zig_str = ZigString.init(slice).withEncoding();
- // if (!zig_str.isUTF8()) {
- // return zig_str.toExternalValue(ctx.ptr()).asObjectRef();
- // } else {
- // return zig_str.toValueGC(ctx.ptr()).asObjectRef();
- // }
- // }
+ return ret;
}
pub fn registerMacro(
- // this
- _: void,
- ctx: js.JSContextRef,
- // function
- _: js.JSObjectRef,
- // thisObject
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef {
- if (arguments.len != 2 or !js.JSValueIsNumber(ctx, arguments[0])) {
- JSError(getAllocator(ctx), "Internal error registering macros: invalid args", .{}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ globalObject: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+) callconv(.C) JSC.JSValue {
+ const arguments_ = callframe.arguments(2);
+ const arguments = arguments_.slice();
+ if (arguments.len != 2 or !arguments[0].isNumber()) {
+ globalObject.throwInvalidArguments("Internal error registering macros: invalid args", .{});
+ return .undefined;
}
- // TODO: make this faster
- const id = @as(i32, @truncate(@as(i64, @intFromFloat(js.JSValueToNumber(ctx, arguments[0], exception)))));
+ const id = arguments[0].toInt32();
if (id == -1 or id == 0) {
- JSError(getAllocator(ctx), "Internal error registering macros: invalid id", .{}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ globalObject.throwInvalidArguments("Internal error registering macros: invalid id", .{});
+ return .undefined;
}
- if (!arguments[1].?.value().isCell() or !arguments[1].?.value().isCallable(ctx.vm())) {
- JSError(getAllocator(ctx), "Macro must be a function. Received: {s}", .{@tagName(js.JSValueGetType(ctx, arguments[1]))}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ if (!arguments[1].isCell() or !arguments[1].isCallable(globalObject.vm())) {
+ // TODO: add "toTypeOf" helper
+ globalObject.throw("Macro must be a function", .{});
+ return .undefined;
}
var get_or_put_result = VirtualMachine.get().macros.getOrPut(id) catch unreachable;
if (get_or_put_result.found_existing) {
- js.JSValueUnprotect(ctx, get_or_put_result.value_ptr.*);
+ get_or_put_result.value_ptr.*.?.value().unprotect();
}
- js.JSValueProtect(ctx, arguments[1]);
- get_or_put_result.value_ptr.* = arguments[1];
+ arguments[1].protect();
+ get_or_put_result.value_ptr.* = arguments[1].asObjectRef();
- return js.JSValueMakeUndefined(ctx);
+ return .undefined;
}
pub fn getCWD(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return ZigString.init(VirtualMachine.get().bundler.fs.top_level_dir).toValue(ctx.ptr()).asRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return ZigString.init(VirtualMachine.get().bundler.fs.top_level_dir).toValueGC(globalThis);
}
pub fn getOrigin(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return ZigString.init(VirtualMachine.get().origin.origin).toValue(ctx.ptr()).asRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return ZigString.init(VirtualMachine.get().origin.origin).toValueGC(globalThis);
}
pub fn getStdin(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("BunSTDIN"));
- if (existing.isEmpty()) {
- var rare_data = JSC.VirtualMachine.get().rareData();
- var store = rare_data.stdin();
- var blob = bun.default_allocator.create(JSC.WebCore.Blob) catch unreachable;
- blob.* = JSC.WebCore.Blob.initWithStore(store, ctx.ptr());
-
- return ctx.ptr().putCachedObject(
- ZigString.static("BunSTDIN"),
- blob.toJS(ctx),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ var rare_data = globalThis.bunVM().rareData();
+ var store = rare_data.stdin();
+ store.ref();
+ var blob = bun.default_allocator.create(JSC.WebCore.Blob) catch unreachable;
+ blob.* = JSC.WebCore.Blob.initWithStore(store, globalThis);
+ return blob.toJS(globalThis);
}
pub fn getStderr(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("BunSTDERR"));
- if (existing.isEmpty()) {
- var rare_data = JSC.VirtualMachine.get().rareData();
- var store = rare_data.stderr();
- var blob = bun.default_allocator.create(JSC.WebCore.Blob) catch unreachable;
- blob.* = JSC.WebCore.Blob.initWithStore(store, ctx.ptr());
-
- return ctx.ptr().putCachedObject(
- ZigString.static("BunSTDERR"),
- blob.toJS(ctx),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ var rare_data = globalThis.bunVM().rareData();
+ var store = rare_data.stderr();
+ store.ref();
+ var blob = bun.default_allocator.create(JSC.WebCore.Blob) catch unreachable;
+ blob.* = JSC.WebCore.Blob.initWithStore(store, globalThis);
+ return blob.toJS(globalThis);
}
pub fn getStdout(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("BunSTDOUT"));
- if (existing.isEmpty()) {
- var rare_data = JSC.VirtualMachine.get().rareData();
- var store = rare_data.stdout();
- var blob = bun.default_allocator.create(JSC.WebCore.Blob) catch unreachable;
- blob.* = JSC.WebCore.Blob.initWithStore(store, ctx.ptr());
-
- return ctx.ptr().putCachedObject(
- &ZigString.init("BunSTDOUT"),
- blob.toJS(ctx),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ var rare_data = globalThis.bunVM().rareData();
+ var store = rare_data.stdout();
+ store.ref();
+ var blob = bun.default_allocator.create(JSC.WebCore.Blob) catch unreachable;
+ blob.* = JSC.WebCore.Blob.initWithStore(store, globalThis);
+ return blob.toJS(globalThis);
}
pub fn enableANSIColors(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return js.JSValueMakeBoolean(ctx, Output.enable_ansi_colors);
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ _ = globalThis;
+ return JSValue.jsBoolean(Output.enable_ansi_colors);
}
pub fn getMain(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return ZigString.init(VirtualMachine.get().main).toValue(ctx.ptr()).asRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return ZigString.init(globalThis.bunVM().main).toValueGC(globalThis);
}
pub fn getAssetPrefix(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return ZigString.init(VirtualMachine.get().bundler.options.routes.asset_prefix_path).toValueGC(ctx.ptr()).asRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return ZigString.init(VirtualMachine.get().bundler.options.routes.asset_prefix_path).toValueGC(globalThis);
}
pub fn getArgv(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- // TODO: cache this
- return JSC.Node.Process.getArgv(ctx).asObjectRef();
-}
-
-pub fn getRoutesDir(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- if (!VirtualMachine.get().bundler.options.routes.routes_enabled or VirtualMachine.get().bundler.options.routes.dir.len == 0) {
- return js.JSValueMakeUndefined(ctx);
- }
-
- return ZigString.init(VirtualMachine.get().bundler.options.routes.dir).toValue(ctx.ptr()).asRef();
-}
-
-pub fn getFilePath(ctx: js.JSContextRef, arguments: []const js.JSValueRef, buf: []u8, exception: js.ExceptionRef) ?string {
- if (arguments.len != 1) {
- JSError(getAllocator(ctx), "Expected a file path as a string or an array of strings to be part of a file path.", .{}, ctx, exception);
- return null;
- }
-
- const value = arguments[0];
- if (JSC.JSValue.c(value).isString()) {
- const out = JSC.JSValue.c(value).toSlice(ctx, bun.default_allocator);
- defer out.deinit();
-
- // The dots are kind of unnecessary. They'll be normalized.
- if (out.len == 0 or std.mem.eql(u8, out.slice(), "..") or std.mem.eql(u8, out.slice(), "../")) {
- JSError(getAllocator(ctx), "Expected a file path as a string or an array of strings to be part of a file path.", .{}, ctx, exception);
- return null;
- }
-
- var parts = [_]string{out.slice()};
- // This does the equivalent of Node's path.normalize(path.join(cwd, out_slice))
- var res = VirtualMachine.get().bundler.fs.absBuf(&parts, buf);
-
- return res;
- } else if (js.JSValueIsArray(ctx, value)) {
- var temp_strings_list: [32]string = undefined;
- var temp_strings_list_len: u8 = 0;
- defer {
- for (temp_strings_list[0..temp_strings_list_len], 0..) |_, i| {
- temp_strings_list[i] = "";
- }
- }
-
- var iter = JSValue.fromRef(value).arrayIterator(ctx.ptr());
- while (iter.next()) |item| {
- if (temp_strings_list_len >= temp_strings_list.len) {
- break;
- }
-
- if (!item.isString()) {
- JSError(getAllocator(ctx), "Expected a file path as a string or an array of strings to be part of a file path.", .{}, ctx, exception);
- return null;
- }
-
- const out = JSC.JSValue.c(value).toSlice(ctx, bun.default_allocator);
- defer out.deinit();
-
- // The dots are kind of unnecessary. They'll be normalized.
- if (out.len == 0 or std.mem.eql(u8, out.slice(), "..") or std.mem.eql(u8, out.slice(), "../")) {
- JSError(getAllocator(ctx), "Expected a file path as a string or an array of strings to be part of a file path.", .{}, ctx, exception);
- return null;
- }
-
- const out_slice = out.slice();
-
- temp_strings_list[temp_strings_list_len] = out_slice;
- // The dots are kind of unnecessary. They'll be normalized.
- if (out.len == 0 or @intFromPtr(out.ptr) == 0 or std.mem.eql(u8, out_slice, ".") or std.mem.eql(u8, out_slice, "..") or std.mem.eql(u8, out_slice, "../")) {
- JSError(getAllocator(ctx), "Expected a file path as a string or an array of strings to be part of a file path.", .{}, ctx, exception);
- return null;
- }
- temp_strings_list_len += 1;
- }
-
- if (temp_strings_list_len == 0) {
- JSError(getAllocator(ctx), "Expected a file path as a string or an array of strings to be part of a file path.", .{}, ctx, exception);
- return null;
- }
-
- return VirtualMachine.get().bundler.fs.absBuf(temp_strings_list[0..temp_strings_list_len], buf);
- } else {
- JSError(getAllocator(ctx), "Expected a file path as a string or an array of strings to be part of a file path.", .{}, ctx, exception);
- return null;
- }
-}
-
-pub fn getImportedStyles(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- defer flushCSSImports();
- const styles = getCSSImports();
- if (styles.len == 0) {
- return js.JSObjectMakeArray(ctx, 0, null, null);
- }
-
- return JSValue.createStringArray(ctx.ptr(), styles.ptr, styles.len, true).asRef();
-}
-
-pub fn newOs(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return Node.Os.create(ctx.ptr()).asObjectRef();
-}
-
-pub fn newPath(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- args: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- const is_windows = args.len == 1 and JSValue.fromRef(args[0]).toBoolean();
- return Node.Path.create(ctx.ptr(), is_windows).asObjectRef();
-}
-
-pub fn getRouteFiles(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- if (VirtualMachine.get().bundler.router == null) return js.JSObjectMakeArray(ctx, 0, null, null);
-
- const router = &VirtualMachine.get().bundler.router.?;
- const list = router.getPublicPaths() catch unreachable;
-
- for (routes_list_strings[0..@min(list.len, routes_list_strings.len)], 0..) |_, i| {
- routes_list_strings[i] = ZigString.init(list[i]);
- }
-
- const ref = JSValue.createStringArray(ctx.ptr(), &routes_list_strings, list.len, true).asRef();
- return ref;
-}
-
-pub fn getRouteNames(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- if (VirtualMachine.get().bundler.router == null) return js.JSObjectMakeArray(ctx, 0, null, null);
-
- const router = &VirtualMachine.get().bundler.router.?;
- const list = router.getNames() catch unreachable;
-
- for (routes_list_strings[0..@min(list.len, routes_list_strings.len)], 0..) |_, i| {
- routes_list_strings[i] = ZigString.init(list[i]);
- }
-
- const ref = JSValue.createStringArray(ctx.ptr(), &routes_list_strings, list.len, true).asRef();
- return ref;
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return JSC.Node.Process.getArgv(globalThis);
}
const Editor = @import("../../open.zig").Editor;
pub fn openInEditor(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- args: []const js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef {
+ globalThis: js.JSContextRef,
+ callframe: *JSC.CallFrame,
+) callconv(.C) JSValue {
var edit = &VirtualMachine.get().rareData().editor_context;
-
- var arguments = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), args);
+ const args = callframe.arguments(4);
+ var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), args.slice());
defer arguments.deinit();
var path: string = "";
var editor_choice: ?Editor = null;
@@ -703,13 +591,13 @@ pub fn openInEditor(
var column: ?string = null;
if (arguments.nextEat()) |file_path_| {
- path = file_path_.toSlice(ctx.ptr(), bun.default_allocator).slice();
+ path = file_path_.toSlice(globalThis, arguments.arena.allocator()).slice();
}
if (arguments.nextEat()) |opts| {
if (!opts.isUndefinedOrNull()) {
- if (opts.getTruthy(ctx.ptr(), "editor")) |editor_val| {
- var sliced = editor_val.toSlice(ctx.ptr(), bun.default_allocator);
+ if (opts.getTruthy(globalThis, "editor")) |editor_val| {
+ var sliced = editor_val.toSlice(globalThis, arguments.arena.allocator());
var prev_name = edit.name;
if (!strings.eqlLong(prev_name, sliced.slice(), true)) {
@@ -719,21 +607,21 @@ pub fn openInEditor(
editor_choice = edit.editor;
if (editor_choice == null) {
edit.* = prev;
- JSError(getAllocator(ctx), "Could not find editor \"{s}\"", .{sliced.slice()}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ globalThis.throw("Could not find editor \"{s}\"", .{sliced.slice()});
+ return .undefined;
} else if (edit.name.ptr == edit.path.ptr) {
- edit.name = bun.default_allocator.dupe(u8, edit.path) catch unreachable;
+ edit.name = arguments.arena.allocator().dupe(u8, edit.path) catch unreachable;
edit.path = edit.path;
}
}
}
- if (opts.getTruthy(ctx.ptr(), "line")) |line_| {
- line = line_.toSlice(ctx.ptr(), bun.default_allocator).slice();
+ if (opts.getTruthy(globalThis, "line")) |line_| {
+ line = line_.toSlice(globalThis, arguments.arena.allocator()).slice();
}
- if (opts.getTruthy(ctx.ptr(), "column")) |column_| {
- column = column_.toSlice(ctx.ptr(), bun.default_allocator).slice();
+ if (opts.getTruthy(globalThis, "column")) |column_| {
+ column = column_.toSlice(globalThis, arguments.arena.allocator()).slice();
}
}
}
@@ -741,24 +629,24 @@ pub fn openInEditor(
const editor = editor_choice orelse edit.editor orelse brk: {
edit.autoDetectEditor(VirtualMachine.get().bundler.env);
if (edit.editor == null) {
- JSC.JSError(bun.default_allocator, "Failed to auto-detect editor", .{}, ctx, exception);
- return null;
+ globalThis.throw("Failed to auto-detect editor", .{});
+ return .zero;
}
break :brk edit.editor.?;
};
if (path.len == 0) {
- JSError(getAllocator(ctx), "No file path specified", .{}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ globalThis.throw("No file path specified", .{});
+ return .zero;
}
- editor.open(edit.path, path, line, column, bun.default_allocator) catch |err| {
- JSC.JSError(bun.default_allocator, "Opening editor failed {s}", .{@errorName(err)}, ctx, exception);
- return null;
+ editor.open(edit.path, path, line, column, arguments.arena.allocator()) catch |err| {
+ globalThis.throw("Opening editor failed {s}", .{@errorName(err)});
+ return .zero;
};
- return JSC.JSValue.jsUndefined().asObjectRef();
+ return JSC.JSValue.jsUndefined();
}
pub fn getPublicPath(to: string, origin: URL, comptime Writer: type, writer: Writer) void {
@@ -794,117 +682,72 @@ pub fn getPublicPathWithAssetPrefix(to: string, dir: string, origin: URL, asset_
}
}
-pub fn sleepSync(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- // This function always returns undefined
- const ret = js.JSValueMakeUndefined(ctx);
+pub fn sleepSync(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1);
// Expect at least one argument. We allow more than one but ignore them; this
// is useful for supporting things like `[1, 2].map(sleepSync)`
if (arguments.len < 1) {
- ctx.throwInvalidArguments("expected one argument, got {}", .{arguments.len});
- return ret;
+ globalObject.throwNotEnoughArguments("sleepSync", 1, 0);
+ return .undefined;
}
- const arg = JSValue.fromRef(arguments[0]);
+ const arg = arguments.slice()[0];
// The argument must be a number
if (!arg.isNumber()) {
- ctx.throwInvalidArguments("argument to sleepSync must be a number, got {}", .{arg.jsTypeLoose()});
- return ret;
+ globalObject.throwInvalidArgumentType("sleepSync", "milliseconds", "number");
+ return .undefined;
}
//NOTE: if argument is > max(i32) then it will be truncated
- const milliseconds = arg.coerce(i32, ctx);
+ const milliseconds = arg.coerce(i32, globalObject);
if (milliseconds < 0) {
- ctx.throwInvalidArguments("argument to sleepSync must not be negative, got {}", .{milliseconds});
- return ret;
+ globalObject.throwInvalidArguments("argument to sleepSync must not be negative, got {d}", .{milliseconds});
+ return .undefined;
}
std.time.sleep(@as(u64, @intCast(milliseconds)) * std.time.ns_per_ms);
- return ret;
-}
-
-pub fn createNodeFS(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- var module = ctx.allocator().create(JSC.Node.NodeJSFS) catch unreachable;
- module.* = .{};
- var vm = ctx.bunVM();
- if (vm.standalone_module_graph != null)
- module.node_fs.vm = vm;
-
- return module.toJS(ctx).asObjectRef();
+ return .undefined;
}
-pub fn generateHeapSnapshot(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return ctx.ptr().generateHeapSnapshot().asObjectRef();
+pub fn generateHeapSnapshot(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ return globalObject.generateHeapSnapshot();
}
-pub fn runGC(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return ctx.bunVM().garbageCollect(arguments.len > 0 and JSC.JSValue.c(arguments[0]).toBoolean()).asObjectRef();
+pub fn runGC(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ const arguments_ = callframe.arguments(1);
+ const arguments = arguments_.slice();
+ return globalObject.bunVM().garbageCollect(arguments.len > 0 and arguments[0].isBoolean() and arguments[0].toBoolean());
}
-
-pub fn shrink(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- ctx.ptr().vm().shrinkFootprint();
- return JSValue.jsUndefined().asRef();
+pub fn shrink(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ globalObject.vm().shrinkFootprint();
+ return .undefined;
}
fn doResolve(
- ctx: js.JSContextRef,
- arguments: []const js.JSValueRef,
+ globalThis: *JSC.JSGlobalObject,
+ arguments: []const JSValue,
exception: js.ExceptionRef,
) ?JSC.JSValue {
- var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
+ var args = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments);
defer args.deinit();
const specifier = args.protectEatNext() orelse {
- JSC.throwInvalidArguments("Expected a specifier and a from path", .{}, ctx, exception);
+ JSC.throwInvalidArguments("Expected a specifier and a from path", .{}, globalThis, exception);
return null;
};
if (specifier.isUndefinedOrNull()) {
- JSC.throwInvalidArguments("specifier must be a string", .{}, ctx, exception);
+ JSC.throwInvalidArguments("specifier must be a string", .{}, globalThis, exception);
return null;
}
const from = args.protectEatNext() orelse {
- JSC.throwInvalidArguments("Expected a from path", .{}, ctx, exception);
+ JSC.throwInvalidArguments("Expected a from path", .{}, globalThis, exception);
return null;
};
if (from.isUndefinedOrNull()) {
- JSC.throwInvalidArguments("from must be a string", .{}, ctx, exception);
+ JSC.throwInvalidArguments("from must be a string", .{}, globalThis, exception);
return null;
}
@@ -913,12 +756,12 @@ fn doResolve(
if (next.isBoolean()) {
is_esm = next.toBoolean();
} else {
- JSC.throwInvalidArguments("esm must be a boolean", .{}, ctx, exception);
+ JSC.throwInvalidArguments("esm must be a boolean", .{}, globalThis, exception);
return null;
}
}
- return doResolveWithArgs(ctx, specifier.toBunString(ctx.ptr()), from.toBunString(ctx.ptr()), exception, is_esm, false);
+ return doResolveWithArgs(globalThis, specifier.toBunString(globalThis), from.toBunString(globalThis), exception, is_esm, false);
}
fn doResolveWithArgs(
@@ -976,32 +819,27 @@ fn doResolveWithArgs(
return errorable.result.value.toJS(ctx);
}
-pub fn resolveSync(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef {
- const value = doResolve(ctx, arguments, exception) orelse return null;
- return value.asObjectRef();
+pub fn resolveSync(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var exception_ = [1]JSC.JSValueRef{null};
+ var exception = &exception_;
+ const arguments = callframe.arguments(3);
+ const result = doResolve(globalObject, arguments.slice(), exception);
+
+ if (exception_[0] != null) {
+ globalObject.throwValue(exception_[0].?.value());
+ }
+
+ return result orelse .zero;
}
-pub fn resolve(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef {
- const value = doResolve(ctx, arguments, exception) orelse {
- var exception_value = exception.*.?;
- exception.* = null;
- return JSC.JSPromise.rejectedPromiseValue(ctx.ptr(), JSC.JSValue.fromRef(exception_value)).asObjectRef();
+pub fn resolve(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var exception_ = [1]JSC.JSValueRef{null};
+ var exception = &exception_;
+ const arguments = callframe.arguments(3);
+ const value = doResolve(globalObject, arguments.slice(), exception) orelse {
+ return JSC.JSPromise.rejectedPromiseValue(globalObject, exception_[0].?.value());
};
- return JSC.JSPromise.resolvedPromiseValue(ctx.ptr(), value).asObjectRef();
+ return JSC.JSPromise.resolvedPromiseValue(globalObject, value);
}
export fn Bun__resolve(
@@ -1013,7 +851,7 @@ export fn Bun__resolve(
var exception_ = [1]JSC.JSValueRef{null};
var exception = &exception_;
const value = doResolveWithArgs(global, specifier.toBunString(global), source.toBunString(global), exception, is_esm, true) orelse {
- return JSC.JSPromise.rejectedPromiseValue(global, JSC.JSValue.fromRef(exception[0]));
+ return JSC.JSPromise.rejectedPromiseValue(global, exception_[0].?.value());
};
return JSC.JSPromise.resolvedPromiseValue(global, value);
}
@@ -1052,278 +890,68 @@ comptime {
}
}
-var public_path_temp_str: [bun.MAX_PATH_BYTES]u8 = undefined;
-
-pub fn getPublicPathJS(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- var zig_str: ZigString = ZigString.Empty;
- JSValue.toZigString(JSValue.fromRef(arguments[0]), &zig_str, ctx.ptr());
-
- const to = zig_str.slice();
+pub fn getPublicPathJS(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1).slice();
+ if (arguments.len < 1) {
+ return bun.String.empty.toJSConst(globalObject);
+ }
+ var public_path_temp_str: [bun.MAX_PATH_BYTES]u8 = undefined;
+ const to = arguments[0].toSlice(globalObject, bun.default_allocator);
+ defer to.deinit();
var stream = std.io.fixedBufferStream(&public_path_temp_str);
var writer = stream.writer();
- getPublicPath(to, VirtualMachine.get().origin, @TypeOf(&writer), &writer);
+ getPublicPath(to.slice(), VirtualMachine.get().origin, @TypeOf(&writer), &writer);
- return ZigString.init(stream.buffer[0..stream.pos]).toValueGC(ctx.ptr()).asObjectRef();
+ return ZigString.init(stream.buffer[0..stream.pos]).toValueGC(globalObject);
}
-pub const Class = NewClass(
- void,
- .{
- .name = "Bun",
- .read_only = true,
- },
- .{
- // Private
- // TODO: We should remove _Os, _Path, and make registerMacro and fs be private builtins
- .DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump = .{
- .rfn = &dump_mimalloc,
- .enumerable = false,
- },
- ._Os = .{
- .rfn = &Bun.newOs,
- .enumerable = false,
- },
- ._Path = .{
- .rfn = &Bun.newPath,
- .enumerable = false,
- },
- .registerMacro = .{
- .rfn = &Bun.registerMacro,
- .enumerable = false,
- },
- .fs = .{
- .rfn = &Bun.createNodeFS,
- .enumerable = false,
- },
- .jest = .{
- .rfn = &@import("../test/jest.zig").Jest.call,
- .enumerable = false,
- },
+fn fs(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var module = globalObject.allocator().create(JSC.Node.NodeJSFS) catch unreachable;
+ module.* = .{};
+ var vm = globalObject.bunVM();
+ if (vm.standalone_module_graph != null)
+ module.node_fs.vm = vm;
- // TODO: remove these deprecated methods before 1.0
- .getImportedStyles = .{
- .rfn = &Bun.getImportedStyles,
- .enumerable = false,
- },
- .getRouteFiles = .{
- .rfn = &Bun.getRouteFiles,
- .enumerable = false,
- },
- .match = .{
- .rfn = &Router.deprecatedBunGlobalMatch,
- .enumerable = false,
- },
- .getRouteNames = .{
- .rfn = &Bun.getRouteNames,
- .enumerable = false,
- },
+ return module.toJS(globalObject);
+}
- // Public API
- .sleepSync = .{
- .rfn = &sleepSync,
- },
- // .fetch = .{
- // .rfn = &Fetch.call,
- // },
- .inspect = .{
- .rfn = &Bun.inspect,
- },
- .resolveSync = .{
- .rfn = &Bun.resolveSync,
- },
- .resolve = .{
- .rfn = &Bun.resolve,
- },
- .getPublicPath = .{
- .rfn = &Bun.getPublicPathJS,
- },
- .indexOfLine = .{
- .rfn = &Bun.indexOfLine,
- },
- .gc = .{
- .rfn = &Bun.runGC,
- },
- .allocUnsafe = .{
- .rfn = &Bun.allocUnsafe,
- },
- .mmap = .{
- .rfn = &Bun.mmapFile,
- },
- .generateHeapSnapshot = .{
- .rfn = &Bun.generateHeapSnapshot,
- },
- .shrink = .{
- .rfn = &Bun.shrink,
- },
- .openInEditor = .{
- .rfn = &Bun.openInEditor,
- },
- .serve = .{
- .rfn = &Bun.serve,
- },
- .file = .{
- .rfn = &JSC.WebCore.Blob.constructFile,
- },
- .write = .{
- .rfn = &JSC.WebCore.Blob.writeFile,
- },
- .sha = .{
- .rfn = &JSC.wrapWithHasContainer(Crypto.SHA512_256, "hash_", false, false, true),
- },
- .nanoseconds = .{
- .rfn = &nanoseconds,
- },
- .gzipSync = .{
- .rfn = &JSC.wrapWithHasContainer(JSZlib, "gzipSync", false, false, true),
- },
- .deflateSync = .{
- .rfn = &JSC.wrapWithHasContainer(JSZlib, "deflateSync", false, false, true),
- },
- .gunzipSync = .{
- .rfn = &JSC.wrapWithHasContainer(JSZlib, "gunzipSync", false, false, true),
- },
- .inflateSync = .{
- .rfn = &JSC.wrapWithHasContainer(JSZlib, "inflateSync", false, false, true),
- },
- .which = .{
- .rfn = &which,
- },
- .spawn = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.Subprocess, "spawn", false, false, false),
- },
- .spawnSync = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.Subprocess, "spawnSync", false, false, false),
- },
- .build = .{
- .rfn = &Bun.JSBundler.buildFn,
- },
- .listen = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.API.Listener, "listen", false, false, false),
- },
- .connect = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.API.Listener, "connect", false, false, false),
- },
- },
- .{
- .main = .{
- .get = getMain,
- },
- // TODO: decide what we want to do
- .cwd = .{
- .get = getCWD,
- .enumerable = false,
- },
- .origin = .{
- .get = getOrigin,
- },
- .stdin = .{
- .get = getStdin,
- },
- .stdout = .{
- .get = getStdout,
- },
- .stderr = .{
- .get = getStderr,
- },
- // TODO: remove this before 1.0
- .routesDir = .{
- .get = getRoutesDir,
- .enumerable = false,
- },
- // TODO: remove this before 1.0
- .assetPrefix = .{
- .get = getAssetPrefix,
- .enumerable = false,
- },
- .argv = .{
- .get = getArgv,
- },
- .enableANSIColors = .{
- .get = enableANSIColors,
- },
- .Transpiler = .{
- .get = getTranspilerConstructor,
- },
- .hash = .{
- .get = getHashObject,
- },
- .TOML = .{
- .get = getTOMLObject,
- },
- .unsafe = .{
- .get = getUnsafe,
- },
- .SHA1 = .{
- .get = Crypto.SHA1.getter,
- },
- .MD5 = .{
- .get = Crypto.MD5.getter,
- },
- .MD4 = .{
- .get = Crypto.MD4.getter,
- },
- .SHA224 = .{
- .get = Crypto.SHA224.getter,
- },
- .SHA512 = .{
- .get = Crypto.SHA512.getter,
- },
- .SHA384 = .{
- .get = Crypto.SHA384.getter,
- },
- .SHA256 = .{
- .get = Crypto.SHA256.getter,
- },
- .SHA512_256 = .{
- .get = Crypto.SHA512_256.getter,
- },
- .CryptoHasher = .{
- .get = Crypto.CryptoHasher.getter,
- },
- .FFI = .{
- .get = FFI.getter,
- },
- .FileSystemRouter = .{
- .get = getFileSystemRouter,
- },
- },
-);
-
-fn dump_mimalloc(
- _: void,
- globalThis: JSC.C.JSContextRef,
- _: JSC.C.JSObjectRef,
- _: JSC.C.JSObjectRef,
- _: []const JSC.C.JSValueRef,
- _: JSC.C.ExceptionRef,
-) JSC.C.JSValueRef {
- globalThis.bunVM().arena.dumpStats();
- return JSC.JSValue.jsUndefined().asObjectRef();
+fn _Os(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ return Node.Os.create(globalObject);
+}
+
+fn _Path(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1);
+ const args = arguments.slice();
+ const is_windows = args.len == 1 and args[0].toBoolean();
+ return Node.Path.create(globalObject, is_windows);
+}
+
+/// @deprecated
+fn getImportedStyles(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ defer flushCSSImports();
+ const styles = getCSSImports();
+ if (styles.len == 0) {
+ return JSC.JSValue.createEmptyArray(globalObject, 0);
+ }
+
+ return JSValue.createStringArray(globalObject, styles.ptr, styles.len, true);
}
-pub fn indexOfLine(
- _: void,
- globalThis: JSC.C.JSContextRef,
- _: JSC.C.JSObjectRef,
- _: JSC.C.JSObjectRef,
- args: []const JSC.C.JSValueRef,
- _: JSC.C.ExceptionRef,
-) JSC.C.JSValueRef {
- const arguments = bun.cast([]const JSC.JSValue, args);
+pub fn dump_mimalloc(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ globalObject.bunVM().arena.dumpStats();
+ return .undefined;
+}
+
+pub fn indexOfLine(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ const arguments_ = callframe.arguments(2);
+ const arguments = arguments_.slice();
if (arguments.len == 0) {
- return JSC.JSValue.jsNumberFromInt32(-1).asObjectRef();
+ return JSC.JSValue.jsNumberFromInt32(-1);
}
var buffer = arguments[0].asArrayBuffer(globalThis) orelse {
- return JSC.JSValue.jsNumberFromInt32(-1).asObjectRef();
+ return JSC.JSValue.jsNumberFromInt32(-1);
};
var offset: usize = 0;
@@ -1351,10 +979,10 @@ pub fn indexOfLine(
if (byte == '\r') {
if (i + 1 < bytes.len and bytes[i + 1] == '\n') {
- return JSC.JSValue.jsNumber(i + 1).asObjectRef();
+ return JSC.JSValue.jsNumber(i + 1);
}
} else if (byte == '\n') {
- return JSC.JSValue.jsNumber(i).asObjectRef();
+ return JSC.JSValue.jsNumber(i);
}
current_offset = i + 1;
@@ -1363,7 +991,7 @@ pub fn indexOfLine(
}
}
- return JSC.JSValue.jsNumberFromInt32(-1).asObjectRef();
+ return JSC.JSValue.jsNumberFromInt32(-1);
}
pub const Crypto = struct {
@@ -1882,22 +1510,22 @@ pub const Crypto = struct {
object.put(
globalObject,
ZigString.static("hash"),
- JSC.NewFunction(globalObject, ZigString.static("hash"), 2, JSPasswordObject__hash, false),
+ JSC.createCallback(globalObject, ZigString.static("hash"), 2, JSPasswordObject__hash),
);
object.put(
globalObject,
ZigString.static("hashSync"),
- JSC.NewFunction(globalObject, ZigString.static("hashSync"), 2, JSPasswordObject__hashSync, false),
+ JSC.createCallback(globalObject, ZigString.static("hashSync"), 2, JSPasswordObject__hashSync),
);
object.put(
globalObject,
ZigString.static("verify"),
- JSC.NewFunction(globalObject, ZigString.static("verify"), 2, JSPasswordObject__verify, false),
+ JSC.createCallback(globalObject, ZigString.static("verify"), 2, JSPasswordObject__verify),
);
object.put(
globalObject,
ZigString.static("verifySync"),
- JSC.NewFunction(globalObject, ZigString.static("verifySync"), 2, JSPasswordObject__verifySync, false),
+ JSC.createCallback(globalObject, ZigString.static("verifySync"), 2, JSPasswordObject__verifySync),
);
return object;
}
@@ -2508,13 +2136,10 @@ pub const Crypto = struct {
}
pub fn getter(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return CryptoHasher.getConstructor(ctx).asObjectRef();
+ globalObject: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+ ) callconv(.C) JSC.JSValue {
+ return CryptoHasher.getConstructor(globalObject);
}
pub fn update(this: *CryptoHasher, globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
@@ -2522,7 +2147,7 @@ pub const Crypto = struct {
const arguments = callframe.arguments(2);
const input = arguments.ptr[0];
const encoding = arguments.ptr[1];
- const buffer = JSC.Node.SliceOrBuffer.fromJSWithEncoding(globalThis.ptr(), globalThis.bunVM().allocator, input, encoding) orelse {
+ const buffer = JSC.Node.SliceOrBuffer.fromJSWithEncoding(globalThis, globalThis.bunVM().allocator, input, encoding) orelse {
globalThis.throwInvalidArguments("expected string or buffer", .{});
return JSC.JSValue.zero;
};
@@ -2725,19 +2350,16 @@ pub const Crypto = struct {
}
pub fn getter(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ThisHasher.getConstructor(ctx).asObjectRef();
+ globalObject: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+ ) callconv(.C) JSC.JSValue {
+ return ThisHasher.getConstructor(globalObject);
}
pub fn update(this: *@This(), globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
const thisValue = callframe.this();
const input = callframe.argument(0);
- const buffer = JSC.Node.SliceOrBuffer.fromJS(globalThis.ptr(), globalThis.bunVM().allocator, input) orelse {
+ const buffer = JSC.Node.SliceOrBuffer.fromJS(globalThis, globalThis.bunVM().allocator, input) orelse {
globalThis.throwInvalidArguments("expected string or buffer", .{});
return JSC.JSValue.zero;
};
@@ -2840,87 +2462,100 @@ pub const Crypto = struct {
};
pub fn nanoseconds(
- _: void,
- _: JSC.C.JSContextRef,
- _: JSC.C.JSObjectRef,
- _: JSC.C.JSObjectRef,
- _: []const JSC.C.JSValueRef,
- _: JSC.C.ExceptionRef,
-) JSC.C.JSValueRef {
- const ns = JSC.VirtualMachine.get().origin_timer.read();
- return JSC.JSValue.jsNumberFromUint64(ns).asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.CallFrame,
+) callconv(.C) JSC.JSValue {
+ const ns = globalThis.bunVM().origin_timer.read();
+ return JSC.JSValue.jsNumberFromUint64(ns);
}
pub fn serve(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
- const config = JSC.API.ServerConfig.fromJS(ctx.ptr(), &args, exception);
- if (exception.* != null) {
- return null;
- }
+ globalObject: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(2).slice();
+ const config: JSC.API.ServerConfig = brk: {
+ var exception_ = [1]JSC.JSValueRef{null};
+ var exception = &exception_;
+
+ var args = JSC.Node.ArgumentsSlice.init(globalObject.bunVM(), arguments);
+ const config_ = JSC.API.ServerConfig.fromJS(globalObject.ptr(), &args, exception);
+ if (exception[0] != null) {
+ globalObject.throwValue(exception_[0].?.value());
+ return .undefined;
+ }
+
+ break :brk config_;
+ };
+
+ var exception_value: *JSC.JSValue = undefined;
// Listen happens on the next tick!
// This is so we can return a Server object
if (config.ssl_config != null) {
if (config.development) {
- var server = JSC.API.DebugSSLServer.init(config, ctx.ptr());
+ var server = JSC.API.DebugHTTPSServer.init(config, globalObject.ptr());
+ exception_value = &server.thisObject;
server.listen();
if (!server.thisObject.isEmpty()) {
- exception.* = server.thisObject.asObjectRef();
+ exception_value.unprotect();
+ globalObject.throwValue(server.thisObject);
server.thisObject = JSC.JSValue.zero;
server.deinit();
- return null;
+ return .zero;
}
- var obj = JSC.API.DebugSSLServer.Class.make(ctx, server);
- JSC.C.JSValueProtect(ctx, obj);
- server.thisObject = JSValue.c(obj);
+ const obj = server.toJS(globalObject);
+ obj.protect();
+
+ server.thisObject = obj;
return obj;
} else {
- var server = JSC.API.SSLServer.init(config, ctx.ptr());
+ var server = JSC.API.HTTPSServer.init(config, globalObject.ptr());
+ exception_value = &server.thisObject;
server.listen();
- if (!server.thisObject.isEmpty()) {
- exception.* = server.thisObject.asObjectRef();
+ if (!exception_value.isEmpty()) {
+ exception_value.unprotect();
+ globalObject.throwValue(exception_value.*);
server.thisObject = JSC.JSValue.zero;
server.deinit();
- return null;
+ return .zero;
}
- var obj = JSC.API.SSLServer.Class.make(ctx, server);
- JSC.C.JSValueProtect(ctx, obj);
- server.thisObject = JSValue.c(obj);
+ const obj = server.toJS(globalObject);
+ obj.protect();
+ server.thisObject = obj;
return obj;
}
} else {
if (config.development) {
- var server = JSC.API.DebugServer.init(config, ctx.ptr());
+ var server = JSC.API.DebugHTTPServer.init(config, globalObject.ptr());
+ exception_value = &server.thisObject;
server.listen();
- if (!server.thisObject.isEmpty()) {
- exception.* = server.thisObject.asObjectRef();
+ if (!exception_value.isEmpty()) {
+ exception_value.unprotect();
+ globalObject.throwValue(exception_value.*);
server.thisObject = JSC.JSValue.zero;
server.deinit();
- return null;
+ return .zero;
}
- var obj = JSC.API.DebugServer.Class.make(ctx, server);
- JSC.C.JSValueProtect(ctx, obj);
- server.thisObject = JSValue.c(obj);
+ const obj = server.toJS(globalObject);
+ obj.protect();
+ server.thisObject = obj;
return obj;
} else {
- var server = JSC.API.Server.init(config, ctx.ptr());
+ var server = JSC.API.HTTPServer.init(config, globalObject.ptr());
+ exception_value = &server.thisObject;
server.listen();
- if (!server.thisObject.isEmpty()) {
- exception.* = server.thisObject.asObjectRef();
+ if (!exception_value.isEmpty()) {
+ exception_value.unprotect();
+ globalObject.throwValue(exception_value.*);
server.thisObject = JSC.JSValue.zero;
server.deinit();
- return null;
+ return .zero;
}
- var obj = JSC.API.Server.Class.make(ctx, server);
- JSC.C.JSValueProtect(ctx, obj);
- server.thisObject = JSValue.c(obj);
+ const obj = server.toJS(globalObject);
+ obj.protect();
+
+ server.thisObject = obj;
return obj;
}
}
@@ -3021,47 +2656,43 @@ comptime {
}
pub fn allocUnsafe(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
-
- const length = @as(
- usize,
- @intCast(@min(
- @max(1, (args.nextEat() orelse JSC.JSValue.jsNumber(@as(i32, 1))).toInt32()),
- std.math.maxInt(i32),
- )),
- );
- var bytes = bun.default_allocator.alloc(u8, length) catch {
- JSC.JSError(bun.default_allocator, "OOM! Out of memory", .{}, ctx, exception);
- return null;
- };
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1);
+ const size = arguments.ptr[0];
+ if (!size.isUInt32AsAnyInt()) {
+ globalThis.throwInvalidArguments("Expected a positive number", .{});
+ return JSC.JSValue.zero;
+ }
- return JSC.MarkedArrayBuffer.fromBytes(
- bytes,
- bun.default_allocator,
- .Uint8Array,
- ).toJSObjectRef(ctx, null);
+ return JSC.JSValue.createUninitializedUint8Array(globalThis, size.toUInt64NoTruncate());
}
pub fn mmapFile(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+) callconv(.C) JSC.JSValue {
+ const arguments_ = callframe.arguments(2);
+ var args = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
+ defer args.deinit();
var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
- const path = getFilePath(ctx, arguments[0..@min(1, arguments.len)], &buf, exception) orelse return null;
- args.eat();
+ const path = brk: {
+ if (args.nextEat()) |path| {
+ if (path.isString()) {
+ const path_str = path.toSlice(globalThis, args.arena.allocator());
+ if (path_str.len > bun.MAX_PATH_BYTES) {
+ globalThis.throwInvalidArguments("Path too long", .{});
+ return JSC.JSValue.zero;
+ }
+ const paths = &[_]string{path_str.slice()};
+ break :brk bun.path.joinAbsStringBuf(bun.fs.FileSystem.instance.top_level_dir, &buf, paths, .auto);
+ }
+ }
+ globalThis.throwInvalidArguments("Expected a path", .{});
+ return JSC.JSValue.zero;
+ };
buf[path.len] = 0;
@@ -3076,16 +2707,16 @@ pub fn mmapFile(
var map_size: ?usize = null;
if (args.nextEat()) |opts| {
- const sync = opts.get(ctx.ptr(), "sync") orelse JSC.JSValue.jsBoolean(false);
- const shared = opts.get(ctx.ptr(), "shared") orelse JSC.JSValue.jsBoolean(true);
+ const sync = opts.get(globalThis, "sync") orelse JSC.JSValue.jsBoolean(false);
+ const shared = opts.get(globalThis, "shared") orelse JSC.JSValue.jsBoolean(true);
flags |= @as(u32, if (sync.toBoolean()) sync_flags else 0);
flags |= @as(u32, if (shared.toBoolean()) std.os.MAP.SHARED else std.os.MAP.PRIVATE);
- if (opts.get(ctx.ptr(), "size")) |value| {
+ if (opts.get(globalThis, "size")) |value| {
map_size = @as(usize, @intCast(value.toInt64()));
}
- if (opts.get(ctx.ptr(), "offset")) |value| {
+ if (opts.get(globalThis, "offset")) |value| {
offset = @as(usize, @intCast(value.toInt64()));
offset = std.mem.alignBackwardAnyAlign(offset, std.mem.page_size);
}
@@ -3097,115 +2728,85 @@ pub fn mmapFile(
.result => |map| map,
.err => |err| {
- exception.* = err.toJS(ctx);
- return null;
+ globalThis.throwValue(err.toJSC(globalThis));
+ return .zero;
},
};
- return JSC.C.JSObjectMakeTypedArrayWithBytesNoCopy(ctx, JSC.C.JSTypedArrayType.kJSTypedArrayTypeUint8Array, @as(?*anyopaque, @ptrCast(map.ptr)), map.len, struct {
+ return JSC.C.JSObjectMakeTypedArrayWithBytesNoCopy(globalThis, JSC.C.JSTypedArrayType.kJSTypedArrayTypeUint8Array, @as(?*anyopaque, @ptrCast(map.ptr)), map.len, struct {
pub fn x(ptr: ?*anyopaque, size: ?*anyopaque) callconv(.C) void {
_ = JSC.Node.Syscall.munmap(@as([*]align(std.mem.page_size) u8, @ptrCast(@alignCast(ptr)))[0..@intFromPtr(size)]);
}
- }.x, @as(?*anyopaque, @ptrFromInt(map.len)), exception);
+ }.x, @as(?*anyopaque, @ptrFromInt(map.len)), null).?.value();
}
pub fn getTranspilerConstructor(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return JSC.API.JSTranspiler.getConstructor(ctx).asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return JSC.API.JSTranspiler.getConstructor(globalThis);
}
pub fn getFileSystemRouter(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- return JSC.API.FileSystemRouter.getConstructor(ctx).asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return JSC.API.FileSystemRouter.getConstructor(globalThis);
}
pub fn getHashObject(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("BunHash"));
- if (existing.isEmpty()) {
- return ctx.ptr().putCachedObject(
- &ZigString.init("BunHash"),
- JSC.JSValue.fromRef(JSC.C.JSObjectMake(ctx, Hash.Class.get().*, null)),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return HashObject.create(globalThis);
}
-pub const Hash = struct {
- pub const Class = NewClass(
- void,
- .{
- .name = "Hash",
- },
- .{
- .call = .{
- .rfn = call,
- },
- .wyhash = .{
- .rfn = hashWrap(std.hash.Wyhash).hash,
- },
- .adler32 = .{
- .rfn = hashWrap(std.hash.Adler32).hash,
- },
- .crc32 = .{
- .rfn = hashWrap(std.hash.Crc32).hash,
- },
- .cityHash32 = .{
- .rfn = hashWrap(std.hash.CityHash32).hash,
- },
- .cityHash64 = .{
- .rfn = hashWrap(std.hash.CityHash64).hash,
- },
- .murmur32v2 = .{
- .rfn = hashWrap(std.hash.murmur.Murmur2_32).hash,
- },
- .murmur32v3 = .{
- .rfn = hashWrap(std.hash.murmur.Murmur3_32).hash,
- },
- .murmur64v2 = .{
- .rfn = hashWrap(std.hash.murmur.Murmur2_64).hash,
- },
- },
- .{},
- );
+const HashObject = struct {
+ pub const wyhash = hashWrap(std.hash.Wyhash).hash;
+ pub const adler32 = hashWrap(std.hash.Adler32).hash;
+ pub const crc32 = hashWrap(std.hash.Crc32).hash;
+ pub const cityHash32 = hashWrap(std.hash.CityHash32).hash;
+ pub const cityHash64 = hashWrap(std.hash.CityHash64).hash;
+ pub const murmur32v2 = hashWrap(std.hash.murmur.Murmur2_32).hash;
+ pub const murmur32v3 = hashWrap(std.hash.murmur.Murmur3_32).hash;
+ pub const murmur64v2 = hashWrap(std.hash.murmur.Murmur2_64).hash;
+
+ pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ const function = JSC.createCallback(globalThis, ZigString.static("hash"), 1, &wyhash);
+ const fns = comptime .{
+ "wyhash",
+ "adler32",
+ "crc32",
+ "cityHash32",
+ "cityHash64",
+ "murmur32v2",
+ "murmur32v3",
+ "murmur64v2",
+ };
+ inline for (fns) |name| {
+ const value = JSC.createCallback(
+ globalThis,
+ ZigString.static(name),
+ 1,
+ &@field(HashObject, name),
+ );
+ function.put(globalThis, comptime ZigString.static(name), value);
+ }
- pub fn call(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- return hashWrap(std.hash.Wyhash).hash({}, ctx, null, null, arguments, exception);
+ return function;
}
- fn hashWrap(comptime Hasher: anytype) type {
+
+ fn hashWrap(comptime Hasher_: anytype) type {
return struct {
+ const Hasher = Hasher_;
pub fn hash(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(2).slice();
+ var args = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments);
+ defer args.deinit();
+
var input: []const u8 = "";
var input_slice = ZigString.Slice.empty;
defer input_slice.deinit();
@@ -3229,14 +2830,14 @@ pub const Hash = struct {
.BigUint64Array,
.DataView,
=> {
- var array_buffer = arg.asArrayBuffer(ctx.ptr()) orelse {
- JSC.throwInvalidArguments("ArrayBuffer conversion error", .{}, ctx, exception);
- return null;
+ var array_buffer = arg.asArrayBuffer(globalThis) orelse {
+ globalThis.throwInvalidArguments("ArrayBuffer conversion error", .{});
+ return .zero;
};
input = array_buffer.byteSlice();
},
else => {
- input_slice = arg.toSlice(ctx.ptr(), bun.default_allocator);
+ input_slice = arg.toSlice(globalThis, bun.default_allocator);
input = input_slice.slice();
},
}
@@ -3248,7 +2849,7 @@ pub const Hash = struct {
const Function = if (@hasDecl(Hasher, "hashWithSeed")) Hasher.hashWithSeed else Hasher.hash;
var function_args: std.meta.ArgsTuple(@TypeOf(Function)) = undefined;
if (comptime std.meta.fields(std.meta.ArgsTuple(@TypeOf(Function))).len == 1) {
- return JSC.JSValue.jsNumber(Function(input)).asObjectRef();
+ return JSC.JSValue.jsNumber(Function(input));
} else {
var seed: u64 = 0;
if (args.nextEat()) |arg| {
@@ -3267,9 +2868,9 @@ pub const Hash = struct {
const value = @call(.auto, Function, function_args);
if (@TypeOf(value) == u32) {
- return JSC.JSValue.jsNumber(@as(u32, @bitCast(value))).asObjectRef();
+ return JSC.JSValue.jsNumber(@as(u32, @bitCast(value)));
}
- return JSC.JSValue.fromUInt64NoTruncate(ctx.ptr(), value).asObjectRef();
+ return JSC.JSValue.fromUInt64NoTruncate(globalThis, value);
}
}
};
@@ -3277,66 +2878,45 @@ pub const Hash = struct {
};
pub fn getTOMLObject(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("TOML"));
- if (existing.isEmpty()) {
- return ctx.ptr().putCachedObject(
- &ZigString.init("TOML"),
- JSValue.fromRef(js.JSObjectMake(ctx, TOML.Class.get().?[0], null)),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return TOMLObject.create(globalThis);
}
pub fn getUnsafe(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
-) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("Unsafe"));
- if (existing.isEmpty()) {
- return ctx.ptr().putCachedObject(
- &ZigString.init("Unsafe"),
- JSValue.fromRef(js.JSObjectMake(ctx, Unsafe.Class.get().?[0], null)),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+) callconv(.C) JSC.JSValue {
+ return UnsafeObject.create(globalThis);
}
-pub const Unsafe = struct {
- pub const Class = NewClass(
- void,
- .{ .name = "Unsafe", .read_only = true },
- .{
- .segfault = .{
- .rfn = __debug__doSegfault,
- },
- .arrayBufferToString = .{
- .rfn = arrayBufferToString,
- },
- .gcAggressionLevel = .{
- .rfn = &JSC.wrapWithHasContainer(Unsafe, "gcAggressionLevel", false, false, false),
- },
- },
- .{},
- );
+const UnsafeObject = struct {
+ pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ const object = JSValue.createEmptyObject(globalThis, 3);
+ const fields = comptime .{
+ .gcAggressionLevel = &gcAggressionLevel,
+ .segfault = &__debug__doSegfault,
+ .arrayBufferToString = &arrayBufferToString,
+ };
+ inline for (comptime std.meta.fieldNames(@TypeOf(fields))) |name| {
+ object.put(
+ globalThis,
+ comptime ZigString.static(name),
+ JSC.createCallback(globalThis, comptime ZigString.static(name), 1, comptime @field(fields, name)),
+ );
+ }
+ return object;
+ }
pub fn gcAggressionLevel(
globalThis: *JSC.JSGlobalObject,
- value_: ?JSValue,
- ) JSValue {
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
const ret = JSValue.jsNumber(@as(i32, @intFromEnum(globalThis.bunVM().aggressive_garbage_collection)));
+ const value = callframe.arguments(1).ptr[0];
- if (value_) |value| {
+ if (!value.isEmptyOrUndefinedOrNull()) {
switch (value.coerce(i32, globalThis)) {
1 => globalThis.bunVM().aggressive_garbage_collection = .mild,
2 => globalThis.bunVM().aggressive_garbage_collection = .aggressive,
@@ -3349,212 +2929,87 @@ pub const Unsafe = struct {
// For testing the segfault handler
pub fn __debug__doSegfault(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- _ = ctx;
+ _: *JSC.JSGlobalObject,
+ _: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
const Reporter = @import("../../report.zig");
Reporter.globalError(error.SegfaultTest, null);
}
pub fn arrayBufferToString(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- args: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- const array_buffer = JSC.ArrayBuffer.fromTypedArray(ctx, JSC.JSValue.fromRef(args[0]), exception);
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const args = callframe.arguments(2).slice();
+ const array_buffer = JSC.ArrayBuffer.fromTypedArray(globalThis, args[0]);
switch (array_buffer.typed_array_type) {
.Uint16Array, .Int16Array => {
var zig_str = ZigString.init("");
zig_str._unsafe_ptr_do_not_use = @as([*]const u8, @ptrCast(@alignCast(array_buffer.ptr)));
zig_str.len = array_buffer.len;
zig_str.markUTF16();
- // the deinitializer for string causes segfaults
- // if we don't clone it
- return ZigString.toValueGC(&zig_str, ctx.ptr()).asObjectRef();
+ return zig_str.toValueGC(globalThis);
},
else => {
- // the deinitializer for string causes segfaults
- // if we don't clone it
- return ZigString.init(array_buffer.slice()).toValueGC(ctx.ptr()).asObjectRef();
+ return ZigString.init(array_buffer.slice()).toValueGC(globalThis);
},
}
}
};
-// pub const Lockfile = struct {
-// const BunLockfile = @import("../../install/install.zig").Lockfile;
-// lockfile: *BunLockfile,
-
-// pub const RefCountedLockfile = bun.RefCount(Lockfile, true);
-
-// pub const StaticClass = NewClass(
-// void,
-// .{
-// .name = "Lockfile",
-// .read_only = true,
-// },
-// .{
-// .load = .{
-// .rfn = &BunLockfile.load,
-// },
-// },
-// .{},
-// );
-
-// pub const Class = NewClass(
-// RefCountedLockfile,
-// .{
-// .name = "Lockfile",
-// .read_only = true,
-// },
-// .{
-// .findPackagesByName = .{
-// .rfn = &BunLockfile.load,
-// },
-// .dependencies = .{
-// .rfn = &BunLockfile.load,
-// },
-// },
-// .{},
-// );
-
-// pub fn deinit(this: *Lockfile) void {
-// this.lockfile.deinit();
-// }
-
-// pub fn load(
-// // this
-// _: void,
-// ctx: js.JSContextRef,
-// // function
-// _: js.JSObjectRef,
-// // thisObject
-// _: js.JSObjectRef,
-// arguments: []const js.JSValueRef,
-// exception: js.ExceptionRef,
-// ) js.JSValueRef {
-// if (arguments.len == 0) {
-// JSError(undefined, "Expected file path string or buffer", .{}, ctx, exception);
-// return null;
-// }
-
-// var lockfile: *BunLockfile = getAllocator(ctx).create(BunLockfile) catch return JSValue.jsUndefined().asRef();
-
-// var log = logger.Log.init(default_allocator);
-// var args_slice = @ptrCast([*]const JSValue, arguments.ptr)[0..arguments.len];
-
-// var arguments_slice = Node.ArgumentsSlice.init(args_slice);
-// var path_or_buffer = Node.PathLike.fromJS(ctx, &arguments_slice, exception) orelse {
-// getAllocator(ctx).destroy(lockfile);
-// JSError(undefined, "Expected file path string or buffer", .{}, ctx, exception);
-// return null;
-// };
-
-// const load_from_disk_result = switch (path_or_buffer) {
-// Node.PathLike.Tag.string => lockfile.loadFromDisk(getAllocator(ctx), &log, path_or_buffer.string),
-// Node.PathLike.Tag.buffer => lockfile.loadFromBytes(getAllocator(ctx), path_or_buffer.buffer.slice(), &log),
-// else => {
-// getAllocator(ctx).destroy(lockfile);
-// JSError(undefined, "Expected file path string or buffer", .{}, ctx, exception);
-// return null;
-// },
-// };
-
-// switch (load_from_disk_result) {
-// .err => |cause| {
-// defer getAllocator(ctx).destroy(lockfile);
-// switch (cause.step) {
-// .open_file => {
-// JSError(undefined, "error opening lockfile: {s}", .{
-// @errorName(cause.value),
-// }, ctx, exception);
-// return null;
-// },
-// .parse_file => {
-// JSError(undefined, "error parsing lockfile: {s}", .{
-// @errorName(cause.value),
-// }, ctx, exception);
-// return null;
-// },
-// .read_file => {
-// JSError(undefined, "error reading lockfile: {s}", .{
-// @errorName(cause.value),
-// }, ctx, exception);
-// return null;
-// },
-// }
-// },
-// .ok => {},
-// }
-// }
-// };
-
-pub const TOML = struct {
+const TOMLObject = struct {
const TOMLParser = @import("../../toml/toml_parser.zig").TOML;
- pub const Class = NewClass(
- void,
- .{
- .name = "TOML",
- .read_only = true,
- },
- .{
- .parse = .{
- .rfn = TOML.parse,
- },
- },
- .{},
- );
+
+ pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ const object = JSValue.createEmptyObject(globalThis, 1);
+ object.put(
+ globalThis,
+ ZigString.static("parse"),
+ JSC.createCallback(
+ globalThis,
+ ZigString.static("parse"),
+ 1,
+ &parse,
+ ),
+ );
+
+ return object;
+ }
pub fn parse(
- // this
- _: void,
- ctx: js.JSContextRef,
- // function
- _: js.JSObjectRef,
- // thisObject
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- var arena = @import("root").bun.ArenaAllocator.init(getAllocator(ctx));
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ var arena = @import("root").bun.ArenaAllocator.init(globalThis.allocator());
var allocator = arena.allocator();
defer arena.deinit();
var log = logger.Log.init(default_allocator);
- var input_str = ZigString.init("");
- JSValue.fromRef(arguments[0]).toZigString(&input_str, ctx.ptr());
- var needs_deinit = false;
- var input = input_str.slice();
- if (input_str.is16Bit()) {
- input = std.fmt.allocPrint(allocator, "{}", .{input_str}) catch unreachable;
- needs_deinit = true;
- }
- var source = logger.Source.initPathString("input.toml", input);
+ const arguments = callframe.arguments(1).slice();
+
+ var input_slice = arguments[0].toSlice(globalThis, bun.default_allocator);
+ defer input_slice.deinit();
+ var source = logger.Source.initPathString("input.toml", input_slice.slice());
var parse_result = TOMLParser.parse(&source, &log, allocator) catch {
- exception.* = log.toJS(ctx.ptr(), default_allocator, "Failed to parse toml").asObjectRef();
- return null;
+ globalThis.throwValue(log.toJS(globalThis, default_allocator, "Failed to parse toml"));
+ return .zero;
};
// for now...
- var buffer_writer = try js_printer.BufferWriter.init(allocator);
+ var buffer_writer = js_printer.BufferWriter.init(allocator) catch {
+ globalThis.throwValue(log.toJS(globalThis, default_allocator, "Failed to print toml"));
+ return .zero;
+ };
var writer = js_printer.BufferPrinter.init(buffer_writer);
_ = js_printer.printJSON(*js_printer.BufferPrinter, &writer, parse_result, &source) catch {
- exception.* = log.toJS(ctx.ptr(), default_allocator, "Failed to print toml").asObjectRef();
- return null;
+ globalThis.throwValue(log.toJS(globalThis, default_allocator, "Failed to print toml"));
+ return .zero;
};
var slice = writer.ctx.buffer.toOwnedSliceLeaky();
- var out = ZigString.init(slice);
+ var out = bun.String.fromUTF8(slice);
+ defer out.deref();
- const out_value = js.JSValueMakeFromJSONString(ctx, out.toJSStringRef());
- return out_value;
+ return out.toJSForParseJSON(globalThis);
}
};
@@ -4284,65 +3739,76 @@ pub const Timer = struct {
}
};
-pub const FFI = struct {
- pub const Class = NewClass(
- void,
- .{ .name = "FFI", .has_dom_calls = true },
- .{
- .viewSource = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.FFI, "print", false, false, true),
- },
- .dlopen = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.FFI, "open", false, false, true),
- },
- .callback = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.FFI, "callback", false, false, false),
- },
- .linkSymbols = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.FFI, "linkSymbols", false, false, false),
- },
- .ptr = JSC.DOMCall("FFI", @This(), "ptr", f64, JSC.DOMEffect.forRead(.TypedArrayProperties)),
+pub const FFIObject = struct {
+ const fields = .{
+ .viewSource = JSC.wrapStaticMethod(
+ JSC.FFI,
+ "print",
+ false,
+ ),
+ .dlopen = JSC.wrapStaticMethod(JSC.FFI, "open", false),
+ .callback = JSC.wrapStaticMethod(JSC.FFI, "callback", false),
+ .linkSymbols = JSC.wrapStaticMethod(JSC.FFI, "linkSymbols", false),
+ .toBuffer = JSC.wrapStaticMethod(@This(), "toBuffer", false),
+ .toArrayBuffer = JSC.wrapStaticMethod(@This(), "toArrayBuffer", false),
+ .closeCallback = JSC.wrapStaticMethod(JSC.FFI, "closeCallback", false),
+ .CString = JSC.wrapStaticMethod(Bun.FFIObject, "newCString", false),
+ };
- .toBuffer = .{
- .rfn = &JSC.wrapWithHasContainer(@This(), "toBuffer", false, false, true),
- },
- .toArrayBuffer = .{
- .rfn = &JSC.wrapWithHasContainer(@This(), "toArrayBuffer", false, false, true),
- },
- .closeCallback = .{
- .rfn = &JSC.wrapWithHasContainer(JSC.FFI, "closeCallback", false, false, false),
- },
- },
- .{
- .read = .{
- .get = FFI.Reader.getter,
+ pub fn newCString(globalThis: *JSGlobalObject, value: JSValue, byteOffset: ?JSValue, lengthValue: ?JSValue) JSC.JSValue {
+ switch (FFIObject.getPtrSlice(globalThis, value, byteOffset, lengthValue)) {
+ .err => |err| {
+ return err;
},
- .CString = .{
- .get = UnsafeCString.getter,
+ .slice => |slice| {
+ return WebCore.Encoder.toString(slice.ptr, slice.len, globalThis, .utf8);
},
- },
- );
+ }
+ }
+
+ pub const dom_call = JSC.DOMCall("FFI", @This(), "ptr", f64, JSC.DOMEffect.forRead(.TypedArrayProperties));
+
+ pub fn toJS(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ const object = JSC.JSValue.createEmptyObject(globalObject, comptime std.meta.fieldNames(@TypeOf(fields)).len + 2);
+ inline for (comptime std.meta.fieldNames(@TypeOf(fields))) |field| {
+ object.put(
+ globalObject,
+ comptime ZigString.static(field),
+ JSC.createCallback(globalObject, comptime ZigString.static(field), 1, comptime @field(fields, field)),
+ );
+ }
+
+ dom_call.put(globalObject, object);
+ object.put(globalObject, ZigString.static("read"), Reader.toJS(globalObject));
+
+ return object;
+ }
pub const Reader = struct {
- pub const Class = NewClass(
- void,
- .{ .name = "FFI", .has_dom_calls = true },
- .{
- .u8 = JSC.DOMCall("Reader", @This(), "u8", i32, JSC.DOMEffect.forRead(.World)),
- .u16 = JSC.DOMCall("Reader", @This(), "u16", i32, JSC.DOMEffect.forRead(.World)),
- .u32 = JSC.DOMCall("Reader", @This(), "u32", i32, JSC.DOMEffect.forRead(.World)),
- .ptr = JSC.DOMCall("Reader", @This(), "ptr", i52, JSC.DOMEffect.forRead(.World)),
- .i8 = JSC.DOMCall("Reader", @This(), "i8", i32, JSC.DOMEffect.forRead(.World)),
- .i16 = JSC.DOMCall("Reader", @This(), "i16", i32, JSC.DOMEffect.forRead(.World)),
- .i32 = JSC.DOMCall("Reader", @This(), "i32", i32, JSC.DOMEffect.forRead(.World)),
- .i64 = JSC.DOMCall("Reader", @This(), "i64", i64, JSC.DOMEffect.forRead(.World)),
- .u64 = JSC.DOMCall("Reader", @This(), "u64", u64, JSC.DOMEffect.forRead(.World)),
- .intptr = JSC.DOMCall("Reader", @This(), "intptr", i52, JSC.DOMEffect.forRead(.World)),
- .f32 = JSC.DOMCall("Reader", @This(), "f32", f64, JSC.DOMEffect.forRead(.World)),
- .f64 = JSC.DOMCall("Reader", @This(), "f64", f64, JSC.DOMEffect.forRead(.World)),
- },
- .{},
- );
+ pub const DOMCalls = .{
+ .u8 = JSC.DOMCall("Reader", @This(), "u8", i32, JSC.DOMEffect.forRead(.World)),
+ .u16 = JSC.DOMCall("Reader", @This(), "u16", i32, JSC.DOMEffect.forRead(.World)),
+ .u32 = JSC.DOMCall("Reader", @This(), "u32", i32, JSC.DOMEffect.forRead(.World)),
+ .ptr = JSC.DOMCall("Reader", @This(), "ptr", i52, JSC.DOMEffect.forRead(.World)),
+ .i8 = JSC.DOMCall("Reader", @This(), "i8", i32, JSC.DOMEffect.forRead(.World)),
+ .i16 = JSC.DOMCall("Reader", @This(), "i16", i32, JSC.DOMEffect.forRead(.World)),
+ .i32 = JSC.DOMCall("Reader", @This(), "i32", i32, JSC.DOMEffect.forRead(.World)),
+ .i64 = JSC.DOMCall("Reader", @This(), "i64", i64, JSC.DOMEffect.forRead(.World)),
+ .u64 = JSC.DOMCall("Reader", @This(), "u64", u64, JSC.DOMEffect.forRead(.World)),
+ .intptr = JSC.DOMCall("Reader", @This(), "intptr", i52, JSC.DOMEffect.forRead(.World)),
+ .f32 = JSC.DOMCall("Reader", @This(), "f32", f64, JSC.DOMEffect.forRead(.World)),
+ .f64 = JSC.DOMCall("Reader", @This(), "f64", f64, JSC.DOMEffect.forRead(.World)),
+ };
+
+ pub fn toJS(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ const obj = JSC.JSValue.createEmptyObject(globalThis, std.meta.fieldNames(@TypeOf(Reader.DOMCalls)).len);
+
+ inline for (comptime std.meta.fieldNames(@TypeOf(Reader.DOMCalls))) |field| {
+ @field(Reader.DOMCalls, field).put(globalThis, obj);
+ }
+
+ return obj;
+ }
pub fn @"u8"(
_: *JSGlobalObject,
@@ -4581,28 +4047,6 @@ pub const FFI = struct {
const value = @as(*align(1) i64, @ptrFromInt(addr)).*;
return JSValue.fromInt64NoTruncate(global, value);
}
-
- pub fn getter(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("FFIReader"));
- if (existing.isEmpty()) {
- var prototype = JSC.C.JSObjectMake(ctx, FFI.Reader.Class.get().?[0], null);
- var base = JSC.C.JSObjectMake(ctx, null, null);
- JSC.C.JSObjectSetPrototype(ctx, base, prototype);
- FFI.Reader.Class.putDOMCalls(ctx, JSC.JSValue.c(base));
- return ctx.ptr().putCachedObject(
- ZigString.static("FFIReader"),
- JSValue.fromRef(base),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
- }
};
pub fn ptr(
@@ -4879,71 +4323,10 @@ pub const FFI = struct {
}
pub fn getter(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("FFI"));
- if (existing.isEmpty()) {
- var prototype = JSC.C.JSObjectMake(ctx, FFI.Class.get().?[0], null);
- var base = JSC.C.JSObjectMake(ctx, null, null);
- JSC.C.JSObjectSetPrototype(ctx, base, prototype);
- FFI.Class.putDOMCalls(ctx, JSC.JSValue.c(base));
- return ctx.ptr().putCachedObject(
- ZigString.static("FFI"),
- JSValue.fromRef(base),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
- }
-};
-
-pub const UnsafeCString = struct {
- pub fn constructor(
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- len: usize,
- args: [*c]const js.JSValueRef,
- exception: js.ExceptionRef,
- ) callconv(.C) js.JSObjectRef {
- if (len == 0) {
- JSC.throwInvalidArguments("Expected a ptr", .{}, ctx, exception);
- return null;
- }
-
- return newCString(ctx.ptr(), JSC.JSValue.fromRef(args[0]), if (len > 1) JSC.JSValue.fromRef(args[1]) else null, if (len > 2) JSC.JSValue.fromRef(args[2]) else null).asObjectRef();
- }
-
- pub fn newCString(globalThis: *JSGlobalObject, value: JSValue, byteOffset: ?JSValue, lengthValue: ?JSValue) JSC.JSValue {
- switch (FFI.getPtrSlice(globalThis, value, byteOffset, lengthValue)) {
- .err => |err| {
- return err;
- },
- .slice => |slice| {
- return WebCore.Encoder.toString(slice.ptr, slice.len, globalThis, .utf8);
- },
- }
- }
-
- pub fn getter(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- var existing = ctx.ptr().getCachedObject(ZigString.static("UnsafeCString"));
- if (existing.isEmpty()) {
- return ctx.ptr().putCachedObject(
- ZigString.static("UnsafeCString"),
- JSValue.fromRef(JSC.C.JSObjectMakeConstructor(ctx, null, constructor)),
- ).asObjectRef();
- }
-
- return existing.asObjectRef();
+ globalObject: *JSC.JSGlobalObject,
+ _: *JSC.JSObject,
+ ) callconv(.C) JSC.JSValue {
+ return FFIObject.toJS(globalObject);
}
};
@@ -5144,5 +4527,6 @@ pub usingnamespace @import("./bun/subprocess.zig");
comptime {
if (!JSC.is_bindgen) {
_ = Crypto.JSPasswordObject.JSPasswordObject__create;
+ BunObject.exportAll();
}
}
diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig
index 05c382359..7d8025872 100644
--- a/src/bun.js/api/bun/socket.zig
+++ b/src/bun.js/api/bun/socket.zig
@@ -543,9 +543,15 @@ pub const Listener = struct {
pub fn listen(
globalObject: *JSC.JSGlobalObject,
opts: JSValue,
- exception: JSC.C.ExceptionRef,
) JSValue {
log("listen", .{});
+ var exception_ = [1]JSC.JSValueRef{null};
+ var exception: JSC.C.ExceptionRef = &exception_;
+ defer {
+ if (exception_[0] != null) {
+ globalObject.throwValue(exception_[0].?.value());
+ }
+ }
if (opts.isEmptyOrUndefinedOrNull() or opts.isBoolean() or !opts.isObject()) {
exception.* = JSC.toInvalidArguments("Expected object", .{}, globalObject).asObjectRef();
return .zero;
@@ -877,8 +883,14 @@ pub const Listener = struct {
pub fn connect(
globalObject: *JSC.JSGlobalObject,
opts: JSValue,
- exception: JSC.C.ExceptionRef,
) JSValue {
+ var exception_ = [1]JSC.JSValueRef{null};
+ var exception: JSC.C.ExceptionRef = &exception_;
+ defer {
+ if (exception_[0] != null) {
+ globalObject.throwValue(exception_[0].?.value());
+ }
+ }
if (opts.isEmptyOrUndefinedOrNull() or opts.isBoolean() or !opts.isObject()) {
exception.* = JSC.toInvalidArguments("Expected options object", .{}, globalObject).asObjectRef();
return .zero;
diff --git a/src/bun.js/api/crypto.classes.ts b/src/bun.js/api/crypto.classes.ts
index b97ed4b1a..471e87702 100644
--- a/src/bun.js/api/crypto.classes.ts
+++ b/src/bun.js/api/crypto.classes.ts
@@ -34,6 +34,49 @@ const named = names.map(name => {
});
export default [
+ define({
+ name: "Crypto",
+ construct: true,
+ finalize: false,
+
+ proto: {
+ getRandomValues: {
+ fn: "getRandomValues",
+ DOMJIT: {
+ returns: "JSValue",
+ "pure": false,
+ args: ["JSUint8Array"],
+ },
+ },
+ randomUUID: {
+ fn: "randomUUID",
+ length: 1,
+ DOMJIT: {
+ returns: "JSString",
+ "pure": false,
+ args: [],
+ },
+ },
+ timingSafeEqual: {
+ fn: "timingSafeEqual",
+ DOMJIT: {
+ returns: "JSValue",
+ "pure": false,
+ args: ["JSUint8Array", "JSUint8Array"],
+ },
+ length: 2,
+ },
+ randomInt: {
+ fn: "randomInt",
+ length: 2,
+ },
+ scryptSync: {
+ fn: "doScryptSync",
+ length: 2,
+ },
+ },
+ klass: {},
+ }),
...named,
define({
name: "CryptoHasher",
diff --git a/src/bun.js/api/ffi.classes.ts b/src/bun.js/api/ffi.classes.ts
new file mode 100644
index 000000000..0a146b22e
--- /dev/null
+++ b/src/bun.js/api/ffi.classes.ts
@@ -0,0 +1,23 @@
+import { define } from "../scripts/class-definitions";
+
+export default [
+ define({
+ name: "FFI",
+ construct: true,
+ noConstructor: true,
+ finalize: true,
+ klass: {},
+ proto: {
+ close: {
+ fn: "close",
+ length: 0,
+ },
+
+ symbols: {
+ cache: "symbolsValue",
+ getter: "getSymbols",
+ },
+ },
+ values: ["symbolsValue"],
+ }),
+];
diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig
index 3966d8287..1b265af11 100644
--- a/src/bun.js/api/ffi.zig
+++ b/src/bun.js/api/ffi.zig
@@ -45,11 +45,11 @@ const FetchEvent = WebCore.FetchEvent;
const js = @import("root").bun.JSC.C;
const JSC = @import("root").bun.JSC;
const JSError = @import("../base.zig").JSError;
-const d = @import("../base.zig").d;
+
const MarkedArrayBuffer = @import("../base.zig").MarkedArrayBuffer;
const getAllocator = @import("../base.zig").getAllocator;
const JSValue = @import("root").bun.JSC.JSValue;
-const NewClass = @import("../base.zig").NewClass;
+
const Microtask = @import("root").bun.JSC.Microtask;
const JSGlobalObject = @import("root").bun.JSC.JSGlobalObject;
const ExceptionValueRef = @import("root").bun.JSC.ExceptionValueRef;
@@ -82,12 +82,9 @@ pub const FFI = struct {
functions: bun.StringArrayHashMapUnmanaged(Function) = .{},
closed: bool = false,
- pub const Class = JSC.NewClass(
- FFI,
- .{ .name = "class" },
- .{ .call = JSC.wrapWithHasContainer(FFI, "close", false, true, true) },
- .{},
- );
+ pub usingnamespace JSC.Codegen.JSFFI;
+
+ pub fn finalize(_: *FFI) callconv(.C) void {}
pub fn closeCallback(globalThis: *JSGlobalObject, ctx: JSValue) JSValue {
var function = ctx.asPtr(Function);
@@ -147,7 +144,8 @@ pub const FFI = struct {
pub fn close(
this: *FFI,
globalThis: *JSC.JSGlobalObject,
- ) JSValue {
+ _: *JSC.CallFrame,
+ ) callconv(.C) JSValue {
JSC.markBinding(@src());
if (this.closed) {
return JSC.JSValue.jsUndefined();
@@ -320,9 +318,9 @@ pub const FFI = struct {
};
};
- var obj = JSC.JSValue.c(JSC.C.JSObjectMake(global, null, null));
- JSC.C.JSValueProtect(global, obj.asObjectRef());
- defer JSC.C.JSValueUnprotect(global, obj.asObjectRef());
+ var obj = JSC.JSValue.createEmptyObject(global, symbols.values().len);
+ obj.protect();
+ defer obj.unprotect();
for (symbols.values()) |*function| {
const function_name = function.base_name.?;
@@ -400,9 +398,14 @@ pub const FFI = struct {
.functions = symbols,
};
- var close_object = JSC.JSValue.c(Class.make(global, lib));
+ const js_object = lib.toJS(global);
+ JSC.Codegen.JSFFI.symbolsValueSetCached(js_object, global, obj);
+ return js_object;
+ }
- return JSC.JSValue.createObject2(global, &ZigString.init("close"), &ZigString.init("symbols"), close_object, obj);
+ pub fn getSymbols(_: *FFI, _: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
+ // This shouldn't be called. The cachedValue is what should be called.
+ return .undefined;
}
pub fn linkSymbols(global: *JSGlobalObject, object: JSC.JSValue) JSC.JSValue {
@@ -498,9 +501,9 @@ pub const FFI = struct {
.functions = symbols,
};
- var close_object = JSC.JSValue.c(Class.make(global, lib));
-
- return JSC.JSValue.createObject2(global, ZigString.static("close"), ZigString.static("symbols"), close_object, obj);
+ const js_object = lib.toJS(global);
+ JSC.Codegen.JSFFI.symbolsValueSetCached(js_object, global, obj);
+ return js_object;
}
pub fn generateSymbolForFunction(global: *JSGlobalObject, allocator: std.mem.Allocator, value: JSC.JSValue, function: *Function) !?JSValue {
JSC.markBinding(@src());
diff --git a/src/bun.js/api/filesystem_router.zig b/src/bun.js/api/filesystem_router.zig
index edb666040..c15826c31 100644
--- a/src/bun.js/api/filesystem_router.zig
+++ b/src/bun.js/api/filesystem_router.zig
@@ -21,11 +21,10 @@ const JSError = Base.JSError;
const JSValue = JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;
const strings = @import("root").bun.strings;
-const NewClass = Base.NewClass;
+
const To = Base.To;
const Request = WebCore.Request;
-const FetchEvent = WebCore.FetchEvent;
const URLPath = @import("../../http/url_path.zig");
const URL = @import("../../url.zig").URL;
const Log = @import("root").bun.logger;
@@ -41,117 +40,6 @@ const default_extensions = &[_][]const u8{
"js",
};
-const DeprecatedGlobalRouter = struct {
- pub fn deprecatedBunGlobalMatch(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- if (arguments.len == 0) {
- JSError(getAllocator(ctx), "Expected string, FetchEvent, or Request but there were no arguments", .{}, ctx, exception);
- return null;
- }
-
- const arg: JSC.JSValue = brk: {
- if (FetchEvent.Class.isLoaded()) {
- if (JSValue.as(JSValue.fromRef(arguments[0]), FetchEvent)) |fetch_event| {
- if (fetch_event.request_context != null) {
- return deprecatedMatchFetchEvent(ctx, fetch_event, exception);
- }
-
- // When disconencted, we still have a copy of the request data in here
- break :brk JSC.JSValue.fromRef(fetch_event.getRequest(ctx, null, undefined, null));
- }
- }
- break :brk JSC.JSValue.fromRef(arguments[0]);
- };
-
- var router = JavaScript.VirtualMachine.get().bundler.router orelse {
- JSError(getAllocator(ctx), "Bun.match needs a framework configured with routes", .{}, ctx, exception);
- return null;
- };
-
- var path_: ?ZigString.Slice = null;
- var req_url_slice: ZigString.Slice = .{};
- defer req_url_slice.deinit();
- var pathname: string = "";
- defer {
- if (path_) |path| {
- path.deinit();
- }
- }
-
- if (arg.isString()) {
- var path_string = arg.getZigString(ctx);
- path_ = path_string.toSlice(bun.default_allocator);
- var url = URL.parse(path_.?.slice());
- pathname = url.pathname;
- } else if (arg.as(Request)) |req| {
- req_url_slice = req.url.toUTF8(bun.default_allocator);
- var url = URL.parse(req_url_slice.slice());
- pathname = url.pathname;
- }
-
- if (path_ == null) {
- JSError(getAllocator(ctx), "Expected string, FetchEvent, or Request", .{}, ctx, exception);
- return null;
- }
-
- const url_path = URLPath.parse(path_.?.slice()) catch {
- JSError(getAllocator(ctx), "Could not parse URL path", .{}, ctx, exception);
- return null;
- };
-
- var match_params_fallback = std.heap.stackFallback(1024, bun.default_allocator);
- var match_params_allocator = match_params_fallback.get();
- var match_params = Router.Param.List{};
- match_params.ensureTotalCapacity(match_params_allocator, 16) catch unreachable;
- var prev_allocator = router.routes.allocator;
- router.routes.allocator = match_params_allocator;
- defer router.routes.allocator = prev_allocator;
- if (router.routes.matchPage("", url_path, &match_params)) |matched| {
- return createRouteObjectFromMatch(ctx, &matched);
- }
- // router.routes.matchPage
-
- return JSC.JSValue.jsNull().asObjectRef();
- }
-
- fn deprecatedMatchFetchEvent(
- ctx: js.JSContextRef,
- fetch_event: *const FetchEvent,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- return createRouteObject(ctx, fetch_event.request_context.?);
- }
-
- fn createRouteObject(ctx: js.JSContextRef, req: *const http.RequestContext) js.JSValueRef {
- const route = &(req.matched_route orelse {
- return js.JSValueMakeNull(ctx);
- });
-
- return createRouteObjectFromMatch(ctx, route);
- }
-
- fn createRouteObjectFromMatch(
- ctx: js.JSContextRef,
- route: *const Router.Match,
- ) js.JSValueRef {
- var matched = MatchedRoute.init(
- getAllocator(ctx),
- route.*,
- JSC.VirtualMachine.get().refCountedString(JSC.VirtualMachine.get().origin.href, null, false),
- JSC.VirtualMachine.get().refCountedString(JSC.VirtualMachine.get().bundler.options.routes.asset_prefix_path, null, false),
- JSC.VirtualMachine.get().refCountedString(JSC.VirtualMachine.get().bundler.fs.top_level_dir, null, false),
- ) catch unreachable;
-
- return matched.toJS(ctx).asObjectRef();
- }
-};
-
pub const FileSystemRouter = struct {
origin: ?*JSC.RefString = null,
base_dir: ?*JSC.RefString = null,
@@ -764,5 +652,3 @@ pub const MatchedRoute = struct {
return JSValue.createEmptyObject(globalThis, 0);
}
};
-
-pub const deprecatedBunGlobalMatch = DeprecatedGlobalRouter.deprecatedBunGlobalMatch;
diff --git a/src/bun.js/api/server.classes.ts b/src/bun.js/api/server.classes.ts
index 3aaea871f..7db8a3444 100644
--- a/src/bun.js/api/server.classes.ts
+++ b/src/bun.js/api/server.classes.ts
@@ -5,21 +5,56 @@ function generate(name) {
name,
proto: {
fetch: {
- fn: "fetch",
+ fn: "doFetch",
length: 1,
},
+ upgrade: {
+ fn: "doUpgrade",
+ length: 1,
+ },
+ publish: {
+ fn: "doPublish",
+ length: 3,
+ },
+ reload: {
+ fn: "doReload",
+ length: 2,
+ },
+ stop: {
+ fn: "doStop",
+ length: 1,
+ },
+ port: {
+ getter: "getPort",
+ },
+ pendingRequests: {
+ getter: "getPendingRequests",
+ },
+ pendingWebSockets: {
+ getter: "getPendingWebSockets",
+ },
+ hostname: {
+ getter: "getHostname",
+ cache: true,
+ },
+ protocol: {
+ getter: "getProtocol",
+ },
+ development: {
+ getter: "getDevelopment",
+ },
},
- values: ["callback"],
klass: {},
finalize: true,
construct: true,
+ noConstructor: true,
});
}
export default [
- // generate(`HTTPServer`),
- // generate(`DebugModeHTTPServer`),
- // generate(`HTTPSServer`),
- // generate(`DebugModeHTTPSServer`),
+ generate(`HTTPServer`),
+ generate(`DebugHTTPServer`),
+ generate(`HTTPSServer`),
+ generate(`DebugHTTPSServer`),
define({
name: "ServerWebSocket",
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index df3bdba1f..45c82b9fa 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -48,7 +48,7 @@ const JSError = @import("../base.zig").JSError;
const MarkedArrayBuffer = @import("../base.zig").MarkedArrayBuffer;
const getAllocator = @import("../base.zig").getAllocator;
const JSValue = @import("root").bun.JSC.JSValue;
-const NewClass = @import("../base.zig").NewClass;
+
const Microtask = @import("root").bun.JSC.Microtask;
const JSGlobalObject = @import("root").bun.JSC.JSGlobalObject;
const ExceptionValueRef = @import("root").bun.JSC.ExceptionValueRef;
@@ -4518,7 +4518,7 @@ pub const ServerWebSocket = struct {
}
};
-pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
+pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
return struct {
pub const ssl_enabled = ssl_enabled_;
const debug_mode = debug_mode_;
@@ -4554,52 +4554,18 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
has_js_deinited: bool = false,
} = .{},
- pub const Class = JSC.NewClass(
- ThisServer,
- .{ .name = "Server" },
- .{
- .stop = .{
- .rfn = JSC.wrapSync(ThisServer, "stopFromJS"),
- },
- .finalize = .{
- .rfn = finalize,
- },
- .fetch = .{
- .rfn = onFetch,
- },
- .reload = .{
- .rfn = onReload,
- },
- .upgrade = .{
- .rfn = JSC.wrapSync(ThisServer, "onUpgrade"),
- },
+ pub const doStop = JSC.wrapInstanceMethod(ThisServer, "stopFromJS", false);
+ pub const doUpgrade = JSC.wrapInstanceMethod(ThisServer, "onUpgrade", false);
+ pub const doPublish = JSC.wrapInstanceMethod(ThisServer, "publish", false);
+ pub const doReload = onReload;
+ pub const doFetch = onFetch;
- .publish = .{
- .rfn = JSC.wrapSync(ThisServer, "publish"),
- },
- },
- .{
- .port = .{
- .get = JSC.getterWrap(ThisServer, "getPort"),
- },
- .hostname = .{
- .get = JSC.getterWrap(ThisServer, "getHostname"),
- },
- .protocol = .{
- .get = JSC.getterWrap(ThisServer, "getProtocol"),
- },
- .development = .{
- .get = JSC.getterWrap(ThisServer, "getDevelopment"),
- },
- .pendingRequests = .{
- .get = JSC.getterWrap(ThisServer, "getPendingRequests"),
- },
- .pendingWebSockets = .{
- .get = JSC.getterWrap(ThisServer, "getPendingWebSockets"),
- },
- },
- );
+ pub usingnamespace NamespaceType;
+ pub fn constructor(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) ?*ThisServer {
+ globalThis.throw("Server() is not a constructor", .{});
+ return null;
+ }
pub fn publish(this: *ThisServer, globalThis: *JSC.JSGlobalObject, topic: ZigString, message_value: JSValue, compress_value: ?JSValue, exception: JSC.C.ExceptionRef) JSValue {
if (this.config.websocket == null)
return JSValue.jsNumber(0);
@@ -4798,21 +4764,24 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
pub fn onReload(
this: *ThisServer,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1).slice();
if (arguments.len < 1) {
- JSC.throwInvalidArguments("Expected 1 argument, got 0", .{}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ globalThis.throwNotEnoughArguments("reload", 1, 0);
+ return .zero;
}
- var args_slice = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
+ var args_slice = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments);
defer args_slice.deinit();
- var new_config = ServerConfig.fromJS(ctx, &args_slice, exception);
- if (exception.* != null) return js.JSValueMakeUndefined(ctx);
+ var exception_ref = [_]JSC.C.JSValueRef{null};
+ var exception: JSC.C.ExceptionRef = &exception_ref;
+ var new_config = ServerConfig.fromJS(globalThis, &args_slice, exception);
+ if (exception.* != null) {
+ globalThis.throwValue(exception_ref[0].?.value());
+ return .zero;
+ }
// only reload those two
if (this.config.onRequest != new_config.onRequest) {
@@ -4837,32 +4806,29 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
));
}
- ws.globalObject = ctx;
+ ws.globalObject = globalThis;
this.config.websocket = ws.*;
} // we don't remove it
}
- return this.thisObject.asObjectRef();
+ return this.thisObject;
}
pub fn onFetch(
this: *ThisServer,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- var globalThis = ctx.ptr();
+ ctx: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
JSC.markBinding(@src());
+ const arguments = callframe.arguments(2).slice();
if (arguments.len == 0) {
const fetch_error = WebCore.Fetch.fetch_error_no_args;
- return JSPromise.rejectedPromiseValue(globalThis, ZigString.init(fetch_error).toErrorInstance(globalThis)).asRef();
+ return JSPromise.rejectedPromiseValue(ctx, ZigString.init(fetch_error).toErrorInstance(ctx));
}
var headers: ?*JSC.FetchHeaders = null;
var method = HTTP.Method.GET;
- var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), arguments);
defer args.deinit();
var first_arg = args.nextEat().?;
@@ -4870,14 +4836,15 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
var existing_request: WebCore.Request = undefined;
// TODO: set Host header
// TODO: set User-Agent header
+ // TODO: unify with fetch() implementation.
if (first_arg.isString()) {
- const url_zig_str = JSValue.c(arguments[0]).toSlice(globalThis, bun.default_allocator);
+ const url_zig_str = arguments[0].toSlice(ctx, bun.default_allocator);
defer url_zig_str.deinit();
var temp_url_str = url_zig_str.slice();
if (temp_url_str.len == 0) {
const fetch_error = JSC.WebCore.Fetch.fetch_error_blank_url;
- return JSPromise.rejectedPromiseValue(globalThis, ZigString.init(fetch_error).toErrorInstance(globalThis)).asRef();
+ return JSPromise.rejectedPromiseValue(ctx, ZigString.init(fetch_error).toErrorInstance(ctx));
}
var url = URL.parse(temp_url_str);
@@ -4891,8 +4858,8 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
url = URL.parse(temp_url_str);
}
- if (arguments.len >= 2 and arguments[1].?.value().isObject()) {
- var opts = JSValue.fromRef(arguments[1]);
+ if (arguments.len >= 2 and arguments[1].isObject()) {
+ var opts = arguments[1];
if (opts.fastGet(ctx.ptr(), .method)) |method_| {
var slice_ = method_.toSlice(ctx.ptr(), getAllocator(ctx));
defer slice_.deinit();
@@ -4911,7 +4878,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
if (Blob.get(ctx.ptr(), body__, true, false)) |new_blob| {
body = .{ .Blob = new_blob };
} else |_| {
- return JSPromise.rejectedPromiseValue(globalThis, ZigString.init("fetch() received invalid body").toErrorInstance(globalThis)).asRef();
+ return JSPromise.rejectedPromiseValue(ctx, ZigString.init("fetch() received invalid body").toErrorInstance(ctx));
}
}
}
@@ -4926,42 +4893,41 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
request_.cloneInto(
&existing_request,
bun.default_allocator,
- globalThis,
+ ctx,
false,
);
} else {
- const fetch_error = WebCore.Fetch.fetch_type_error_strings.get(js.JSValueGetType(ctx, arguments[0]));
- return JSPromise.rejectedPromiseValue(globalThis, ZigString.init(fetch_error).toErrorInstance(globalThis)).asRef();
+ const fetch_error = JSC.WebCore.Fetch.fetch_type_error_strings.get(js.JSValueGetType(ctx, first_arg.asRef()));
+ const err = JSC.toTypeError(.ERR_INVALID_ARG_TYPE, "{s}", .{fetch_error}, ctx);
+
+ return JSPromise.rejectedPromiseValue(ctx, err);
}
var request = ctx.bunVM().allocator.create(Request) catch unreachable;
request.* = existing_request;
- var args_ = [_]JSC.C.JSValueRef{request.toJS(this.globalThis).asObjectRef()};
- const response_value = JSC.C.JSObjectCallAsFunctionReturnValue(
+ const response_value = this.config.onRequest.callWithThis(
this.globalThis,
- this.config.onRequest,
this.thisObject,
- 1,
- &args_,
+ &[_]JSC.JSValue{request.toJS(this.globalThis)},
);
if (response_value.isAnyError()) {
- return JSC.JSPromise.rejectedPromiseValue(ctx, response_value).asObjectRef();
+ return JSC.JSPromise.rejectedPromiseValue(ctx, response_value);
}
if (response_value.isEmptyOrUndefinedOrNull()) {
- return JSC.JSPromise.rejectedPromiseValue(ctx, ZigString.init("fetch() returned an empty value").toErrorInstance(ctx)).asObjectRef();
+ return JSC.JSPromise.rejectedPromiseValue(ctx, ZigString.init("fetch() returned an empty value").toErrorInstance(ctx));
}
if (response_value.asAnyPromise() != null) {
- return response_value.asObjectRef();
+ return response_value;
}
if (response_value.as(JSC.WebCore.Response)) |resp| {
resp.url = existing_request.url.clone();
}
- return JSC.JSPromise.resolvedPromiseValue(ctx, response_value).asObjectRef();
+ return JSC.JSPromise.resolvedPromiseValue(ctx, response_value);
}
pub fn stopFromJS(this: *ThisServer, abruptly: ?JSValue) JSC.JSValue {
@@ -4983,20 +4949,29 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
return JSC.JSValue.jsUndefined();
}
- pub fn getPort(this: *ThisServer) JSC.JSValue {
+ pub fn getPort(
+ this: *ThisServer,
+ _: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
var listener = this.listener orelse return JSC.JSValue.jsNumber(this.config.port);
return JSC.JSValue.jsNumber(listener.getLocalPort());
}
- pub fn getPendingRequests(this: *ThisServer) JSC.JSValue {
+ pub fn getPendingRequests(
+ this: *ThisServer,
+ _: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
return JSC.JSValue.jsNumber(@as(i32, @intCast(@as(u31, @truncate(this.pending_requests)))));
}
- pub fn getPendingWebSockets(this: *ThisServer) JSC.JSValue {
+ pub fn getPendingWebSockets(
+ this: *ThisServer,
+ _: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
return JSC.JSValue.jsNumber(@as(i32, @intCast(@as(u31, @truncate(this.activeSocketsCount())))));
}
- pub fn getHostname(this: *ThisServer, globalThis: *JSGlobalObject) JSC.JSValue {
+ pub fn getHostname(this: *ThisServer, globalThis: *JSGlobalObject) callconv(.C) JSC.JSValue {
if (this.cached_hostname.isEmpty()) {
if (this.listener) |listener| {
var buf: [1024]u8 = [_]u8{0} ** 1024;
@@ -5014,7 +4989,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
return this.cached_hostname.toJS(globalThis);
}
- pub fn getProtocol(this: *ThisServer, globalThis: *JSGlobalObject) JSC.JSValue {
+ pub fn getProtocol(this: *ThisServer, globalThis: *JSGlobalObject) callconv(.C) JSC.JSValue {
if (this.cached_protocol.isEmpty()) {
this.cached_protocol = bun.String.create(if (ssl_enabled) "https" else "http");
}
@@ -5024,7 +4999,8 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
pub fn getDevelopment(
_: *ThisServer,
- ) JSC.JSValue {
+ _: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
return JSC.JSValue.jsBoolean(debug_mode);
}
@@ -5035,7 +5011,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
this.deinitIfWeCan();
}
- pub fn finalize(this: *ThisServer) void {
+ pub fn finalize(this: *ThisServer) callconv(.C) void {
httplog("finalize", .{});
this.flags.has_js_deinited = true;
this.deinitIfWeCan();
@@ -5137,7 +5113,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
httplog("onListenFailed", .{});
this.unref();
- var zig_str: ZigString = ZigString.init("");
+ var error_instance = JSC.JSValue.zero;
var output_buf: [4096]u8 = undefined;
if (comptime ssl_enabled) {
@@ -5188,22 +5164,20 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
if (written > 0) {
var message = output_buf[0..written];
- zig_str = ZigString.init(std.fmt.allocPrint(bun.default_allocator, "OpenSSL {s}", .{message}) catch unreachable);
- var encoded_str = zig_str.withEncoding();
- encoded_str.mark();
-
- // We shouldn't *need* to do this but it's not entirely clear.
+ error_instance = this.globalThis.createErrorInstance("OpenSSL {s}", .{message});
BoringSSL.ERR_clear_error();
}
}
- if (zig_str.len == 0) {
- zig_str = ZigString.init(std.fmt.bufPrint(&output_buf, "Failed to start server. Is port {d} in use?", .{this.config.port}) catch "Failed to start server");
+ if (error_instance == .zero) {
+ error_instance = ZigString.init(std.fmt.bufPrint(&output_buf, "Failed to start server. Is port {d} in use?", .{this.config.port}) catch "Failed to start server").toErrorInstance(this.globalThis);
}
// store the exception in here
// toErrorInstance clones the string
- this.thisObject = zig_str.toErrorInstance(this.globalThis);
+ error_instance.ensureStillAlive();
+ error_instance.protect();
+ this.thisObject = error_instance;
// reference it in stack memory
this.thisObject.ensureStillAlive();
@@ -5512,17 +5486,10 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
};
}
-pub const Server = NewServer(false, false);
-pub const SSLServer = NewServer(true, false);
-pub const DebugServer = NewServer(false, true);
-pub const DebugSSLServer = NewServer(true, true);
-
-pub const AnyServer = union(enum) {
- Server: *Server,
- SSLServer: *SSLServer,
- DebugServer: *DebugServer,
- DebugSSLServer: *DebugSSLServer,
-};
+pub const HTTPServer = NewServer(JSC.Codegen.JSHTTPServer, false, false);
+pub const HTTPSServer = NewServer(JSC.Codegen.JSHTTPSServer, true, false);
+pub const DebugHTTPServer = NewServer(JSC.Codegen.JSDebugHTTPServer, false, true);
+pub const DebugHTTPSServer = NewServer(JSC.Codegen.JSDebugHTTPSServer, true, true);
const welcome_page_html_gz = @embedFile("welcome-page.html.gz");
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig
index 2bac8bf45..dbb208284 100644
--- a/src/bun.js/base.zig
+++ b/src/bun.js/base.zig
@@ -18,7 +18,6 @@ const Fetch = WebCore.Fetch;
const Response = WebCore.Response;
const Request = WebCore.Request;
const Router = @import("./api/filesystem_router.zig");
-const FetchEvent = WebCore.FetchEvent;
const IdentityContext = @import("../identity_context.zig").IdentityContext;
const uws = @import("root").bun.uws;
const Body = WebCore.Body;
@@ -79,100 +78,6 @@ pub const To = struct {
}
};
pub const JS = struct {
- pub inline fn str(_: anytype, val: anytype) js.JSStringRef {
- return js.JSStringCreateWithUTF8CString(val[0.. :0]);
- }
-
- pub fn functionWithCallback(
- comptime ZigContextType: type,
- zig: ObjectPtrType(ZigContextType),
- name: js.JSStringRef,
- ctx: js.JSContextRef,
- comptime callback: fn (
- obj: ObjectPtrType(ZigContextType),
- ctx: js.JSContextRef,
- function: js.JSObjectRef,
- thisObject: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef,
- ) js.JSObjectRef {
- var function = js.JSObjectMakeFunctionWithCallback(ctx, name, Callback(ZigContextType, callback).rfn);
- std.debug.assert(js.JSObjectSetPrivate(
- function,
- JSPrivateDataPtr.init(zig).ptr(),
- ));
- return function;
- }
-
- pub fn Finalize(
- comptime ZigContextType: type,
- comptime ctxfn: fn (
- this: ObjectPtrType(ZigContextType),
- ) void,
- ) type {
- return struct {
- pub fn rfn(
- object: js.JSObjectRef,
- ) callconv(.C) void {
- return ctxfn(
- GetJSPrivateData(ZigContextType, object) orelse return,
- );
- }
- };
- }
-
- pub fn Constructor(
- comptime ctxfn: fn (
- ctx: js.JSContextRef,
- function: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef,
- ) type {
- return struct {
- pub fn rfn(
- ctx: js.JSContextRef,
- function: js.JSObjectRef,
- argumentCount: usize,
- arguments: [*c]const js.JSValueRef,
- exception: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- return ctxfn(
- ctx,
- function,
- if (arguments) |args| args[0..argumentCount] else &[_]js.JSValueRef{},
- exception,
- );
- }
- };
- }
- pub fn ConstructorCallback(
- comptime ctxfn: fn (
- ctx: js.JSContextRef,
- function: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef,
- ) type {
- return struct {
- pub fn rfn(
- ctx: js.JSContextRef,
- function: js.JSObjectRef,
- argumentCount: usize,
- arguments: [*c]const js.JSValueRef,
- exception: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- return ctxfn(
- ctx,
- function,
- if (arguments) |args| args[0..argumentCount] else &[_]js.JSValueRef{},
- exception,
- );
- }
- };
- }
-
pub fn withType(comptime Type: type, value: Type, context: JSC.C.JSContextRef, exception: JSC.C.ExceptionRef) JSC.C.JSValueRef {
return withTypeClone(Type, value, context, exception, false);
}
@@ -325,93 +230,6 @@ pub const To = struct {
},
};
}
-
- pub fn PropertyGetter(
- comptime Type: type,
- ) type {
- return comptime fn (
- this: ObjectPtrType(Type),
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef;
- }
-
- pub fn Getter(comptime Type: type, comptime field: std.meta.FieldEnum(Type)) PropertyGetter(Type) {
- return struct {
- pub fn rfn(
- this: ObjectPtrType(Type),
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- return withType(std.meta.fieldInfo(Type, field).type, @field(this, @tagName(field)), ctx, exception);
- }
- }.rfn;
- }
-
- pub const JSC_C_Function = fn (
- js.JSContextRef,
- js.JSObjectRef,
- js.JSObjectRef,
- usize,
- [*c]const js.JSValueRef,
- js.ExceptionRef,
- ) callconv(.C) js.JSValueRef;
-
- pub fn Callback(
- comptime ZigContextType: type,
- comptime ctxfn: fn (
- obj: ObjectPtrType(ZigContextType),
- ctx: js.JSContextRef,
- function: js.JSObjectRef,
- thisObject: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef,
- ) type {
- return struct {
- pub fn rfn(
- ctx: js.JSContextRef,
- function: js.JSObjectRef,
- thisObject: js.JSObjectRef,
- argumentCount: usize,
- arguments: [*c]const js.JSValueRef,
- exception: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- if (comptime ZigContextType == anyopaque) {
- return ctxfn(
- js.JSObjectGetPrivate(function) orelse js.JSObjectGetPrivate(thisObject) orelse undefined,
- ctx,
- function,
- thisObject,
- if (arguments) |args| args[0..argumentCount] else &[_]js.JSValueRef{},
- exception,
- );
- } else if (comptime ZigContextType == void) {
- return ctxfn(
- {},
- ctx,
- function,
- thisObject,
- if (arguments) |args| args[0..argumentCount] else &[_]js.JSValueRef{},
- exception,
- );
- } else {
- return ctxfn(
- GetJSPrivateData(ZigContextType, function) orelse GetJSPrivateData(ZigContextType, thisObject) orelse return js.JSValueMakeUndefined(ctx),
- ctx,
- function,
- thisObject,
- if (arguments) |args| args[0..argumentCount] else &[_]js.JSValueRef{},
- exception,
- );
- }
- }
- };
- }
};
};
@@ -460,1132 +278,6 @@ pub const Properties = struct {
}
};
-const hasSetter = std.meta.trait.hasField("set");
-const hasReadOnly = std.meta.trait.hasField("ro");
-const hasFinalize = std.meta.trait.hasField("finalize");
-const hasEnumerable = std.meta.trait.hasField("enumerable");
-
-const hasTypeScriptField = std.meta.trait.hasField("ts");
-fn hasTypeScript(comptime Type: type) bool {
- if (hasTypeScriptField(Type)) {
- return true;
- }
-
- return @hasDecl(Type, "ts");
-}
-
-fn getTypeScript(comptime Type: type, value: Type) d.ts.or_decl {
- if (comptime !@hasDecl(Type, "ts") and !@hasField(Type, "ts")) {
- return d.ts.or_decl{
- .ts = .{ .name = @typeName(Type) },
- };
- }
-
- if (comptime hasTypeScriptField(Type)) {
- if (@TypeOf(value.ts) == d.ts.decl) {
- return d.ts.or_decl{ .decl = value };
- } else {
- return d.ts.or_decl{ .ts = value.ts };
- }
- }
-
- if (@TypeOf(Type.ts) == d.ts.decl) {
- return d.ts.or_decl{ .decl = Type.ts };
- } else {
- return d.ts.or_decl{ .ts = value.ts };
- }
-}
-
-pub const d = struct {
- pub const ts = struct {
- @"return": string = "unknown",
- tsdoc: string = "",
- name: string = "",
- read_only: ?bool = null,
- args: []const arg = &[_]arg{},
- splat_args: bool = false,
-
- pub const or_decl = union(Tag) {
- ts: ts,
- decl: decl,
- pub const Tag = enum { ts, decl };
- };
-
- pub const decl = union(Tag) {
- module: module,
- class: class,
- empty: u0,
- pub const Tag = enum { module, class, empty };
- };
-
- pub const module = struct {
- tsdoc: string = "",
- read_only: ?bool = null,
- path: string = "",
- global: bool = false,
-
- properties: []ts = &[_]ts{},
- functions: []ts = &[_]ts{},
- classes: []class = &[_]class{},
- };
-
- pub const class = struct {
- name: string = "",
- tsdoc: string = "",
- @"return": string = "",
- read_only: ?bool = null,
- interface: bool = true,
- default_export: bool = false,
-
- properties: []ts = &[_]ts{},
- functions: []ts = &[_]ts{},
-
- pub const Printer = struct {
- const indent_level = 2;
- pub fn printIndented(comptime fmt: string, args: anytype, comptime indent: usize) string {
- comptime var buf: string = "";
- comptime buf = buf ++ " " ** indent;
-
- return comptime buf ++ std.fmt.comptimePrint(fmt, args);
- }
-
- pub fn printVar(comptime property: d.ts, comptime indent: usize) string {
- comptime var buf: string = "";
- comptime buf = buf ++ " " ** indent;
-
- comptime {
- if (property.read_only orelse false) {
- buf = buf ++ "readonly ";
- }
-
- buf = buf ++ "var ";
- buf = buf ++ property.name;
- buf = buf ++ ": ";
-
- if (property.@"return".len > 0) {
- buf = buf ++ property.@"return";
- } else {
- buf = buf ++ "any";
- }
-
- buf = buf ++ ";\n";
- }
-
- comptime {
- if (property.tsdoc.len > 0) {
- buf = printTSDoc(property.tsdoc, indent) ++ buf;
- }
- }
-
- return buf;
- }
-
- pub fn printProperty(comptime property: d.ts, comptime indent: usize) string {
- comptime var buf: string = "";
- comptime buf = buf ++ " " ** indent;
-
- comptime {
- if (property.read_only orelse false) {
- buf = buf ++ "readonly ";
- }
-
- buf = buf ++ property.name;
- buf = buf ++ ": ";
-
- if (property.@"return".len > 0) {
- buf = buf ++ property.@"return";
- } else {
- buf = buf ++ "any";
- }
-
- buf = buf ++ ";\n";
- }
-
- comptime {
- if (property.tsdoc.len > 0) {
- buf = printTSDoc(property.tsdoc, indent) ++ buf;
- }
- }
-
- return buf;
- }
- pub fn printInstanceFunction(comptime func: d.ts, comptime _indent: usize, comptime no_type: bool) string {
- comptime var indent = _indent;
- comptime var buf: string = "";
-
- comptime {
- var args: string = "";
- for (func.args, 0..) |a, i| {
- if (i > 0) {
- args = args ++ ", ";
- }
- args = args ++ printArg(a);
- }
-
- if (no_type) {
- buf = buf ++ printIndented("{s}({s});\n", .{
- func.name,
- args,
- }, indent);
- } else {
- buf = buf ++ printIndented("{s}({s}): {s};\n", .{
- func.name,
- args,
- func.@"return",
- }, indent);
- }
- }
-
- comptime {
- if (func.tsdoc.len > 0) {
- buf = printTSDoc(func.tsdoc, indent) ++ buf;
- }
- }
-
- return buf;
- }
- pub fn printFunction(comptime func: d.ts, comptime _indent: usize, comptime no_type: bool) string {
- comptime var indent = _indent;
- comptime var buf: string = "";
-
- comptime {
- var args: string = "";
- for (func.args, 0..) |a, i| {
- if (i > 0) {
- args = args ++ ", ";
- }
- args = args ++ printArg(a);
- }
-
- if (no_type) {
- buf = buf ++ printIndented("function {s}({s});\n", .{
- func.name,
- args,
- }, indent);
- } else {
- buf = buf ++ printIndented("function {s}({s}): {s};\n", .{
- func.name,
- args,
- func.@"return",
- }, indent);
- }
- }
-
- comptime {
- if (func.tsdoc.len > 0) {
- buf = printTSDoc(func.tsdoc, indent) ++ buf;
- }
- }
-
- return buf;
- }
- pub fn printArg(
- comptime _arg: d.ts.arg,
- ) string {
- comptime var buf: string = "";
- comptime {
- buf = buf ++ _arg.name;
- buf = buf ++ ": ";
-
- if (_arg.@"return".len == 0) {
- buf = buf ++ "any";
- } else {
- buf = buf ++ _arg.@"return";
- }
- }
-
- return buf;
- }
-
- pub fn printDecl(comptime klass: d.ts.decl, comptime _indent: usize) string {
- return comptime switch (klass) {
- .module => |mod| printModule(mod, _indent),
- .class => |cla| printClass(cla, _indent),
- .empty => "",
- };
- }
-
- pub fn printModule(comptime klass: d.ts.module, comptime _indent: usize) string {
- comptime var indent = _indent;
- comptime var buf: string = "";
- comptime brk: {
- if (klass.tsdoc.len > 0) {
- buf = buf ++ printTSDoc(klass.tsdoc, indent);
- }
-
- if (klass.global) {
- buf = buf ++ printIndented("declare global {{\n", .{}, indent);
- } else {
- buf = buf ++ printIndented("declare module \"{s}\" {{\n", .{klass.path}, indent);
- }
-
- indent += indent_level;
-
- for (klass.properties, 0..) |property, i| {
- if (i > 0) {
- buf = buf ++ "\n";
- }
-
- buf = buf ++ printVar(property, indent);
- }
-
- buf = buf ++ "\n";
-
- for (klass.functions, 0..) |func, i| {
- if (i > 0) {
- buf = buf ++ "\n";
- }
-
- buf = buf ++ printFunction(
- func,
- indent,
- false,
- );
- }
-
- for (klass.classes, 0..) |func, i| {
- if (i > 0) {
- buf = buf ++ "\n";
- }
-
- buf = buf ++ printClass(
- func,
- indent,
- );
- }
-
- indent -= indent_level;
-
- buf = buf ++ printIndented("}}\n", .{}, indent);
-
- break :brk;
- }
- return comptime buf;
- }
-
- pub fn printClass(comptime klass: d.ts.class, comptime _indent: usize) string {
- comptime var indent = _indent;
- comptime var buf: string = "";
- comptime brk: {
- if (klass.tsdoc.len > 0) {
- buf = buf ++ printTSDoc(klass.tsdoc, indent);
- }
-
- const qualifier = if (!klass.default_export) "export " else "";
-
- if (klass.interface) {
- buf = buf ++ printIndented("export interface {s} {{\n", .{klass.name}, indent);
- } else {
- buf = buf ++ printIndented("{s}class {s} {{\n", .{ qualifier, klass.name }, indent);
- }
-
- indent += indent_level;
-
- var did_print_constructor = false;
- for (klass.functions) |func| {
- if (!strings.eqlComptime(func.name, "constructor")) continue;
- did_print_constructor = true;
- buf = buf ++ printInstanceFunction(
- func,
- indent,
- !klass.interface,
- );
- }
-
- for (klass.properties, 0..) |property, i| {
- if (i > 0 or did_print_constructor) {
- buf = buf ++ "\n";
- }
-
- buf = buf ++ printProperty(property, indent);
- }
-
- buf = buf ++ "\n";
-
- for (klass.functions, 0..) |func, i| {
- if (i > 0) {
- buf = buf ++ "\n";
- }
-
- if (strings.eqlComptime(func.name, "constructor")) continue;
-
- buf = buf ++ printInstanceFunction(
- func,
- indent,
- false,
- );
- }
-
- indent -= indent_level;
-
- buf = buf ++ printIndented("}}\n", .{}, indent);
-
- if (klass.default_export) {
- buf = buf ++ printIndented("export = {s};\n", .{klass.name}, indent);
- }
-
- break :brk;
- }
- return comptime buf;
- }
-
- pub fn printTSDoc(comptime str: string, comptime indent: usize) string {
- comptime var buf: string = "";
-
- comptime brk: {
- var splitter = std.mem.split(u8, str, "\n");
-
- const first = splitter.next() orelse break :brk;
- const second = splitter.next() orelse {
- buf = buf ++ printIndented("/** {s} */\n", .{std.mem.trim(u8, first, " ")}, indent);
- break :brk;
- };
- buf = buf ++ printIndented("/**\n", .{}, indent);
- buf = buf ++ printIndented(" * {s}\n", .{std.mem.trim(u8, first, " ")}, indent);
- buf = buf ++ printIndented(" * {s}\n", .{std.mem.trim(u8, second, " ")}, indent);
- while (splitter.next()) |line| {
- buf = buf ++ printIndented(" * {s}\n", .{std.mem.trim(u8, line, " ")}, indent);
- }
- buf = buf ++ printIndented("*/\n", .{}, indent);
- }
-
- return buf;
- }
- };
- };
-
- pub const arg = struct {
- name: string = "",
- @"return": string = "any",
- optional: bool = false,
- };
- };
-};
-
-// This should only exist at compile-time.
-pub const ClassOptions = struct {
- name: stringZ,
-
- read_only: bool = false,
- hidden: []const string = &[_]string{},
- no_inheritance: bool = false,
- singleton: bool = false,
- ts: d.ts.decl = d.ts.decl{ .empty = 0 },
- has_dom_calls: bool = false,
-};
-
-pub fn NewConstructor(
- comptime InstanceType: type,
- comptime staticFunctions: anytype,
- comptime properties: anytype,
-) type {
- return struct {
- pub usingnamespace NewClassWithInstanceType(void, InstanceType.Class.class_options, staticFunctions, properties, InstanceType);
- const name_string = ZigString.static(InstanceType.Class.class_options.name);
- pub fn constructor(ctx: js.JSContextRef) callconv(.C) js.JSObjectRef {
- return JSValue.makeWithNameAndPrototype(
- ctx.ptr(),
- @This().get().*,
- InstanceType.Class.get().*,
- name_string,
- ).asObjectRef();
- }
- };
-}
-
-const _to_json: stringZ = "toJSON";
-
-pub fn NewClass(
- comptime ZigType: type,
- comptime options: ClassOptions,
- comptime staticFunctions: anytype,
- comptime properties: anytype,
-) type {
- return NewClassWithInstanceType(ZigType, options, staticFunctions, properties, void);
-}
-
-pub fn NewClassWithInstanceType(
- comptime ZigType: type,
- comptime options: ClassOptions,
- comptime staticFunctions: anytype,
- comptime properties: anytype,
- comptime InstanceType: type,
-) type {
- return struct {
- const read_only = options.read_only;
- const singleton = options.singleton;
- pub const name = options.name;
- pub const class_options = options;
- pub const isJavaScriptCoreClass = true;
- pub const Zig = ZigType;
- const ClassDefinitionCreator = @This();
- const function_names = std.meta.fieldNames(@TypeOf(staticFunctions));
- pub const functionDefinitions = staticFunctions;
- const function_name_literals = function_names;
- var function_name_refs: [function_names.len]js.JSStringRef = undefined;
- var function_name_refs_set = false;
-
- const property_names = std.meta.fieldNames(@TypeOf(properties));
- var property_name_refs: [property_names.len]js.JSStringRef = undefined;
- var property_name_refs_set: bool = false;
- const property_name_literals = property_names;
-
- const LazyClassRef = struct {
- ref: js.JSClassRef = null,
- loaded: bool = false,
- };
-
- threadlocal var lazy_ref: LazyClassRef = LazyClassRef{};
-
- pub inline fn isLoaded() bool {
- return lazy_ref.loaded;
- }
-
- const ConstructorWrapper = struct {
- pub fn rfn(
- ctx: js.JSContextRef,
- function: js.JSObjectRef,
- _: js.JSObjectRef,
- argumentCount: usize,
- arguments: [*c]const js.JSValueRef,
- exception: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- return getClassDefinition().callAsConstructor.?(ctx, function, argumentCount, arguments, exception);
- }
- };
-
- pub fn throwInvalidConstructorError(ctx: js.JSContextRef, _: js.JSObjectRef, _: usize, _: [*c]const js.JSValueRef, exception: js.ExceptionRef) callconv(.C) js.JSObjectRef {
- JSError(getAllocator(ctx), "" ++ name ++ " is not a constructor", .{}, ctx, exception);
- return null;
- }
-
- pub fn throwInvalidFunctionError(
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: usize,
- _: [*c]const js.JSValueRef,
- exception: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- JSError(getAllocator(ctx), "" ++ name ++ " is not a function", .{}, ctx, exception);
- return null;
- }
-
- pub const Constructor = ConstructorWrapper.rfn;
-
- var class_definition: js.JSClassDefinition = undefined;
- var class_definition_set: bool = false;
- const static_functions__: [function_name_literals.len + 1]js.JSStaticFunction = if (function_name_literals.len > 0) generateDef([function_name_literals.len + 1]js.JSStaticFunction) else undefined;
- const static_values_ptr = &static_properties;
-
- fn generateClassDefinition() void {
- class_definition = comptime brk: {
- var def = generateDef(JSC.C.JSClassDefinition);
- if (function_name_literals.len > 0)
- def.staticFunctions = &static_functions__;
- if (options.no_inheritance) {
- def.attributes = JSC.C.JSClassAttributes.kJSClassAttributeNoAutomaticPrototype;
- }
- if (property_names.len > 0) {
- def.staticValues = static_values_ptr;
- }
-
- def.className = options.name.ptr;
- // def.getProperty = getPropertyCallback;
-
- if (def.callAsConstructor == null) {
- def.callAsConstructor = &throwInvalidConstructorError;
- }
-
- if (def.callAsFunction == null) {
- def.callAsFunction = &throwInvalidFunctionError;
- }
-
- if (def.getPropertyNames == null) {
- def.getPropertyNames = &getPropertyNames;
- }
-
- if (!singleton and def.hasInstance == null)
- def.hasInstance = &customHasInstance;
- break :brk def;
- };
- }
-
- fn getClassDefinition() *const JSC.C.JSClassDefinition {
- if (!class_definition_set) {
- class_definition_set = true;
- generateClassDefinition();
- }
-
- return &class_definition;
- }
-
- pub fn get() callconv(.C) [*c]js.JSClassRef {
- var lazy = lazy_ref;
-
- if (!lazy.loaded) {
- lazy = .{
- .ref = js.JSClassCreate(getClassDefinition()),
- .loaded = true,
- };
- lazy_ref = lazy;
- }
-
- _ = js.JSClassRetain(lazy.ref);
-
- return &lazy.ref;
- }
-
- pub fn customHasInstance(ctx: js.JSContextRef, _: js.JSObjectRef, value: js.JSValueRef, _: js.ExceptionRef) callconv(.C) bool {
- if (InstanceType != void) {
- var current = value;
- while (current != null) {
- if (js.JSValueIsObjectOfClass(ctx, current, InstanceType.Class.get().*)) {
- return true;
- }
- current = js.JSObjectGetPrototype(ctx, current);
- }
- return false;
- }
-
- return js.JSValueIsObjectOfClass(ctx, value, get().*);
- }
-
- pub fn make(ctx: js.JSContextRef, ptr: *ZigType) js.JSObjectRef {
- var real_ptr = JSPrivateDataPtr.init(ptr).ptr();
- if (comptime Environment.allow_assert) {
- std.debug.assert(JSPrivateDataPtr.isValidPtr(real_ptr));
- std.debug.assert(JSPrivateDataPtr.from(real_ptr).get(ZigType).? == ptr);
- }
-
- var result = js.JSObjectMake(
- ctx,
- get().*,
- real_ptr,
- );
-
- if (comptime Environment.allow_assert) {
- std.debug.assert(JSPrivateDataPtr.from(js.JSObjectGetPrivate(result)).ptr() == real_ptr);
- }
-
- return result;
- }
-
- pub fn putDOMCalls(globalThis: *JSC.JSGlobalObject, value: JSValue) void {
- inline for (function_name_literals) |functionName| {
- const Function = comptime @field(staticFunctions, functionName);
- if (@TypeOf(Function) == type and @hasDecl(Function, "is_dom_call")) {
- Function.put(globalThis, value);
- }
- }
- }
-
- pub fn GetClass(comptime ReceiverType: type) type {
- const ClassGetter = struct {
- get: fn (
- *ReceiverType,
- js.JSContextRef,
- js.JSObjectRef,
- js.ExceptionRef,
- ) js.JSValueRef = rfn,
-
- pub fn rfn(
- _: *ReceiverType,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return js.JSObjectMake(ctx, get().*, null);
- }
- };
-
- return ClassGetter;
- }
-
- fn StaticProperty(comptime id: usize) type {
- return struct {
- pub fn getter(
- ctx: js.JSContextRef,
- obj: js.JSObjectRef,
- prop: js.JSStringRef,
- exception: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- var this: ObjectPtrType(ZigType) = if (comptime ZigType == void) {} else GetJSPrivateData(ZigType, obj) orelse return js.JSValueMakeUndefined(ctx);
-
- const Field = @TypeOf(@field(
- properties,
- property_names[id],
- ));
- switch (comptime @typeInfo(Field)) {
- .Fn => {
- return @field(
- properties,
- property_names[id],
- )(
- this,
- ctx,
- obj,
- exception,
- );
- },
- .Struct => {
- comptime {
- if (!@hasField(@TypeOf(@field(properties, property_names[id])), "get")) {
- @compileError(
- "Cannot get static property " ++ property_names[id] ++ " of " ++ name ++ " because it is a struct without a getter",
- );
- }
- }
- const func = @field(
- @field(
- properties,
- property_names[id],
- ),
- "get",
- );
-
- const Func = @typeInfo(@TypeOf(func));
- const WithPropFn = fn (
- ObjectPtrType(ZigType),
- js.JSContextRef,
- js.JSObjectRef,
- js.JSStringRef,
- js.ExceptionRef,
- ) js.JSValueRef;
-
- if (Func.Fn.params.len == @typeInfo(WithPropFn).Fn.params.len) {
- return func(
- this,
- ctx,
- obj,
- prop,
- exception,
- );
- } else {
- return func(
- this,
- ctx,
- obj,
- exception,
- );
- }
- },
- else => unreachable,
- }
- }
-
- pub fn setter(
- ctx: js.JSContextRef,
- obj: js.JSObjectRef,
- prop: js.JSStringRef,
- value: js.JSValueRef,
- exception: js.ExceptionRef,
- ) callconv(.C) bool {
- var this = GetJSPrivateData(ZigType, obj) orelse return false;
-
- switch (comptime @typeInfo(@TypeOf(@field(
- properties,
- property_names[id],
- )))) {
- .Struct => {
- return @field(
- @field(
- properties,
- property_names[id],
- ),
- "set",
- )(
- this,
- ctx,
- obj,
- prop,
- value,
- exception,
- );
- },
- else => unreachable,
- }
- }
- };
- }
-
- pub fn getPropertyNames(
- _: js.JSContextRef,
- _: js.JSObjectRef,
- props: js.JSPropertyNameAccumulatorRef,
- ) callconv(.C) void {
- if (comptime property_name_refs.len > 0) {
- if (!property_name_refs_set) {
- comptime var i: usize = 0;
- property_name_refs_set = true;
- inline while (i < comptime property_name_refs.len) : (i += 1) {
- property_name_refs[i] = js.JSStringCreateStatic(property_names[i].ptr, property_names[i].len);
- }
- comptime i = 0;
- } else {
- comptime var i: usize = 0;
- inline while (i < property_name_refs.len) : (i += 1) {
- js.JSPropertyNameAccumulatorAddName(props, property_name_refs[i]);
- }
- }
- }
-
- const ref_len = comptime function_name_refs.len;
- if (comptime function_name_refs.len > 0) {
- if (!function_name_refs_set) {
- comptime var j: usize = 0;
- function_name_refs_set = true;
- inline while (j < ref_len) : (j += 1) {
- function_name_refs[j] = js.JSStringCreateStatic(function_names[j].ptr, function_names[j].len);
- }
- comptime j = 0;
-
- inline while (j < ref_len) : (j += 1) {
- js.JSPropertyNameAccumulatorAddName(props, function_name_refs[j]);
- }
- } else {
- comptime var j: usize = 0;
- inline while (j < ref_len) : (j += 1) {
- js.JSPropertyNameAccumulatorAddName(props, function_name_refs[j]);
- }
- }
- }
- }
-
- const static_properties: [property_names.len + 1]js.JSStaticValue = brk: {
- var props: [property_names.len + 1]js.JSStaticValue = undefined;
- @memset(
- &props,
- js.JSStaticValue{
- .name = @as([*c]const u8, @ptrFromInt(0)),
- .getProperty = null,
- .setProperty = null,
- .attributes = js.JSPropertyAttributes.kJSPropertyAttributeNone,
- },
- );
- if (property_name_literals.len > 0 and @TypeOf(property_name_literals[0]) == [:0]const u8) {
- @compileError("@typeInfo() struct field names are null-terminated");
- }
- for (property_name_literals, 0..) |lit, i| {
- props[i] = brk2: {
- var static_prop = JSC.C.JSStaticValue{
- // TODO: update when @typeInfo struct field names are sentinel terminated
- // https://github.com/ziglang/zig/issues/16072
- .name = lit ++ .{0},
- .getProperty = null,
- .setProperty = null,
- .attributes = @as(js.JSPropertyAttributes, @enumFromInt(0)),
- };
- static_prop.getProperty = StaticProperty(i).getter;
-
- const field = @field(properties, property_names[i]);
-
- if (hasSetter(@TypeOf(field))) {
- static_prop.setProperty = StaticProperty(i).setter;
- }
- break :brk2 static_prop;
- };
- }
- break :brk props;
- };
-
- // this madness is a workaround for stage1 compiler bugs
- fn generateDef(comptime ReturnType: type) ReturnType {
- var count: usize = 0;
- var def: js.JSClassDefinition = js.JSClassDefinition{
- .version = 0,
- .attributes = js.JSClassAttributes.kJSClassAttributeNone,
- .className = "",
- .parentClass = null,
- .staticValues = null,
- .staticFunctions = null,
- .initialize = null,
- .finalize = null,
- .hasProperty = null,
- .getProperty = null,
- .setProperty = null,
- .deleteProperty = null,
- .getPropertyNames = null,
- .callAsFunction = null,
- .callAsConstructor = null,
- .hasInstance = null,
- .convertToType = null,
- };
- var __static_functions: [function_name_literals.len + 1]js.JSStaticFunction = undefined;
- for (__static_functions, 0..) |_, i| {
- __static_functions[i] = js.JSStaticFunction{
- .name = "",
- .callAsFunction = null,
- .attributes = js.JSPropertyAttributes.kJSPropertyAttributeNone,
- };
- }
-
- @setEvalBranchQuota(50_000);
- const is_read_only = options.read_only;
-
- inline for (comptime function_name_literals) |function_name_literal| {
- const CtxField = comptime @field(staticFunctions, function_name_literal);
-
- switch (comptime @typeInfo(@TypeOf(CtxField))) {
- .Struct => {
- if (comptime strings.eqlComptime(function_name_literal, "constructor")) {
- def.callAsConstructor = &To.JS.Constructor(staticFunctions.constructor.rfn).rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "finalize")) {
- def.finalize = &To.JS.Finalize(ZigType, staticFunctions.finalize.rfn).rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "call")) {
- def.callAsFunction = &To.JS.Callback(ZigType, staticFunctions.call.rfn).rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "callAsFunction")) {
- const ctxfn = @field(staticFunctions, function_name_literal).rfn;
- const Func: std.builtin.Type.Fn = @typeInfo(@TypeOf(if (@typeInfo(@TypeOf(ctxfn)) == .Pointer) ctxfn.* else ctxfn)).Fn;
-
- const PointerType = std.meta.Child(Func.params[0].type.?);
-
- def.callAsFunction = &(if (Func.calling_convention == .C) ctxfn else To.JS.Callback(
- PointerType,
- ctxfn,
- ).rfn);
- } else if (comptime strings.eqlComptime(function_name_literal, "hasProperty")) {
- def.hasProperty = @field(staticFunctions, "hasProperty").rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "getProperty")) {
- def.getProperty = @field(staticFunctions, "getProperty").rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "setProperty")) {
- def.setProperty = @field(staticFunctions, "setProperty").rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "deleteProperty")) {
- def.deleteProperty = &@field(staticFunctions, "deleteProperty").rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "getPropertyNames")) {
- def.getPropertyNames = @field(staticFunctions, "getPropertyNames").rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "convertToType")) {
- def.convertToType = @field(staticFunctions, "convertToType").rfn;
- } else if (comptime !@hasField(@TypeOf(CtxField), "is_dom_call")) {
- if (!@hasField(@TypeOf(CtxField), "rfn")) {
- @compileError("Expected " ++ options.name ++ "." ++ function_name_literal ++ " to have .rfn");
- }
- const ctxfn = CtxField.rfn;
- const Func: std.builtin.Type.Fn = @typeInfo(@TypeOf(if (@typeInfo(@TypeOf(ctxfn)) == .Pointer) ctxfn.* else ctxfn)).Fn;
-
- var attributes: c_uint = @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeNone);
-
- if (comptime is_read_only or hasReadOnly(@TypeOf(CtxField))) {
- attributes |= @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeReadOnly);
- }
-
- if (comptime hasEnumerable(@TypeOf(CtxField)) and !CtxField.enumerable) {
- attributes |= @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeDontEnum);
- }
-
- const PointerType = comptime brk: {
- if (Func.params[0].type.? != void) {
- break :brk std.meta.Child(Func.params[0].type.?);
- }
- break :brk void;
- };
-
- __static_functions[count] = js.JSStaticFunction{
- .name = bun.sliceTo(function_name_literal ++ [_]u8{0}, 0).ptr,
- .callAsFunction = if (Func.calling_convention == .C) &CtxField.rfn else &To.JS.Callback(
- PointerType,
- if (@typeInfo(@TypeOf(ctxfn)) == .Pointer) ctxfn.* else ctxfn,
- ).rfn,
- .attributes = @as(js.JSPropertyAttributes, @enumFromInt(attributes)),
- };
-
- count += 1;
- }
- },
- .Fn => {
- if (comptime strings.eqlComptime(function_name_literal, "constructor")) {
- def.callAsConstructor = &To.JS.Constructor(staticFunctions.constructor).rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "finalize")) {
- def.finalize = &To.JS.Finalize(ZigType, staticFunctions.finalize).rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "call")) {
- def.callAsFunction = &To.JS.Callback(ZigType, staticFunctions.call).rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "getPropertyNames")) {
- def.getPropertyNames = &To.JS.Callback(ZigType, staticFunctions.getPropertyNames).rfn;
- } else if (comptime strings.eqlComptime(function_name_literal, "hasInstance")) {
- def.hasInstance = &staticFunctions.hasInstance;
- } else {
- const attributes: js.JSPropertyAttributes = brk: {
- var base = @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeNone);
-
- if (is_read_only)
- base |= @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeReadOnly);
-
- break :brk @as(js.JSPropertyAttributes, @enumFromInt(base));
- };
-
- __static_functions[count] = js.JSStaticFunction{
- .name = (function_name_literal ++ [_]u8{0})[0..function_name_literal.len :0],
- .callAsFunction = &To.JS.Callback(
- ZigType,
- @field(staticFunctions, function_name_literal),
- ).rfn,
- .attributes = attributes,
- };
-
- count += 1;
- }
- },
- else => {},
- }
- }
-
- if (comptime ReturnType == JSC.C.JSClassDefinition) {
- return def;
- } else {
- return __static_functions;
- }
- }
- };
-}
-
-// pub fn NewInstanceFunction(
-// comptime className: []const u8,
-// comptime functionName: []const u8,
-// comptime InstanceType: type,
-// comptime target: anytype,
-// ) type {
-// return struct {
-// pub const shim = JSC.Shimmer("ZigGenerated__" ++ className, functionName, @This());
-// pub const name = functionName;
-// pub const Type = InstanceType;
-
-// pub fn callAsFunction(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
-// var this = InstanceType.toWrapped(callframe.this()) orelse {
-// callframe.toInvalidArguments("Expected this to be a " ++ className, .{}, globalObject);
-// return JSC.JSValue.jsUndefined();
-// };
-
-// return target(globalObject, this, callframe.arguments());
-// }
-
-// pub const Export = shim.exportFunctions(.{
-// .callAsFunction = callAsFunction,
-// });
-
-// pub const symbol = Export[0].symbol_name;
-
-// comptime {
-// if (!JSC.is_bindgen) {
-// @export(callAsFunction, .{
-// .name = Export[0].symbol_name,
-// });
-// }
-// }
-// };
-// }
-
-// pub fn NewStaticFunction(
-// comptime className: []const u8,
-// comptime functionName: []const u8,
-// comptime target: anytype,
-// ) type {
-// return struct {
-// pub const shim = JSC.Shimmer("ZigGenerated__Static__" ++ className, functionName, @This());
-// pub const name = functionName;
-
-// pub fn callAsFunction(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
-// return target(globalObject, callframe.arguments());
-// }
-
-// pub const Export = shim.exportFunctions(.{
-// .callAsFunction = callAsFunction,
-// });
-
-// pub const symbol = Export[0].symbol_name;
-
-// comptime {
-// if (!JSC.is_bindgen) {
-// @export(callAsFunction, .{
-// .name = Export[0].symbol_name,
-// });
-// }
-// }
-// };
-// }
-
-// pub fn NewStaticConstructor(
-// comptime className: []const u8,
-// comptime functionName: []const u8,
-// comptime target: anytype,
-// ) type {
-// return struct {
-// pub const shim = JSC.Shimmer("ZigGenerated__Static__" ++ className, functionName, @This());
-// pub const name = functionName;
-
-// pub fn callAsConstructor(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
-// return target(globalObject, callframe.arguments());
-// }
-
-// pub const Export = shim.exportFunctions(.{
-// .callAsConstructor = callAsConstructor,
-// });
-
-// pub const symbol = Export[0].symbol_name;
-
-// comptime {
-// if (!JSC.is_bindgen) {
-// @export(callAsConstructor, .{
-// .name = Export[0].symbol_name,
-// });
-// }
-// }
-// };
-// }
-
-// pub fn NewStaticObject(
-// comptime className: []const u8,
-// comptime function_definitions: anytype,
-// comptime property_definitions_: anytype,
-// ) type {
-// return struct {
-// const property_definitions = property_definitions_;
-// pub const shim = JSC.Shimmer("ZigGenerated", name, @This());
-// pub const name = className;
-// pub const Type = void;
-
-// const function_names = std.meta.fieldNames(@TypeOf(function_definitions));
-// pub fn getFunctions() [function_names.len]type {
-// var data: [function_names.len]type = undefined;
-// var i: usize = 0;
-// while (i < function_names.len) : (i += 1) {
-// if (strings.eqlComptime(function_names[i], "constructor")) {
-// data[i] = NewStaticConstructor(className, function_names[i], @TypeOf(function_definitions)[function_names[i]]);
-// } else {
-// data[i] = NewStaticFunction(className, function_names[i], @TypeOf(function_definitions)[function_names[i]]);
-// }
-// }
-
-// return data;
-// }
-
-// const property_names = std.meta.fieldNames(@TypeOf(property_definitions));
-// pub fn getProperties() [property_definitions.len]type {
-// var data: [property_definitions.len]type = undefined;
-// var i: usize = 0;
-// while (i < property_definitions.len) : (i += 1) {
-// const definition = property_definitions[i];
-// if (@hasField(definition, "lazyClass")) {
-// data[i] = New(className, property_names[i], @field(property_definitions, property_names[i]));
-// } else if (@hasField(definition, "lazyProperty")) {
-// data[i] = NewLazyProperty(className, property_names[i], @field(property_definitions, property_names[i]));
-// } else if (@hasField(definition, "get") and @hasField(definition, "set")) {
-// data[i] = NewStaticProperty(className, property_names[i], definition.get, definition.set);
-// } else if (@hasField(definition, "get")) {
-// data[i] = NewStaticProperty(className, property_names[i], definition.get, {});
-// } else if (@hasField(definition, "set")) {
-// data[i] = NewStaticProperty(className, property_names[i], {}, definition.set);
-// } else {
-// @compileError(className ++ "." ++ property_names[i] ++ " missing lazy, get, or set");
-// }
-// }
-
-// return data;
-// }
-
-// pub const entries = getProperties() ++ getFunctions();
-// };
-// }
-
const JSValue = JSC.JSValue;
const ZigString = JSC.ZigString;
@@ -1765,7 +457,7 @@ pub const ArrayBuffer = extern struct {
extern "C" fn Bun__createUint8ArrayForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize, buffer: bool) JSValue;
extern "C" fn Bun__createArrayBufferForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize) JSValue;
- pub fn fromTypedArray(ctx: JSC.C.JSContextRef, value: JSC.JSValue, _: JSC.C.ExceptionRef) ArrayBuffer {
+ pub fn fromTypedArray(ctx: JSC.C.JSContextRef, value: JSC.JSValue) ArrayBuffer {
var out = std.mem.zeroes(ArrayBuffer);
std.debug.assert(value.asArrayBuffer_(ctx.ptr(), &out));
out.value = value;
@@ -1927,16 +619,16 @@ pub const MarkedArrayBuffer = struct {
return this.buffer.stream();
}
- pub fn fromTypedArray(ctx: JSC.C.JSContextRef, value: JSC.JSValue, exception: JSC.C.ExceptionRef) MarkedArrayBuffer {
+ pub fn fromTypedArray(ctx: JSC.C.JSContextRef, value: JSC.JSValue) MarkedArrayBuffer {
return MarkedArrayBuffer{
.allocator = null,
- .buffer = ArrayBuffer.fromTypedArray(ctx, value, exception),
+ .buffer = ArrayBuffer.fromTypedArray(ctx, value),
};
}
- pub fn fromArrayBuffer(ctx: JSC.C.JSContextRef, value: JSC.JSValue, exception: JSC.C.ExceptionRef) MarkedArrayBuffer {
+ pub fn fromArrayBuffer(ctx: JSC.C.JSContextRef, value: JSC.JSValue) MarkedArrayBuffer {
return MarkedArrayBuffer{
.allocator = null,
- .buffer = ArrayBuffer.fromArrayBuffer(ctx, value, exception),
+ .buffer = ArrayBuffer.fromArrayBuffer(ctx, value),
};
}
@@ -2138,13 +830,6 @@ pub export fn BlobArrayBuffer_deallocator(_: *anyopaque, blob: *anyopaque) void
store.deref();
}
-pub fn castObj(obj: js.JSObjectRef, comptime Type: type) *Type {
- return JSPrivateDataPtr.from(js.JSObjectGetPrivate(obj)).as(Type);
-}
-
-const JSNode = @import("../js_ast.zig").Macro.JSNode;
-const LazyPropertiesObject = @import("../js_ast.zig").Macro.LazyPropertiesObject;
-const ModuleNamespace = @import("../js_ast.zig").Macro.ModuleNamespace;
const Expect = Test.Expect;
const DescribeScope = Test.DescribeScope;
const TestScope = Test.TestScope;
@@ -2174,24 +859,6 @@ const SHA256 = JSC.API.Bun.Crypto.SHA256;
const SHA512_256 = JSC.API.Bun.Crypto.SHA512_256;
const MD5_SHA1 = JSC.API.Bun.Crypto.MD5_SHA1;
const FFI = JSC.FFI;
-pub const JSPrivateDataPtr = TaggedPointerUnion(.{
- DebugServer,
- DebugSSLServer,
- FetchEvent,
- JSNode,
- LazyPropertiesObject,
-
- ModuleNamespace,
- Router,
- Server,
-
- SSLServer,
- FFI,
-});
-
-pub inline fn GetJSPrivateData(comptime Type: type, ref: js.JSObjectRef) ?*Type {
- return JSPrivateDataPtr.from(js.JSObjectGetPrivate(ref)).get(Type);
-}
pub const JSPropertyNameIterator = struct {
array: js.JSPropertyNameArrayRef,
@@ -2207,78 +874,6 @@ pub const JSPropertyNameIterator = struct {
}
};
-pub fn getterWrap(comptime Container: type, comptime name: string) GetterType(Container) {
- return struct {
- const FunctionType = @TypeOf(@field(Container, name));
- const FunctionTypeInfo: std.builtin.Type.Fn = @typeInfo(FunctionType).Fn;
- const ArgsTuple = std.meta.ArgsTuple(FunctionType);
-
- pub fn callback(
- this: *Container,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- const result: JSValue = if (comptime std.meta.fields(ArgsTuple).len == 1)
- @call(.auto, @field(Container, name), .{
- this,
- })
- else
- @call(.auto, @field(Container, name), .{ this, ctx.ptr() });
- if (result.isError()) {
- exception.* = result.asObjectRef();
- return null;
- }
-
- return result.asObjectRef();
- }
- }.callback;
-}
-
-fn GetterType(comptime Container: type) type {
- return fn (
- this: *Container,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef;
-}
-
-fn MethodType(comptime Container: type, comptime has_container: bool) type {
- return fn (
- this: if (has_container) *Container else void,
- ctx: js.JSContextRef,
- thisObject: js.JSObjectRef,
- target: js.JSObjectRef,
- args: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef;
-}
-
-pub fn wrapSync(
- comptime Container: type,
- comptime name: string,
-) MethodType(Container, true) {
- return wrap(Container, name, false);
-}
-
-pub fn wrapAsync(
- comptime Container: type,
- comptime name: string,
-) MethodType(Container, true) {
- return wrap(Container, name, true);
-}
-
-pub fn wrap(
- comptime Container: type,
- comptime name: string,
- comptime maybe_async: bool,
-) MethodType(Container, true) {
- return wrapWithHasContainer(Container, name, maybe_async, true, true);
-}
-
pub const DOMEffect = struct {
reads: [4]ID = std.mem.zeroes([4]ID),
writes: [4]ID = std.mem.zeroes([4]ID),
@@ -2649,202 +1244,6 @@ pub fn DOMCall(
};
}
-pub fn wrapWithHasContainer(
- comptime Container: type,
- comptime name: string,
- comptime maybe_async: bool,
- comptime has_container: bool,
- comptime auto_protect: bool,
-) MethodType(Container, has_container) {
- return struct {
- const FunctionType = @TypeOf(@field(Container, name));
- const FunctionTypeInfo: std.builtin.Type.Fn = @typeInfo(FunctionType).Fn;
- const Args = std.meta.ArgsTuple(FunctionType);
- const eater = if (auto_protect) JSC.Node.ArgumentsSlice.protectEatNext else JSC.Node.ArgumentsSlice.nextEat;
-
- pub fn callback(
- this: if (has_container) *Container else void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- thisObject: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- var iter = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
- defer iter.deinit();
- var args: Args = undefined;
-
- comptime var passed_exception_ref = false;
- comptime var i: usize = 0;
- inline while (i < FunctionTypeInfo.params.len) : (i += 1) {
- const ArgType = comptime FunctionTypeInfo.params[i].type.?;
-
- switch (comptime ArgType) {
- *Container => {
- args[i] = this;
- },
- *JSC.JSGlobalObject => {
- args[i] = ctx.ptr();
- },
- JSC.Node.StringOrBuffer => {
- const arg = iter.nextEat() orelse {
- exception.* = JSC.toInvalidArguments("expected string or buffer", .{}, ctx).asObjectRef();
- return null;
- };
- args[i] = JSC.Node.StringOrBuffer.fromJS(ctx.ptr(), iter.arena.allocator(), arg, exception) orelse {
- exception.* = JSC.toInvalidArguments("expected string or buffer", .{}, ctx).asObjectRef();
- return null;
- };
- },
- ?JSC.Node.StringOrBuffer => {
- if (iter.nextEat()) |arg| {
- if (!arg.isEmptyOrUndefinedOrNull()) {
- args[i] = JSC.Node.StringOrBuffer.fromJS(ctx.ptr(), iter.arena.allocator(), arg, exception) orelse {
- exception.* = JSC.toInvalidArguments("expected string or buffer", .{}, ctx).asObjectRef();
- return null;
- };
- } else {
- args[i] = null;
- }
- } else {
- args[i] = null;
- }
- },
- ?JSC.Node.SliceOrBuffer => {
- if (iter.nextEat()) |arg| {
- if (!arg.isEmptyOrUndefinedOrNull()) {
- args[i] = JSC.Node.SliceOrBuffer.fromJS(ctx.ptr(), iter.arena.allocator(), arg, exception) orelse {
- exception.* = JSC.toInvalidArguments("expected string or buffer", .{}, ctx).asObjectRef();
- return null;
- };
- } else {
- args[i] = null;
- }
- } else {
- args[i] = null;
- }
- },
- JSC.ArrayBuffer => {
- if (iter.nextEat()) |arg| {
- args[i] = arg.asArrayBuffer(ctx.ptr()) orelse {
- exception.* = JSC.toInvalidArguments("expected TypedArray", .{}, ctx).asObjectRef();
- return null;
- };
- } else {
- exception.* = JSC.toInvalidArguments("expected TypedArray", .{}, ctx).asObjectRef();
- return null;
- }
- },
- ?JSC.ArrayBuffer => {
- if (iter.nextEat()) |arg| {
- if (!arg.isEmptyOrUndefinedOrNull()) {
- args[i] = arg.asArrayBuffer(ctx.ptr()) orelse {
- exception.* = JSC.toInvalidArguments("expected TypedArray", .{}, ctx).asObjectRef();
- return null;
- };
- } else {
- args[i] = null;
- }
- } else {
- args[i] = null;
- }
- },
- ZigString => {
- var string_value = eater(&iter) orelse {
- JSC.throwInvalidArguments("Missing argument", .{}, ctx, exception);
- return null;
- };
-
- if (string_value.isUndefinedOrNull()) {
- JSC.throwInvalidArguments("Expected string", .{}, ctx, exception);
- return null;
- }
-
- args[i] = string_value.getZigString(ctx.ptr());
- },
- ?JSC.Cloudflare.ContentOptions => {
- if (iter.nextEat()) |content_arg| {
- if (content_arg.get(ctx.ptr(), "html")) |html_val| {
- args[i] = .{ .html = html_val.toBoolean() };
- }
- } else {
- args[i] = null;
- }
- },
- *Response => {
- args[i] = (eater(&iter) orelse {
- JSC.throwInvalidArguments("Missing Response object", .{}, ctx, exception);
- iter.deinit();
- return null;
- }).as(Response) orelse {
- JSC.throwInvalidArguments("Expected Response object", .{}, ctx, exception);
- iter.deinit();
- return null;
- };
- },
- *Request => {
- args[i] = (eater(&iter) orelse {
- JSC.throwInvalidArguments("Missing Request object", .{}, ctx, exception);
- return null;
- }).as(Request) orelse {
- JSC.throwInvalidArguments("Expected Request object", .{}, ctx, exception);
- return null;
- };
- },
- js.JSObjectRef => {
- args[i] = thisObject;
- if (!JSValue.fromRef(thisObject).isCell() or !JSValue.fromRef(thisObject).isObject()) {
- JSC.throwInvalidArguments("Expected object", .{}, ctx, exception);
- return null;
- }
- },
- js.ExceptionRef => {
- args[i] = exception;
- passed_exception_ref = true;
- },
- JSValue => {
- const val = eater(&iter) orelse {
- JSC.throwInvalidArguments("Missing argument", .{}, ctx, exception);
- return null;
- };
- args[i] = val;
- },
- ?JSValue => {
- args[i] = eater(&iter);
- },
- else => @compileError("Unexpected Type " ++ @typeName(ArgType)),
- }
- }
-
- var result: JSValue = @call(.auto, @field(Container, name), args);
- if (comptime passed_exception_ref) {
- if (exception.* != null) {
- return null;
- }
- } else {
- if (result.isError()) {
- exception.* = result.asObjectRef();
- return null;
- }
- }
-
- if (comptime maybe_async) {
- if (result.asAnyPromise()) |promise| {
- var vm = ctx.ptr().bunVM();
- vm.waitForPromise(promise);
- result = promise.result(ctx.vm());
- }
- }
-
- if (result == .zero) {
- return null;
- }
-
- return result.asObjectRef();
- }
- }.callback;
-}
-
pub fn InstanceMethodType(comptime Container: type) type {
return fn (instance: *Container, globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue;
}
@@ -2869,6 +1268,21 @@ pub fn wrapInstanceMethod(
var iter = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments.ptr[0..arguments.len]);
var args: Args = undefined;
+ const has_exception_ref: bool = comptime brk: {
+ var i: usize = 0;
+ while (i < FunctionTypeInfo.params.len) : (i += 1) {
+ const ArgType = FunctionTypeInfo.params[i].type.?;
+
+ if (ArgType == JSC.C.ExceptionRef) {
+ break :brk true;
+ }
+ }
+
+ break :brk false;
+ };
+ var exception_value = [_]JSC.C.JSValueRef{null};
+ var exception: JSC.C.ExceptionRef = if (comptime has_exception_ref) &exception_value else undefined;
+
comptime var i: usize = 0;
inline while (i < FunctionTypeInfo.params.len) : (i += 1) {
const ArgType = comptime FunctionTypeInfo.params[i].type.?;
@@ -3006,12 +1420,23 @@ pub fn wrapInstanceMethod(
?JSValue => {
args[i] = eater(&iter);
},
+ JSC.C.ExceptionRef => {
+ args[i] = exception;
+ },
else => @compileError("Unexpected Type " ++ @typeName(ArgType)),
}
}
defer iter.deinit();
+ defer {
+ if (comptime has_exception_ref) {
+ if (exception_value[0] != null) {
+ globalThis.throwValue(exception_value[0].?.value());
+ }
+ }
+ }
+
return @call(.auto, @field(Container, name), args);
}
}.method;
@@ -3171,7 +1596,7 @@ pub fn wrapStaticMethod(
?JSValue => {
args[i] = eater(&iter);
},
- else => @compileError("Unexpected Type " ++ @typeName(ArgType)),
+ else => @compileError(std.fmt.comptimePrint("Unexpected Type " ++ @typeName(ArgType) ++ " at argument {d} in {s}#{s}", .{ i, @typeName(Container), name })),
}
}
diff --git a/src/bun.js/bindings/BunDebugger.cpp b/src/bun.js/bindings/BunDebugger.cpp
index 9d14a75b7..0df94b6d1 100644
--- a/src/bun.js/bindings/BunDebugger.cpp
+++ b/src/bun.js/bindings/BunDebugger.cpp
@@ -1,5 +1,4 @@
#include "root.h"
-#include <uws/src/App.h>
#include <JavaScriptCore/InspectorFrontendChannel.h>
#include <JavaScriptCore/JSGlobalObjectDebuggable.h>
@@ -8,8 +7,11 @@
#include "ScriptExecutionContext.h"
#include "Strong.h"
#include "debug-helpers.h"
+#include "BunInjectedScriptHost.h"
+#include <JavaScriptCore/JSGlobalObjectInspectorController.h>
extern "C" void Bun__tickWhilePaused(bool*);
+extern "C" void Bun__eventLoop__incrementRefConcurrently(void* bunVM, int delta);
namespace Bun {
using namespace JSC;
@@ -31,10 +33,11 @@ enum class ConnectionStatus : int32_t {
class BunInspectorConnection : public Inspector::FrontendChannel {
public:
- BunInspectorConnection(ScriptExecutionContext& scriptExecutionContext, JSC::JSGlobalObject* globalObject)
+ BunInspectorConnection(ScriptExecutionContext& scriptExecutionContext, JSC::JSGlobalObject* globalObject, bool shouldRefEventLoop)
: Inspector::FrontendChannel()
, globalObject(globalObject)
, scriptExecutionContextIdentifier(scriptExecutionContext.identifier())
+ , unrefOnDisconnect(shouldRefEventLoop)
{
}
@@ -42,9 +45,9 @@ public:
{
}
- static BunInspectorConnection* create(ScriptExecutionContext& scriptExecutionContext, JSC::JSGlobalObject* globalObject)
+ static BunInspectorConnection* create(ScriptExecutionContext& scriptExecutionContext, JSC::JSGlobalObject* globalObject, bool shouldRefEventLoop)
{
- return new BunInspectorConnection(scriptExecutionContext, globalObject);
+ return new BunInspectorConnection(scriptExecutionContext, globalObject, shouldRefEventLoop);
}
ConnectionType connectionType() const override
@@ -72,6 +75,9 @@ public:
case ConnectionStatus::Pending: {
connection->status = ConnectionStatus::Connected;
auto* globalObject = context.jsGlobalObject();
+ if (connection->unrefOnDisconnect) {
+ Bun__eventLoop__incrementRefConcurrently(reinterpret_cast<Zig::GlobalObject*>(globalObject)->bunVM(), 1);
+ }
globalObject->setInspectable(true);
auto& inspector = globalObject->inspectorDebuggable();
@@ -117,6 +123,10 @@ public:
connection->status = ConnectionStatus::Disconnected;
connection->inspector().disconnect(*connection);
+ if (connection->unrefOnDisconnect) {
+ connection->unrefOnDisconnect = false;
+ Bun__eventLoop__incrementRefConcurrently(reinterpret_cast<Zig::GlobalObject*>(context.jsGlobalObject())->bunVM(), -1);
+ }
});
}
@@ -288,6 +298,8 @@ public:
WTF::Lock jsWaitForMessageFromInspectorLock;
std::atomic<ConnectionStatus> status = ConnectionStatus::Pending;
+
+ bool unrefOnDisconnect = false;
};
JSC_DECLARE_HOST_FUNCTION(jsFunctionSend);
@@ -396,6 +408,7 @@ extern "C" void Bun__ensureDebugger(ScriptExecutionContextIdentifier scriptId, b
{
auto* globalObject = ScriptExecutionContext::getScriptExecutionContext(scriptId)->jsGlobalObject();
+ globalObject->m_inspectorController = makeUnique<Inspector::JSGlobalObjectInspectorController>(*globalObject, Bun::BunInjectedScriptHost::create());
globalObject->setInspectable(true);
auto& inspector = globalObject->inspectorDebuggable();
@@ -419,7 +432,8 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateConnection, (JSGlobalObject * globalObj
return JSValue::encode(jsUndefined());
ScriptExecutionContext* targetContext = ScriptExecutionContext::getScriptExecutionContext(static_cast<ScriptExecutionContextIdentifier>(callFrame->argument(0).toUInt32(globalObject)));
- JSFunction* onMessageFn = jsCast<JSFunction*>(callFrame->argument(1).toObject(globalObject));
+ bool shouldRef = !callFrame->argument(1).toBoolean(globalObject);
+ JSFunction* onMessageFn = jsCast<JSFunction*>(callFrame->argument(2).toObject(globalObject));
if (!targetContext || !onMessageFn)
return JSValue::encode(jsUndefined());
@@ -427,7 +441,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateConnection, (JSGlobalObject * globalObj
auto& vm = globalObject->vm();
auto connection = BunInspectorConnection::create(
*targetContext,
- targetContext->jsGlobalObject());
+ targetContext->jsGlobalObject(), shouldRef);
{
WTF::LockHolder locker(inspectorConnectionsLock);
@@ -453,7 +467,7 @@ extern "C" BunString Bun__startJSDebuggerThread(Zig::GlobalObject* debuggerGloba
arguments.append(jsNumber(static_cast<unsigned int>(scriptId)));
arguments.append(Bun::toJS(debuggerGlobalObject, *portOrPathString));
- arguments.append(JSFunction::create(vm, debuggerGlobalObject, 1, String(), jsFunctionCreateConnection, ImplementationVisibility::Public));
+ arguments.append(JSFunction::create(vm, debuggerGlobalObject, 3, String(), jsFunctionCreateConnection, ImplementationVisibility::Public));
arguments.append(JSFunction::create(vm, debuggerGlobalObject, 1, String("send"_s), jsFunctionSend, ImplementationVisibility::Public));
arguments.append(JSFunction::create(vm, debuggerGlobalObject, 0, String("disconnect"_s), jsFunctionDisconnect, ImplementationVisibility::Public));
diff --git a/src/bun.js/bindings/BunInjectedScriptHost.cpp b/src/bun.js/bindings/BunInjectedScriptHost.cpp
new file mode 100644
index 000000000..2be574025
--- /dev/null
+++ b/src/bun.js/bindings/BunInjectedScriptHost.cpp
@@ -0,0 +1,211 @@
+#include "root.h"
+#include "BunInjectedScriptHost.h"
+
+#include "ZigGeneratedClasses.h"
+#include "DOMException.h"
+
+#include "JSDOMException.h"
+#include "JSEventListener.h"
+#include "JSEventTarget.h"
+#include "JSWorker.h"
+#include "JavaScriptCore/ObjectConstructor.h"
+
+#include "JSFetchHeaders.h"
+#include "JSURLSearchParams.h"
+#include "JSDOMFormData.h"
+#include <JavaScriptCore/JSCallbackObject.h>
+namespace Bun {
+
+using namespace JSC;
+using namespace WebCore;
+
+JSValue BunInjectedScriptHost::subtype(JSGlobalObject* exec, JSValue value)
+{
+ VM& vm = exec->vm();
+
+ if (
+ value.inherits<JSDOMException>() || value.inherits<JSResolveMessage>() || value.inherits<JSBuildMessage>())
+ return jsNontrivialString(vm, "error"_s);
+
+ return jsUndefined();
+}
+
+static JSObject* constructInternalProperty(VM& vm, JSGlobalObject* exec, const String& name, JSValue value)
+{
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, name));
+ object->putDirect(vm, Identifier::fromString(vm, "value"_s), value);
+ return object;
+}
+
+static JSObject* constructInternalProperty(VM& vm, JSGlobalObject* exec, Identifier name, JSValue value)
+{
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(vm, "name"_s), JSC::identifierToJSValue(vm, name));
+ object->putDirect(vm, Identifier::fromString(vm, "value"_s), value);
+ return object;
+}
+
+static JSObject* objectForEventTargetListeners(VM& vm, JSGlobalObject* exec, EventTarget* eventTarget)
+{
+ auto* scriptExecutionContext = eventTarget->scriptExecutionContext();
+ if (!scriptExecutionContext)
+ return nullptr;
+
+ JSObject* listeners = nullptr;
+
+ for (auto& eventType : eventTarget->eventTypes()) {
+ unsigned listenersForEventIndex = 0;
+ auto* listenersForEvent = constructEmptyArray(exec, nullptr);
+
+ for (auto& eventListener : eventTarget->eventListeners(eventType)) {
+ if (!is<JSEventListener>(eventListener->callback()))
+ continue;
+
+ auto& jsListener = downcast<JSEventListener>(eventListener->callback());
+ // if (jsListener.isolatedWorld() != &currentWorld(*exec))
+ // continue;
+
+ auto* jsFunction = jsListener.ensureJSFunction(*scriptExecutionContext);
+ if (!jsFunction)
+ continue;
+
+ auto* propertiesForListener = constructEmptyObject(exec);
+ propertiesForListener->putDirect(vm, Identifier::fromString(vm, "callback"_s), jsFunction);
+ propertiesForListener->putDirect(vm, Identifier::fromString(vm, "capture"_s), jsBoolean(eventListener->useCapture()));
+ propertiesForListener->putDirect(vm, Identifier::fromString(vm, "passive"_s), jsBoolean(eventListener->isPassive()));
+ propertiesForListener->putDirect(vm, Identifier::fromString(vm, "once"_s), jsBoolean(eventListener->isOnce()));
+ listenersForEvent->putDirectIndex(exec, listenersForEventIndex++, propertiesForListener);
+ }
+
+ if (listenersForEventIndex) {
+ if (!listeners)
+ listeners = constructEmptyObject(exec);
+ listeners->putDirect(vm, Identifier::fromString(vm, eventType), listenersForEvent);
+ }
+ }
+
+ return listeners;
+}
+
+static JSValue constructDataProperties(VM& vm, JSGlobalObject* exec, JSArray* array, JSValue value)
+{
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (!value.isObject())
+ return value;
+
+ auto* object = asObject(value);
+ PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
+ object->getPropertyNames(exec, propertyNames, DontEnumPropertiesMode::Exclude);
+ RETURN_IF_EXCEPTION(scope, {});
+ unsigned i = 0;
+
+ for (auto& propertyName : propertyNames) {
+ auto propertyValue = object->getDirect(vm, propertyName);
+
+ array->putDirectIndex(exec, i++, constructInternalProperty(vm, exec, propertyName, propertyValue));
+ RETURN_IF_EXCEPTION(scope, {});
+ }
+
+ RELEASE_AND_RETURN(scope, array);
+}
+
+static JSValue constructDataPropertiesSlow(VM& vm, JSGlobalObject* exec, JSArray* array, JSValue value)
+{
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (!value.isObject())
+ return value;
+
+ auto* object = asObject(value);
+ PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
+ object->getPropertyNames(exec, propertyNames, DontEnumPropertiesMode::Exclude);
+ RETURN_IF_EXCEPTION(scope, {});
+ unsigned i = 0;
+ auto catcher = DECLARE_CATCH_SCOPE(vm);
+
+ for (auto& propertyName : propertyNames) {
+ auto propertyValue = object->get(exec, propertyName);
+ if (catcher.exception()) {
+ catcher.clearException();
+ propertyValue = jsUndefined();
+ }
+
+ array->putDirectIndex(exec, i++, constructInternalProperty(vm, exec, propertyName, propertyValue));
+ RETURN_IF_EXCEPTION(scope, {});
+ }
+
+ RELEASE_AND_RETURN(scope, array);
+}
+
+JSValue BunInjectedScriptHost::getInternalProperties(VM& vm, JSGlobalObject* exec, JSC::JSValue value)
+{
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (auto* worker = JSWorker::toWrapped(vm, value)) {
+ unsigned index = 0;
+ auto* array = constructEmptyArray(exec, nullptr);
+
+ String name = worker->name();
+ if (!name.isEmpty())
+ array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "name"_s, jsString(vm, WTFMove(name))));
+
+ array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "terminated"_s, jsBoolean(worker->wasTerminated())));
+
+ if (auto* listeners = objectForEventTargetListeners(vm, exec, worker))
+ array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "listeners"_s, listeners));
+
+ RETURN_IF_EXCEPTION(scope, {});
+ return array;
+ }
+
+ if (value.isCell()) {
+ JSC::JSCell* cell = value.asCell();
+ JSC::JSType type = cell->type();
+
+ if (type == JSDOMWrapperType) {
+ if (auto* headers = jsDynamicCast<JSFetchHeaders*>(value)) {
+ auto* array = constructEmptyArray(exec, nullptr);
+ unsigned index = 0;
+ // array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "#inspect"_s, WebCore::getInternalProperties(vm, exec, headers)));
+ constructDataProperties(vm, exec, array, WebCore::getInternalProperties(vm, exec, headers));
+ RETURN_IF_EXCEPTION(scope, {});
+ return array;
+ }
+
+ if (auto* params = jsDynamicCast<JSURLSearchParams*>(value)) {
+ auto* array = constructEmptyArray(exec, nullptr);
+ unsigned index = 0;
+ // array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "#inspect"_s, WebCore::getInternalProperties(vm, exec, params)));
+ constructDataProperties(vm, exec, array, WebCore::getInternalProperties(vm, exec, params));
+ RETURN_IF_EXCEPTION(scope, {});
+ return array;
+ }
+
+ if (auto* formData = jsDynamicCast<JSDOMFormData*>(value)) {
+ unsigned index = 0;
+ auto* array = constructEmptyArray(exec, nullptr);
+ // array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "#inspect"_s, WebCore::getInternalProperties(vm, exec, formData)));
+ constructDataProperties(vm, exec, array, WebCore::getInternalProperties(vm, exec, formData));
+ RETURN_IF_EXCEPTION(scope, {});
+ return array;
+ }
+ }
+ }
+
+ if (auto* eventTarget = JSEventTarget::toWrapped(vm, value)) {
+ unsigned index = 0;
+ auto* array = constructEmptyArray(exec, nullptr);
+
+ if (auto* listeners = objectForEventTargetListeners(vm, exec, eventTarget))
+ array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "listeners"_s, listeners));
+
+ RETURN_IF_EXCEPTION(scope, {});
+ return array;
+ }
+
+ return {};
+}
+
+} \ No newline at end of file
diff --git a/src/bun.js/bindings/BunInjectedScriptHost.h b/src/bun.js/bindings/BunInjectedScriptHost.h
new file mode 100644
index 000000000..09e7e1361
--- /dev/null
+++ b/src/bun.js/bindings/BunInjectedScriptHost.h
@@ -0,0 +1,15 @@
+#pragma once
+#include <JavaScriptCore/InjectedScriptHost.h>
+
+namespace Bun {
+
+class BunInjectedScriptHost final : public Inspector::InjectedScriptHost {
+public:
+ static Ref<BunInjectedScriptHost> create() { return adoptRef(*new BunInjectedScriptHost); }
+
+ JSC::JSValue subtype(JSC::JSGlobalObject*, JSC::JSValue) override;
+ JSC::JSValue getInternalProperties(JSC::VM&, JSC::JSGlobalObject*, JSC::JSValue) override;
+ bool isHTMLAllCollection(JSC::VM&, JSC::JSValue) override { return false; }
+};
+
+} \ No newline at end of file
diff --git a/src/bun.js/bindings/BunObject+exports.h b/src/bun.js/bindings/BunObject+exports.h
new file mode 100644
index 000000000..c081a7c1c
--- /dev/null
+++ b/src/bun.js/bindings/BunObject+exports.h
@@ -0,0 +1,82 @@
+// clang-format off
+
+#define FOR_EACH_GETTER(macro) \
+ macro(CryptoHasher) \
+ macro(FFI) \
+ macro(FileSystemRouter) \
+ macro(MD4) \
+ macro(MD5) \
+ macro(SHA1) \
+ macro(SHA224) \
+ macro(SHA256) \
+ macro(SHA384) \
+ macro(SHA512) \
+ macro(SHA512_256) \
+ macro(TOML) \
+ macro(Transpiler) \
+ macro(argv) \
+ macro(assetPrefix) \
+ macro(cwd) \
+ macro(enableANSIColors) \
+ macro(hash) \
+ macro(main) \
+ macro(origin) \
+ macro(stderr) \
+ macro(stdin) \
+ macro(stdout) \
+ macro(unsafe) \
+// --- Getters ---
+
+#define FOR_EACH_CALLBACK(macro) \
+ macro(DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump) \
+ macro(_Os) \
+ macro(_Path) \
+ macro(allocUnsafe) \
+ macro(build) \
+ macro(connect) \
+ macro(deflateSync) \
+ macro(file) \
+ macro(fs) \
+ macro(gc) \
+ macro(generateHeapSnapshot) \
+ macro(getImportedStyles) \
+ macro(gunzipSync) \
+ macro(gzipSync) \
+ macro(indexOfLine) \
+ macro(inflateSync) \
+ macro(inspect) \
+ macro(jest) \
+ macro(listen) \
+ macro(mmap) \
+ macro(nanoseconds) \
+ macro(openInEditor) \
+ macro(registerMacro) \
+ macro(resolve) \
+ macro(resolveSync) \
+ macro(serve) \
+ macro(sha) \
+ macro(shrink) \
+ macro(sleepSync) \
+ macro(spawn) \
+ macro(spawnSync) \
+ macro(which) \
+ macro(write) \
+
+
+#define DECLARE_ZIG_BUN_OBJECT_CALLBACK(name) extern "C" JSC::EncodedJSValue BunObject_callback_##name(JSC::JSGlobalObject*, JSC::CallFrame*);
+FOR_EACH_CALLBACK(DECLARE_ZIG_BUN_OBJECT_CALLBACK);
+#undef DECLARE_ZIG_BUN_OBJECT_CALLBACK
+
+#define DECLARE_ZIG_BUN_OBJECT_GETTER(name) extern "C" JSC::EncodedJSValue BunObject_getter_##name(JSC::JSGlobalObject*, JSC::JSObject*);
+FOR_EACH_GETTER(DECLARE_ZIG_BUN_OBJECT_GETTER);
+#undef DECLARE_ZIG_BUN_OBJECT_GETTER
+
+#define DEFINE_ZIG_BUN_OBJECT_GETTER_WRAPPER(name) JSC::JSValue BunObject_getter_wrap_##name(JSC::VM &vm, JSC::JSObject *object) { \
+ return JSC::JSValue::decode(BunObject_getter_##name(object->globalObject(), object)); \
+} \
+
+FOR_EACH_GETTER(DEFINE_ZIG_BUN_OBJECT_GETTER_WRAPPER);
+#undef DEFINE_ZIG_BUN_OBJECT_GETTER_WRAPPER
+
+#undef FOR_EACH_GETTER
+#undef FOR_EACH_CALLBACK \ No newline at end of file
diff --git a/src/bun.js/bindings/BunObject.cpp b/src/bun.js/bindings/BunObject.cpp
new file mode 100644
index 000000000..5bbc5a191
--- /dev/null
+++ b/src/bun.js/bindings/BunObject.cpp
@@ -0,0 +1,706 @@
+#include "root.h"
+#include "ZigGlobalObject.h"
+
+#include "JSDOMURL.h"
+#include "helpers.h"
+#include "IDLTypes.h"
+#include "DOMURL.h"
+#include "JavaScriptCore/JSPromise.h"
+#include "JavaScriptCore/JSBase.h"
+#include "JavaScriptCore/BuiltinNames.h"
+#include "ScriptExecutionContext.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/InternalFunction.h>
+#include <JavaScriptCore/LazyClassStructure.h>
+#include <JavaScriptCore/LazyClassStructureInlines.h>
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/DateInstance.h>
+#include <JavaScriptCore/ObjectConstructor.h>
+#include "headers.h"
+#include "BunObject.h"
+#include "WebCoreJSBuiltins.h"
+#include "JavaScriptCore/JSObject.h"
+#include "DOMJITIDLConvert.h"
+#include "DOMJITIDLType.h"
+#include "DOMJITIDLTypeFilter.h"
+#include "Exception.h"
+#include "BunObject+exports.h"
+#include "JSDOMException.h"
+#include "JSDOMConvert.h"
+
+namespace Bun {
+
+using namespace JSC;
+using namespace WebCore;
+
+extern "C" JSC::EncodedJSValue Bun__fetch(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+
+static JSValue BunObject_getter_wrap_ArrayBufferSink(VM& vm, JSObject* bunObject)
+{
+ return jsCast<Zig::GlobalObject*>(bunObject->globalObject())->ArrayBufferSink();
+}
+
+static JSValue constructEnvObject(VM& vm, JSObject* object)
+{
+ return jsCast<Zig::GlobalObject*>(object->globalObject())->processEnvObject();
+}
+
+static inline EncodedJSValue flattenArrayOfBuffersIntoArrayBuffer(JSGlobalObject* lexicalGlobalObject, JSValue arrayValue)
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ auto clientData = WebCore::clientData(vm);
+ if (arrayValue.isUndefinedOrNull() || !arrayValue) {
+ return JSC::JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1)));
+ }
+
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+ auto array = JSC::jsDynamicCast<JSC::JSArray*>(arrayValue);
+ if (UNLIKELY(!array)) {
+ throwTypeError(lexicalGlobalObject, throwScope, "Argument must be an array"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ size_t arrayLength = array->length();
+ if (arrayLength < 1) {
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1))));
+ }
+
+ size_t byteLength = 0;
+ bool any_buffer = false;
+ bool any_typed = false;
+
+ for (size_t i = 0; i < arrayLength; i++) {
+ auto element = array->getIndex(lexicalGlobalObject, i);
+ RETURN_IF_EXCEPTION(throwScope, {});
+
+ if (auto* typedArray = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(element)) {
+ if (UNLIKELY(typedArray->isDetached())) {
+ throwTypeError(lexicalGlobalObject, throwScope, "ArrayBufferView is detached"_s);
+ return JSValue::encode(jsUndefined());
+ }
+ byteLength += typedArray->byteLength();
+ any_typed = true;
+ } else if (auto* arrayBuffer = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(element)) {
+ auto* impl = arrayBuffer->impl();
+ if (UNLIKELY(!impl)) {
+ throwTypeError(lexicalGlobalObject, throwScope, "ArrayBuffer is detached"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ byteLength += impl->byteLength();
+ any_buffer = true;
+ } else {
+ throwTypeError(lexicalGlobalObject, throwScope, "Expected TypedArray"_s);
+ return JSValue::encode(jsUndefined());
+ }
+ }
+
+ if (byteLength == 0) {
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1))));
+ }
+
+ auto buffer = JSC::ArrayBuffer::tryCreateUninitialized(byteLength, 1);
+ if (UNLIKELY(!buffer)) {
+ throwTypeError(lexicalGlobalObject, throwScope, "Failed to allocate ArrayBuffer"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ size_t remain = byteLength;
+ auto* head = reinterpret_cast<char*>(buffer->data());
+
+ if (!any_buffer) {
+ for (size_t i = 0; i < arrayLength && remain > 0; i++) {
+ auto element = array->getIndex(lexicalGlobalObject, i);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ auto* view = JSC::jsCast<JSC::JSArrayBufferView*>(element);
+ size_t length = std::min(remain, view->byteLength());
+ memcpy(head, view->vector(), length);
+ remain -= length;
+ head += length;
+ }
+ } else if (!any_typed) {
+ for (size_t i = 0; i < arrayLength && remain > 0; i++) {
+ auto element = array->getIndex(lexicalGlobalObject, i);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ auto* view = JSC::jsCast<JSC::JSArrayBuffer*>(element);
+ size_t length = std::min(remain, view->impl()->byteLength());
+ memcpy(head, view->impl()->data(), length);
+ remain -= length;
+ head += length;
+ }
+ } else {
+ for (size_t i = 0; i < arrayLength && remain > 0; i++) {
+ auto element = array->getIndex(lexicalGlobalObject, i);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ size_t length = 0;
+ if (auto* view = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(element)) {
+ length = std::min(remain, view->impl()->byteLength());
+ memcpy(head, view->impl()->data(), length);
+ } else {
+ auto* typedArray = JSC::jsCast<JSC::JSArrayBufferView*>(element);
+ length = std::min(remain, typedArray->byteLength());
+ memcpy(head, typedArray->vector(), length);
+ }
+
+ remain -= length;
+ head += length;
+ }
+ }
+
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), WTFMove(buffer))));
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArrays, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto& vm = globalObject->vm();
+
+ if (UNLIKELY(callFrame->argumentCount() < 1)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected at least one argument"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ auto arrayValue = callFrame->uncheckedArgument(0);
+
+ return flattenArrayOfBuffersIntoArrayBuffer(globalObject, arrayValue);
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionConcatTypedArrays);
+
+static JSValue constructBunVersion(VM& vm, JSObject*)
+{
+ return JSC::jsString(vm, makeString(Bun__version + 1));
+}
+
+static JSValue constructBunRevision(VM& vm, JSObject*)
+{
+ return JSC::jsString(vm, makeString(Bun__version_sha));
+}
+
+static JSValue constructIsMainThread(VM&, JSObject* object)
+{
+ return jsBoolean(jsCast<Zig::GlobalObject*>(object->globalObject())->scriptExecutionContext()->isMainThread());
+}
+
+static JSValue constructPluginObject(VM& vm, JSObject* bunObject)
+{
+ auto* globalObject = bunObject->globalObject();
+ JSFunction* pluginFunction = JSFunction::create(vm, globalObject, 1, String("plugin"_s), jsFunctionBunPlugin, ImplementationVisibility::Public, NoIntrinsic);
+ pluginFunction->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "clearAll"_s), 1, jsFunctionBunPluginClear, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+
+ return pluginFunction;
+}
+
+extern "C" EncodedJSValue JSPasswordObject__create(JSGlobalObject*);
+
+static JSValue constructPasswordObject(VM& vm, JSObject* bunObject)
+{
+ return JSValue::decode(JSPasswordObject__create(bunObject->globalObject()));
+}
+
+extern "C" EncodedJSValue Bun__DNSResolver__lookup(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolve(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolveSrv(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolveTxt(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolveSoa(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolveNaptr(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolveMx(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolveCaa(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolveNs(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolvePtr(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__resolveCname(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__getServers(JSGlobalObject*, JSC::CallFrame*);
+
+static JSValue constructDNSObject(VM& vm, JSObject* bunObject)
+{
+ JSGlobalObject* globalObject = bunObject->globalObject();
+ JSC::JSObject* dnsObject = JSC::constructEmptyObject(globalObject);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookup"_s), 2, Bun__DNSResolver__lookup, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolve"_s), 2, Bun__DNSResolver__resolve, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSrv"_s), 2, Bun__DNSResolver__resolveSrv, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveTxt"_s), 2, Bun__DNSResolver__resolveTxt, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSoa"_s), 2, Bun__DNSResolver__resolveSoa, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNaptr"_s), 2, Bun__DNSResolver__resolveNaptr, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveMx"_s), 2, Bun__DNSResolver__resolveMx, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCaa"_s), 2, Bun__DNSResolver__resolveCaa, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNs"_s), 2, Bun__DNSResolver__resolveNs, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolvePtr"_s), 2, Bun__DNSResolver__resolvePtr, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCname"_s), 2, Bun__DNSResolver__resolveCname, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getServers"_s), 2, Bun__DNSResolver__getServers, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ return dnsObject;
+}
+
+static JSValue constructBunPeekObject(VM& vm, JSObject* bunObject)
+{
+ JSGlobalObject* globalObject = bunObject->globalObject();
+ JSC::Identifier identifier = JSC::Identifier::fromString(vm, "peek"_s);
+ JSFunction* peekFunction = JSFunction::create(vm, globalObject, 2, WTF::String("peek"_s), functionBunPeek, ImplementationVisibility::Public, NoIntrinsic);
+ JSFunction* peekStatus = JSFunction::create(vm, globalObject, 1, WTF::String("status"_s), functionBunPeekStatus, ImplementationVisibility::Public, NoIntrinsic);
+ peekFunction->putDirect(vm, PropertyName(JSC::Identifier::fromString(vm, "status"_s)), peekStatus, JSC::PropertyAttribute::Function | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+
+ return peekFunction;
+}
+
+extern "C" uint64_t Bun__readOriginTimer(void*);
+extern "C" double Bun__readOriginTimerStart(void*);
+static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(functionBunEscapeHTMLWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject*, JSObject*, JSString*));
+
+JSC_DEFINE_HOST_FUNCTION(functionBunSleepThenCallback,
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ RELEASE_ASSERT(callFrame->argumentCount() == 1);
+ JSPromise* promise = jsCast<JSC::JSPromise*>(callFrame->argument(0));
+ RELEASE_ASSERT(promise);
+
+ promise->resolve(globalObject, JSC::jsUndefined());
+
+ return JSC::JSValue::encode(promise);
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionBunPeek,
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSValue promiseValue = callFrame->argument(0);
+ if (UNLIKELY(!promiseValue)) {
+ return JSValue::encode(jsUndefined());
+ } else if (!promiseValue.isCell()) {
+ return JSValue::encode(promiseValue);
+ }
+
+ auto* promise = jsDynamicCast<JSPromise*>(promiseValue);
+
+ if (!promise) {
+ return JSValue::encode(promiseValue);
+ }
+
+ JSValue invalidateValue = callFrame->argument(1);
+ bool invalidate = invalidateValue.isBoolean() && invalidateValue.asBoolean();
+
+ switch (promise->status(vm)) {
+ case JSPromise::Status::Pending: {
+ break;
+ }
+ case JSPromise::Status::Fulfilled: {
+ JSValue result = promise->result(vm);
+ if (invalidate) {
+ promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(vm, promise, jsUndefined());
+ }
+ return JSValue::encode(result);
+ }
+ case JSPromise::Status::Rejected: {
+ JSValue result = promise->result(vm);
+ JSC::EnsureStillAliveScope ensureStillAliveScope(result);
+
+ if (invalidate) {
+ promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(promise->internalField(JSC::JSPromise::Field::Flags).get().asUInt32() | JSC::JSPromise::isHandledFlag));
+ promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(vm, promise, JSC::jsUndefined());
+ }
+
+ return JSValue::encode(result);
+ }
+ }
+
+ return JSValue::encode(promiseValue);
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionBunPeekStatus,
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+ static NeverDestroyed<String> fulfilled = MAKE_STATIC_STRING_IMPL("fulfilled");
+
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSValue promiseValue = callFrame->argument(0);
+ if (!promiseValue || !promiseValue.isCell()) {
+ return JSValue::encode(jsOwnedString(vm, fulfilled));
+ }
+
+ auto* promise = jsDynamicCast<JSPromise*>(promiseValue);
+
+ if (!promise) {
+ return JSValue::encode(jsOwnedString(vm, fulfilled));
+ }
+
+ switch (promise->status(vm)) {
+ case JSPromise::Status::Pending: {
+ static NeverDestroyed<String> pending = MAKE_STATIC_STRING_IMPL("pending");
+ return JSValue::encode(jsOwnedString(vm, pending));
+ }
+ case JSPromise::Status::Fulfilled: {
+ return JSValue::encode(jsOwnedString(vm, fulfilled));
+ }
+ case JSPromise::Status::Rejected: {
+ static NeverDestroyed<String> rejected = MAKE_STATIC_STRING_IMPL("rejected");
+ return JSValue::encode(jsOwnedString(vm, rejected));
+ }
+ }
+
+ return JSValue::encode(jsUndefined());
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionBunSleep,
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ JSC::JSValue millisecondsValue = callFrame->argument(0);
+
+ if (millisecondsValue.inherits<JSC::DateInstance>()) {
+ auto now = MonotonicTime::now();
+ auto milliseconds = jsCast<JSC::DateInstance*>(millisecondsValue)->internalNumber() - now.approximateWallTime().secondsSinceEpoch().milliseconds();
+ millisecondsValue = JSC::jsNumber(milliseconds > 0 ? milliseconds : 0);
+ }
+
+ if (!millisecondsValue.isNumber()) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "sleep expects a number (milliseconds)"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ Zig::GlobalObject* global = JSC::jsCast<Zig::GlobalObject*>(globalObject);
+ JSC::JSPromise* promise = JSC::JSPromise::create(vm, globalObject->promiseStructure());
+ Bun__Timer__setTimeout(globalObject, JSC::JSValue::encode(global->bunSleepThenCallback()), JSC::JSValue::encode(millisecondsValue), JSValue::encode(promise));
+ return JSC::JSValue::encode(promise);
+}
+
+extern "C" EncodedJSValue Bun__escapeHTML8(JSGlobalObject* globalObject, EncodedJSValue input, const LChar* ptr, size_t length);
+extern "C" EncodedJSValue Bun__escapeHTML16(JSGlobalObject* globalObject, EncodedJSValue input, const UChar* ptr, size_t length);
+
+// JSC_DEFINE_JIT_OPERATION(functionBunEscapeHTMLWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSObject* castedglobalObject, JSString* string))
+// {
+// JSC::VM& vm = JSC::getVM(lexicalGlobalObject);
+// IGNORE_WARNINGS_BEGIN("frame-address")
+// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
+// IGNORE_WARNINGS_END
+// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
+// size_t length = string->length();
+// if (!length)
+// return JSValue::encode(string);
+
+// auto resolvedString = string->value(lexicalGlobalObject);
+// if (!resolvedString.is8Bit()) {
+// return Bun__escapeHTML16(lexicalGlobalObject, JSValue::encode(string), resolvedString.characters16(), length);
+// } else {
+// return Bun__escapeHTML8(lexicalGlobalObject, JSValue::encode(string), resolvedString.characters8(), length);
+// }
+// }
+
+JSC_DEFINE_HOST_FUNCTION(functionBunEscapeHTML, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
+{
+ JSC::VM& vm = JSC::getVM(lexicalGlobalObject);
+ JSC::JSValue argument = callFrame->argument(0);
+ if (argument.isEmpty())
+ return JSValue::encode(jsEmptyString(vm));
+ if (argument.isNumber() || argument.isBoolean())
+ return JSValue::encode(argument.toString(lexicalGlobalObject));
+
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ auto string = argument.toString(lexicalGlobalObject);
+ RETURN_IF_EXCEPTION(scope, {});
+ size_t length = string->length();
+ if (!length)
+ RELEASE_AND_RETURN(scope, JSValue::encode(string));
+
+ auto resolvedString = string->value(lexicalGlobalObject);
+ EncodedJSValue encodedInput = JSValue::encode(string);
+ if (!resolvedString.is8Bit()) {
+ RELEASE_AND_RETURN(scope, Bun__escapeHTML16(lexicalGlobalObject, encodedInput, resolvedString.characters16(), length));
+ } else {
+ RELEASE_AND_RETURN(scope, Bun__escapeHTML8(lexicalGlobalObject, encodedInput, resolvedString.characters8(), length));
+ }
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionBunDeepEquals, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto* global = reinterpret_cast<GlobalObject*>(globalObject);
+ JSC::VM& vm = global->vm();
+
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (callFrame->argumentCount() < 2) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected 2 values to compare"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ JSC::JSValue arg1 = callFrame->uncheckedArgument(0);
+ JSC::JSValue arg2 = callFrame->uncheckedArgument(1);
+ JSC::JSValue arg3 = callFrame->argument(2);
+
+ Vector<std::pair<JSValue, JSValue>, 16> stack;
+
+ if (arg3.isBoolean() && arg3.asBoolean()) {
+ bool isEqual = Bun__deepEquals<true, false>(globalObject, arg1, arg2, stack, &scope, true);
+ RETURN_IF_EXCEPTION(scope, {});
+ return JSValue::encode(jsBoolean(isEqual));
+ } else {
+ bool isEqual = Bun__deepEquals<false, false>(globalObject, arg1, arg2, stack, &scope, true);
+ RETURN_IF_EXCEPTION(scope, {});
+ return JSValue::encode(jsBoolean(isEqual));
+ }
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionBunDeepMatch, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto* global = reinterpret_cast<GlobalObject*>(globalObject);
+ JSC::VM& vm = global->vm();
+
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (callFrame->argumentCount() < 2) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected 2 values to compare"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ JSC::JSValue subset = callFrame->uncheckedArgument(0);
+ JSC::JSValue object = callFrame->uncheckedArgument(1);
+
+ if (!subset.isObject() || !object.isObject()) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected 2 objects to match"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ bool match = Bun__deepMatch<false>(object, subset, globalObject, &scope, false);
+ RETURN_IF_EXCEPTION(scope, {});
+ return JSValue::encode(jsBoolean(match));
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionBunNanoseconds, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto* global = reinterpret_cast<GlobalObject*>(globalObject);
+ uint64_t time = Bun__readOriginTimer(global->bunVM());
+ return JSValue::encode(jsNumber(time));
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionPathToFileURL, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
+{
+ auto& globalObject = *reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto& vm = globalObject.vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto path = JSC::JSValue::encode(callFrame->argument(0));
+
+ JSC::JSString* pathString = JSC::JSValue::decode(path).toString(lexicalGlobalObject);
+ RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined()));
+
+ auto fileURL = WTF::URL::fileURLWithFileSystemPath(pathString->value(lexicalGlobalObject));
+ auto object = WebCore::DOMURL::create(fileURL.string(), String());
+ auto jsValue = WebCore::toJSNewlyCreated<IDLInterface<DOMURL>>(*lexicalGlobalObject, globalObject, throwScope, WTFMove(object));
+ RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(jsValue));
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionFileURLToPath, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSValue arg0 = callFrame->argument(0);
+ auto path = JSC::JSValue::encode(arg0);
+ auto* domURL = WebCoreCast<WebCore::JSDOMURL, WebCore__DOMURL>(path);
+ if (!domURL) {
+ if (arg0.isString()) {
+ auto url = WTF::URL(arg0.toWTFString(globalObject));
+ if (UNLIKELY(!url.protocolIs("file"_s))) {
+ throwTypeError(globalObject, scope, "Argument must be a file URL"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+ RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined()));
+ RELEASE_AND_RETURN(scope, JSValue::encode(jsString(vm, url.fileSystemPath())));
+ }
+ throwTypeError(globalObject, scope, "Argument must be a URL"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ auto& url = domURL->href();
+ if (UNLIKELY(!url.protocolIs("file"_s))) {
+ throwTypeError(globalObject, scope, "Argument must be a file URL"_s);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ return JSC::JSValue::encode(JSC::jsString(vm, url.fileSystemPath()));
+}
+
+JSC_DEFINE_HOST_FUNCTION(functionHashCode,
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ JSC::JSValue stringToHash = callFrame->argument(0);
+ JSC::JSString* str = stringToHash.toStringOrNull(globalObject);
+ if (!str) {
+ return JSC::JSValue::encode(jsNumber(0));
+ }
+
+ auto view = str->value(globalObject);
+ return JSC::JSValue::encode(jsNumber(view.hash()));
+}
+
+/* Source for BunObject.lut.h
+@begin bunObjectTable
+ ArrayBufferSink BunObject_getter_wrap_ArrayBufferSink DontDelete|PropertyCallback
+ CryptoHasher BunObject_getter_wrap_CryptoHasher DontDelete|PropertyCallback
+ DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump BunObject_callback_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump DontEnum|DontDelete|Function 1
+ FFI BunObject_getter_wrap_FFI DontDelete|PropertyCallback
+ FileSystemRouter BunObject_getter_wrap_FileSystemRouter DontDelete|PropertyCallback
+ MD4 BunObject_getter_wrap_MD4 DontDelete|PropertyCallback
+ MD5 BunObject_getter_wrap_MD5 DontDelete|PropertyCallback
+ SHA1 BunObject_getter_wrap_SHA1 DontDelete|PropertyCallback
+ SHA224 BunObject_getter_wrap_SHA224 DontDelete|PropertyCallback
+ SHA256 BunObject_getter_wrap_SHA256 DontDelete|PropertyCallback
+ SHA384 BunObject_getter_wrap_SHA384 DontDelete|PropertyCallback
+ SHA512 BunObject_getter_wrap_SHA512 DontDelete|PropertyCallback
+ SHA512_256 BunObject_getter_wrap_SHA512_256 DontDelete|PropertyCallback
+ TOML BunObject_getter_wrap_TOML DontDelete|PropertyCallback
+ Transpiler BunObject_getter_wrap_Transpiler DontDelete|PropertyCallback
+ _Os BunObject_callback__Os DontEnum|DontDelete|Function 1
+ _Path BunObject_callback__Path DontEnum|DontDelete|Function 1
+ allocUnsafe BunObject_callback_allocUnsafe DontDelete|Function 1
+ argv BunObject_getter_wrap_argv DontDelete|PropertyCallback
+ assetPrefix BunObject_getter_wrap_assetPrefix DontEnum|DontDelete|PropertyCallback
+ build BunObject_callback_build DontDelete|Function 1
+ concatArrayBuffers functionConcatTypedArrays DontDelete|Function 1
+ connect BunObject_callback_connect DontDelete|Function 1
+ cwd BunObject_getter_wrap_cwd DontEnum|DontDelete|PropertyCallback
+ deepEquals functionBunDeepEquals DontDelete|Function 2
+ deepMatch functionBunDeepMatch DontDelete|Function 2
+ deflateSync BunObject_callback_deflateSync DontDelete|Function 1
+ dns constructDNSObject ReadOnly|DontDelete|PropertyCallback
+ enableANSIColors BunObject_getter_wrap_enableANSIColors DontDelete|PropertyCallback
+ env constructEnvObject ReadOnly|DontDelete|PropertyCallback
+ escapeHTML functionBunEscapeHTML DontDelete|Function 2
+ fetch Bun__fetch ReadOnly|DontDelete|Function 1
+ file BunObject_callback_file DontDelete|Function 1
+ fileURLToPath functionFileURLToPath DontDelete|Function 1
+ fs BunObject_callback_fs DontEnum|DontDelete|Function 1
+ gc BunObject_callback_gc DontDelete|Function 1
+ generateHeapSnapshot BunObject_callback_generateHeapSnapshot DontDelete|Function 1
+ getImportedStyles BunObject_callback_getImportedStyles DontEnum|DontDelete|Function 1
+ gunzipSync BunObject_callback_gunzipSync DontDelete|Function 1
+ gzipSync BunObject_callback_gzipSync DontDelete|Function 1
+ hash BunObject_getter_wrap_hash DontDelete|PropertyCallback
+ indexOfLine BunObject_callback_indexOfLine DontDelete|Function 1
+ inflateSync BunObject_callback_inflateSync DontDelete|Function 1
+ inspect BunObject_callback_inspect DontDelete|Function 1
+ isMainThread constructIsMainThread ReadOnly|DontDelete|PropertyCallback
+ jest BunObject_callback_jest DontEnum|DontDelete|Function 1
+ listen BunObject_callback_listen DontDelete|Function 1
+ main BunObject_getter_wrap_main DontDelete|PropertyCallback
+ mmap BunObject_callback_mmap DontDelete|Function 1
+ nanoseconds functionBunNanoseconds DontDelete|Function 0
+ openInEditor BunObject_callback_openInEditor DontDelete|Function 1
+ origin BunObject_getter_wrap_origin DontDelete|PropertyCallback
+ password constructPasswordObject DontDelete|PropertyCallback
+ pathToFileURL functionPathToFileURL DontDelete|Function 1
+ peek constructBunPeekObject DontDelete|PropertyCallback
+ plugin constructPluginObject ReadOnly|DontDelete|PropertyCallback
+ readableStreamToArray JSBuiltin Builtin|Function 1
+ readableStreamToArrayBuffer JSBuiltin Builtin|Function 1
+ readableStreamToBlob JSBuiltin Builtin|Function 1
+ readableStreamToFormData JSBuiltin Builtin|Function 1
+ readableStreamToJSON JSBuiltin Builtin|Function 1
+ readableStreamToText JSBuiltin Builtin|Function 1
+ registerMacro BunObject_callback_registerMacro DontEnum|DontDelete|Function 1
+ resolve BunObject_callback_resolve DontDelete|Function 1
+ resolveSync BunObject_callback_resolveSync DontDelete|Function 1
+ revision constructBunRevision ReadOnly|DontDelete|PropertyCallback
+ serve BunObject_callback_serve DontDelete|Function 1
+ sha BunObject_callback_sha DontDelete|Function 1
+ shrink BunObject_callback_shrink DontDelete|Function 1
+ sleep functionBunSleep DontDelete|Function 1
+ sleepSync BunObject_callback_sleepSync DontDelete|Function 1
+ spawn BunObject_callback_spawn DontDelete|Function 1
+ spawnSync BunObject_callback_spawnSync DontDelete|Function 1
+ stderr BunObject_getter_wrap_stderr DontDelete|PropertyCallback
+ stdin BunObject_getter_wrap_stdin DontDelete|PropertyCallback
+ stdout BunObject_getter_wrap_stdout DontDelete|PropertyCallback
+ stringHashCode functionHashCode DontDelete|Function 1
+ unsafe BunObject_getter_wrap_unsafe DontDelete|PropertyCallback
+ version constructBunVersion ReadOnly|DontDelete|PropertyCallback
+ which BunObject_callback_which DontDelete|Function 1
+ write BunObject_callback_write DontDelete|Function 1
+@end
+*/
+
+class JSBunObject : public JSC::JSNonFinalObject {
+ using Base = JSC::JSNonFinalObject;
+
+public:
+ JSBunObject(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ DECLARE_INFO;
+
+ static constexpr bool needsDestruction = false;
+ static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
+
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+ void finishCreation(JSC::VM& vm)
+ {
+ Base::finishCreation(vm);
+
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+ }
+
+ static JSBunObject* create(JSC::VM& vm, JSGlobalObject* globalObject)
+ {
+ auto* object = new (NotNull, JSC::allocateCell<JSBunObject>(vm)) JSBunObject(vm, createStructure(vm, globalObject, globalObject->objectPrototype()));
+ object->finishCreation(vm);
+
+ return object;
+ }
+};
+
+#define bunObjectReadableStreamToArrayCodeGenerator WebCore::readableStreamReadableStreamToArrayCodeGenerator
+#define bunObjectReadableStreamToArrayBufferCodeGenerator WebCore::readableStreamReadableStreamToArrayBufferCodeGenerator
+#define bunObjectReadableStreamToBlobCodeGenerator WebCore::readableStreamReadableStreamToBlobCodeGenerator
+#define bunObjectReadableStreamToFormDataCodeGenerator WebCore::readableStreamReadableStreamToFormDataCodeGenerator
+#define bunObjectReadableStreamToJSONCodeGenerator WebCore::readableStreamReadableStreamToJSONCodeGenerator
+#define bunObjectReadableStreamToTextCodeGenerator WebCore::readableStreamReadableStreamToTextCodeGenerator
+
+#include "BunObject.lut.h"
+
+#undef bunObjectReadableStreamToArrayCodeGenerator
+#undef bunObjectReadableStreamToArrayBufferCodeGenerator
+#undef bunObjectReadableStreamToBlobCodeGenerator
+#undef bunObjectReadableStreamToFormDataCodeGenerator
+#undef bunObjectReadableStreamToJSONCodeGenerator
+#undef bunObjectReadableStreamToTextCodeGenerator
+
+const JSC::ClassInfo JSBunObject::s_info = { "Bun"_s, &JSNonFinalObject::s_info, &bunObjectTable, nullptr, CREATE_METHOD_TABLE(JSBunObject) };
+
+JSValue createBunObject(Zig::GlobalObject* globalObject)
+{
+ return JSBunObject::create(globalObject->vm(), globalObject);
+}
+
+}
diff --git a/src/bun.js/bindings/BunObject.h b/src/bun.js/bindings/BunObject.h
new file mode 100644
index 000000000..c2abfe06f
--- /dev/null
+++ b/src/bun.js/bindings/BunObject.h
@@ -0,0 +1,17 @@
+#pragma once
+
+namespace Bun {
+
+JSC_DECLARE_HOST_FUNCTION(functionBunPeek);
+JSC_DECLARE_HOST_FUNCTION(functionBunPeekStatus);
+JSC_DECLARE_HOST_FUNCTION(functionBunSleep);
+JSC_DECLARE_HOST_FUNCTION(functionBunSleepThenCallback);
+JSC_DECLARE_HOST_FUNCTION(functionBunEscapeHTML);
+JSC_DECLARE_HOST_FUNCTION(functionBunDeepEquals);
+JSC_DECLARE_HOST_FUNCTION(functionBunDeepMatch);
+JSC_DECLARE_HOST_FUNCTION(functionBunNanoseconds);
+JSC_DECLARE_HOST_FUNCTION(functionPathToFileURL);
+JSC_DECLARE_HOST_FUNCTION(functionFileURLToPath);
+
+JSC::JSValue createBunObject(Zig::GlobalObject* globalObject);
+}
diff --git a/src/bun.js/bindings/BunObject.lut.h b/src/bun.js/bindings/BunObject.lut.h
new file mode 100644
index 000000000..0596146e6
--- /dev/null
+++ b/src/bun.js/bindings/BunObject.lut.h
@@ -0,0 +1,359 @@
+// File generated via `make generate-builtins`
+static const struct CompactHashIndex bunObjectTableIndex[269] = {
+ { 75, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 38, -1 },
+ { -1, -1 },
+ { 44, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 4, -1 },
+ { -1, -1 },
+ { 2, -1 },
+ { 48, -1 },
+ { 34, 261 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 71, -1 },
+ { 79, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 60, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 11, 258 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 45, 264 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 67, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 59, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 47, 265 },
+ { 32, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 70, -1 },
+ { 65, -1 },
+ { -1, -1 },
+ { 14, -1 },
+ { 23, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 43, -1 },
+ { -1, -1 },
+ { 52, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 37, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 64, -1 },
+ { -1, -1 },
+ { 20, 256 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 73, -1 },
+ { -1, -1 },
+ { 77, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 74, -1 },
+ { 22, 259 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 53, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 40, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 29, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 63, -1 },
+ { 35, 266 },
+ { -1, -1 },
+ { 33, -1 },
+ { 54, -1 },
+ { -1, -1 },
+ { 26, -1 },
+ { 15, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 6, -1 },
+ { 10, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 18, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 0, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 5, -1 },
+ { 16, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 24, -1 },
+ { 1, -1 },
+ { 31, 267 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 46, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 8, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 69, -1 },
+ { -1, -1 },
+ { 76, 268 },
+ { -1, -1 },
+ { 36, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 39, 260 },
+ { -1, -1 },
+ { -1, -1 },
+ { 7, 262 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 66, -1 },
+ { 3, -1 },
+ { -1, -1 },
+ { 61, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 28, -1 },
+ { 19, 257 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 9, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 49, -1 },
+ { 12, -1 },
+ { -1, -1 },
+ { 80, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 17, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 27, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 13, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 25, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 42, 263 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { -1, -1 },
+ { 21, -1 },
+ { 30, -1 },
+ { 41, -1 },
+ { 50, -1 },
+ { 51, -1 },
+ { 55, -1 },
+ { 56, -1 },
+ { 57, -1 },
+ { 58, -1 },
+ { 62, -1 },
+ { 68, -1 },
+ { 72, -1 },
+ { 78, -1 },
+};
+
+static const struct HashTableValue bunObjectTableValues[81] = {
+ { "ArrayBufferSink"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_ArrayBufferSink } },
+ { "CryptoHasher"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_CryptoHasher } },
+ { "DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_mimalloc_dump, 1 } },
+ { "FFI"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_FFI } },
+ { "FileSystemRouter"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_FileSystemRouter } },
+ { "MD4"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_MD4 } },
+ { "MD5"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_MD5 } },
+ { "SHA1"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_SHA1 } },
+ { "SHA224"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_SHA224 } },
+ { "SHA256"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_SHA256 } },
+ { "SHA384"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_SHA384 } },
+ { "SHA512"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_SHA512 } },
+ { "SHA512_256"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_SHA512_256 } },
+ { "TOML"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_TOML } },
+ { "Transpiler"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_Transpiler } },
+ { "_Os"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback__Os, 1 } },
+ { "_Path"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback__Path, 1 } },
+ { "allocUnsafe"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_allocUnsafe, 1 } },
+ { "argv"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_argv } },
+ { "assetPrefix"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_assetPrefix } },
+ { "build"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_build, 1 } },
+ { "concatArrayBuffers"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionConcatTypedArrays, 1 } },
+ { "connect"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_connect, 1 } },
+ { "cwd"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_cwd } },
+ { "deepEquals"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionBunDeepEquals, 2 } },
+ { "deepMatch"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionBunDeepMatch, 2 } },
+ { "deflateSync"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_deflateSync, 1 } },
+ { "dns"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructDNSObject } },
+ { "enableANSIColors"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_enableANSIColors } },
+ { "env"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructEnvObject } },
+ { "escapeHTML"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionBunEscapeHTML, 2 } },
+ { "fetch"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Bun__fetch, 1 } },
+ { "file"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_file, 1 } },
+ { "fileURLToPath"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionFileURLToPath, 1 } },
+ { "fs"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_fs, 1 } },
+ { "gc"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_gc, 1 } },
+ { "generateHeapSnapshot"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_generateHeapSnapshot, 1 } },
+ { "getImportedStyles"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_getImportedStyles, 1 } },
+ { "gunzipSync"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_gunzipSync, 1 } },
+ { "gzipSync"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_gzipSync, 1 } },
+ { "hash"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_hash } },
+ { "indexOfLine"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_indexOfLine, 1 } },
+ { "inflateSync"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_inflateSync, 1 } },
+ { "inspect"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_inspect, 1 } },
+ { "isMainThread"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructIsMainThread } },
+ { "jest"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_jest, 1 } },
+ { "listen"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_listen, 1 } },
+ { "main"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_main } },
+ { "mmap"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_mmap, 1 } },
+ { "nanoseconds"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionBunNanoseconds, 0 } },
+ { "openInEditor"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_openInEditor, 1 } },
+ { "origin"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_origin } },
+ { "password"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructPasswordObject } },
+ { "pathToFileURL"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionPathToFileURL, 1 } },
+ { "peek"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructBunPeekObject } },
+ { "plugin"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructPluginObject } },
+ { "readableStreamToArray"_s, ((static_cast<unsigned>(PropertyAttribute::Builtin|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, bunObjectReadableStreamToArrayCodeGenerator, 1 } },
+ { "readableStreamToArrayBuffer"_s, ((static_cast<unsigned>(PropertyAttribute::Builtin|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, bunObjectReadableStreamToArrayBufferCodeGenerator, 1 } },
+ { "readableStreamToBlob"_s, ((static_cast<unsigned>(PropertyAttribute::Builtin|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, bunObjectReadableStreamToBlobCodeGenerator, 1 } },
+ { "readableStreamToFormData"_s, ((static_cast<unsigned>(PropertyAttribute::Builtin|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, bunObjectReadableStreamToFormDataCodeGenerator, 1 } },
+ { "readableStreamToJSON"_s, ((static_cast<unsigned>(PropertyAttribute::Builtin|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, bunObjectReadableStreamToJSONCodeGenerator, 1 } },
+ { "readableStreamToText"_s, ((static_cast<unsigned>(PropertyAttribute::Builtin|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, bunObjectReadableStreamToTextCodeGenerator, 1 } },
+ { "registerMacro"_s, static_cast<unsigned>(PropertyAttribute::DontEnum|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_registerMacro, 1 } },
+ { "resolve"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_resolve, 1 } },
+ { "resolveSync"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_resolveSync, 1 } },
+ { "revision"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructBunRevision } },
+ { "serve"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_serve, 1 } },
+ { "sha"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_sha, 1 } },
+ { "shrink"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_shrink, 1 } },
+ { "sleep"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionBunSleep, 1 } },
+ { "sleepSync"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_sleepSync, 1 } },
+ { "spawn"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_spawn, 1 } },
+ { "spawnSync"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_spawnSync, 1 } },
+ { "stderr"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_stderr } },
+ { "stdin"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_stdin } },
+ { "stdout"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_stdout } },
+ { "stringHashCode"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, functionHashCode, 1 } },
+ { "unsafe"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, BunObject_getter_wrap_unsafe } },
+ { "version"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructBunVersion } },
+ { "which"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_which, 1 } },
+ { "write"_s, static_cast<unsigned>(PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BunObject_callback_write, 1 } },
+};
+
+static const struct HashTable bunObjectTable =
+ { 81, 255, false, nullptr, bunObjectTableValues, bunObjectTableIndex };
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
index f62d43bff..3d878ab22 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
@@ -3,8 +3,11 @@ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlob;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlobConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildArtifact;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildMessage;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildMessageConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForComment;
-std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasher;
-std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasherConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirent;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCrypto;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasher;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasherConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDebugHTTPSServer;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDebugHTTPServer;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirent;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirentConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDocEnd;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDocType;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForElement;
@@ -14,10 +17,13 @@ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectConstructor;std:
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectAnything;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectStringContaining;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectStringMatching;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFFI;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFSWatcher;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouter;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouterConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTMLRewriter;
-std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTMLRewriterConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForListener;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTMLRewriterConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTTPSServer;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTTPServer;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForListener;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD4;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD4Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMatchedRoute;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
index a24e7126b..47fac3029 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
@@ -3,8 +3,11 @@ std::unique_ptr<IsoSubspace> m_subspaceForBlob;
std::unique_ptr<IsoSubspace> m_subspaceForBlobConstructor;std::unique_ptr<IsoSubspace> m_subspaceForBuildArtifact;
std::unique_ptr<IsoSubspace> m_subspaceForBuildMessage;
std::unique_ptr<IsoSubspace> m_subspaceForBuildMessageConstructor;std::unique_ptr<IsoSubspace> m_subspaceForComment;
-std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasher;
-std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasherConstructor;std::unique_ptr<IsoSubspace> m_subspaceForDirent;
+std::unique_ptr<IsoSubspace> m_subspaceForCrypto;
+std::unique_ptr<IsoSubspace> m_subspaceForCryptoConstructor;std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasher;
+std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasherConstructor;std::unique_ptr<IsoSubspace> m_subspaceForDebugHTTPSServer;
+std::unique_ptr<IsoSubspace> m_subspaceForDebugHTTPServer;
+std::unique_ptr<IsoSubspace> m_subspaceForDirent;
std::unique_ptr<IsoSubspace> m_subspaceForDirentConstructor;std::unique_ptr<IsoSubspace> m_subspaceForDocEnd;
std::unique_ptr<IsoSubspace> m_subspaceForDocType;
std::unique_ptr<IsoSubspace> m_subspaceForElement;
@@ -14,10 +17,13 @@ std::unique_ptr<IsoSubspace> m_subspaceForExpectConstructor;std::unique_ptr<IsoS
std::unique_ptr<IsoSubspace> m_subspaceForExpectAnything;
std::unique_ptr<IsoSubspace> m_subspaceForExpectStringContaining;
std::unique_ptr<IsoSubspace> m_subspaceForExpectStringMatching;
+std::unique_ptr<IsoSubspace> m_subspaceForFFI;
std::unique_ptr<IsoSubspace> m_subspaceForFSWatcher;
std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouter;
std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouterConstructor;std::unique_ptr<IsoSubspace> m_subspaceForHTMLRewriter;
-std::unique_ptr<IsoSubspace> m_subspaceForHTMLRewriterConstructor;std::unique_ptr<IsoSubspace> m_subspaceForListener;
+std::unique_ptr<IsoSubspace> m_subspaceForHTMLRewriterConstructor;std::unique_ptr<IsoSubspace> m_subspaceForHTTPSServer;
+std::unique_ptr<IsoSubspace> m_subspaceForHTTPServer;
+std::unique_ptr<IsoSubspace> m_subspaceForListener;
std::unique_ptr<IsoSubspace> m_subspaceForMD4;
std::unique_ptr<IsoSubspace> m_subspaceForMD4Constructor;std::unique_ptr<IsoSubspace> m_subspaceForMD5;
std::unique_ptr<IsoSubspace> m_subspaceForMD5Constructor;std::unique_ptr<IsoSubspace> m_subspaceForMatchedRoute;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
index 0fcf93e1d..731ecd81d 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
@@ -28,12 +28,30 @@ JSC::Structure* JSCommentStructure() { return m_JSComment.getInitializedOnMainTh
JSC::LazyClassStructure m_JSComment;
bool hasJSCommentSetterValue { false };
mutable JSC::WriteBarrier<JSC::Unknown> m_JSCommentSetterValue;
+JSC::Structure* JSCryptoStructure() { return m_JSCrypto.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSCryptoConstructor() { return m_JSCrypto.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSCryptoPrototype() { return m_JSCrypto.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSCrypto;
+ bool hasJSCryptoSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSCryptoSetterValue;
JSC::Structure* JSCryptoHasherStructure() { return m_JSCryptoHasher.getInitializedOnMainThread(this); }
JSC::JSObject* JSCryptoHasherConstructor() { return m_JSCryptoHasher.constructorInitializedOnMainThread(this); }
JSC::JSValue JSCryptoHasherPrototype() { return m_JSCryptoHasher.prototypeInitializedOnMainThread(this); }
JSC::LazyClassStructure m_JSCryptoHasher;
bool hasJSCryptoHasherSetterValue { false };
mutable JSC::WriteBarrier<JSC::Unknown> m_JSCryptoHasherSetterValue;
+JSC::Structure* JSDebugHTTPSServerStructure() { return m_JSDebugHTTPSServer.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSDebugHTTPSServerConstructor() { return m_JSDebugHTTPSServer.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSDebugHTTPSServerPrototype() { return m_JSDebugHTTPSServer.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSDebugHTTPSServer;
+ bool hasJSDebugHTTPSServerSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSDebugHTTPSServerSetterValue;
+JSC::Structure* JSDebugHTTPServerStructure() { return m_JSDebugHTTPServer.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSDebugHTTPServerConstructor() { return m_JSDebugHTTPServer.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSDebugHTTPServerPrototype() { return m_JSDebugHTTPServer.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSDebugHTTPServer;
+ bool hasJSDebugHTTPServerSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSDebugHTTPServerSetterValue;
JSC::Structure* JSDirentStructure() { return m_JSDirent.getInitializedOnMainThread(this); }
JSC::JSObject* JSDirentConstructor() { return m_JSDirent.constructorInitializedOnMainThread(this); }
JSC::JSValue JSDirentPrototype() { return m_JSDirent.prototypeInitializedOnMainThread(this); }
@@ -94,6 +112,12 @@ JSC::Structure* JSExpectStringMatchingStructure() { return m_JSExpectStringMatch
JSC::LazyClassStructure m_JSExpectStringMatching;
bool hasJSExpectStringMatchingSetterValue { false };
mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectStringMatchingSetterValue;
+JSC::Structure* JSFFIStructure() { return m_JSFFI.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSFFIConstructor() { return m_JSFFI.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSFFIPrototype() { return m_JSFFI.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSFFI;
+ bool hasJSFFISetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSFFISetterValue;
JSC::Structure* JSFSWatcherStructure() { return m_JSFSWatcher.getInitializedOnMainThread(this); }
JSC::JSObject* JSFSWatcherConstructor() { return m_JSFSWatcher.constructorInitializedOnMainThread(this); }
JSC::JSValue JSFSWatcherPrototype() { return m_JSFSWatcher.prototypeInitializedOnMainThread(this); }
@@ -112,6 +136,18 @@ JSC::Structure* JSHTMLRewriterStructure() { return m_JSHTMLRewriter.getInitializ
JSC::LazyClassStructure m_JSHTMLRewriter;
bool hasJSHTMLRewriterSetterValue { false };
mutable JSC::WriteBarrier<JSC::Unknown> m_JSHTMLRewriterSetterValue;
+JSC::Structure* JSHTTPSServerStructure() { return m_JSHTTPSServer.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSHTTPSServerConstructor() { return m_JSHTTPSServer.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSHTTPSServerPrototype() { return m_JSHTTPSServer.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSHTTPSServer;
+ bool hasJSHTTPSServerSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSHTTPSServerSetterValue;
+JSC::Structure* JSHTTPServerStructure() { return m_JSHTTPServer.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSHTTPServerConstructor() { return m_JSHTTPServer.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSHTTPServerPrototype() { return m_JSHTTPServer.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSHTTPServer;
+ bool hasJSHTTPServerSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSHTTPServerSetterValue;
JSC::Structure* JSListenerStructure() { return m_JSListener.getInitializedOnMainThread(this); }
JSC::JSObject* JSListenerConstructor() { return m_JSListener.constructorInitializedOnMainThread(this); }
JSC::JSValue JSListenerPrototype() { return m_JSListener.prototypeInitializedOnMainThread(this); }
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
index eaae3aa32..9c31c6708 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
@@ -29,12 +29,30 @@ void GlobalObject::initGeneratedLazyClasses() {
init.setStructure(WebCore::JSComment::createStructure(init.vm, init.global, init.prototype));
});
+ m_JSCrypto.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSCrypto::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSCrypto::createStructure(init.vm, init.global, init.prototype));
+ init.setConstructor(WebCore::JSCrypto::createConstructor(init.vm, init.global, init.prototype));
+ });
m_JSCryptoHasher.initLater(
[](LazyClassStructure::Initializer& init) {
init.setPrototype(WebCore::JSCryptoHasher::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
init.setStructure(WebCore::JSCryptoHasher::createStructure(init.vm, init.global, init.prototype));
init.setConstructor(WebCore::JSCryptoHasher::createConstructor(init.vm, init.global, init.prototype));
});
+ m_JSDebugHTTPSServer.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSDebugHTTPSServer::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSDebugHTTPSServer::createStructure(init.vm, init.global, init.prototype));
+
+ });
+ m_JSDebugHTTPServer.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSDebugHTTPServer::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSDebugHTTPServer::createStructure(init.vm, init.global, init.prototype));
+
+ });
m_JSDirent.initLater(
[](LazyClassStructure::Initializer& init) {
init.setPrototype(WebCore::JSDirent::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
@@ -95,6 +113,12 @@ void GlobalObject::initGeneratedLazyClasses() {
init.setStructure(WebCore::JSExpectStringMatching::createStructure(init.vm, init.global, init.prototype));
});
+ m_JSFFI.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSFFI::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSFFI::createStructure(init.vm, init.global, init.prototype));
+
+ });
m_JSFSWatcher.initLater(
[](LazyClassStructure::Initializer& init) {
init.setPrototype(WebCore::JSFSWatcher::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
@@ -113,6 +137,18 @@ void GlobalObject::initGeneratedLazyClasses() {
init.setStructure(WebCore::JSHTMLRewriter::createStructure(init.vm, init.global, init.prototype));
init.setConstructor(WebCore::JSHTMLRewriter::createConstructor(init.vm, init.global, init.prototype));
});
+ m_JSHTTPSServer.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSHTTPSServer::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSHTTPSServer::createStructure(init.vm, init.global, init.prototype));
+
+ });
+ m_JSHTTPServer.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSHTTPServer::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSHTTPServer::createStructure(init.vm, init.global, init.prototype));
+
+ });
m_JSListener.initLater(
[](LazyClassStructure::Initializer& init) {
init.setPrototype(WebCore::JSListener::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
@@ -260,7 +296,10 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor&
thisObject->m_JSBuildArtifact.visit(visitor); visitor.append(thisObject->m_JSBuildArtifactSetterValue);
thisObject->m_JSBuildMessage.visit(visitor); visitor.append(thisObject->m_JSBuildMessageSetterValue);
thisObject->m_JSComment.visit(visitor); visitor.append(thisObject->m_JSCommentSetterValue);
+ thisObject->m_JSCrypto.visit(visitor); visitor.append(thisObject->m_JSCryptoSetterValue);
thisObject->m_JSCryptoHasher.visit(visitor); visitor.append(thisObject->m_JSCryptoHasherSetterValue);
+ thisObject->m_JSDebugHTTPSServer.visit(visitor); visitor.append(thisObject->m_JSDebugHTTPSServerSetterValue);
+ thisObject->m_JSDebugHTTPServer.visit(visitor); visitor.append(thisObject->m_JSDebugHTTPServerSetterValue);
thisObject->m_JSDirent.visit(visitor); visitor.append(thisObject->m_JSDirentSetterValue);
thisObject->m_JSDocEnd.visit(visitor); visitor.append(thisObject->m_JSDocEndSetterValue);
thisObject->m_JSDocType.visit(visitor); visitor.append(thisObject->m_JSDocTypeSetterValue);
@@ -271,9 +310,12 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor&
thisObject->m_JSExpectAnything.visit(visitor); visitor.append(thisObject->m_JSExpectAnythingSetterValue);
thisObject->m_JSExpectStringContaining.visit(visitor); visitor.append(thisObject->m_JSExpectStringContainingSetterValue);
thisObject->m_JSExpectStringMatching.visit(visitor); visitor.append(thisObject->m_JSExpectStringMatchingSetterValue);
+ thisObject->m_JSFFI.visit(visitor); visitor.append(thisObject->m_JSFFISetterValue);
thisObject->m_JSFSWatcher.visit(visitor); visitor.append(thisObject->m_JSFSWatcherSetterValue);
thisObject->m_JSFileSystemRouter.visit(visitor); visitor.append(thisObject->m_JSFileSystemRouterSetterValue);
thisObject->m_JSHTMLRewriter.visit(visitor); visitor.append(thisObject->m_JSHTMLRewriterSetterValue);
+ thisObject->m_JSHTTPSServer.visit(visitor); visitor.append(thisObject->m_JSHTTPSServerSetterValue);
+ thisObject->m_JSHTTPServer.visit(visitor); visitor.append(thisObject->m_JSHTTPServerSetterValue);
thisObject->m_JSListener.visit(visitor); visitor.append(thisObject->m_JSListenerSetterValue);
thisObject->m_JSMD4.visit(visitor); visitor.append(thisObject->m_JSMD4SetterValue);
thisObject->m_JSMD5.visit(visitor); visitor.append(thisObject->m_JSMD5SetterValue);
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp
index a54501afd..1609480e9 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.cpp
+++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp
@@ -86,7 +86,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsAttributeIteratorConstructor, (JSGlobalObject * lexic
auto* prototype = jsDynamicCast<JSAttributeIteratorPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for AttributeIterator"_s);
return JSValue::encode(globalObject->JSAttributeIteratorConstructor());
}
@@ -98,7 +98,8 @@ JSC_DEFINE_HOST_FUNCTION(AttributeIteratorPrototype__iteratorCallback, (JSGlobal
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof AttributeIterator"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -125,7 +126,8 @@ JSC_DEFINE_HOST_FUNCTION(AttributeIteratorPrototype__nextCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof AttributeIterator"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -368,7 +370,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsBlobConstructor, (JSGlobalObject * lexicalGlobalObjec
auto* prototype = jsDynamicCast<JSBlobPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Blob"_s);
return JSValue::encode(globalObject->JSBlobConstructor());
}
@@ -380,7 +382,8 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Blob"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -407,7 +410,8 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__existsCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Blob"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -434,7 +438,8 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__formDataCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Blob"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -461,7 +466,8 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__jsonCallback, (JSGlobalObject * lexicalG
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Blob"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -543,7 +549,8 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__sliceCallback, (JSGlobalObject * lexical
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Blob"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -570,7 +577,8 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__streamCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Blob"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -597,7 +605,8 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__textCallback, (JSGlobalObject * lexicalG
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Blob"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -636,7 +645,8 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__writerCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Blob"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -934,7 +944,8 @@ JSC_DEFINE_HOST_FUNCTION(BuildArtifactPrototype__arrayBufferCallback, (JSGlobalO
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof BuildArtifact"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -992,7 +1003,8 @@ JSC_DEFINE_HOST_FUNCTION(BuildArtifactPrototype__jsonCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof BuildArtifact"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -1124,7 +1136,8 @@ JSC_DEFINE_HOST_FUNCTION(BuildArtifactPrototype__sliceCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof BuildArtifact"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -1182,7 +1195,8 @@ JSC_DEFINE_HOST_FUNCTION(BuildArtifactPrototype__streamCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof BuildArtifact"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -1209,7 +1223,8 @@ JSC_DEFINE_HOST_FUNCTION(BuildArtifactPrototype__textCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof BuildArtifact"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -1496,7 +1511,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsBuildMessageConstructor, (JSGlobalObject * lexicalGlo
auto* prototype = jsDynamicCast<JSBuildMessagePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for BuildMessage"_s);
return JSValue::encode(globalObject->JSBuildMessageConstructor());
}
@@ -1508,7 +1523,8 @@ JSC_DEFINE_HOST_FUNCTION(BuildMessagePrototype__toPrimitiveCallback, (JSGlobalOb
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof BuildMessage"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -1628,7 +1644,8 @@ JSC_DEFINE_HOST_FUNCTION(BuildMessagePrototype__toJSONCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof BuildMessage"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -1655,7 +1672,8 @@ JSC_DEFINE_HOST_FUNCTION(BuildMessagePrototype__toStringCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof BuildMessage"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -1941,7 +1959,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsCommentConstructor, (JSGlobalObject * lexicalGlobalOb
auto* prototype = jsDynamicCast<JSCommentPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Comment"_s);
return JSValue::encode(globalObject->JSCommentConstructor());
}
@@ -1953,7 +1971,8 @@ JSC_DEFINE_HOST_FUNCTION(CommentPrototype__afterCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Comment"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -1980,7 +1999,8 @@ JSC_DEFINE_HOST_FUNCTION(CommentPrototype__beforeCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Comment"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2007,7 +2027,8 @@ JSC_DEFINE_HOST_FUNCTION(CommentPrototype__removeCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Comment"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2046,7 +2067,8 @@ JSC_DEFINE_HOST_FUNCTION(CommentPrototype__replaceCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Comment"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2171,6 +2193,459 @@ extern "C" EncodedJSValue Comment__create(Zig::GlobalObject* globalObject, void*
return JSValue::encode(instance);
}
+class JSCryptoPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSCryptoPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSCryptoPrototype* ptr = new (NotNull, JSC::allocateCell<JSCryptoPrototype>(vm)) JSCryptoPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSCryptoPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+class JSCryptoConstructor final : public JSC::InternalFunction {
+public:
+ using Base = JSC::InternalFunction;
+ static JSCryptoConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSCryptoPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSCryptoConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForCryptoConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCryptoConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForCryptoConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForCryptoConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSCryptoPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSCryptoConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSCryptoPrototype* prototype);
+};
+
+extern "C" void* CryptoClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsCryptoConstructor);
+
+extern "C" void CryptoClass__finalize(void*);
+
+extern "C" EncodedJSValue CryptoPrototype__getRandomValues(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(CryptoPrototype__getRandomValuesCallback);
+
+extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(CryptoPrototype__getRandomValuesWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg0));
+extern "C" EncodedJSValue CryptoPrototype__getRandomValuesWithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSUint8Array* arg0);
+
+static const JSC::DOMJIT::Signature DOMJITSignatureForCryptoPrototype__getRandomValues(CryptoPrototype__getRandomValuesWithoutTypeChecksWrapper,
+ JSCrypto::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ JSC::SpecHeapTop, JSC::SpecUint8Array);
+
+JSC_DEFINE_JIT_OPERATION(CryptoPrototype__getRandomValuesWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg0))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ IGNORE_WARNINGS_BEGIN("frame-address")
+ CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
+ IGNORE_WARNINGS_END
+ JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
+ return CryptoPrototype__getRandomValuesWithoutTypeChecks(reinterpret_cast<JSCrypto*>(thisValue)->wrapped(), lexicalGlobalObject, arg0);
+}
+
+extern "C" EncodedJSValue CryptoPrototype__randomInt(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(CryptoPrototype__randomIntCallback);
+
+extern "C" EncodedJSValue CryptoPrototype__randomUUID(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(CryptoPrototype__randomUUIDCallback);
+
+extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(CryptoPrototype__randomUUIDWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
+extern "C" EncodedJSValue CryptoPrototype__randomUUIDWithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+
+static const JSC::DOMJIT::Signature DOMJITSignatureForCryptoPrototype__randomUUID(CryptoPrototype__randomUUIDWithoutTypeChecksWrapper,
+ JSCrypto::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ JSC::SpecString);
+
+JSC_DEFINE_JIT_OPERATION(CryptoPrototype__randomUUIDWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ IGNORE_WARNINGS_BEGIN("frame-address")
+ CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
+ IGNORE_WARNINGS_END
+ JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
+ return CryptoPrototype__randomUUIDWithoutTypeChecks(reinterpret_cast<JSCrypto*>(thisValue)->wrapped(), lexicalGlobalObject);
+}
+
+extern "C" EncodedJSValue CryptoPrototype__doScryptSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(CryptoPrototype__scryptSyncCallback);
+
+extern "C" EncodedJSValue CryptoPrototype__timingSafeEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(CryptoPrototype__timingSafeEqualCallback);
+
+extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(CryptoPrototype__timingSafeEqualWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg0, JSC::JSUint8Array* arg1));
+extern "C" EncodedJSValue CryptoPrototype__timingSafeEqualWithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSUint8Array* arg0, JSC::JSUint8Array* arg1);
+
+static const JSC::DOMJIT::Signature DOMJITSignatureForCryptoPrototype__timingSafeEqual(CryptoPrototype__timingSafeEqualWithoutTypeChecksWrapper,
+ JSCrypto::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ JSC::SpecHeapTop, JSC::SpecUint8Array, JSC::SpecUint8Array);
+
+JSC_DEFINE_JIT_OPERATION(CryptoPrototype__timingSafeEqualWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg0, JSC::JSUint8Array* arg1))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ IGNORE_WARNINGS_BEGIN("frame-address")
+ CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
+ IGNORE_WARNINGS_END
+ JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
+ return CryptoPrototype__timingSafeEqualWithoutTypeChecks(reinterpret_cast<JSCrypto*>(thisValue)->wrapped(), lexicalGlobalObject, arg0, arg1);
+}
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSCryptoPrototype, JSCryptoPrototype::Base);
+
+static const HashTableValue JSCryptoPrototypeTableValues[] = {
+ { "getRandomValues"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, CryptoPrototype__getRandomValuesCallback, &DOMJITSignatureForCryptoPrototype__getRandomValues } },
+ { "randomInt"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, CryptoPrototype__randomIntCallback, 2 } },
+ { "randomUUID"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, CryptoPrototype__randomUUIDCallback, &DOMJITSignatureForCryptoPrototype__randomUUID } },
+ { "scryptSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, CryptoPrototype__scryptSyncCallback, 2 } },
+ { "timingSafeEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, CryptoPrototype__timingSafeEqualCallback, &DOMJITSignatureForCryptoPrototype__timingSafeEqual } }
+};
+
+const ClassInfo JSCryptoPrototype::s_info = { "Crypto"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCryptoPrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsCryptoConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSCryptoPrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Crypto"_s);
+ return JSValue::encode(globalObject->JSCryptoConstructor());
+}
+
+JSC_DEFINE_HOST_FUNCTION(CryptoPrototype__getRandomValuesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSCrypto* thisObject = jsDynamicCast<JSCrypto*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Crypto"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return CryptoPrototype__getRandomValues(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(CryptoPrototype__randomIntCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSCrypto* thisObject = jsDynamicCast<JSCrypto*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Crypto"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return CryptoPrototype__randomInt(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(CryptoPrototype__randomUUIDCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSCrypto* thisObject = jsDynamicCast<JSCrypto*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Crypto"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return CryptoPrototype__randomUUID(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(CryptoPrototype__scryptSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSCrypto* thisObject = jsDynamicCast<JSCrypto*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Crypto"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return CryptoPrototype__doScryptSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(CryptoPrototype__timingSafeEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSCrypto* thisObject = jsDynamicCast<JSCrypto*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Crypto"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return CryptoPrototype__timingSafeEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+void JSCryptoPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSCrypto::info(), JSCryptoPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+void JSCryptoConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSCryptoPrototype* prototype)
+{
+ Base::finishCreation(vm, 0, "Crypto"_s, PropertyAdditionMode::WithoutStructureTransition);
+
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ ASSERT(inherits(info()));
+}
+
+JSCryptoConstructor::JSCryptoConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
+
+JSCryptoConstructor* JSCryptoConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSCryptoPrototype* prototype)
+{
+ JSCryptoConstructor* ptr = new (NotNull, JSC::allocateCell<JSCryptoConstructor>(vm)) JSCryptoConstructor(vm, structure);
+ ptr->finishCreation(vm, globalObject, prototype);
+ return ptr;
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSCryptoConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
+{
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
+ JSObject* newTarget = asObject(callFrame->newTarget());
+ auto* constructor = globalObject->JSCryptoConstructor();
+ Structure* structure = globalObject->JSCryptoStructure();
+ if (constructor != newTarget) {
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSCryptoStructure());
+ }
+
+ void* ptr = CryptoClass__construct(globalObject, callFrame);
+
+ if (UNLIKELY(!ptr)) {
+ return JSValue::encode(JSC::jsUndefined());
+ }
+
+ JSCrypto* instance = JSCrypto::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+void JSCryptoConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSCryptoPrototype* prototype)
+{
+}
+
+const ClassInfo JSCryptoConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCryptoConstructor) };
+
+extern "C" EncodedJSValue Crypto__getConstructor(Zig::GlobalObject* globalObject)
+{
+ return JSValue::encode(globalObject->JSCryptoConstructor());
+}
+
+JSCrypto::~JSCrypto()
+{
+}
+void JSCrypto::destroy(JSCell* cell)
+{
+ static_cast<JSCrypto*>(cell)->JSCrypto::~JSCrypto();
+}
+
+const ClassInfo JSCrypto::s_info = { "Crypto"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCrypto) };
+
+void JSCrypto::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSCrypto* JSCrypto::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSCrypto* ptr = new (NotNull, JSC::allocateCell<JSCrypto>(vm)) JSCrypto(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* Crypto__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSCrypto* object = JSC::jsDynamicCast<JSCrypto*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool Crypto__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSCrypto* object = JSC::jsDynamicCast<JSCrypto*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t Crypto__ptrOffset = JSCrypto::offsetOfWrapped();
+
+void JSCrypto::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSCrypto*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSCrypto::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+ return WebCore::JSCryptoConstructor::create(vm, globalObject, WebCore::JSCryptoConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSCryptoPrototype*>(prototype));
+}
+
+JSObject* JSCrypto::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSCryptoPrototype::create(vm, globalObject, JSCryptoPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue Crypto__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSCryptoStructure();
+ JSCrypto* instance = JSCrypto::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
class JSCryptoHasherPrototype final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
@@ -2279,7 +2754,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsCryptoHasherConstructor, (JSGlobalObject * lexicalGlo
auto* prototype = jsDynamicCast<JSCryptoHasherPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for CryptoHasher"_s);
return JSValue::encode(globalObject->JSCryptoHasherConstructor());
}
@@ -2334,7 +2809,8 @@ JSC_DEFINE_HOST_FUNCTION(CryptoHasherPrototype__copyCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof CryptoHasher"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2361,7 +2837,8 @@ JSC_DEFINE_HOST_FUNCTION(CryptoHasherPrototype__digestCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof CryptoHasher"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2388,7 +2865,8 @@ JSC_DEFINE_HOST_FUNCTION(CryptoHasherPrototype__updateCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof CryptoHasher"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2600,6 +3078,898 @@ void JSCryptoHasher::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSCryptoHasher);
+class JSDebugHTTPSServerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSDebugHTTPSServerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSDebugHTTPSServerPrototype* ptr = new (NotNull, JSC::allocateCell<JSDebugHTTPSServerPrototype>(vm)) JSDebugHTTPSServerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSDebugHTTPSServerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+extern "C" void* DebugHTTPSServerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsDebugHTTPSServerConstructor);
+
+extern "C" void DebugHTTPSServerClass__finalize(void*);
+
+extern "C" JSC::EncodedJSValue DebugHTTPSServerPrototype__getDevelopment(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPSServerPrototype__developmentGetterWrap);
+
+extern "C" EncodedJSValue DebugHTTPSServerPrototype__doFetch(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPSServerPrototype__fetchCallback);
+
+extern "C" JSC::EncodedJSValue DebugHTTPSServerPrototype__getHostname(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPSServerPrototype__hostnameGetterWrap);
+
+extern "C" JSC::EncodedJSValue DebugHTTPSServerPrototype__getPendingRequests(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPSServerPrototype__pendingRequestsGetterWrap);
+
+extern "C" JSC::EncodedJSValue DebugHTTPSServerPrototype__getPendingWebSockets(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPSServerPrototype__pendingWebSocketsGetterWrap);
+
+extern "C" JSC::EncodedJSValue DebugHTTPSServerPrototype__getPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPSServerPrototype__portGetterWrap);
+
+extern "C" JSC::EncodedJSValue DebugHTTPSServerPrototype__getProtocol(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPSServerPrototype__protocolGetterWrap);
+
+extern "C" EncodedJSValue DebugHTTPSServerPrototype__doPublish(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPSServerPrototype__publishCallback);
+
+extern "C" EncodedJSValue DebugHTTPSServerPrototype__doReload(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPSServerPrototype__reloadCallback);
+
+extern "C" EncodedJSValue DebugHTTPSServerPrototype__doStop(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPSServerPrototype__stopCallback);
+
+extern "C" EncodedJSValue DebugHTTPSServerPrototype__doUpgrade(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPSServerPrototype__upgradeCallback);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDebugHTTPSServerPrototype, JSDebugHTTPSServerPrototype::Base);
+
+static const HashTableValue JSDebugHTTPSServerPrototypeTableValues[] = {
+ { "development"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPSServerPrototype__developmentGetterWrap, 0 } },
+ { "fetch"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPSServerPrototype__fetchCallback, 1 } },
+ { "hostname"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPSServerPrototype__hostnameGetterWrap, 0 } },
+ { "pendingRequests"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPSServerPrototype__pendingRequestsGetterWrap, 0 } },
+ { "pendingWebSockets"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPSServerPrototype__pendingWebSocketsGetterWrap, 0 } },
+ { "port"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPSServerPrototype__portGetterWrap, 0 } },
+ { "protocol"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPSServerPrototype__protocolGetterWrap, 0 } },
+ { "publish"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPSServerPrototype__publishCallback, 3 } },
+ { "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPSServerPrototype__reloadCallback, 2 } },
+ { "stop"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPSServerPrototype__stopCallback, 1 } },
+ { "upgrade"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPSServerPrototype__upgradeCallback, 1 } }
+};
+
+const ClassInfo JSDebugHTTPSServerPrototype::s_info = { "DebugHTTPSServer"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDebugHTTPSServerPrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsDebugHTTPSServerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSDebugHTTPSServerPrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for DebugHTTPSServer"_s);
+ return JSValue::encode(globalObject->JSDebugHTTPSServerConstructor());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPSServerPrototype__developmentGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPSServer* thisObject = jsCast<JSDebugHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPSServerPrototype__getDevelopment(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPSServerPrototype__fetchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPSServer* thisObject = jsDynamicCast<JSDebugHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPSServerPrototype__doFetch(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPSServerPrototype__hostnameGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPSServer* thisObject = jsCast<JSDebugHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_hostname.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ DebugHTTPSServerPrototype__getHostname(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_hostname.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void DebugHTTPSServerPrototype__hostnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSDebugHTTPSServer*>(JSValue::decode(thisValue));
+ thisObject->m_hostname.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue DebugHTTPSServerPrototype__hostnameGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSDebugHTTPSServer*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_hostname.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPSServerPrototype__pendingRequestsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPSServer* thisObject = jsCast<JSDebugHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPSServerPrototype__getPendingRequests(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPSServerPrototype__pendingWebSocketsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPSServer* thisObject = jsCast<JSDebugHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPSServerPrototype__getPendingWebSockets(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPSServerPrototype__portGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPSServer* thisObject = jsCast<JSDebugHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPSServerPrototype__getPort(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPSServerPrototype__protocolGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPSServer* thisObject = jsCast<JSDebugHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPSServerPrototype__getProtocol(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPSServerPrototype__publishCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPSServer* thisObject = jsDynamicCast<JSDebugHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPSServerPrototype__doPublish(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPSServerPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPSServer* thisObject = jsDynamicCast<JSDebugHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPSServerPrototype__doReload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPSServerPrototype__stopCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPSServer* thisObject = jsDynamicCast<JSDebugHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPSServerPrototype__doStop(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPSServerPrototype__upgradeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPSServer* thisObject = jsDynamicCast<JSDebugHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPSServerPrototype__doUpgrade(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+void JSDebugHTTPSServerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSDebugHTTPSServer::info(), JSDebugHTTPSServerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+JSDebugHTTPSServer::~JSDebugHTTPSServer()
+{
+ if (m_ctx) {
+ DebugHTTPSServerClass__finalize(m_ctx);
+ }
+}
+void JSDebugHTTPSServer::destroy(JSCell* cell)
+{
+ static_cast<JSDebugHTTPSServer*>(cell)->JSDebugHTTPSServer::~JSDebugHTTPSServer();
+}
+
+const ClassInfo JSDebugHTTPSServer::s_info = { "DebugHTTPSServer"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDebugHTTPSServer) };
+
+void JSDebugHTTPSServer::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSDebugHTTPSServer* JSDebugHTTPSServer::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSDebugHTTPSServer* ptr = new (NotNull, JSC::allocateCell<JSDebugHTTPSServer>(vm)) JSDebugHTTPSServer(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* DebugHTTPSServer__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSDebugHTTPSServer* object = JSC::jsDynamicCast<JSDebugHTTPSServer*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool DebugHTTPSServer__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSDebugHTTPSServer* object = JSC::jsDynamicCast<JSDebugHTTPSServer*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t DebugHTTPSServer__ptrOffset = JSDebugHTTPSServer::offsetOfWrapped();
+
+void JSDebugHTTPSServer::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSDebugHTTPSServer*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSDebugHTTPSServer::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSDebugHTTPSServerPrototype::create(vm, globalObject, JSDebugHTTPSServerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue DebugHTTPSServer__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSDebugHTTPSServerStructure();
+ JSDebugHTTPSServer* instance = JSDebugHTTPSServer::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSDebugHTTPSServer::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSDebugHTTPSServer* thisObject = jsCast<JSDebugHTTPSServer*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.append(thisObject->m_hostname);
+}
+
+DEFINE_VISIT_CHILDREN(JSDebugHTTPSServer);
+
+template<typename Visitor>
+void JSDebugHTTPSServer::visitAdditionalChildren(Visitor& visitor)
+{
+ JSDebugHTTPSServer* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+
+ visitor.append(thisObject->m_hostname);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSDebugHTTPSServer);
+
+template<typename Visitor>
+void JSDebugHTTPSServer::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSDebugHTTPSServer* thisObject = jsCast<JSDebugHTTPSServer*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSDebugHTTPSServer);
+class JSDebugHTTPServerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSDebugHTTPServerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSDebugHTTPServerPrototype* ptr = new (NotNull, JSC::allocateCell<JSDebugHTTPServerPrototype>(vm)) JSDebugHTTPServerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSDebugHTTPServerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+extern "C" void* DebugHTTPServerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsDebugHTTPServerConstructor);
+
+extern "C" void DebugHTTPServerClass__finalize(void*);
+
+extern "C" JSC::EncodedJSValue DebugHTTPServerPrototype__getDevelopment(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPServerPrototype__developmentGetterWrap);
+
+extern "C" EncodedJSValue DebugHTTPServerPrototype__doFetch(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPServerPrototype__fetchCallback);
+
+extern "C" JSC::EncodedJSValue DebugHTTPServerPrototype__getHostname(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPServerPrototype__hostnameGetterWrap);
+
+extern "C" JSC::EncodedJSValue DebugHTTPServerPrototype__getPendingRequests(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPServerPrototype__pendingRequestsGetterWrap);
+
+extern "C" JSC::EncodedJSValue DebugHTTPServerPrototype__getPendingWebSockets(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPServerPrototype__pendingWebSocketsGetterWrap);
+
+extern "C" JSC::EncodedJSValue DebugHTTPServerPrototype__getPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPServerPrototype__portGetterWrap);
+
+extern "C" JSC::EncodedJSValue DebugHTTPServerPrototype__getProtocol(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(DebugHTTPServerPrototype__protocolGetterWrap);
+
+extern "C" EncodedJSValue DebugHTTPServerPrototype__doPublish(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPServerPrototype__publishCallback);
+
+extern "C" EncodedJSValue DebugHTTPServerPrototype__doReload(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPServerPrototype__reloadCallback);
+
+extern "C" EncodedJSValue DebugHTTPServerPrototype__doStop(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPServerPrototype__stopCallback);
+
+extern "C" EncodedJSValue DebugHTTPServerPrototype__doUpgrade(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(DebugHTTPServerPrototype__upgradeCallback);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDebugHTTPServerPrototype, JSDebugHTTPServerPrototype::Base);
+
+static const HashTableValue JSDebugHTTPServerPrototypeTableValues[] = {
+ { "development"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPServerPrototype__developmentGetterWrap, 0 } },
+ { "fetch"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPServerPrototype__fetchCallback, 1 } },
+ { "hostname"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPServerPrototype__hostnameGetterWrap, 0 } },
+ { "pendingRequests"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPServerPrototype__pendingRequestsGetterWrap, 0 } },
+ { "pendingWebSockets"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPServerPrototype__pendingWebSocketsGetterWrap, 0 } },
+ { "port"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPServerPrototype__portGetterWrap, 0 } },
+ { "protocol"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DebugHTTPServerPrototype__protocolGetterWrap, 0 } },
+ { "publish"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPServerPrototype__publishCallback, 3 } },
+ { "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPServerPrototype__reloadCallback, 2 } },
+ { "stop"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPServerPrototype__stopCallback, 1 } },
+ { "upgrade"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DebugHTTPServerPrototype__upgradeCallback, 1 } }
+};
+
+const ClassInfo JSDebugHTTPServerPrototype::s_info = { "DebugHTTPServer"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDebugHTTPServerPrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsDebugHTTPServerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSDebugHTTPServerPrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for DebugHTTPServer"_s);
+ return JSValue::encode(globalObject->JSDebugHTTPServerConstructor());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPServerPrototype__developmentGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPServer* thisObject = jsCast<JSDebugHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPServerPrototype__getDevelopment(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPServerPrototype__fetchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPServer* thisObject = jsDynamicCast<JSDebugHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPServerPrototype__doFetch(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPServerPrototype__hostnameGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPServer* thisObject = jsCast<JSDebugHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_hostname.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ DebugHTTPServerPrototype__getHostname(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_hostname.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void DebugHTTPServerPrototype__hostnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSDebugHTTPServer*>(JSValue::decode(thisValue));
+ thisObject->m_hostname.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue DebugHTTPServerPrototype__hostnameGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSDebugHTTPServer*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_hostname.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPServerPrototype__pendingRequestsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPServer* thisObject = jsCast<JSDebugHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPServerPrototype__getPendingRequests(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPServerPrototype__pendingWebSocketsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPServer* thisObject = jsCast<JSDebugHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPServerPrototype__getPendingWebSockets(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPServerPrototype__portGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPServer* thisObject = jsCast<JSDebugHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPServerPrototype__getPort(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(DebugHTTPServerPrototype__protocolGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSDebugHTTPServer* thisObject = jsCast<JSDebugHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = DebugHTTPServerPrototype__getProtocol(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPServerPrototype__publishCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPServer* thisObject = jsDynamicCast<JSDebugHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPServerPrototype__doPublish(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPServerPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPServer* thisObject = jsDynamicCast<JSDebugHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPServerPrototype__doReload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPServerPrototype__stopCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPServer* thisObject = jsDynamicCast<JSDebugHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPServerPrototype__doStop(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(DebugHTTPServerPrototype__upgradeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSDebugHTTPServer* thisObject = jsDynamicCast<JSDebugHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DebugHTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return DebugHTTPServerPrototype__doUpgrade(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+void JSDebugHTTPServerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSDebugHTTPServer::info(), JSDebugHTTPServerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+JSDebugHTTPServer::~JSDebugHTTPServer()
+{
+ if (m_ctx) {
+ DebugHTTPServerClass__finalize(m_ctx);
+ }
+}
+void JSDebugHTTPServer::destroy(JSCell* cell)
+{
+ static_cast<JSDebugHTTPServer*>(cell)->JSDebugHTTPServer::~JSDebugHTTPServer();
+}
+
+const ClassInfo JSDebugHTTPServer::s_info = { "DebugHTTPServer"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDebugHTTPServer) };
+
+void JSDebugHTTPServer::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSDebugHTTPServer* JSDebugHTTPServer::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSDebugHTTPServer* ptr = new (NotNull, JSC::allocateCell<JSDebugHTTPServer>(vm)) JSDebugHTTPServer(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* DebugHTTPServer__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSDebugHTTPServer* object = JSC::jsDynamicCast<JSDebugHTTPServer*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool DebugHTTPServer__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSDebugHTTPServer* object = JSC::jsDynamicCast<JSDebugHTTPServer*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t DebugHTTPServer__ptrOffset = JSDebugHTTPServer::offsetOfWrapped();
+
+void JSDebugHTTPServer::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSDebugHTTPServer*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSDebugHTTPServer::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSDebugHTTPServerPrototype::create(vm, globalObject, JSDebugHTTPServerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue DebugHTTPServer__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSDebugHTTPServerStructure();
+ JSDebugHTTPServer* instance = JSDebugHTTPServer::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSDebugHTTPServer::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSDebugHTTPServer* thisObject = jsCast<JSDebugHTTPServer*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.append(thisObject->m_hostname);
+}
+
+DEFINE_VISIT_CHILDREN(JSDebugHTTPServer);
+
+template<typename Visitor>
+void JSDebugHTTPServer::visitAdditionalChildren(Visitor& visitor)
+{
+ JSDebugHTTPServer* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+
+ visitor.append(thisObject->m_hostname);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSDebugHTTPServer);
+
+template<typename Visitor>
+void JSDebugHTTPServer::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSDebugHTTPServer* thisObject = jsCast<JSDebugHTTPServer*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSDebugHTTPServer);
class JSDirentPrototype final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
@@ -2720,7 +4090,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsDirentConstructor, (JSGlobalObject * lexicalGlobalObj
auto* prototype = jsDynamicCast<JSDirentPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Dirent"_s);
return JSValue::encode(globalObject->JSDirentConstructor());
}
@@ -2732,7 +4102,8 @@ JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isBlockDeviceCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Dirent"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2759,7 +4130,8 @@ JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isCharacterDeviceCallback, (JSGlobalOb
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Dirent"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2786,7 +4158,8 @@ JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isDirectoryCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Dirent"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2813,7 +4186,8 @@ JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isFIFOCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Dirent"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2840,7 +4214,8 @@ JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isFileCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Dirent"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2867,7 +4242,8 @@ JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isSocketCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Dirent"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -2894,7 +4270,8 @@ JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isSymbolicLinkCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Dirent"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3182,7 +4559,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsDocEndConstructor, (JSGlobalObject * lexicalGlobalObj
auto* prototype = jsDynamicCast<JSDocEndPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for DocEnd"_s);
return JSValue::encode(globalObject->JSDocEndConstructor());
}
@@ -3194,7 +4571,8 @@ JSC_DEFINE_HOST_FUNCTION(DocEndPrototype__appendCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof DocEnd"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3359,7 +4737,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsDocTypeConstructor, (JSGlobalObject * lexicalGlobalOb
auto* prototype = jsDynamicCast<JSDocTypePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for DocType"_s);
return JSValue::encode(globalObject->JSDocTypeConstructor());
}
@@ -3698,7 +5076,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsElementConstructor, (JSGlobalObject * lexicalGlobalOb
auto* prototype = jsDynamicCast<JSElementPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Element"_s);
return JSValue::encode(globalObject->JSElementConstructor());
}
@@ -3710,7 +5088,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__afterCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3737,7 +5116,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__appendCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3776,7 +5156,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__beforeCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3803,7 +5184,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__getAttributeCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3830,7 +5212,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__hasAttributeCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3888,7 +5271,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__onEndTagCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3915,7 +5299,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__prependCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3942,7 +5327,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__removeCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3969,7 +5355,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__removeAndKeepContentCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3996,7 +5383,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__removeAttributeCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4035,7 +5423,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__replaceCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4062,7 +5451,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__setAttributeCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4089,7 +5479,8 @@ JSC_DEFINE_HOST_FUNCTION(ElementPrototype__setInnerContentCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Element"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4317,7 +5708,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsEndTagConstructor, (JSGlobalObject * lexicalGlobalObj
auto* prototype = jsDynamicCast<JSEndTagPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for EndTag"_s);
return JSValue::encode(globalObject->JSEndTagConstructor());
}
@@ -4329,7 +5720,8 @@ JSC_DEFINE_HOST_FUNCTION(EndTagPrototype__afterCallback, (JSGlobalObject * lexic
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof EndTag"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4356,7 +5748,8 @@ JSC_DEFINE_HOST_FUNCTION(EndTagPrototype__beforeCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof EndTag"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4406,7 +5799,8 @@ JSC_DEFINE_HOST_FUNCTION(EndTagPrototype__removeCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof EndTag"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4857,7 +6251,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsExpectConstructor, (JSGlobalObject * lexicalGlobalObj
auto* prototype = jsDynamicCast<JSExpectPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Expect"_s);
return JSValue::encode(globalObject->JSExpectConstructor());
}
@@ -4869,7 +6263,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__failCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4908,7 +6303,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__passCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4959,7 +6355,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4986,7 +6383,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeArrayCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5013,7 +6411,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeArrayOfSizeCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5040,7 +6439,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeBooleanCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5067,7 +6467,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeCloseToCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5094,7 +6495,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeDateCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5121,7 +6523,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeDefinedCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5148,7 +6551,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeEmptyCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5175,7 +6579,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeEvenCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5202,7 +6607,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeFalseCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5229,7 +6635,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeFalsyCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5256,7 +6663,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeFiniteCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5283,7 +6691,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeFunctionCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5310,7 +6719,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5337,7 +6747,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanOrEqualCallback, (JSGlo
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5364,7 +6775,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeInstanceOfCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5391,7 +6803,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeIntegerCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5418,7 +6831,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeLessThanCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5445,7 +6859,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeLessThanOrEqualCallback, (JSGlobal
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5472,7 +6887,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNaNCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5499,7 +6915,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNegativeCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5526,7 +6943,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNilCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5553,7 +6971,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNullCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5580,7 +6999,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNumberCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5607,7 +7027,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeOddCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5634,7 +7055,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBePositiveCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5661,7 +7083,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeStringCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5688,7 +7111,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeSymbolCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5715,7 +7139,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeTrueCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5742,7 +7167,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeTruthyCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5769,7 +7195,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeTypeOfCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5796,7 +7223,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeUndefinedCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5823,7 +7251,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeWithinCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5850,7 +7279,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toContainCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5877,7 +7307,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toContainEqualCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5904,7 +7335,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toEndWithCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5931,7 +7363,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toEqualCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5958,7 +7391,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5985,7 +7419,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledTimesCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6012,7 +7447,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledWithCallback, (JSGloba
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6039,7 +7475,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenLastCalledWithCallback, (JSG
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6066,7 +7503,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenNthCalledWithCallback, (JSGl
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6093,7 +7531,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveLastReturnedWithCallback, (JSGlo
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6120,7 +7559,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveLengthCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6147,7 +7587,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveNthReturnedWithCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6174,7 +7615,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHavePropertyCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6201,7 +7643,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedTimesCallback, (JSGlobal
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6228,7 +7671,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedWithCallback, (JSGlobalO
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6255,7 +7699,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toIncludeCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6282,7 +7727,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toIncludeRepeatedCallback, (JSGlobalOb
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6309,7 +7755,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6336,7 +7783,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchInlineSnapshotCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6363,7 +7811,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchObjectCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6390,7 +7839,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchSnapshotCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6417,7 +7867,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toSatisfyCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6444,7 +7895,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toStartWithCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6471,7 +7923,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toStrictEqualCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6498,7 +7951,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6525,7 +7979,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingInlineSnapshotCall
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6552,7 +8007,8 @@ JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingSnapshotCallback,
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Expect"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7434,6 +8890,255 @@ void JSExpectStringMatching::visitOutputConstraintsImpl(JSCell* cell, Visitor& v
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSExpectStringMatching);
+class JSFFIPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSFFIPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSFFIPrototype* ptr = new (NotNull, JSC::allocateCell<JSFFIPrototype>(vm)) JSFFIPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSFFIPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+extern "C" void* FFIClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsFFIConstructor);
+
+extern "C" void FFIClass__finalize(void*);
+
+extern "C" EncodedJSValue FFIPrototype__close(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(FFIPrototype__closeCallback);
+
+extern "C" JSC::EncodedJSValue FFIPrototype__getSymbols(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(FFIPrototype__symbolsGetterWrap);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFFIPrototype, JSFFIPrototype::Base);
+
+static const HashTableValue JSFFIPrototypeTableValues[] = {
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FFIPrototype__closeCallback, 0 } },
+ { "symbols"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, FFIPrototype__symbolsGetterWrap, 0 } }
+};
+
+const ClassInfo JSFFIPrototype::s_info = { "FFI"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFFIPrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsFFIConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSFFIPrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for FFI"_s);
+ return JSValue::encode(globalObject->JSFFIConstructor());
+}
+
+JSC_DEFINE_HOST_FUNCTION(FFIPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSFFI* thisObject = jsDynamicCast<JSFFI*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof FFI"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return FFIPrototype__close(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(FFIPrototype__symbolsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSFFI* thisObject = jsCast<JSFFI*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_symbolsValue.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ FFIPrototype__getSymbols(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_symbolsValue.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void FFIPrototype__symbolsSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSFFI*>(JSValue::decode(thisValue));
+ thisObject->m_symbolsValue.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue FFIPrototype__symbolsGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSFFI*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_symbolsValue.get());
+}
+
+extern "C" void FFIPrototype__symbolsValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSFFI*>(JSValue::decode(thisValue));
+ thisObject->m_symbolsValue.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue FFIPrototype__symbolsValueGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSFFI*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_symbolsValue.get());
+}
+
+void JSFFIPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSFFI::info(), JSFFIPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+JSFFI::~JSFFI()
+{
+ if (m_ctx) {
+ FFIClass__finalize(m_ctx);
+ }
+}
+void JSFFI::destroy(JSCell* cell)
+{
+ static_cast<JSFFI*>(cell)->JSFFI::~JSFFI();
+}
+
+const ClassInfo JSFFI::s_info = { "FFI"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFFI) };
+
+void JSFFI::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSFFI* JSFFI::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSFFI* ptr = new (NotNull, JSC::allocateCell<JSFFI>(vm)) JSFFI(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* FFI__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSFFI* object = JSC::jsDynamicCast<JSFFI*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool FFI__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSFFI* object = JSC::jsDynamicCast<JSFFI*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t FFI__ptrOffset = JSFFI::offsetOfWrapped();
+
+void JSFFI::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSFFI*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSFFI::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSFFIPrototype::create(vm, globalObject, JSFFIPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue FFI__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSFFIStructure();
+ JSFFI* instance = JSFFI::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSFFI::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSFFI* thisObject = jsCast<JSFFI*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+ visitor.append(thisObject->m_symbolsValue);
+}
+
+DEFINE_VISIT_CHILDREN(JSFFI);
+
+template<typename Visitor>
+void JSFFI::visitAdditionalChildren(Visitor& visitor)
+{
+ JSFFI* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ visitor.append(thisObject->m_symbolsValue);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSFFI);
+
+template<typename Visitor>
+void JSFFI::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSFFI* thisObject = jsCast<JSFFI*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSFFI);
class JSFSWatcherPrototype final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
@@ -7498,7 +9203,8 @@ JSC_DEFINE_HOST_FUNCTION(FSWatcherPrototype__closeCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof FSWatcher"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7525,7 +9231,8 @@ JSC_DEFINE_HOST_FUNCTION(FSWatcherPrototype__hasRefCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof FSWatcher"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7552,7 +9259,8 @@ JSC_DEFINE_HOST_FUNCTION(FSWatcherPrototype__refCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof FSWatcher"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7579,7 +9287,8 @@ JSC_DEFINE_HOST_FUNCTION(FSWatcherPrototype__unrefCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof FSWatcher"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7843,7 +9552,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsFileSystemRouterConstructor, (JSGlobalObject * lexica
auto* prototype = jsDynamicCast<JSFileSystemRouterPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for FileSystemRouter"_s);
return JSValue::encode(globalObject->JSFileSystemRouterConstructor());
}
@@ -7855,7 +9564,8 @@ JSC_DEFINE_HOST_FUNCTION(FileSystemRouterPrototype__matchCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof FileSystemRouter"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7913,7 +9623,8 @@ JSC_DEFINE_HOST_FUNCTION(FileSystemRouterPrototype__reloadCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof FileSystemRouter"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8281,7 +9992,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsHTMLRewriterConstructor, (JSGlobalObject * lexicalGlo
auto* prototype = jsDynamicCast<JSHTMLRewriterPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for HTMLRewriter"_s);
return JSValue::encode(globalObject->JSHTMLRewriterConstructor());
}
@@ -8293,7 +10004,8 @@ JSC_DEFINE_HOST_FUNCTION(HTMLRewriterPrototype__onCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTMLRewriter"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8320,7 +10032,8 @@ JSC_DEFINE_HOST_FUNCTION(HTMLRewriterPrototype__onDocumentCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTMLRewriter"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8347,7 +10060,8 @@ JSC_DEFINE_HOST_FUNCTION(HTMLRewriterPrototype__transformCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTMLRewriter"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8516,6 +10230,898 @@ extern "C" EncodedJSValue HTMLRewriter__create(Zig::GlobalObject* globalObject,
return JSValue::encode(instance);
}
+class JSHTTPSServerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSHTTPSServerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSHTTPSServerPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTTPSServerPrototype>(vm)) JSHTTPSServerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSHTTPSServerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+extern "C" void* HTTPSServerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsHTTPSServerConstructor);
+
+extern "C" void HTTPSServerClass__finalize(void*);
+
+extern "C" JSC::EncodedJSValue HTTPSServerPrototype__getDevelopment(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPSServerPrototype__developmentGetterWrap);
+
+extern "C" EncodedJSValue HTTPSServerPrototype__doFetch(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPSServerPrototype__fetchCallback);
+
+extern "C" JSC::EncodedJSValue HTTPSServerPrototype__getHostname(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPSServerPrototype__hostnameGetterWrap);
+
+extern "C" JSC::EncodedJSValue HTTPSServerPrototype__getPendingRequests(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPSServerPrototype__pendingRequestsGetterWrap);
+
+extern "C" JSC::EncodedJSValue HTTPSServerPrototype__getPendingWebSockets(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPSServerPrototype__pendingWebSocketsGetterWrap);
+
+extern "C" JSC::EncodedJSValue HTTPSServerPrototype__getPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPSServerPrototype__portGetterWrap);
+
+extern "C" JSC::EncodedJSValue HTTPSServerPrototype__getProtocol(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPSServerPrototype__protocolGetterWrap);
+
+extern "C" EncodedJSValue HTTPSServerPrototype__doPublish(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPSServerPrototype__publishCallback);
+
+extern "C" EncodedJSValue HTTPSServerPrototype__doReload(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPSServerPrototype__reloadCallback);
+
+extern "C" EncodedJSValue HTTPSServerPrototype__doStop(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPSServerPrototype__stopCallback);
+
+extern "C" EncodedJSValue HTTPSServerPrototype__doUpgrade(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPSServerPrototype__upgradeCallback);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPSServerPrototype, JSHTTPSServerPrototype::Base);
+
+static const HashTableValue JSHTTPSServerPrototypeTableValues[] = {
+ { "development"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPSServerPrototype__developmentGetterWrap, 0 } },
+ { "fetch"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSServerPrototype__fetchCallback, 1 } },
+ { "hostname"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPSServerPrototype__hostnameGetterWrap, 0 } },
+ { "pendingRequests"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPSServerPrototype__pendingRequestsGetterWrap, 0 } },
+ { "pendingWebSockets"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPSServerPrototype__pendingWebSocketsGetterWrap, 0 } },
+ { "port"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPSServerPrototype__portGetterWrap, 0 } },
+ { "protocol"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPSServerPrototype__protocolGetterWrap, 0 } },
+ { "publish"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSServerPrototype__publishCallback, 3 } },
+ { "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSServerPrototype__reloadCallback, 2 } },
+ { "stop"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSServerPrototype__stopCallback, 1 } },
+ { "upgrade"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSServerPrototype__upgradeCallback, 1 } }
+};
+
+const ClassInfo JSHTTPSServerPrototype::s_info = { "HTTPSServer"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPSServerPrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsHTTPSServerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSHTTPSServerPrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for HTTPSServer"_s);
+ return JSValue::encode(globalObject->JSHTTPSServerConstructor());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPSServerPrototype__developmentGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPSServer* thisObject = jsCast<JSHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPSServerPrototype__getDevelopment(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPSServerPrototype__fetchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPSServer* thisObject = jsDynamicCast<JSHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPSServerPrototype__doFetch(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPSServerPrototype__hostnameGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPSServer* thisObject = jsCast<JSHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_hostname.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ HTTPSServerPrototype__getHostname(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_hostname.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void HTTPSServerPrototype__hostnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSHTTPSServer*>(JSValue::decode(thisValue));
+ thisObject->m_hostname.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue HTTPSServerPrototype__hostnameGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSHTTPSServer*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_hostname.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPSServerPrototype__pendingRequestsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPSServer* thisObject = jsCast<JSHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPSServerPrototype__getPendingRequests(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPSServerPrototype__pendingWebSocketsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPSServer* thisObject = jsCast<JSHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPSServerPrototype__getPendingWebSockets(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPSServerPrototype__portGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPSServer* thisObject = jsCast<JSHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPSServerPrototype__getPort(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPSServerPrototype__protocolGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPSServer* thisObject = jsCast<JSHTTPSServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPSServerPrototype__getProtocol(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPSServerPrototype__publishCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPSServer* thisObject = jsDynamicCast<JSHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPSServerPrototype__doPublish(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPSServerPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPSServer* thisObject = jsDynamicCast<JSHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPSServerPrototype__doReload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPSServerPrototype__stopCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPSServer* thisObject = jsDynamicCast<JSHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPSServerPrototype__doStop(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPSServerPrototype__upgradeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPSServer* thisObject = jsDynamicCast<JSHTTPSServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPSServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPSServerPrototype__doUpgrade(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+void JSHTTPSServerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSHTTPSServer::info(), JSHTTPSServerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+JSHTTPSServer::~JSHTTPSServer()
+{
+ if (m_ctx) {
+ HTTPSServerClass__finalize(m_ctx);
+ }
+}
+void JSHTTPSServer::destroy(JSCell* cell)
+{
+ static_cast<JSHTTPSServer*>(cell)->JSHTTPSServer::~JSHTTPSServer();
+}
+
+const ClassInfo JSHTTPSServer::s_info = { "HTTPSServer"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPSServer) };
+
+void JSHTTPSServer::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSHTTPSServer* JSHTTPSServer::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSHTTPSServer* ptr = new (NotNull, JSC::allocateCell<JSHTTPSServer>(vm)) JSHTTPSServer(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* HTTPSServer__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSHTTPSServer* object = JSC::jsDynamicCast<JSHTTPSServer*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool HTTPSServer__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSHTTPSServer* object = JSC::jsDynamicCast<JSHTTPSServer*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t HTTPSServer__ptrOffset = JSHTTPSServer::offsetOfWrapped();
+
+void JSHTTPSServer::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSHTTPSServer*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSHTTPSServer::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSHTTPSServerPrototype::create(vm, globalObject, JSHTTPSServerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue HTTPSServer__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSHTTPSServerStructure();
+ JSHTTPSServer* instance = JSHTTPSServer::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSHTTPSServer::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSHTTPSServer* thisObject = jsCast<JSHTTPSServer*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.append(thisObject->m_hostname);
+}
+
+DEFINE_VISIT_CHILDREN(JSHTTPSServer);
+
+template<typename Visitor>
+void JSHTTPSServer::visitAdditionalChildren(Visitor& visitor)
+{
+ JSHTTPSServer* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+
+ visitor.append(thisObject->m_hostname);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSHTTPSServer);
+
+template<typename Visitor>
+void JSHTTPSServer::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSHTTPSServer* thisObject = jsCast<JSHTTPSServer*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSHTTPSServer);
+class JSHTTPServerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSHTTPServerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSHTTPServerPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTTPServerPrototype>(vm)) JSHTTPServerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSHTTPServerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+extern "C" void* HTTPServerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsHTTPServerConstructor);
+
+extern "C" void HTTPServerClass__finalize(void*);
+
+extern "C" JSC::EncodedJSValue HTTPServerPrototype__getDevelopment(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPServerPrototype__developmentGetterWrap);
+
+extern "C" EncodedJSValue HTTPServerPrototype__doFetch(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPServerPrototype__fetchCallback);
+
+extern "C" JSC::EncodedJSValue HTTPServerPrototype__getHostname(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPServerPrototype__hostnameGetterWrap);
+
+extern "C" JSC::EncodedJSValue HTTPServerPrototype__getPendingRequests(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPServerPrototype__pendingRequestsGetterWrap);
+
+extern "C" JSC::EncodedJSValue HTTPServerPrototype__getPendingWebSockets(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPServerPrototype__pendingWebSocketsGetterWrap);
+
+extern "C" JSC::EncodedJSValue HTTPServerPrototype__getPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPServerPrototype__portGetterWrap);
+
+extern "C" JSC::EncodedJSValue HTTPServerPrototype__getProtocol(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(HTTPServerPrototype__protocolGetterWrap);
+
+extern "C" EncodedJSValue HTTPServerPrototype__doPublish(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPServerPrototype__publishCallback);
+
+extern "C" EncodedJSValue HTTPServerPrototype__doReload(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPServerPrototype__reloadCallback);
+
+extern "C" EncodedJSValue HTTPServerPrototype__doStop(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPServerPrototype__stopCallback);
+
+extern "C" EncodedJSValue HTTPServerPrototype__doUpgrade(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(HTTPServerPrototype__upgradeCallback);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPServerPrototype, JSHTTPServerPrototype::Base);
+
+static const HashTableValue JSHTTPServerPrototypeTableValues[] = {
+ { "development"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPServerPrototype__developmentGetterWrap, 0 } },
+ { "fetch"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPServerPrototype__fetchCallback, 1 } },
+ { "hostname"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPServerPrototype__hostnameGetterWrap, 0 } },
+ { "pendingRequests"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPServerPrototype__pendingRequestsGetterWrap, 0 } },
+ { "pendingWebSockets"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPServerPrototype__pendingWebSocketsGetterWrap, 0 } },
+ { "port"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPServerPrototype__portGetterWrap, 0 } },
+ { "protocol"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, HTTPServerPrototype__protocolGetterWrap, 0 } },
+ { "publish"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPServerPrototype__publishCallback, 3 } },
+ { "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPServerPrototype__reloadCallback, 2 } },
+ { "stop"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPServerPrototype__stopCallback, 1 } },
+ { "upgrade"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPServerPrototype__upgradeCallback, 1 } }
+};
+
+const ClassInfo JSHTTPServerPrototype::s_info = { "HTTPServer"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPServerPrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsHTTPServerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSHTTPServerPrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for HTTPServer"_s);
+ return JSValue::encode(globalObject->JSHTTPServerConstructor());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPServerPrototype__developmentGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPServer* thisObject = jsCast<JSHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPServerPrototype__getDevelopment(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPServerPrototype__fetchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPServer* thisObject = jsDynamicCast<JSHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPServerPrototype__doFetch(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPServerPrototype__hostnameGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPServer* thisObject = jsCast<JSHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_hostname.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ HTTPServerPrototype__getHostname(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_hostname.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void HTTPServerPrototype__hostnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSHTTPServer*>(JSValue::decode(thisValue));
+ thisObject->m_hostname.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue HTTPServerPrototype__hostnameGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSHTTPServer*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_hostname.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPServerPrototype__pendingRequestsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPServer* thisObject = jsCast<JSHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPServerPrototype__getPendingRequests(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPServerPrototype__pendingWebSocketsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPServer* thisObject = jsCast<JSHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPServerPrototype__getPendingWebSockets(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPServerPrototype__portGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPServer* thisObject = jsCast<JSHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPServerPrototype__getPort(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(HTTPServerPrototype__protocolGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSHTTPServer* thisObject = jsCast<JSHTTPServer*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EncodedJSValue result = HTTPServerPrototype__getProtocol(thisObject->wrapped(), globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, result);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPServerPrototype__publishCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPServer* thisObject = jsDynamicCast<JSHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPServerPrototype__doPublish(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPServerPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPServer* thisObject = jsDynamicCast<JSHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPServerPrototype__doReload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPServerPrototype__stopCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPServer* thisObject = jsDynamicCast<JSHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPServerPrototype__doStop(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(HTTPServerPrototype__upgradeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSHTTPServer* thisObject = jsDynamicCast<JSHTTPServer*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof HTTPServer"_s);
+ return JSValue::encode({});
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+#ifdef BUN_DEBUG
+ /** View the file name of the JS file that called this function
+ * from a debugger */
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ const char* fileName = sourceOrigin.string().utf8().data();
+ static const char* lastFileName = nullptr;
+ if (lastFileName != fileName) {
+ lastFileName = fileName;
+ }
+#endif
+
+ return HTTPServerPrototype__doUpgrade(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+void JSHTTPServerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSHTTPServer::info(), JSHTTPServerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+JSHTTPServer::~JSHTTPServer()
+{
+ if (m_ctx) {
+ HTTPServerClass__finalize(m_ctx);
+ }
+}
+void JSHTTPServer::destroy(JSCell* cell)
+{
+ static_cast<JSHTTPServer*>(cell)->JSHTTPServer::~JSHTTPServer();
+}
+
+const ClassInfo JSHTTPServer::s_info = { "HTTPServer"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPServer) };
+
+void JSHTTPServer::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSHTTPServer* JSHTTPServer::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSHTTPServer* ptr = new (NotNull, JSC::allocateCell<JSHTTPServer>(vm)) JSHTTPServer(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* HTTPServer__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSHTTPServer* object = JSC::jsDynamicCast<JSHTTPServer*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool HTTPServer__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSHTTPServer* object = JSC::jsDynamicCast<JSHTTPServer*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t HTTPServer__ptrOffset = JSHTTPServer::offsetOfWrapped();
+
+void JSHTTPServer::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSHTTPServer*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSHTTPServer::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSHTTPServerPrototype::create(vm, globalObject, JSHTTPServerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue HTTPServer__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSHTTPServerStructure();
+ JSHTTPServer* instance = JSHTTPServer::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSHTTPServer::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSHTTPServer* thisObject = jsCast<JSHTTPServer*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.append(thisObject->m_hostname);
+}
+
+DEFINE_VISIT_CHILDREN(JSHTTPServer);
+
+template<typename Visitor>
+void JSHTTPServer::visitAdditionalChildren(Visitor& visitor)
+{
+ JSHTTPServer* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+
+ visitor.append(thisObject->m_hostname);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSHTTPServer);
+
+template<typename Visitor>
+void JSHTTPServer::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSHTTPServer* thisObject = jsCast<JSHTTPServer*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSHTTPServer);
class JSListenerPrototype final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
@@ -8602,7 +11208,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsListenerConstructor, (JSGlobalObject * lexicalGlobalO
auto* prototype = jsDynamicCast<JSListenerPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Listener"_s);
return JSValue::encode(globalObject->JSListenerConstructor());
}
@@ -8680,7 +11286,8 @@ JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__refCallback, (JSGlobalObject * lexic
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Listener"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8707,7 +11314,8 @@ JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__reloadCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Listener"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8734,7 +11342,8 @@ JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__stopCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Listener"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8792,7 +11401,8 @@ JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__unrefCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Listener"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -9029,7 +11639,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsMD4Constructor, (JSGlobalObject * lexicalGlobalObject
auto* prototype = jsDynamicCast<JSMD4Prototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for MD4"_s);
return JSValue::encode(globalObject->JSMD4Constructor());
}
@@ -9053,7 +11663,8 @@ JSC_DEFINE_HOST_FUNCTION(MD4Prototype__digestCallback, (JSGlobalObject * lexical
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof MD4"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -9080,7 +11691,8 @@ JSC_DEFINE_HOST_FUNCTION(MD4Prototype__updateCallback, (JSGlobalObject * lexical
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof MD4"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -9357,7 +11969,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsMD5Constructor, (JSGlobalObject * lexicalGlobalObject
auto* prototype = jsDynamicCast<JSMD5Prototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for MD5"_s);
return JSValue::encode(globalObject->JSMD5Constructor());
}
@@ -9381,7 +11993,8 @@ JSC_DEFINE_HOST_FUNCTION(MD5Prototype__digestCallback, (JSGlobalObject * lexical
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof MD5"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -9408,7 +12021,8 @@ JSC_DEFINE_HOST_FUNCTION(MD5Prototype__updateCallback, (JSGlobalObject * lexical
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof MD5"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -9668,7 +12282,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsMatchedRouteConstructor, (JSGlobalObject * lexicalGlo
auto* prototype = jsDynamicCast<JSMatchedRoutePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for MatchedRoute"_s);
return JSValue::encode(globalObject->JSMatchedRouteConstructor());
}
@@ -10468,7 +13082,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsNodeJSFSConstructor, (JSGlobalObject * lexicalGlobalO
auto* prototype = jsDynamicCast<JSNodeJSFSPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for NodeJSFS"_s);
return JSValue::encode(globalObject->JSNodeJSFSConstructor());
}
@@ -10480,7 +13094,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__accessCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10507,7 +13122,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__accessSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10534,7 +13150,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__appendFileCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10561,7 +13178,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__appendFileSyncCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10588,7 +13206,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chmodCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10615,7 +13234,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chmodSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10642,7 +13262,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chownCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10669,7 +13290,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chownSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10696,7 +13318,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__closeCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10723,7 +13346,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__closeSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10750,7 +13374,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__copyFileCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10777,7 +13402,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__copyFileSyncCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10816,7 +13442,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__existsCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10843,7 +13470,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__existsSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10870,7 +13498,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchmodCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10897,7 +13526,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchmodSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10924,7 +13554,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchownCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10951,7 +13582,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchownSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10978,7 +13610,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fdatasyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11005,7 +13638,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fdatasyncSyncCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11032,7 +13666,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fstatCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11059,7 +13694,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fstatSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11086,7 +13722,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fsyncCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11113,7 +13750,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fsyncSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11140,7 +13778,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__ftruncateCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11167,7 +13806,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__ftruncateSyncCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11194,7 +13834,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__futimesCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11221,7 +13862,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__futimesSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11248,7 +13890,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchmodCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11275,7 +13918,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchmodSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11302,7 +13946,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchownCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11329,7 +13974,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchownSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11356,7 +14002,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__linkCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11383,7 +14030,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__linkSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11410,7 +14058,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lstatCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11437,7 +14086,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lstatSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11464,7 +14114,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lutimesCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11491,7 +14142,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lutimesSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11518,7 +14170,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdirCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11545,7 +14198,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdirSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11572,7 +14226,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdtempCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11599,7 +14254,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdtempSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11626,7 +14282,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__openCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11653,7 +14310,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__opendirCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11680,7 +14338,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__opendirSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11707,7 +14366,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__openSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11734,7 +14394,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11761,7 +14422,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readdirCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11788,7 +14450,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readdirSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11815,7 +14478,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readFileCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11842,7 +14506,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readFileSyncCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11869,7 +14534,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readlinkCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11896,7 +14562,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readlinkSyncCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11923,7 +14590,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11950,7 +14618,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readvCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11977,7 +14646,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readvSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12004,7 +14674,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__realpathCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12031,7 +14702,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__realpathSyncCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12058,7 +14730,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__renameCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12085,7 +14758,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__renameSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12112,7 +14786,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12139,7 +14814,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmdirCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12166,7 +14842,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmdirSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12193,7 +14870,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmSyncCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12220,7 +14898,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__statCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12259,7 +14938,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__statSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12286,7 +14966,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__symlinkCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12313,7 +14994,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__symlinkSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12340,7 +15022,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__truncateCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12367,7 +15050,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__truncateSyncCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12394,7 +15078,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__unlinkCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12421,7 +15106,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__unlinkSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12448,7 +15134,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__utimesCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12475,7 +15162,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__utimesSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12502,7 +15190,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__watchCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12529,7 +15218,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12556,7 +15246,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeFileCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12583,7 +15274,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeFileSyncCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12610,7 +15302,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeSyncCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12637,7 +15330,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writevCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12664,7 +15358,8 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writevSyncCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof NodeJSFS"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12998,7 +15693,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsRequestConstructor, (JSGlobalObject * lexicalGlobalOb
auto* prototype = jsDynamicCast<JSRequestPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Request"_s);
return JSValue::encode(globalObject->JSRequestConstructor());
}
@@ -13010,7 +15705,8 @@ JSC_DEFINE_HOST_FUNCTION(RequestPrototype__arrayBufferCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Request"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13037,7 +15733,8 @@ JSC_DEFINE_HOST_FUNCTION(RequestPrototype__blobCallback, (JSGlobalObject * lexic
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Request"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13119,7 +15816,8 @@ JSC_DEFINE_HOST_FUNCTION(RequestPrototype__cloneCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Request"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13170,7 +15868,8 @@ JSC_DEFINE_HOST_FUNCTION(RequestPrototype__formDataCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Request"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13240,7 +15939,8 @@ JSC_DEFINE_HOST_FUNCTION(RequestPrototype__jsonCallback, (JSGlobalObject * lexic
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Request"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13358,7 +16058,8 @@ JSC_DEFINE_HOST_FUNCTION(RequestPrototype__textCallback, (JSGlobalObject * lexic
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Request"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13726,7 +16427,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsResolveMessageConstructor, (JSGlobalObject * lexicalG
auto* prototype = jsDynamicCast<JSResolveMessagePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for ResolveMessage"_s);
return JSValue::encode(globalObject->JSResolveMessageConstructor());
}
@@ -13738,7 +16439,8 @@ JSC_DEFINE_HOST_FUNCTION(ResolveMessagePrototype__toPrimitiveCallback, (JSGlobal
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ResolveMessage"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13951,7 +16653,8 @@ JSC_DEFINE_HOST_FUNCTION(ResolveMessagePrototype__toJSONCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ResolveMessage"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13978,7 +16681,8 @@ JSC_DEFINE_HOST_FUNCTION(ResolveMessagePrototype__toStringCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ResolveMessage"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -14341,7 +17045,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsResponseConstructor, (JSGlobalObject * lexicalGlobalO
auto* prototype = jsDynamicCast<JSResponsePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Response"_s);
return JSValue::encode(globalObject->JSResponseConstructor());
}
@@ -14353,7 +17057,8 @@ JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__arrayBufferCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Response"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -14380,7 +17085,8 @@ JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__blobCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Response"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -14450,7 +17156,8 @@ JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__cloneCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Response"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -14477,7 +17184,8 @@ JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__formDataCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Response"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -14535,7 +17243,8 @@ JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__jsonCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Response"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -14629,7 +17338,8 @@ JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__textCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Response"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -14995,7 +17705,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA1Constructor, (JSGlobalObject * lexicalGlobalObjec
auto* prototype = jsDynamicCast<JSSHA1Prototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for SHA1"_s);
return JSValue::encode(globalObject->JSSHA1Constructor());
}
@@ -15019,7 +17729,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__digestCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA1"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -15046,7 +17757,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__updateCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA1"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -15323,7 +18035,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA224Constructor, (JSGlobalObject * lexicalGlobalObj
auto* prototype = jsDynamicCast<JSSHA224Prototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for SHA224"_s);
return JSValue::encode(globalObject->JSSHA224Constructor());
}
@@ -15347,7 +18059,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__digestCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA224"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -15374,7 +18087,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__updateCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA224"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -15651,7 +18365,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA256Constructor, (JSGlobalObject * lexicalGlobalObj
auto* prototype = jsDynamicCast<JSSHA256Prototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for SHA256"_s);
return JSValue::encode(globalObject->JSSHA256Constructor());
}
@@ -15675,7 +18389,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__digestCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA256"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -15702,7 +18417,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__updateCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA256"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -15979,7 +18695,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA384Constructor, (JSGlobalObject * lexicalGlobalObj
auto* prototype = jsDynamicCast<JSSHA384Prototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for SHA384"_s);
return JSValue::encode(globalObject->JSSHA384Constructor());
}
@@ -16003,7 +18719,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__digestCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA384"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -16030,7 +18747,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__updateCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA384"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -16307,7 +19025,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA512Constructor, (JSGlobalObject * lexicalGlobalObj
auto* prototype = jsDynamicCast<JSSHA512Prototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for SHA512"_s);
return JSValue::encode(globalObject->JSSHA512Constructor());
}
@@ -16331,7 +19049,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__digestCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA512"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -16358,7 +19077,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__updateCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA512"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -16635,7 +19355,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA512_256Constructor, (JSGlobalObject * lexicalGloba
auto* prototype = jsDynamicCast<JSSHA512_256Prototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for SHA512_256"_s);
return JSValue::encode(globalObject->JSSHA512_256Constructor());
}
@@ -16659,7 +19379,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__digestCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA512_256"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -16686,7 +19407,8 @@ JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__updateCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof SHA512_256"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17105,7 +19827,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsServerWebSocketConstructor, (JSGlobalObject * lexical
auto* prototype = jsDynamicCast<JSServerWebSocketPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for ServerWebSocket"_s);
return JSValue::encode(globalObject->JSServerWebSocketConstructor());
}
@@ -17140,7 +19862,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__closeCallback, (JSGlobalObjec
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17167,7 +19890,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__corkCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17236,7 +19960,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__getBufferedAmountCallback, (J
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17263,7 +19988,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__isSubscribedCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17290,7 +20016,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__pingCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17317,7 +20044,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__pongCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17344,7 +20072,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17371,7 +20100,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishBinaryCallback, (JSGlo
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17398,7 +20128,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishTextCallback, (JSGloba
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17468,7 +20199,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17495,7 +20227,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendBinaryCallback, (JSGlobal
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17522,7 +20255,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendTextCallback, (JSGlobalOb
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17549,7 +20283,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__subscribeCallback, (JSGlobalO
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17576,7 +20311,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__terminateCallback, (JSGlobalO
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -17603,7 +20339,8 @@ JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__unsubscribeCallback, (JSGloba
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ServerWebSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18121,7 +20858,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsStatsConstructor, (JSGlobalObject * lexicalGlobalObje
auto* prototype = jsDynamicCast<JSStatsPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Stats"_s);
return JSValue::encode(globalObject->JSStatsConstructor());
}
@@ -18303,7 +21040,8 @@ JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isBlockDeviceCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Stats"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18330,7 +21068,8 @@ JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isCharacterDeviceCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Stats"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18357,7 +21096,8 @@ JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isDirectoryCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Stats"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18384,7 +21124,8 @@ JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isFIFOCallback, (JSGlobalObject * lexic
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Stats"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18411,7 +21152,8 @@ JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isFileCallback, (JSGlobalObject * lexic
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Stats"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18438,7 +21180,8 @@ JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isSocketCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Stats"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18465,7 +21208,8 @@ JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isSymbolicLinkCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Stats"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18877,7 +21621,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsSubprocessConstructor, (JSGlobalObject * lexicalGloba
auto* prototype = jsDynamicCast<JSSubprocessPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Subprocess"_s);
return JSValue::encode(globalObject->JSSubprocessConstructor());
}
@@ -18913,7 +21657,8 @@ JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__killCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Subprocess"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -18995,7 +21740,8 @@ JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__refCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Subprocess"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19127,7 +21873,8 @@ JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__unrefCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Subprocess"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19483,7 +22230,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsTCPSocketConstructor, (JSGlobalObject * lexicalGlobal
auto* prototype = jsDynamicCast<JSTCPSocketPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for TCPSocket"_s);
return JSValue::encode(globalObject->JSTCPSocketConstructor());
}
@@ -19561,7 +22308,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__endCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19588,7 +22336,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__exportKeyingMaterialCallback, (JSGl
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19615,7 +22364,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__flushCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19642,7 +22392,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getAuthorizationErrorCallback, (JSG
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19669,7 +22420,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getCertificateCallback, (JSGlobalOb
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19696,7 +22448,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getCipherCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19723,7 +22476,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getEphemeralKeyInfoCallback, (JSGlo
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19750,7 +22504,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getPeerCertificateCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19777,7 +22532,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getSessionCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19804,7 +22560,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getSharedSigalgsCallback, (JSGlobal
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19831,7 +22588,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getTLSFinishedMessageCallback, (JSG
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19858,7 +22616,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getTLSPeerFinishedMessageCallback,
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19885,7 +22644,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getTLSTicketCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19912,7 +22672,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getTLSVersionCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -19975,7 +22736,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__refCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20002,7 +22764,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__reloadCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20060,7 +22823,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__setMaxSendFragmentCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20087,7 +22851,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__setServernameCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20114,7 +22879,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__setSessionCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20141,7 +22907,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__shutdownCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20168,7 +22935,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__timeoutCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20195,7 +22963,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20222,7 +22991,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__upgradeTLSCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20249,7 +23019,8 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__writeCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TCPSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20572,7 +23343,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsTLSSocketConstructor, (JSGlobalObject * lexicalGlobal
auto* prototype = jsDynamicCast<JSTLSSocketPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for TLSSocket"_s);
return JSValue::encode(globalObject->JSTLSSocketConstructor());
}
@@ -20650,7 +23421,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__endCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20677,7 +23449,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__exportKeyingMaterialCallback, (JSGl
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20704,7 +23477,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__flushCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20731,7 +23505,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getAuthorizationErrorCallback, (JSG
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20758,7 +23533,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getCertificateCallback, (JSGlobalOb
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20785,7 +23561,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getCipherCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20812,7 +23589,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getEphemeralKeyInfoCallback, (JSGlo
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20839,7 +23617,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getPeerCertificateCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20866,7 +23645,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getSessionCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20893,7 +23673,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getSharedSigalgsCallback, (JSGlobal
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20920,7 +23701,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getTLSFinishedMessageCallback, (JSG
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20947,7 +23729,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getTLSPeerFinishedMessageCallback,
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -20974,7 +23757,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getTLSTicketCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21001,7 +23785,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getTLSVersionCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21064,7 +23849,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__refCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21091,7 +23877,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__reloadCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21149,7 +23936,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__setMaxSendFragmentCallback, (JSGlob
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21176,7 +23964,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__setServernameCallback, (JSGlobalObj
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21203,7 +23992,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__setSessionCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21230,7 +24020,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__shutdownCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21257,7 +24048,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__timeoutCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21284,7 +24076,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21311,7 +24104,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__upgradeTLSCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21338,7 +24132,8 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__writeCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TLSSocket"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21562,7 +24357,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsTextChunkConstructor, (JSGlobalObject * lexicalGlobal
auto* prototype = jsDynamicCast<JSTextChunkPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for TextChunk"_s);
return JSValue::encode(globalObject->JSTextChunkConstructor());
}
@@ -21574,7 +24369,8 @@ JSC_DEFINE_HOST_FUNCTION(TextChunkPrototype__afterCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TextChunk"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21601,7 +24397,8 @@ JSC_DEFINE_HOST_FUNCTION(TextChunkPrototype__beforeCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TextChunk"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21659,7 +24456,8 @@ JSC_DEFINE_HOST_FUNCTION(TextChunkPrototype__removeCallback, (JSGlobalObject * l
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TextChunk"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21698,7 +24496,8 @@ JSC_DEFINE_HOST_FUNCTION(TextChunkPrototype__replaceCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TextChunk"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -21963,7 +24762,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsTextDecoderConstructor, (JSGlobalObject * lexicalGlob
auto* prototype = jsDynamicCast<JSTextDecoderPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for TextDecoder"_s);
return JSValue::encode(globalObject->JSTextDecoderConstructor());
}
@@ -21975,7 +24774,8 @@ JSC_DEFINE_HOST_FUNCTION(TextDecoderPrototype__decodeCallback, (JSGlobalObject *
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof TextDecoder"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22287,7 +25087,8 @@ JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__toPrimitiveCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Timeout"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22314,7 +25115,8 @@ JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__hasRefCallback, (JSGlobalObject * lex
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Timeout"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22341,7 +25143,8 @@ JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__refCallback, (JSGlobalObject * lexica
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Timeout"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22368,7 +25171,8 @@ JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__refreshCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Timeout"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22395,7 +25199,8 @@ JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__unrefCallback, (JSGlobalObject * lexi
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Timeout"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22661,7 +25466,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsTranspilerConstructor, (JSGlobalObject * lexicalGloba
auto* prototype = jsDynamicCast<JSTranspilerPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for Transpiler"_s);
return JSValue::encode(globalObject->JSTranspilerConstructor());
}
@@ -22673,7 +25478,8 @@ JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__scanCallback, (JSGlobalObject * le
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Transpiler"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22700,7 +25506,8 @@ JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__scanImportsCallback, (JSGlobalObje
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Transpiler"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22727,7 +25534,8 @@ JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__transformCallback, (JSGlobalObject
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Transpiler"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -22754,7 +25562,8 @@ JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__transformSyncCallback, (JSGlobalOb
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof Transpiler"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index cae28b60c..bd7750ebf 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -291,6 +291,56 @@ public:
void finishCreation(JSC::VM&);
};
+class JSCrypto final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSCrypto* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSCrypto, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForCrypto.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCrypto = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForCrypto.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForCrypto = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSCrypto();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSCrypto, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSCrypto(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
+
class JSCryptoHasher final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
@@ -348,6 +398,118 @@ public:
mutable JSC::WriteBarrier<JSC::Unknown> m_algorithm;
};
+class JSDebugHTTPSServer final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSDebugHTTPSServer* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSDebugHTTPSServer, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForDebugHTTPSServer.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForDebugHTTPSServer = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForDebugHTTPSServer.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForDebugHTTPSServer = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSDebugHTTPSServer();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSDebugHTTPSServer, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSDebugHTTPSServer(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_hostname;
+};
+
+class JSDebugHTTPServer final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSDebugHTTPServer* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSDebugHTTPServer, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForDebugHTTPServer.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForDebugHTTPServer = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForDebugHTTPServer.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForDebugHTTPServer = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSDebugHTTPServer();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSDebugHTTPServer, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSDebugHTTPServer(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_hostname;
+};
+
class JSDirent final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
@@ -893,6 +1055,62 @@ public:
mutable JSC::WriteBarrier<JSC::Unknown> m_testValue;
};
+class JSFFI final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSFFI* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSFFI, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForFFI.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForFFI = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForFFI.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForFFI = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSFFI();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSFFI, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSFFI(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_symbolsValue;
+};
+
class JSFSWatcher final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
@@ -1084,6 +1302,118 @@ public:
void finishCreation(JSC::VM&);
};
+class JSHTTPSServer final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSHTTPSServer* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSHTTPSServer, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForHTTPSServer.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForHTTPSServer = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForHTTPSServer.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForHTTPSServer = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSHTTPSServer();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSHTTPSServer, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSHTTPSServer(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_hostname;
+};
+
+class JSHTTPServer final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSHTTPServer* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSHTTPServer, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForHTTPServer.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForHTTPServer = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForHTTPServer.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForHTTPServer = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSHTTPServer();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSHTTPServer, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSHTTPServer(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_hostname;
+};
+
class JSListener final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
diff --git a/src/bun.js/bindings/ZigGeneratedCode.cpp b/src/bun.js/bindings/ZigGeneratedCode.cpp
index 6a57e43ea..057eaf28e 100644
--- a/src/bun.js/bindings/ZigGeneratedCode.cpp
+++ b/src/bun.js/bindings/ZigGeneratedCode.cpp
@@ -547,124 +547,4 @@ extern "C" void Reader__f64__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0);
}
-extern "C" JSC_DECLARE_HOST_FUNCTION(Crypto__getRandomValues__slowpathWrapper);
-extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__getRandomValues__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*));
-
-JSC_DEFINE_JIT_OPERATION(Crypto__getRandomValues__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1))
-{
- VM& vm = JSC::getVM(lexicalGlobalObject);
- IGNORE_WARNINGS_BEGIN("frame-address")
- CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
- IGNORE_WARNINGS_END
- JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
- return Crypto__getRandomValues__fastpath(lexicalGlobalObject, thisValue, arg1);
-}
-JSC_DEFINE_HOST_FUNCTION(Crypto__getRandomValues__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
-{
- return Crypto__getRandomValues__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
-}
-
-extern "C" void Crypto__getRandomValues__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
-{
- JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
- static const JSC::DOMJIT::Signature DOMJIT_getRandomValues_signature(
- Crypto__getRandomValues__fastpathWrapper,
- thisObject->classInfo(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- JSC::SpecHeapTop,
- JSC::SpecUint8Array);
- JSFunction* function = JSFunction::create(
- globalObject->vm(),
- globalObject,
- 1,
- String("getRandomValues"_s),
- Crypto__getRandomValues__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__getRandomValues__slowpathWrapper,
- &DOMJIT_getRandomValues_signature);
- thisObject->putDirect(
- globalObject->vm(),
- Identifier::fromString(globalObject->vm(), "getRandomValues"_s),
- function,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0);
-}
-
-extern "C" JSC_DECLARE_HOST_FUNCTION(Crypto__randomUUID__slowpathWrapper);
-extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__randomUUID__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
-
-JSC_DEFINE_JIT_OPERATION(Crypto__randomUUID__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
-{
- VM& vm = JSC::getVM(lexicalGlobalObject);
- IGNORE_WARNINGS_BEGIN("frame-address")
- CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
- IGNORE_WARNINGS_END
- JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
- return Crypto__randomUUID__fastpath(lexicalGlobalObject, thisValue);
-}
-JSC_DEFINE_HOST_FUNCTION(Crypto__randomUUID__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
-{
- return Crypto__randomUUID__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
-}
-
-extern "C" void Crypto__randomUUID__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
-{
- JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
- static const JSC::DOMJIT::Signature DOMJIT_randomUUID_signature(
- Crypto__randomUUID__fastpathWrapper,
- thisObject->classInfo(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- JSC::SpecString);
- JSFunction* function = JSFunction::create(
- globalObject->vm(),
- globalObject,
- 0,
- String("randomUUID"_s),
- Crypto__randomUUID__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__randomUUID__slowpathWrapper,
- &DOMJIT_randomUUID_signature);
- thisObject->putDirect(
- globalObject->vm(),
- Identifier::fromString(globalObject->vm(), "randomUUID"_s),
- function,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0);
-}
-
-extern "C" JSC_DECLARE_HOST_FUNCTION(Crypto__timingSafeEqual__slowpathWrapper);
-extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__timingSafeEqual__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*, JSC::JSUint8Array*));
-
-JSC_DEFINE_JIT_OPERATION(Crypto__timingSafeEqual__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1, JSC::JSUint8Array* arg2))
-{
- VM& vm = JSC::getVM(lexicalGlobalObject);
- IGNORE_WARNINGS_BEGIN("frame-address")
- CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
- IGNORE_WARNINGS_END
- JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
- return Crypto__timingSafeEqual__fastpath(lexicalGlobalObject, thisValue, arg1, arg2);
-}
-JSC_DEFINE_HOST_FUNCTION(Crypto__timingSafeEqual__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
-{
- return Crypto__timingSafeEqual__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
-}
-
-extern "C" void Crypto__timingSafeEqual__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
-{
- JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
- static const JSC::DOMJIT::Signature DOMJIT_timingSafeEqual_signature(
- Crypto__timingSafeEqual__fastpathWrapper,
- thisObject->classInfo(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- JSC::SpecHeapTop,
- JSC::SpecUint8Array,
- JSC::SpecUint8Array);
- JSFunction* function = JSFunction::create(
- globalObject->vm(),
- globalObject,
- 2,
- String("timingSafeEqual"_s),
- Crypto__timingSafeEqual__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__timingSafeEqual__slowpathWrapper,
- &DOMJIT_timingSafeEqual_signature);
- thisObject->putDirect(
- globalObject->vm(),
- Identifier::fromString(globalObject->vm(), "timingSafeEqual"_s),
- function,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0);
-}
-
/* -- END DOMCall DEFINITIONS-- */
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index b6ac8e7ea..016da0fd6 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -126,6 +126,8 @@
#include "JavaScriptCore/RemoteInspectorServer.h"
#endif
+#include "BunObject.h"
+
using namespace Bun;
extern "C" JSC::EncodedJSValue Bun__fetch(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
@@ -428,8 +430,7 @@ static String computeErrorInfo(JSC::VM& vm, Vector<StackFrame>& stackTrace, unsi
return computeErrorInfoWithoutPrepareStackTrace(vm, stackTrace, line, column, sourceURL, errorInstance);
}
-extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObjectClass, int count,
- void* console_client, int32_t executionContextId, bool miniMode, void* worker_ptr)
+extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(void* console_client, int32_t executionContextId, bool miniMode, void* worker_ptr)
{
auto heapSize = miniMode ? JSC::HeapType::Small : JSC::HeapType::Large;
@@ -474,10 +475,6 @@ extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObje
globalObject->setStackTraceLimit(DEFAULT_ERROR_STACK_TRACE_LIMIT); // Node.js defaults to 10
vm.setOnComputeErrorInfo(computeErrorInfo);
- if (count > 0) {
- globalObject->installAPIGlobals(globalObjectClass, count, vm);
- }
-
JSC::gcProtect(globalObject);
vm.ref();
@@ -663,20 +660,14 @@ using namespace WebCore;
const JSC::ClassInfo GlobalObject::s_info = { "GlobalObject"_s, &Base::s_info, nullptr, nullptr,
CREATE_METHOD_TABLE(GlobalObject) };
-extern "C" JSClassRef* Zig__getAPIGlobals(size_t* count);
-
static JSGlobalObject* deriveShadowRealmGlobalObject(JSGlobalObject* globalObject)
{
auto& vm = globalObject->vm();
Zig::GlobalObject* shadow = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::JSGlobalObject::create(vm, JSC::JSGlobalObject::createStructure(vm, JSC::jsNull())), JSC::jsNull()));
shadow->setConsole(shadow);
size_t count = 0;
- JSClassRef* globalObjectClass = Zig__getAPIGlobals(&count);
shadow->setConsole(shadow);
- if (count > 0) {
- shadow->installAPIGlobals(globalObjectClass, count, vm);
- }
return shadow;
}
@@ -699,9 +690,6 @@ extern "C" JSC__JSValue JSC__JSValue__makeWithNameAndPrototype(JSC__JSGlobalObje
return JSC::JSValue::encode(JSC::JSValue(object));
}
-extern "C" EncodedJSValue Bun__escapeHTML8(JSGlobalObject* globalObject, EncodedJSValue input, const LChar* ptr, size_t length);
-extern "C" EncodedJSValue Bun__escapeHTML16(JSGlobalObject* globalObject, EncodedJSValue input, const UChar* ptr, size_t length);
-
const JSC::GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = {
&supportsRichSourceInfo,
&shouldInterruptScript,
@@ -910,6 +898,9 @@ GENERATED_CONSTRUCTOR_SETTER(JSBlob);
GENERATED_CONSTRUCTOR_GETTER(JSHTMLRewriter);
GENERATED_CONSTRUCTOR_SETTER(JSHTMLRewriter);
+GENERATED_CONSTRUCTOR_GETTER(JSCrypto);
+GENERATED_CONSTRUCTOR_SETTER(JSCrypto);
+
WEBCORE_GENERATED_CONSTRUCTOR_GETTER(JSMessageEvent);
WEBCORE_GENERATED_CONSTRUCTOR_SETTER(JSMessageEvent);
@@ -1004,6 +995,16 @@ JSC_DEFINE_CUSTOM_GETTER(property_lazyProcessGetter,
globalObject->processObject());
}
+JSC_DEFINE_CUSTOM_GETTER(property_lazyCryptoGetter,
+ (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue,
+ JSC::PropertyName property))
+{
+ Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(JSValue::decode(thisValue));
+ JSValue cryptoObject = thisObject->cryptoObject();
+ thisObject->putDirect(thisObject->vm(), property, cryptoObject, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ return JSValue::encode(cryptoObject);
+}
+
JSC_DEFINE_CUSTOM_SETTER(lazyProcessEnvSetter,
(JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
JSC::EncodedJSValue value, JSC::PropertyName))
@@ -1049,20 +1050,6 @@ JSC_DEFINE_HOST_FUNCTION(functionQueueMicrotask,
return JSC::JSValue::encode(JSC::jsUndefined());
}
-JSC_DEFINE_HOST_FUNCTION(functionBunSleepThenCallback,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- JSC::VM& vm = globalObject->vm();
-
- RELEASE_ASSERT(callFrame->argumentCount() == 1);
- JSPromise* promise = jsCast<JSC::JSPromise*>(callFrame->argument(0));
- RELEASE_ASSERT(promise);
-
- promise->resolve(globalObject, JSC::jsUndefined());
-
- return JSC::JSValue::encode(promise);
-}
-
using MicrotaskCallback = void (*)(void*);
JSC_DEFINE_HOST_FUNCTION(functionNativeMicrotaskTrampoline,
@@ -1078,31 +1065,6 @@ JSC_DEFINE_HOST_FUNCTION(functionNativeMicrotaskTrampoline,
return JSValue::encode(jsUndefined());
}
-JSC_DEFINE_HOST_FUNCTION(functionBunSleep,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- JSC::VM& vm = globalObject->vm();
-
- JSC::JSValue millisecondsValue = callFrame->argument(0);
-
- if (millisecondsValue.inherits<JSC::DateInstance>()) {
- auto now = MonotonicTime::now();
- auto milliseconds = jsCast<JSC::DateInstance*>(millisecondsValue)->internalNumber() - now.approximateWallTime().secondsSinceEpoch().milliseconds();
- millisecondsValue = JSC::jsNumber(milliseconds > 0 ? milliseconds : 0);
- }
-
- if (!millisecondsValue.isNumber()) {
- auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
- JSC::throwTypeError(globalObject, scope, "sleep expects a number (milliseconds)"_s);
- return JSC::JSValue::encode(JSC::JSValue {});
- }
-
- Zig::GlobalObject* global = JSC::jsCast<Zig::GlobalObject*>(globalObject);
- JSC::JSPromise* promise = JSC::JSPromise::create(vm, globalObject->promiseStructure());
- Bun__Timer__setTimeout(globalObject, JSC::JSValue::encode(global->bunSleepThenCallback()), JSC::JSValue::encode(millisecondsValue), JSValue::encode(promise));
- return JSC::JSValue::encode(promise);
-}
-
JSC_DEFINE_HOST_FUNCTION(functionSetTimeout,
(JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
@@ -1351,19 +1313,6 @@ static JSC_DEFINE_HOST_FUNCTION(functionATOB,
RELEASE_AND_RETURN(throwScope, JSValue::encode(jsString(vm, result.releaseReturnValue())));
}
-static JSC_DEFINE_HOST_FUNCTION(functionHashCode,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- JSC::JSValue stringToHash = callFrame->argument(0);
- JSC::JSString* str = stringToHash.toStringOrNull(globalObject);
- if (!str) {
- return JSC::JSValue::encode(jsNumber(0));
- }
-
- auto view = str->value(globalObject);
- return JSC::JSValue::encode(jsNumber(view.hash()));
-}
-
static JSC_DEFINE_HOST_FUNCTION(functionReportError,
(JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
@@ -1442,55 +1391,6 @@ JSC_DEFINE_HOST_FUNCTION(functionCallback, (JSC::JSGlobalObject * globalObject,
return JSC::JSValue::encode(JSC::call(globalObject, callback, callData, JSC::jsUndefined(), JSC::MarkedArgumentBuffer()));
}
-JSC_DECLARE_HOST_FUNCTION(functionPathToFileURL);
-JSC_DECLARE_HOST_FUNCTION(functionFileURLToPath);
-
-JSC_DEFINE_HOST_FUNCTION(functionPathToFileURL, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
-{
- auto& globalObject = *reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- auto& vm = globalObject.vm();
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- auto path = JSC::JSValue::encode(callFrame->argument(0));
-
- JSC::JSString* pathString = JSC::JSValue::decode(path).toString(lexicalGlobalObject);
- RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined()));
-
- auto fileURL = WTF::URL::fileURLWithFileSystemPath(pathString->value(lexicalGlobalObject));
- auto object = WebCore::DOMURL::create(fileURL.string(), String());
- auto jsValue = toJSNewlyCreated<IDLInterface<DOMURL>>(*lexicalGlobalObject, globalObject, throwScope, WTFMove(object));
- RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(jsValue));
-}
-
-JSC_DEFINE_HOST_FUNCTION(functionFileURLToPath, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- auto& vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- JSValue arg0 = callFrame->argument(0);
- auto path = JSC::JSValue::encode(arg0);
- auto* domURL = WebCoreCast<WebCore::JSDOMURL, WebCore__DOMURL>(path);
- if (!domURL) {
- if (arg0.isString()) {
- auto url = WTF::URL(arg0.toWTFString(globalObject));
- if (UNLIKELY(!url.protocolIs("file"_s))) {
- throwTypeError(globalObject, scope, "Argument must be a file URL"_s);
- return JSC::JSValue::encode(JSC::JSValue {});
- }
- RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined()));
- RELEASE_AND_RETURN(scope, JSValue::encode(jsString(vm, url.fileSystemPath())));
- }
- throwTypeError(globalObject, scope, "Argument must be a URL"_s);
- return JSC::JSValue::encode(JSC::JSValue {});
- }
-
- auto& url = domURL->href();
- if (UNLIKELY(!url.protocolIs("file"_s))) {
- throwTypeError(globalObject, scope, "Argument must be a file URL"_s);
- return JSC::JSValue::encode(JSC::JSValue {});
- }
-
- return JSC::JSValue::encode(JSC::jsString(vm, url.fileSystemPath()));
-}
-
static void cleanupAsyncHooksData(JSC::VM& vm)
{
vm.setOnEachMicrotaskTick(nullptr);
@@ -2241,130 +2141,6 @@ extern "C" JSC__JSValue ZigGlobalObject__createNativeReadableStream(Zig::GlobalO
return JSC::JSValue::encode(call(globalObject, function, callData, JSC::jsUndefined(), arguments));
}
-static inline EncodedJSValue flattenArrayOfBuffersIntoArrayBuffer(JSGlobalObject* lexicalGlobalObject, JSValue arrayValue)
-{
- auto& vm = lexicalGlobalObject->vm();
-
- auto clientData = WebCore::clientData(vm);
- if (arrayValue.isUndefinedOrNull() || !arrayValue) {
- return JSC::JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1)));
- }
-
- auto throwScope = DECLARE_THROW_SCOPE(vm);
-
- auto array = JSC::jsDynamicCast<JSC::JSArray*>(arrayValue);
- if (UNLIKELY(!array)) {
- throwTypeError(lexicalGlobalObject, throwScope, "Argument must be an array"_s);
- return JSValue::encode(jsUndefined());
- }
-
- size_t arrayLength = array->length();
- if (arrayLength < 1) {
- RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1))));
- }
-
- size_t byteLength = 0;
- bool any_buffer = false;
- bool any_typed = false;
-
- for (size_t i = 0; i < arrayLength; i++) {
- auto element = array->getIndex(lexicalGlobalObject, i);
- RETURN_IF_EXCEPTION(throwScope, {});
-
- if (auto* typedArray = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(element)) {
- if (UNLIKELY(typedArray->isDetached())) {
- throwTypeError(lexicalGlobalObject, throwScope, "ArrayBufferView is detached"_s);
- return JSValue::encode(jsUndefined());
- }
- byteLength += typedArray->byteLength();
- any_typed = true;
- } else if (auto* arrayBuffer = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(element)) {
- auto* impl = arrayBuffer->impl();
- if (UNLIKELY(!impl)) {
- throwTypeError(lexicalGlobalObject, throwScope, "ArrayBuffer is detached"_s);
- return JSValue::encode(jsUndefined());
- }
-
- byteLength += impl->byteLength();
- any_buffer = true;
- } else {
- throwTypeError(lexicalGlobalObject, throwScope, "Expected TypedArray"_s);
- return JSValue::encode(jsUndefined());
- }
- }
-
- if (byteLength == 0) {
- RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1))));
- }
-
- auto buffer = JSC::ArrayBuffer::tryCreateUninitialized(byteLength, 1);
- if (UNLIKELY(!buffer)) {
- throwTypeError(lexicalGlobalObject, throwScope, "Failed to allocate ArrayBuffer"_s);
- return JSValue::encode(jsUndefined());
- }
-
- size_t remain = byteLength;
- auto* head = reinterpret_cast<char*>(buffer->data());
-
- if (!any_buffer) {
- for (size_t i = 0; i < arrayLength && remain > 0; i++) {
- auto element = array->getIndex(lexicalGlobalObject, i);
- RETURN_IF_EXCEPTION(throwScope, {});
- auto* view = JSC::jsCast<JSC::JSArrayBufferView*>(element);
- size_t length = std::min(remain, view->byteLength());
- memcpy(head, view->vector(), length);
- remain -= length;
- head += length;
- }
- } else if (!any_typed) {
- for (size_t i = 0; i < arrayLength && remain > 0; i++) {
- auto element = array->getIndex(lexicalGlobalObject, i);
- RETURN_IF_EXCEPTION(throwScope, {});
- auto* view = JSC::jsCast<JSC::JSArrayBuffer*>(element);
- size_t length = std::min(remain, view->impl()->byteLength());
- memcpy(head, view->impl()->data(), length);
- remain -= length;
- head += length;
- }
- } else {
- for (size_t i = 0; i < arrayLength && remain > 0; i++) {
- auto element = array->getIndex(lexicalGlobalObject, i);
- RETURN_IF_EXCEPTION(throwScope, {});
- size_t length = 0;
- if (auto* view = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(element)) {
- length = std::min(remain, view->impl()->byteLength());
- memcpy(head, view->impl()->data(), length);
- } else {
- auto* typedArray = JSC::jsCast<JSC::JSArrayBufferView*>(element);
- length = std::min(remain, typedArray->byteLength());
- memcpy(head, typedArray->vector(), length);
- }
-
- remain -= length;
- head += length;
- }
- }
-
- RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), WTFMove(buffer))));
-}
-
-JSC_DECLARE_HOST_FUNCTION(functionConcatTypedArrays);
-
-JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArrays, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- auto& vm = globalObject->vm();
-
- if (UNLIKELY(callFrame->argumentCount() < 1)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- throwTypeError(globalObject, throwScope, "Expected at least one argument"_s);
- return JSValue::encode(jsUndefined());
- }
-
- auto arrayValue = callFrame->uncheckedArgument(0);
-
- return flattenArrayOfBuffersIntoArrayBuffer(globalObject, arrayValue);
-}
-
extern "C" uint64_t Bun__readOriginTimer(void*);
extern "C" double Bun__readOriginTimerStart(void*);
@@ -2381,8 +2157,6 @@ extern "C" {
class JSPerformanceObject;
static JSC_DECLARE_HOST_FUNCTION(functionPerformanceNow);
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(functionPerformanceNowWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject*, JSPerformanceObject*));
-static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(functionBunNanosecondsWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject*, JSObject*));
-static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(functionBunEscapeHTMLWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject*, JSObject*, JSString*));
}
class JSPerformanceObject final : public JSC::JSNonFinalObject {
@@ -2464,145 +2238,6 @@ JSC_DEFINE_JIT_OPERATION(functionPerformanceNowWithoutTypeCheck, JSC::EncodedJSV
return functionPerformanceNowBody(lexicalGlobalObject);
}
-JSC_DEFINE_JIT_OPERATION(functionBunEscapeHTMLWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSObject* castedThis, JSString* string))
-{
- JSC::VM& vm = JSC::getVM(lexicalGlobalObject);
- IGNORE_WARNINGS_BEGIN("frame-address")
- CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
- IGNORE_WARNINGS_END
- JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
- size_t length = string->length();
- if (!length)
- return JSValue::encode(string);
-
- auto resolvedString = string->value(lexicalGlobalObject);
- if (!resolvedString.is8Bit()) {
- return Bun__escapeHTML16(lexicalGlobalObject, JSValue::encode(string), resolvedString.characters16(), length);
- } else {
- return Bun__escapeHTML8(lexicalGlobalObject, JSValue::encode(string), resolvedString.characters8(), length);
- }
-}
-
-JSC_DECLARE_HOST_FUNCTION(functionBunEscapeHTML);
-JSC_DEFINE_HOST_FUNCTION(functionBunEscapeHTML, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
-{
- JSC::VM& vm = JSC::getVM(lexicalGlobalObject);
- JSC::JSValue argument = callFrame->argument(0);
- if (argument.isEmpty())
- return JSValue::encode(jsEmptyString(vm));
- if (argument.isNumber() || argument.isBoolean())
- return JSValue::encode(argument.toString(lexicalGlobalObject));
-
- auto scope = DECLARE_THROW_SCOPE(vm);
- auto string = argument.toString(lexicalGlobalObject);
- RETURN_IF_EXCEPTION(scope, {});
- size_t length = string->length();
- if (!length)
- RELEASE_AND_RETURN(scope, JSValue::encode(string));
-
- auto resolvedString = string->value(lexicalGlobalObject);
- EncodedJSValue encodedInput = JSValue::encode(string);
- if (!resolvedString.is8Bit()) {
- RELEASE_AND_RETURN(scope, Bun__escapeHTML16(lexicalGlobalObject, encodedInput, resolvedString.characters16(), length));
- } else {
- RELEASE_AND_RETURN(scope, Bun__escapeHTML8(lexicalGlobalObject, encodedInput, resolvedString.characters8(), length));
- }
-}
-
-JSC_DECLARE_HOST_FUNCTION(functionBunDeepEquals);
-
-JSC_DEFINE_HOST_FUNCTION(functionBunDeepEquals, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- auto* global = reinterpret_cast<GlobalObject*>(globalObject);
- JSC::VM& vm = global->vm();
-
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- if (callFrame->argumentCount() < 2) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- throwTypeError(globalObject, throwScope, "Expected 2 values to compare"_s);
- return JSValue::encode(jsUndefined());
- }
-
- JSC::JSValue arg1 = callFrame->uncheckedArgument(0);
- JSC::JSValue arg2 = callFrame->uncheckedArgument(1);
- JSC::JSValue arg3 = callFrame->argument(2);
-
- Vector<std::pair<JSValue, JSValue>, 16> stack;
-
- if (arg3.isBoolean() && arg3.asBoolean()) {
- bool isEqual = Bun__deepEquals<true, false>(globalObject, arg1, arg2, stack, &scope, true);
- RETURN_IF_EXCEPTION(scope, {});
- return JSValue::encode(jsBoolean(isEqual));
- } else {
- bool isEqual = Bun__deepEquals<false, false>(globalObject, arg1, arg2, stack, &scope, true);
- RETURN_IF_EXCEPTION(scope, {});
- return JSValue::encode(jsBoolean(isEqual));
- }
-}
-
-JSC_DECLARE_HOST_FUNCTION(functionBunDeepMatch);
-
-JSC_DEFINE_HOST_FUNCTION(functionBunDeepMatch, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- auto* global = reinterpret_cast<GlobalObject*>(globalObject);
- JSC::VM& vm = global->vm();
-
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- if (callFrame->argumentCount() < 2) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- throwTypeError(globalObject, throwScope, "Expected 2 values to compare"_s);
- return JSValue::encode(jsUndefined());
- }
-
- JSC::JSValue subset = callFrame->uncheckedArgument(0);
- JSC::JSValue object = callFrame->uncheckedArgument(1);
-
- if (!subset.isObject() || !object.isObject()) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- throwTypeError(globalObject, throwScope, "Expected 2 objects to match"_s);
- return JSValue::encode(jsUndefined());
- }
-
- bool match = Bun__deepMatch<false>(object, subset, globalObject, &scope, false);
- RETURN_IF_EXCEPTION(scope, {});
- return JSValue::encode(jsBoolean(match));
-}
-
-JSC_DECLARE_HOST_FUNCTION(functionBunNanoseconds);
-
-JSC_DEFINE_HOST_FUNCTION(functionBunNanoseconds, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- auto* global = reinterpret_cast<GlobalObject*>(globalObject);
- uint64_t time = Bun__readOriginTimer(global->bunVM());
- return JSValue::encode(jsNumber(time));
-}
-
-JSC_DECLARE_HOST_FUNCTION(functionConcatTypedArraysFromIterator);
-
-JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArraysFromIterator, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- auto& vm = globalObject->vm();
-
- if (UNLIKELY(callFrame->argumentCount() < 1)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- throwTypeError(globalObject, throwScope, "Expected at least one argument"_s);
- return JSValue::encode(jsUndefined());
- }
-
- auto arrayValue = callFrame->uncheckedArgument(0);
- if (UNLIKELY(!arrayValue.isObject())) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- throwTypeError(globalObject, throwScope, "Expected an object"_s);
- return JSValue::encode(jsUndefined());
- }
-
- auto* iter = JSC::jsCast<JSC::JSObject*>(arrayValue);
-
- return flattenArrayOfBuffersIntoArrayBuffer(globalObject, iter->getDirect(vm, vm.propertyNames->value));
-}
-
extern "C" JSC__JSValue Bun__Jest__createTestModuleObject(JSC::JSGlobalObject*);
extern "C" JSC__JSValue Bun__Jest__createTestPreloadObject(JSC::JSGlobalObject*);
extern "C" JSC__JSValue Bun__Jest__testPreloadObject(Zig::GlobalObject* globalObject)
@@ -2829,19 +2464,6 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotask, (JSGlobalObject * globalObj
return JSValue::encode(jsUndefined());
}
-extern "C" EncodedJSValue Bun__DNSResolver__lookup(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolve(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolveSrv(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolveTxt(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolveSoa(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolveNaptr(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolveMx(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolveCaa(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolveNs(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolvePtr(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__resolveCname(JSGlobalObject*, JSC::CallFrame*);
-extern "C" EncodedJSValue Bun__DNSResolver__getServers(JSGlobalObject*, JSC::CallFrame*);
-
JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotaskVariadic, (JSGlobalObject * globalObject, CallFrame* callframe))
{
auto& vm = globalObject->vm();
@@ -2981,8 +2603,6 @@ JSC::JSValue GlobalObject::formatStackTrace(JSC::VM& vm, JSC::JSGlobalObject* le
return JSC::JSValue(jsString(vm, sb.toString()));
}
-extern "C" EncodedJSValue JSPasswordObject__create(JSC::JSGlobalObject*, bool);
-
JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncAppendStackTrace, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
GlobalObject* globalObject = reinterpret_cast<GlobalObject*>(lexicalGlobalObject);
@@ -3109,11 +2729,27 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb
return JSC::JSValue::encode(JSC::jsUndefined());
}
+extern "C" EncodedJSValue CryptoObject__create(JSGlobalObject*);
+
void GlobalObject::finishCreation(VM& vm)
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
+ m_cryptoObject.initLater(
+ [](const Initializer<JSObject>& init) {
+ JSC::JSGlobalObject* globalObject = init.owner;
+ JSObject* crypto = JSValue::decode(CryptoObject__create(globalObject)).getObject();
+ // this should technically go on the prototype i think?
+ crypto->putDirectCustomAccessor(
+ init.vm,
+ Identifier::fromString(init.vm, "subtle"_s),
+ JSC::CustomGetterSetter::create(init.vm, getterSubtleCrypto, nullptr),
+ JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+
+ init.set(crypto);
+ });
+
m_lazyRequireCacheObject.initLater(
[](const Initializer<JSObject>& init) {
JSC::VM& vm = init.vm;
@@ -3135,15 +2771,6 @@ void GlobalObject::finishCreation(VM& vm)
init.set(result.toObject(globalObject));
});
- m_lazyPasswordObject.initLater(
- [](const Initializer<JSObject>& init) {
- JSC::VM& vm = init.vm;
- JSC::JSGlobalObject* globalObject = init.owner;
-
- JSValue result = JSValue::decode(JSPasswordObject__create(globalObject, false));
- init.set(result.toObject(globalObject));
- });
-
m_lazyPreloadTestModuleObject.initLater(
[](const Initializer<JSObject>& init) {
JSC::VM& vm = init.vm;
@@ -3205,38 +2832,6 @@ void GlobalObject::finishCreation(VM& vm)
init.set(JSModuleNamespaceObject::createStructure(init.vm, init.owner, init.owner->objectPrototype()));
});
- m_dnsObject.initLater(
- [](const Initializer<JSObject>& init) {
- JSC::VM& vm = init.vm;
- JSC::JSGlobalObject* globalObject = init.owner;
- JSC::JSObject* dnsObject = JSC::constructEmptyObject(globalObject);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookup"_s), 2, Bun__DNSResolver__lookup, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolve"_s), 2, Bun__DNSResolver__resolve, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSrv"_s), 2, Bun__DNSResolver__resolveSrv, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveTxt"_s), 2, Bun__DNSResolver__resolveTxt, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSoa"_s), 2, Bun__DNSResolver__resolveSoa, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNaptr"_s), 2, Bun__DNSResolver__resolveNaptr, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveMx"_s), 2, Bun__DNSResolver__resolveMx, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCaa"_s), 2, Bun__DNSResolver__resolveCaa, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNs"_s), 2, Bun__DNSResolver__resolveNs, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolvePtr"_s), 2, Bun__DNSResolver__resolvePtr, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCname"_s), 2, Bun__DNSResolver__resolveCname, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getServers"_s), 2, Bun__DNSResolver__getServers, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- init.set(dnsObject);
- });
-
m_vmModuleContextMap.initLater(
[](const Initializer<JSWeakMap>& init) {
init.set(JSWeakMap::create(init.vm, init.owner->weakMapStructure()));
@@ -3691,90 +3286,6 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPostMessage,
return JSValue::encode(jsUndefined());
}
-JSC_DEFINE_HOST_FUNCTION(functionBunPeek,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- JSC::VM& vm = globalObject->vm();
-
- auto scope = DECLARE_THROW_SCOPE(vm);
- JSValue promiseValue = callFrame->argument(0);
- if (UNLIKELY(!promiseValue)) {
- return JSValue::encode(jsUndefined());
- } else if (!promiseValue.isCell()) {
- return JSValue::encode(promiseValue);
- }
-
- auto* promise = jsDynamicCast<JSPromise*>(promiseValue);
-
- if (!promise) {
- return JSValue::encode(promiseValue);
- }
-
- JSValue invalidateValue = callFrame->argument(1);
- bool invalidate = invalidateValue.isBoolean() && invalidateValue.asBoolean();
-
- switch (promise->status(vm)) {
- case JSPromise::Status::Pending: {
- break;
- }
- case JSPromise::Status::Fulfilled: {
- JSValue result = promise->result(vm);
- if (invalidate) {
- promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(vm, promise, jsUndefined());
- }
- return JSValue::encode(result);
- }
- case JSPromise::Status::Rejected: {
- JSValue result = promise->result(vm);
- JSC::EnsureStillAliveScope ensureStillAliveScope(result);
-
- if (invalidate) {
- promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(promise->internalField(JSC::JSPromise::Field::Flags).get().asUInt32() | JSC::JSPromise::isHandledFlag));
- promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(vm, promise, JSC::jsUndefined());
- }
-
- return JSValue::encode(result);
- }
- }
-
- return JSValue::encode(promiseValue);
-}
-
-JSC_DEFINE_HOST_FUNCTION(functionBunPeekStatus,
- (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
-{
- JSC::VM& vm = globalObject->vm();
- static NeverDestroyed<String> fulfilled = MAKE_STATIC_STRING_IMPL("fulfilled");
-
- auto scope = DECLARE_THROW_SCOPE(vm);
- JSValue promiseValue = callFrame->argument(0);
- if (!promiseValue || !promiseValue.isCell()) {
- return JSValue::encode(jsOwnedString(vm, fulfilled));
- }
-
- auto* promise = jsDynamicCast<JSPromise*>(promiseValue);
-
- if (!promise) {
- return JSValue::encode(jsOwnedString(vm, fulfilled));
- }
-
- switch (promise->status(vm)) {
- case JSPromise::Status::Pending: {
- static NeverDestroyed<String> pending = MAKE_STATIC_STRING_IMPL("pending");
- return JSValue::encode(jsOwnedString(vm, pending));
- }
- case JSPromise::Status::Fulfilled: {
- return JSValue::encode(jsOwnedString(vm, fulfilled));
- }
- case JSPromise::Status::Rejected: {
- static NeverDestroyed<String> rejected = MAKE_STATIC_STRING_IMPL("rejected");
- return JSValue::encode(jsOwnedString(vm, rejected));
- }
- }
-
- return JSValue::encode(jsUndefined());
-}
-
JSC_DEFINE_CUSTOM_GETTER(BunCommonJSModule_getter, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName))
{
Zig::GlobalObject* bunGlobalObject = jsCast<Zig::GlobalObject*>(globalObject);
@@ -3834,11 +3345,6 @@ JSC_DEFINE_CUSTOM_GETTER(JSModuleLoader_getter, (JSGlobalObject * globalObject,
return JSValue::encode(globalObject->moduleLoader());
}
-JSC_DEFINE_CUSTOM_GETTER(bunDns_getter, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName))
-{
- return JSValue::encode(reinterpret_cast<Zig::GlobalObject*>(globalObject)->dnsObject());
-}
-
JSC_DEFINE_CUSTOM_GETTER(functionResolveMessageGetter, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName))
{
return JSValue::encode(reinterpret_cast<Zig::GlobalObject*>(globalObject)->JSResolveMessageConstructor());
@@ -3982,6 +3488,10 @@ JSC::GCClient::IsoSubspace* GlobalObject::subspaceForImpl(JSC::VM& vm)
[](auto& server) -> JSC::HeapCellType& { return server.m_heapCellTypeForJSWorkerGlobalScope; });
}
+extern "C" EncodedJSValue WebCore__alert(JSC::JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue WebCore__prompt(JSC::JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue WebCore__confirm(JSC::JSGlobalObject*, JSC::CallFrame*);
+
void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
{
m_builtinInternalFunctions.initialize(*this);
@@ -3990,7 +3500,7 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
auto& builtinNames = WebCore::builtinNames(vm);
WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
- extraStaticGlobals.reserveCapacity(49);
+ extraStaticGlobals.reserveCapacity(51);
JSC::Identifier queueMicrotaskIdentifier = JSC::Identifier::fromString(vm, "queueMicrotask"_s);
extraStaticGlobals.uncheckedAppend(
@@ -4077,6 +3587,41 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
}
+ {
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { JSC::Identifier::fromString(vm, "alert"_s),
+ JSC::JSFunction::create(vm, this, 1,
+ "alert"_s, WebCore__alert, ImplementationVisibility::Public),
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
+ }
+
+ {
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { JSC::Identifier::fromString(vm, "confirm"_s),
+ JSC::JSFunction::create(vm, this, 1,
+ "confirm"_s, WebCore__confirm, ImplementationVisibility::Public),
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
+ }
+
+ {
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { JSC::Identifier::fromString(vm, "prompt"_s),
+ JSC::JSFunction::create(vm, this, 1,
+ "prompt"_s, WebCore__prompt, ImplementationVisibility::Public),
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
+ }
+
+ JSValue bunObject = Bun::createBunObject(this);
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { builtinNames.BunPrivateName(),
+ bunObject,
+ JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0 });
+
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { builtinNames.BunPublicName(),
+ bunObject,
+ JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0 });
+
extraStaticGlobals.uncheckedAppend(
GlobalPropertyInfo { builtinNames.startDirectStreamPrivateName(),
JSC::JSFunction::create(vm, this, 1,
@@ -4185,6 +3730,9 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "HTMLRewriter"_s), JSC::CustomGetterSetter::create(vm, JSHTMLRewriter_getter, JSHTMLRewriter_setter),
JSC::PropertyAttribute::DontDelete | 0);
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Crypto"_s), JSC::CustomGetterSetter::create(vm, JSCrypto_getter, JSCrypto_setter),
+ JSC::PropertyAttribute::DontDelete | 0);
+
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "DOMException"_s), JSC::CustomGetterSetter::create(vm, JSDOMException_getter, nullptr),
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
@@ -4208,6 +3756,9 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "onmessage"_s), JSC::CustomGetterSetter::create(vm, globalGetterOnMessage, globalSetterOnMessage), 0);
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "onerror"_s), JSC::CustomGetterSetter::create(vm, globalGetterOnError, globalSetterOnError), 0);
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "crypto"_s), JSC::CustomGetterSetter::create(vm, property_lazyCryptoGetter, nullptr),
+ JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+
auto bufferAccessor = JSC::CustomGetterSetter::create(vm, JSBuffer_getter, JSBuffer_setter);
auto realBufferAccessor = JSC::CustomGetterSetter::create(vm, JSBuffer_privateGetter, nullptr);
@@ -4302,266 +3853,6 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
}
-// We set it in here since it's a global
-extern "C" void Crypto__randomUUID__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value);
-extern "C" void Crypto__getRandomValues__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value);
-
-DEFINE_BUN_LAZY_GETTER(BUN_LAZY_GETTER_FN_NAME(password), passwordObject)
-
-// This is not a publicly exposed API currently.
-// This is used by the bundler to make Response, Request, FetchEvent,
-// and any other objects available globally.
-void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm)
-{
- auto clientData = WebCore::clientData(vm);
- auto& builtinNames = clientData->builtinNames();
- WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
- extraStaticGlobals.reserveCapacity((size_t)count + 3 + 1 + 1);
-
- int j = 0;
- {
- // first one is Bun object
- auto jsClass = globals[j];
-
- JSC::JSCallbackObject<JSNonFinalObject>* object = JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- jsClass, nullptr);
- if (JSObject* prototype = object->classRef()->prototype(this))
- object->setPrototypeDirect(vm, prototype);
-
- {
- // on the Bun object we make this read-only so that it is the "safer" one to use
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "fetch"_s);
- object->putDirectNativeFunction(vm, this, identifier, 2, Bun__fetch, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "escapeHTML"_s);
- static ClassInfo escapeHTMLClassInfo = *object->classInfo();
- static const JSC::DOMJIT::Signature DOMJITSignatureForEscapeHTML(
- functionBunEscapeHTMLWithoutTypeCheck,
- object->classInfo(),
- JSC::DOMJIT::Effect::forPure(),
- SpecString,
- SpecString);
- object->putDirectNativeFunction(vm, this, identifier, 1, functionBunEscapeHTML, ImplementationVisibility::Public, NoIntrinsic, &DOMJITSignatureForEscapeHTML,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "peek"_s);
- JSFunction* peekFunction = JSFunction::create(vm, this, 2, WTF::String("peek"_s), functionBunPeek, ImplementationVisibility::Public, NoIntrinsic);
- JSFunction* peekStatus = JSFunction::create(vm, this, 1, WTF::String("status"_s), functionBunPeekStatus, ImplementationVisibility::Public, NoIntrinsic);
- peekFunction->putDirect(vm, PropertyName(JSC::Identifier::fromString(vm, "status"_s)), peekStatus, JSC::PropertyAttribute::Function | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
- object->putDirect(vm, PropertyName(identifier), JSValue(peekFunction),
- JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- // TODO: code generate these
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "password"_s);
- object->putDirectCustomAccessor(vm, identifier, JSC::CustomGetterSetter::create(vm, BUN_LAZY_GETTER_FN_NAME(password), nullptr),
- JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "readableStreamToArrayBuffer"_s);
- object->putDirectBuiltinFunction(vm, this, identifier, readableStreamReadableStreamToArrayBufferCodeGenerator(vm),
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "readableStreamToFormData"_s);
- object->putDirectBuiltinFunction(vm, this, identifier, readableStreamReadableStreamToFormDataCodeGenerator(vm),
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "readableStreamToText"_s);
- object->putDirectBuiltinFunction(vm, this, identifier, readableStreamReadableStreamToTextCodeGenerator(vm),
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "readableStreamToBlob"_s);
- object->putDirectBuiltinFunction(vm, this, identifier, readableStreamReadableStreamToBlobCodeGenerator(vm),
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "readableStreamToArray"_s);
- object->putDirectBuiltinFunction(vm, this, identifier, readableStreamReadableStreamToArrayCodeGenerator(vm),
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "readableStreamToJSON"_s);
- object->putDirectBuiltinFunction(vm, this, identifier, readableStreamReadableStreamToJSONCodeGenerator(vm),
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "concatArrayBuffers"_s);
- object->putDirectNativeFunction(vm, this, identifier, 1, functionConcatTypedArrays, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "ArrayBufferSink"_s);
- object->putDirectCustomAccessor(vm, identifier, JSC::CustomGetterSetter::create(vm, functionArrayBufferSink__getter, nullptr),
- JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "nanoseconds"_s);
- object->putDirectNativeFunction(vm, this, identifier, 1, functionBunNanoseconds, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "deepEquals"_s);
- object->putDirectNativeFunction(vm, this, identifier, 2, functionBunDeepEquals, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "deepMatch"_s);
- object->putDirectNativeFunction(vm, this, identifier, 2, functionBunDeepMatch, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
-
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "version"_s);
- object->putDirect(vm, PropertyName(identifier), JSC::jsOwnedString(vm, makeString(Bun__version + 1)),
- JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
-
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "revision"_s);
- object->putDirect(vm, PropertyName(identifier), JSC::jsOwnedString(vm, makeString(Bun__version_sha)),
- JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
-
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "sleep"_s);
- object->putDirectNativeFunction(vm, this, identifier, 1, functionBunSleep, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
-
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "env"_s);
- object->putDirectCustomAccessor(vm, identifier,
- JSC::CustomGetterSetter::create(vm, lazyProcessEnvGetter, lazyProcessEnvSetter),
- JSC::PropertyAttribute::DontDelete
- | JSC::PropertyAttribute::CustomValue
- | 0);
- }
-
- {
-
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "isMainThread"_s);
- object->putDirect(vm, identifier,
- jsBoolean(scriptExecutionContext()->isMainThread()),
- JSC::PropertyAttribute::DontDelete
- | JSC::PropertyAttribute::ReadOnly
- | 0);
- }
-
- {
-
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, pathToFileURLString);
- object->putDirectNativeFunction(vm, this, identifier, 1, functionPathToFileURL, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, fileURLToPathString);
- object->putDirectNativeFunction(vm, this, identifier, 1, functionFileURLToPath, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "stringHashCode"_s);
- object->putDirectNativeFunction(vm, this, identifier, 1, functionHashCode, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "dns"_s);
- object->putDirectCustomAccessor(vm, PropertyName(identifier), JSC::CustomGetterSetter::create(vm, bunDns_getter, nullptr), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- {
- JSC::Identifier identifier = JSC::Identifier::fromString(vm, "plugin"_s);
- JSFunction* pluginFunction = JSFunction::create(vm, this, 1, String("plugin"_s), jsFunctionBunPlugin, ImplementationVisibility::Public, NoIntrinsic);
- pluginFunction->putDirectNativeFunction(vm, this, JSC::Identifier::fromString(vm, "clearAll"_s), 1, jsFunctionBunPluginClear, ImplementationVisibility::Public, NoIntrinsic,
- JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- object->putDirect(vm, PropertyName(identifier), pluginFunction, JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
- }
-
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { builtinNames.BunPublicName(),
- JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { builtinNames.BunPrivateName(),
- JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
- }
-
- {
- j = 1;
- auto jsClass = globals[j];
-
- JSC::JSCallbackObject<JSNonFinalObject>* object = JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- jsClass, nullptr);
- if (JSObject* prototype = object->classRef()->prototype(this))
- object->setPrototypeDirect(vm, prototype);
-
- Crypto__getRandomValues__put(this, JSValue::encode(object));
- Crypto__randomUUID__put(this, JSValue::encode(object));
- Crypto__timingSafeEqual__put(this, JSValue::encode(object));
- object->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "subtle"_s), JSC::CustomGetterSetter::create(vm, getterSubtleCrypto, nullptr),
- JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
- this->putDirect(vm, JSC::Identifier::fromString(vm, "crypto"_s), object, JSC::PropertyAttribute::DontDelete | 0);
- }
-
- for (j = 2; j < count; j++) {
- auto jsClass = globals[j];
-
- JSC::JSCallbackObject<JSNonFinalObject>* object = JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- jsClass, nullptr);
- if (JSObject* prototype = object->classRef()->prototype(this))
- object->setPrototypeDirect(vm, prototype);
-
- this->putDirect(vm, JSC::Identifier::fromString(vm, jsClass->className()), JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0);
- }
-
- // // The last one must be "process.env"
- // // Runtime-support is for if they change
- // {
- // auto jsClass = globals[i];
-
- // JSC::JSCallbackObject<JSNonFinalObject> *object =
- // JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- // jsClass, nullptr);
- // if (JSObject *prototype = jsClass->prototype(this)) object->setPrototypeDirect(vm,
- // prototype);
-
- // process->putDirect(this->vm, JSC::Identifier::fromString(this->vm, "env"),
- // JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0);
- // }
-
- this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
-
- // putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "SQL"_s), JSC::CustomGetterSetter::create(vm, JSSQLStatement_getter, nullptr),
- // JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
-
- extraStaticGlobals.releaseBuffer();
-}
-
extern "C" bool JSC__JSGlobalObject__startRemoteInspector(JSC__JSGlobalObject* globalObject, unsigned char* host, uint16_t arg1)
{
#if !ENABLE(REMOTE_INSPECTOR)
@@ -4660,6 +3951,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
thisObject->m_callSiteStructure.visit(visitor);
thisObject->m_emitReadableNextTickFunction.visit(visitor);
thisObject->m_JSBufferSubclassStructure.visit(visitor);
+ thisObject->m_cryptoObject.visit(visitor);
thisObject->m_requireFunctionUnbound.visit(visitor);
thisObject->m_requireResolveFunctionUnbound.visit(visitor);
@@ -4668,7 +3960,6 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
thisObject->m_asyncBoundFunctionStructure.visit(visitor);
thisObject->m_internalModuleRegistry.visit(visitor);
- thisObject->m_dnsObject.visit(visitor);
thisObject->m_lazyRequireCacheObject.visit(visitor);
thisObject->m_vmModuleContextMap.visit(visitor);
thisObject->m_bunSleepThenCallback.visit(visitor);
@@ -4676,7 +3967,6 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
thisObject->m_lazyPreloadTestModuleObject.visit(visitor);
thisObject->m_commonJSModuleObjectStructure.visit(visitor);
thisObject->m_memoryFootprintStructure.visit(visitor);
- thisObject->m_lazyPasswordObject.visit(visitor);
thisObject->m_commonJSFunctionArgumentsStructure.visit(visitor);
thisObject->m_cachedGlobalObjectStructure.visit(visitor);
thisObject->m_cachedGlobalProxyStructure.visit(visitor);
diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h
index 68bd8aeb0..8e5aa37c3 100644
--- a/src/bun.js/bindings/ZigGlobalObject.h
+++ b/src/bun.js/bindings/ZigGlobalObject.h
@@ -201,7 +201,6 @@ public:
static void promiseRejectionTracker(JSGlobalObject*, JSC::JSPromise*,
JSC::JSPromiseRejectionOperation);
void setConsole(void* console);
- void installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm);
WebCore::JSBuiltinInternalFunctions& builtinInternalFunctions() { return m_builtinInternalFunctions; }
JSC::Structure* FFIFunctionStructure() { return m_JSFFIFunctionStructure.getInitializedOnMainThread(this); }
JSC::Structure* NapiClassStructure() { return m_NapiClassStructure.getInitializedOnMainThread(this); }
@@ -273,8 +272,6 @@ public:
JSFunction* bunSleepThenCallback() { return m_bunSleepThenCallback.getInitializedOnMainThread(this); }
- JSObject* dnsObject() { return m_dnsObject.getInitializedOnMainThread(this); }
-
Structure* globalObjectStructure() { return m_cachedGlobalObjectStructure.getInitializedOnMainThread(this); }
Structure* globalProxyStructure() { return m_cachedGlobalProxyStructure.getInitializedOnMainThread(this); }
JSObject* lazyTestModuleObject() { return m_lazyTestModuleObject.getInitializedOnMainThread(this); }
@@ -285,8 +282,6 @@ public:
Structure* commonJSFunctionArgumentsStructure() { return m_commonJSFunctionArgumentsStructure.getInitializedOnMainThread(this); }
- JSObject* passwordObject() { return m_lazyPasswordObject.getInitializedOnMainThread(this); }
-
JSWeakMap* vmModuleContextMap() { return m_vmModuleContextMap.getInitializedOnMainThread(this); }
bool hasProcessObject() const { return m_processObject.isInitialized(); }
@@ -464,6 +459,8 @@ public:
LazyProperty<JSGlobalObject, JSObject> m_processEnvObject;
+ JSObject* cryptoObject() { return m_cryptoObject.getInitializedOnMainThread(this); }
+
#include "ZigGeneratedClasses+lazyStructureHeader.h"
private:
@@ -533,12 +530,10 @@ private:
LazyProperty<JSGlobalObject, JSObject> m_subtleCryptoObject;
LazyProperty<JSGlobalObject, Structure> m_JSHTTPResponseController;
LazyProperty<JSGlobalObject, JSC::Structure> m_JSBufferSubclassStructure;
- LazyProperty<JSGlobalObject, JSObject> m_dnsObject;
LazyProperty<JSGlobalObject, JSWeakMap> m_vmModuleContextMap;
LazyProperty<JSGlobalObject, JSObject> m_lazyRequireCacheObject;
LazyProperty<JSGlobalObject, JSObject> m_lazyTestModuleObject;
LazyProperty<JSGlobalObject, JSObject> m_lazyPreloadTestModuleObject;
- LazyProperty<JSGlobalObject, JSObject> m_lazyPasswordObject;
LazyProperty<JSGlobalObject, JSFunction> m_bunSleepThenCallback;
LazyProperty<JSGlobalObject, Structure> m_cachedGlobalObjectStructure;
@@ -546,6 +541,7 @@ private:
LazyProperty<JSGlobalObject, Structure> m_commonJSModuleObjectStructure;
LazyProperty<JSGlobalObject, Structure> m_commonJSFunctionArgumentsStructure;
LazyProperty<JSGlobalObject, Structure> m_memoryFootprintStructure;
+ LazyProperty<JSGlobalObject, JSObject> m_cryptoObject;
LazyProperty<JSGlobalObject, JSC::JSObject> m_requireFunctionUnbound;
LazyProperty<JSGlobalObject, JSC::JSObject> m_requireResolveFunctionUnbound;
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index 5e5f43c99..afa1e254c 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -261,6 +261,9 @@ static void handlePromise(PromiseType* promise, JSC__JSGlobalObject* globalObjec
static bool canPerformFastPropertyEnumerationForIterationBun(Structure* s)
{
+ if (s->hasNonReifiedStaticProperties()) {
+ return false;
+ }
if (s->typeInfo().overridesGetOwnPropertySlot())
return false;
if (s->typeInfo().overridesAnyFormOfGetOwnPropertyNames())
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index dc9740865..124f71d86 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -5385,6 +5385,15 @@ pub fn NewFunction(
return NewRuntimeFunction(globalObject, symbolName, argCount, &functionPointer, strong, false);
}
+pub fn createCallback(
+ globalObject: *JSGlobalObject,
+ symbolName: ?*const ZigString,
+ argCount: u32,
+ comptime functionPointer: *const JSHostFunctionType,
+) JSValue {
+ return NewRuntimeFunction(globalObject, symbolName, argCount, functionPointer, false, false);
+}
+
pub fn NewRuntimeFunction(
globalObject: *JSGlobalObject,
symbolName: ?*const ZigString,
@@ -5731,19 +5740,19 @@ pub fn JSPropertyIterator(comptime options: JSPropertyIteratorOptions) type {
}
// DOMCall Fields
-pub const __DOMCall_ptr = @import("../api/bun.zig").FFI.Class.functionDefinitions.ptr;
-pub const __DOMCall__reader_u8 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.u8;
-pub const __DOMCall__reader_u16 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.u16;
-pub const __DOMCall__reader_u32 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.u32;
-pub const __DOMCall__reader_ptr = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.ptr;
-pub const __DOMCall__reader_i8 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.i8;
-pub const __DOMCall__reader_i16 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.i16;
-pub const __DOMCall__reader_i32 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.i32;
-pub const __DOMCall__reader_f32 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.f32;
-pub const __DOMCall__reader_f64 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.f64;
-pub const __DOMCall__reader_i64 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.i64;
-pub const __DOMCall__reader_u64 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.u64;
-pub const __DOMCall__reader_intptr = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.intptr;
+pub const __DOMCall_ptr = @import("../api/bun.zig").FFIObject.dom_call;
+pub const __DOMCall__reader_u8 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.u8;
+pub const __DOMCall__reader_u16 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.u16;
+pub const __DOMCall__reader_u32 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.u32;
+pub const __DOMCall__reader_ptr = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.ptr;
+pub const __DOMCall__reader_i8 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.i8;
+pub const __DOMCall__reader_i16 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.i16;
+pub const __DOMCall__reader_i32 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.i32;
+pub const __DOMCall__reader_f32 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.f32;
+pub const __DOMCall__reader_f64 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.f64;
+pub const __DOMCall__reader_i64 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.i64;
+pub const __DOMCall__reader_u64 = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.u64;
+pub const __DOMCall__reader_intptr = @import("../api/bun.zig").FFIObject.Reader.DOMCalls.intptr;
pub const __Crypto_getRandomValues = @import("../webcore.zig").Crypto.Class.functionDefinitions.getRandomValues;
pub const __Crypto_randomUUID = @import("../webcore.zig").Crypto.Class.functionDefinitions.randomUUID;
pub const __Crypto_randomInt = @import("../webcore.zig").Crypto.Class.functionDefinitions.randomInt;
diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig
index 0f234f876..faf14a56a 100644
--- a/src/bun.js/bindings/exports.zig
+++ b/src/bun.js/bindings/exports.zig
@@ -24,7 +24,7 @@ const JSPromiseRejectionOperation = JSC.JSPromiseRejectionOperation;
const Exception = JSC.Exception;
const JSModuleLoader = JSC.JSModuleLoader;
const Microtask = JSC.Microtask;
-const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
+
const Backtrace = @import("../../crash_reporter.zig");
const JSPrinter = bun.js_printer;
const JSLexer = bun.js_lexer;
@@ -41,14 +41,12 @@ pub const ZigGlobalObject = extern struct {
pub const Interface: type = NewGlobalObject(JS.VirtualMachine);
pub fn create(
- class_ref: [*]CAPI.JSClassRef,
- count: i32,
console: *anyopaque,
context_id: i32,
mini_mode: bool,
worker_ptr: ?*anyopaque,
) *JSGlobalObject {
- var global = shim.cppFn("create", .{ class_ref, count, console, context_id, mini_mode, worker_ptr });
+ var global = shim.cppFn("create", .{ console, context_id, mini_mode, worker_ptr });
Backtrace.reloadHandlers() catch unreachable;
return global;
}
@@ -136,20 +134,6 @@ pub const ZigErrorType = extern struct {
code: ErrorCode,
ptr: ?*anyopaque,
-
- pub fn isPrivateData(ptr: ?*anyopaque) callconv(.C) bool {
- return JSBase.JSPrivateDataPtr.isValidPtr(ptr);
- }
-
- pub const Export = shim.exportFunctions(.{
- .isPrivateData = isPrivateData,
- });
-
- comptime {
- @export(isPrivateData, .{
- .name = Export[0].symbol_name,
- });
- }
};
pub const NodePath = JSC.Node.Path;
@@ -247,12 +231,6 @@ export fn ZigString__free_global(ptr: [*]const u8, len: usize) void {
Mimalloc.mi_free(untagged);
}
-export fn Zig__getAPIGlobals(count: *usize) [*]JSC.C.JSClassRef {
- var globals = JSC.VirtualMachine.getAPIGlobals();
- count.* = globals.len;
- return globals.ptr;
-}
-
pub const JSErrorCode = enum(u8) {
Error = 0,
EvalError = 1,
@@ -3449,10 +3427,10 @@ comptime {
const Bun = @import("../api/bun.zig");
pub const BunTimer = Bun.Timer;
pub const Formatter = ZigConsoleClient.Formatter;
-pub const HTTPServerRequestContext = JSC.API.Server.RequestContext;
-pub const HTTPSSLServerRequestContext = JSC.API.SSLServer.RequestContext;
-pub const HTTPDebugServerRequestContext = JSC.API.DebugServer.RequestContext;
-pub const HTTPDebugSSLServerRequestContext = JSC.API.DebugSSLServer.RequestContext;
+pub const HTTPServerRequestContext = JSC.API.HTTPServer.RequestContext;
+pub const HTTPSSLServerRequestContext = JSC.API.HTTPSServer.RequestContext;
+pub const HTTPDebugServerRequestContext = JSC.API.DebugHTTPServer.RequestContext;
+pub const HTTPDebugSSLServerRequestContext = JSC.API.DebugHTTPSServer.RequestContext;
pub const TestScope = @import("../test/jest.zig").TestScope;
comptime {
if (!is_bindgen) {
@@ -3468,7 +3446,6 @@ comptime {
_ = Process.getTitle;
_ = Process.setTitle;
- _ = Zig__getAPIGlobals;
Bun.Timer.shim.ref();
NodePath.shim.ref();
JSReadableStreamBlob.shim.ref();
diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig
index a6d58ff2c..130c47277 100644
--- a/src/bun.js/bindings/generated_classes.zig
+++ b/src/bun.js/bindings/generated_classes.zig
@@ -689,6 +689,96 @@ pub const JSComment = struct {
}
}
};
+pub const JSCrypto = struct {
+ const Crypto = Classes.Crypto;
+ const GetterType = fn (*Crypto, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Crypto, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Crypto, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Crypto, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Crypto, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*Crypto {
+ JSC.markBinding(@src());
+ return Crypto__fromJS(value);
+ }
+
+ /// Get the Crypto constructor value.
+ /// This loads lazily from the global object.
+ pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ return Crypto__getConstructor(globalObject);
+ }
+
+ /// Create a new instance of Crypto
+ pub fn toJS(this: *Crypto, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = Crypto__create(globalObject, this);
+ std.debug.assert(value__.as(Crypto).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return Crypto__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of Crypto.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Crypto) bool {
+ JSC.markBinding(@src());
+ return Crypto__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *Crypto, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(Crypto__dangerouslySetPtr(value, null));
+ }
+
+ extern fn Crypto__fromJS(JSC.JSValue) ?*Crypto;
+ extern fn Crypto__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn Crypto__create(globalObject: *JSC.JSGlobalObject, ptr: ?*Crypto) JSC.JSValue;
+
+ extern fn Crypto__dangerouslySetPtr(JSC.JSValue, ?*Crypto) bool;
+
+ comptime {
+ if (@TypeOf(Crypto.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Crypto)) {
+ @compileLog("Crypto.constructor is not a constructor");
+ }
+
+ if (@TypeOf(Crypto.getRandomValuesWithoutTypeChecks) != fn (*Crypto, *JSC.JSGlobalObject, *JSC.JSUint8Array) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Crypto.getRandomValuesWithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Crypto.getRandomValues) != CallbackType)
+ @compileLog("Expected Crypto.getRandomValues to be a callback but received " ++ @typeName(@TypeOf(Crypto.getRandomValues)));
+ if (@TypeOf(Crypto.randomInt) != CallbackType)
+ @compileLog("Expected Crypto.randomInt to be a callback but received " ++ @typeName(@TypeOf(Crypto.randomInt)));
+ if (@TypeOf(Crypto.randomUUIDWithoutTypeChecks) != fn (
+ *Crypto,
+ *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Crypto.randomUUIDWithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Crypto.randomUUID) != CallbackType)
+ @compileLog("Expected Crypto.randomUUID to be a callback but received " ++ @typeName(@TypeOf(Crypto.randomUUID)));
+ if (@TypeOf(Crypto.doScryptSync) != CallbackType)
+ @compileLog("Expected Crypto.doScryptSync to be a callback but received " ++ @typeName(@TypeOf(Crypto.doScryptSync)));
+ if (@TypeOf(Crypto.timingSafeEqualWithoutTypeChecks) != fn (*Crypto, *JSC.JSGlobalObject, *JSC.JSUint8Array, *JSC.JSUint8Array) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Crypto.timingSafeEqualWithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Crypto.timingSafeEqual) != CallbackType)
+ @compileLog("Expected Crypto.timingSafeEqual to be a callback but received " ++ @typeName(@TypeOf(Crypto.timingSafeEqual)));
+ if (!JSC.is_bindgen) {
+ @export(Crypto.constructor, .{ .name = "CryptoClass__construct" });
+ @export(Crypto.doScryptSync, .{ .name = "CryptoPrototype__doScryptSync" });
+ @export(Crypto.getRandomValues, .{ .name = "CryptoPrototype__getRandomValues" });
+ @export(Crypto.getRandomValuesWithoutTypeChecks, .{ .name = "CryptoPrototype__getRandomValuesWithoutTypeChecks" });
+ @export(Crypto.randomInt, .{ .name = "CryptoPrototype__randomInt" });
+ @export(Crypto.randomUUID, .{ .name = "CryptoPrototype__randomUUID" });
+ @export(Crypto.randomUUIDWithoutTypeChecks, .{ .name = "CryptoPrototype__randomUUIDWithoutTypeChecks" });
+ @export(Crypto.timingSafeEqual, .{ .name = "CryptoPrototype__timingSafeEqual" });
+ @export(Crypto.timingSafeEqualWithoutTypeChecks, .{ .name = "CryptoPrototype__timingSafeEqualWithoutTypeChecks" });
+ }
+ }
+};
pub const JSCryptoHasher = struct {
const CryptoHasher = Classes.CryptoHasher;
const GetterType = fn (*CryptoHasher, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
@@ -803,6 +893,240 @@ pub const JSCryptoHasher = struct {
}
}
};
+pub const JSDebugHTTPSServer = struct {
+ const DebugHTTPSServer = Classes.DebugHTTPSServer;
+ const GetterType = fn (*DebugHTTPSServer, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*DebugHTTPSServer, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*DebugHTTPSServer, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*DebugHTTPSServer, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*DebugHTTPSServer, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*DebugHTTPSServer {
+ JSC.markBinding(@src());
+ return DebugHTTPSServer__fromJS(value);
+ }
+
+ extern fn DebugHTTPSServerPrototype__hostnameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn DebugHTTPSServerPrototype__hostnameGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `DebugHTTPSServer.hostname` setter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ DebugHTTPSServerPrototype__hostnameSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `DebugHTTPSServer.hostname` getter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = DebugHTTPSServerPrototype__hostnameGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ /// Create a new instance of DebugHTTPSServer
+ pub fn toJS(this: *DebugHTTPSServer, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = DebugHTTPSServer__create(globalObject, this);
+ std.debug.assert(value__.as(DebugHTTPSServer).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return DebugHTTPSServer__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of DebugHTTPSServer.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*DebugHTTPSServer) bool {
+ JSC.markBinding(@src());
+ return DebugHTTPSServer__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *DebugHTTPSServer, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(DebugHTTPSServer__dangerouslySetPtr(value, null));
+ }
+
+ extern fn DebugHTTPSServer__fromJS(JSC.JSValue) ?*DebugHTTPSServer;
+ extern fn DebugHTTPSServer__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn DebugHTTPSServer__create(globalObject: *JSC.JSGlobalObject, ptr: ?*DebugHTTPSServer) JSC.JSValue;
+
+ extern fn DebugHTTPSServer__dangerouslySetPtr(JSC.JSValue, ?*DebugHTTPSServer) bool;
+
+ comptime {
+ if (@TypeOf(DebugHTTPSServer.finalize) != (fn (*DebugHTTPSServer) callconv(.C) void)) {
+ @compileLog("DebugHTTPSServer.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(DebugHTTPSServer.getDevelopment) != GetterType)
+ @compileLog("Expected DebugHTTPSServer.getDevelopment to be a getter");
+
+ if (@TypeOf(DebugHTTPSServer.doFetch) != CallbackType)
+ @compileLog("Expected DebugHTTPSServer.doFetch to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPSServer.doFetch)));
+ if (@TypeOf(DebugHTTPSServer.getHostname) != GetterType)
+ @compileLog("Expected DebugHTTPSServer.getHostname to be a getter");
+
+ if (@TypeOf(DebugHTTPSServer.getPendingRequests) != GetterType)
+ @compileLog("Expected DebugHTTPSServer.getPendingRequests to be a getter");
+
+ if (@TypeOf(DebugHTTPSServer.getPendingWebSockets) != GetterType)
+ @compileLog("Expected DebugHTTPSServer.getPendingWebSockets to be a getter");
+
+ if (@TypeOf(DebugHTTPSServer.getPort) != GetterType)
+ @compileLog("Expected DebugHTTPSServer.getPort to be a getter");
+
+ if (@TypeOf(DebugHTTPSServer.getProtocol) != GetterType)
+ @compileLog("Expected DebugHTTPSServer.getProtocol to be a getter");
+
+ if (@TypeOf(DebugHTTPSServer.doPublish) != CallbackType)
+ @compileLog("Expected DebugHTTPSServer.doPublish to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPSServer.doPublish)));
+ if (@TypeOf(DebugHTTPSServer.doReload) != CallbackType)
+ @compileLog("Expected DebugHTTPSServer.doReload to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPSServer.doReload)));
+ if (@TypeOf(DebugHTTPSServer.doStop) != CallbackType)
+ @compileLog("Expected DebugHTTPSServer.doStop to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPSServer.doStop)));
+ if (@TypeOf(DebugHTTPSServer.doUpgrade) != CallbackType)
+ @compileLog("Expected DebugHTTPSServer.doUpgrade to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPSServer.doUpgrade)));
+ if (!JSC.is_bindgen) {
+ @export(DebugHTTPSServer.doFetch, .{ .name = "DebugHTTPSServerPrototype__doFetch" });
+ @export(DebugHTTPSServer.doPublish, .{ .name = "DebugHTTPSServerPrototype__doPublish" });
+ @export(DebugHTTPSServer.doReload, .{ .name = "DebugHTTPSServerPrototype__doReload" });
+ @export(DebugHTTPSServer.doStop, .{ .name = "DebugHTTPSServerPrototype__doStop" });
+ @export(DebugHTTPSServer.doUpgrade, .{ .name = "DebugHTTPSServerPrototype__doUpgrade" });
+ @export(DebugHTTPSServer.finalize, .{ .name = "DebugHTTPSServerClass__finalize" });
+ @export(DebugHTTPSServer.getDevelopment, .{ .name = "DebugHTTPSServerPrototype__getDevelopment" });
+ @export(DebugHTTPSServer.getHostname, .{ .name = "DebugHTTPSServerPrototype__getHostname" });
+ @export(DebugHTTPSServer.getPendingRequests, .{ .name = "DebugHTTPSServerPrototype__getPendingRequests" });
+ @export(DebugHTTPSServer.getPendingWebSockets, .{ .name = "DebugHTTPSServerPrototype__getPendingWebSockets" });
+ @export(DebugHTTPSServer.getPort, .{ .name = "DebugHTTPSServerPrototype__getPort" });
+ @export(DebugHTTPSServer.getProtocol, .{ .name = "DebugHTTPSServerPrototype__getProtocol" });
+ }
+ }
+};
+pub const JSDebugHTTPServer = struct {
+ const DebugHTTPServer = Classes.DebugHTTPServer;
+ const GetterType = fn (*DebugHTTPServer, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*DebugHTTPServer, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*DebugHTTPServer, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*DebugHTTPServer, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*DebugHTTPServer, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*DebugHTTPServer {
+ JSC.markBinding(@src());
+ return DebugHTTPServer__fromJS(value);
+ }
+
+ extern fn DebugHTTPServerPrototype__hostnameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn DebugHTTPServerPrototype__hostnameGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `DebugHTTPServer.hostname` setter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ DebugHTTPServerPrototype__hostnameSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `DebugHTTPServer.hostname` getter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = DebugHTTPServerPrototype__hostnameGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ /// Create a new instance of DebugHTTPServer
+ pub fn toJS(this: *DebugHTTPServer, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = DebugHTTPServer__create(globalObject, this);
+ std.debug.assert(value__.as(DebugHTTPServer).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return DebugHTTPServer__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of DebugHTTPServer.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*DebugHTTPServer) bool {
+ JSC.markBinding(@src());
+ return DebugHTTPServer__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *DebugHTTPServer, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(DebugHTTPServer__dangerouslySetPtr(value, null));
+ }
+
+ extern fn DebugHTTPServer__fromJS(JSC.JSValue) ?*DebugHTTPServer;
+ extern fn DebugHTTPServer__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn DebugHTTPServer__create(globalObject: *JSC.JSGlobalObject, ptr: ?*DebugHTTPServer) JSC.JSValue;
+
+ extern fn DebugHTTPServer__dangerouslySetPtr(JSC.JSValue, ?*DebugHTTPServer) bool;
+
+ comptime {
+ if (@TypeOf(DebugHTTPServer.finalize) != (fn (*DebugHTTPServer) callconv(.C) void)) {
+ @compileLog("DebugHTTPServer.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(DebugHTTPServer.getDevelopment) != GetterType)
+ @compileLog("Expected DebugHTTPServer.getDevelopment to be a getter");
+
+ if (@TypeOf(DebugHTTPServer.doFetch) != CallbackType)
+ @compileLog("Expected DebugHTTPServer.doFetch to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPServer.doFetch)));
+ if (@TypeOf(DebugHTTPServer.getHostname) != GetterType)
+ @compileLog("Expected DebugHTTPServer.getHostname to be a getter");
+
+ if (@TypeOf(DebugHTTPServer.getPendingRequests) != GetterType)
+ @compileLog("Expected DebugHTTPServer.getPendingRequests to be a getter");
+
+ if (@TypeOf(DebugHTTPServer.getPendingWebSockets) != GetterType)
+ @compileLog("Expected DebugHTTPServer.getPendingWebSockets to be a getter");
+
+ if (@TypeOf(DebugHTTPServer.getPort) != GetterType)
+ @compileLog("Expected DebugHTTPServer.getPort to be a getter");
+
+ if (@TypeOf(DebugHTTPServer.getProtocol) != GetterType)
+ @compileLog("Expected DebugHTTPServer.getProtocol to be a getter");
+
+ if (@TypeOf(DebugHTTPServer.doPublish) != CallbackType)
+ @compileLog("Expected DebugHTTPServer.doPublish to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPServer.doPublish)));
+ if (@TypeOf(DebugHTTPServer.doReload) != CallbackType)
+ @compileLog("Expected DebugHTTPServer.doReload to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPServer.doReload)));
+ if (@TypeOf(DebugHTTPServer.doStop) != CallbackType)
+ @compileLog("Expected DebugHTTPServer.doStop to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPServer.doStop)));
+ if (@TypeOf(DebugHTTPServer.doUpgrade) != CallbackType)
+ @compileLog("Expected DebugHTTPServer.doUpgrade to be a callback but received " ++ @typeName(@TypeOf(DebugHTTPServer.doUpgrade)));
+ if (!JSC.is_bindgen) {
+ @export(DebugHTTPServer.doFetch, .{ .name = "DebugHTTPServerPrototype__doFetch" });
+ @export(DebugHTTPServer.doPublish, .{ .name = "DebugHTTPServerPrototype__doPublish" });
+ @export(DebugHTTPServer.doReload, .{ .name = "DebugHTTPServerPrototype__doReload" });
+ @export(DebugHTTPServer.doStop, .{ .name = "DebugHTTPServerPrototype__doStop" });
+ @export(DebugHTTPServer.doUpgrade, .{ .name = "DebugHTTPServerPrototype__doUpgrade" });
+ @export(DebugHTTPServer.finalize, .{ .name = "DebugHTTPServerClass__finalize" });
+ @export(DebugHTTPServer.getDevelopment, .{ .name = "DebugHTTPServerPrototype__getDevelopment" });
+ @export(DebugHTTPServer.getHostname, .{ .name = "DebugHTTPServerPrototype__getHostname" });
+ @export(DebugHTTPServer.getPendingRequests, .{ .name = "DebugHTTPServerPrototype__getPendingRequests" });
+ @export(DebugHTTPServer.getPendingWebSockets, .{ .name = "DebugHTTPServerPrototype__getPendingWebSockets" });
+ @export(DebugHTTPServer.getPort, .{ .name = "DebugHTTPServerPrototype__getPort" });
+ @export(DebugHTTPServer.getProtocol, .{ .name = "DebugHTTPServerPrototype__getProtocol" });
+ }
+ }
+};
pub const JSDirent = struct {
const Dirent = Classes.Dirent;
const GetterType = fn (*Dirent, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
@@ -1973,6 +2297,91 @@ pub const JSExpectStringMatching = struct {
}
}
};
+pub const JSFFI = struct {
+ const FFI = Classes.FFI;
+ const GetterType = fn (*FFI, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*FFI, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*FFI, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*FFI, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*FFI, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*FFI {
+ JSC.markBinding(@src());
+ return FFI__fromJS(value);
+ }
+
+ extern fn FFIPrototype__symbolsValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn FFIPrototype__symbolsValueGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `FFI.symbolsValue` setter
+ /// This value will be visited by the garbage collector.
+ pub fn symbolsValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ FFIPrototype__symbolsValueSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `FFI.symbolsValue` getter
+ /// This value will be visited by the garbage collector.
+ pub fn symbolsValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = FFIPrototype__symbolsValueGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ /// Create a new instance of FFI
+ pub fn toJS(this: *FFI, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = FFI__create(globalObject, this);
+ std.debug.assert(value__.as(FFI).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return FFI__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of FFI.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*FFI) bool {
+ JSC.markBinding(@src());
+ return FFI__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *FFI, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(FFI__dangerouslySetPtr(value, null));
+ }
+
+ extern fn FFI__fromJS(JSC.JSValue) ?*FFI;
+ extern fn FFI__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn FFI__create(globalObject: *JSC.JSGlobalObject, ptr: ?*FFI) JSC.JSValue;
+
+ extern fn FFI__dangerouslySetPtr(JSC.JSValue, ?*FFI) bool;
+
+ comptime {
+ if (@TypeOf(FFI.finalize) != (fn (*FFI) callconv(.C) void)) {
+ @compileLog("FFI.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(FFI.close) != CallbackType)
+ @compileLog("Expected FFI.close to be a callback but received " ++ @typeName(@TypeOf(FFI.close)));
+ if (@TypeOf(FFI.getSymbols) != GetterType)
+ @compileLog("Expected FFI.getSymbols to be a getter");
+
+ if (!JSC.is_bindgen) {
+ @export(FFI.close, .{ .name = "FFIPrototype__close" });
+ @export(FFI.finalize, .{ .name = "FFIClass__finalize" });
+ @export(FFI.getSymbols, .{ .name = "FFIPrototype__getSymbols" });
+ }
+ }
+};
pub const JSFSWatcher = struct {
const FSWatcher = Classes.FSWatcher;
const GetterType = fn (*FSWatcher, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
@@ -2293,6 +2702,240 @@ pub const JSHTMLRewriter = struct {
}
}
};
+pub const JSHTTPSServer = struct {
+ const HTTPSServer = Classes.HTTPSServer;
+ const GetterType = fn (*HTTPSServer, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*HTTPSServer, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*HTTPSServer, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*HTTPSServer, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*HTTPSServer, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*HTTPSServer {
+ JSC.markBinding(@src());
+ return HTTPSServer__fromJS(value);
+ }
+
+ extern fn HTTPSServerPrototype__hostnameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn HTTPSServerPrototype__hostnameGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `HTTPSServer.hostname` setter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ HTTPSServerPrototype__hostnameSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `HTTPSServer.hostname` getter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = HTTPSServerPrototype__hostnameGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ /// Create a new instance of HTTPSServer
+ pub fn toJS(this: *HTTPSServer, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = HTTPSServer__create(globalObject, this);
+ std.debug.assert(value__.as(HTTPSServer).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return HTTPSServer__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of HTTPSServer.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*HTTPSServer) bool {
+ JSC.markBinding(@src());
+ return HTTPSServer__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *HTTPSServer, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(HTTPSServer__dangerouslySetPtr(value, null));
+ }
+
+ extern fn HTTPSServer__fromJS(JSC.JSValue) ?*HTTPSServer;
+ extern fn HTTPSServer__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn HTTPSServer__create(globalObject: *JSC.JSGlobalObject, ptr: ?*HTTPSServer) JSC.JSValue;
+
+ extern fn HTTPSServer__dangerouslySetPtr(JSC.JSValue, ?*HTTPSServer) bool;
+
+ comptime {
+ if (@TypeOf(HTTPSServer.finalize) != (fn (*HTTPSServer) callconv(.C) void)) {
+ @compileLog("HTTPSServer.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(HTTPSServer.getDevelopment) != GetterType)
+ @compileLog("Expected HTTPSServer.getDevelopment to be a getter");
+
+ if (@TypeOf(HTTPSServer.doFetch) != CallbackType)
+ @compileLog("Expected HTTPSServer.doFetch to be a callback but received " ++ @typeName(@TypeOf(HTTPSServer.doFetch)));
+ if (@TypeOf(HTTPSServer.getHostname) != GetterType)
+ @compileLog("Expected HTTPSServer.getHostname to be a getter");
+
+ if (@TypeOf(HTTPSServer.getPendingRequests) != GetterType)
+ @compileLog("Expected HTTPSServer.getPendingRequests to be a getter");
+
+ if (@TypeOf(HTTPSServer.getPendingWebSockets) != GetterType)
+ @compileLog("Expected HTTPSServer.getPendingWebSockets to be a getter");
+
+ if (@TypeOf(HTTPSServer.getPort) != GetterType)
+ @compileLog("Expected HTTPSServer.getPort to be a getter");
+
+ if (@TypeOf(HTTPSServer.getProtocol) != GetterType)
+ @compileLog("Expected HTTPSServer.getProtocol to be a getter");
+
+ if (@TypeOf(HTTPSServer.doPublish) != CallbackType)
+ @compileLog("Expected HTTPSServer.doPublish to be a callback but received " ++ @typeName(@TypeOf(HTTPSServer.doPublish)));
+ if (@TypeOf(HTTPSServer.doReload) != CallbackType)
+ @compileLog("Expected HTTPSServer.doReload to be a callback but received " ++ @typeName(@TypeOf(HTTPSServer.doReload)));
+ if (@TypeOf(HTTPSServer.doStop) != CallbackType)
+ @compileLog("Expected HTTPSServer.doStop to be a callback but received " ++ @typeName(@TypeOf(HTTPSServer.doStop)));
+ if (@TypeOf(HTTPSServer.doUpgrade) != CallbackType)
+ @compileLog("Expected HTTPSServer.doUpgrade to be a callback but received " ++ @typeName(@TypeOf(HTTPSServer.doUpgrade)));
+ if (!JSC.is_bindgen) {
+ @export(HTTPSServer.doFetch, .{ .name = "HTTPSServerPrototype__doFetch" });
+ @export(HTTPSServer.doPublish, .{ .name = "HTTPSServerPrototype__doPublish" });
+ @export(HTTPSServer.doReload, .{ .name = "HTTPSServerPrototype__doReload" });
+ @export(HTTPSServer.doStop, .{ .name = "HTTPSServerPrototype__doStop" });
+ @export(HTTPSServer.doUpgrade, .{ .name = "HTTPSServerPrototype__doUpgrade" });
+ @export(HTTPSServer.finalize, .{ .name = "HTTPSServerClass__finalize" });
+ @export(HTTPSServer.getDevelopment, .{ .name = "HTTPSServerPrototype__getDevelopment" });
+ @export(HTTPSServer.getHostname, .{ .name = "HTTPSServerPrototype__getHostname" });
+ @export(HTTPSServer.getPendingRequests, .{ .name = "HTTPSServerPrototype__getPendingRequests" });
+ @export(HTTPSServer.getPendingWebSockets, .{ .name = "HTTPSServerPrototype__getPendingWebSockets" });
+ @export(HTTPSServer.getPort, .{ .name = "HTTPSServerPrototype__getPort" });
+ @export(HTTPSServer.getProtocol, .{ .name = "HTTPSServerPrototype__getProtocol" });
+ }
+ }
+};
+pub const JSHTTPServer = struct {
+ const HTTPServer = Classes.HTTPServer;
+ const GetterType = fn (*HTTPServer, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*HTTPServer, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*HTTPServer, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*HTTPServer, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*HTTPServer, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*HTTPServer {
+ JSC.markBinding(@src());
+ return HTTPServer__fromJS(value);
+ }
+
+ extern fn HTTPServerPrototype__hostnameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn HTTPServerPrototype__hostnameGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `HTTPServer.hostname` setter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ HTTPServerPrototype__hostnameSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `HTTPServer.hostname` getter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = HTTPServerPrototype__hostnameGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ /// Create a new instance of HTTPServer
+ pub fn toJS(this: *HTTPServer, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = HTTPServer__create(globalObject, this);
+ std.debug.assert(value__.as(HTTPServer).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return HTTPServer__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of HTTPServer.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*HTTPServer) bool {
+ JSC.markBinding(@src());
+ return HTTPServer__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *HTTPServer, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(HTTPServer__dangerouslySetPtr(value, null));
+ }
+
+ extern fn HTTPServer__fromJS(JSC.JSValue) ?*HTTPServer;
+ extern fn HTTPServer__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn HTTPServer__create(globalObject: *JSC.JSGlobalObject, ptr: ?*HTTPServer) JSC.JSValue;
+
+ extern fn HTTPServer__dangerouslySetPtr(JSC.JSValue, ?*HTTPServer) bool;
+
+ comptime {
+ if (@TypeOf(HTTPServer.finalize) != (fn (*HTTPServer) callconv(.C) void)) {
+ @compileLog("HTTPServer.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(HTTPServer.getDevelopment) != GetterType)
+ @compileLog("Expected HTTPServer.getDevelopment to be a getter");
+
+ if (@TypeOf(HTTPServer.doFetch) != CallbackType)
+ @compileLog("Expected HTTPServer.doFetch to be a callback but received " ++ @typeName(@TypeOf(HTTPServer.doFetch)));
+ if (@TypeOf(HTTPServer.getHostname) != GetterType)
+ @compileLog("Expected HTTPServer.getHostname to be a getter");
+
+ if (@TypeOf(HTTPServer.getPendingRequests) != GetterType)
+ @compileLog("Expected HTTPServer.getPendingRequests to be a getter");
+
+ if (@TypeOf(HTTPServer.getPendingWebSockets) != GetterType)
+ @compileLog("Expected HTTPServer.getPendingWebSockets to be a getter");
+
+ if (@TypeOf(HTTPServer.getPort) != GetterType)
+ @compileLog("Expected HTTPServer.getPort to be a getter");
+
+ if (@TypeOf(HTTPServer.getProtocol) != GetterType)
+ @compileLog("Expected HTTPServer.getProtocol to be a getter");
+
+ if (@TypeOf(HTTPServer.doPublish) != CallbackType)
+ @compileLog("Expected HTTPServer.doPublish to be a callback but received " ++ @typeName(@TypeOf(HTTPServer.doPublish)));
+ if (@TypeOf(HTTPServer.doReload) != CallbackType)
+ @compileLog("Expected HTTPServer.doReload to be a callback but received " ++ @typeName(@TypeOf(HTTPServer.doReload)));
+ if (@TypeOf(HTTPServer.doStop) != CallbackType)
+ @compileLog("Expected HTTPServer.doStop to be a callback but received " ++ @typeName(@TypeOf(HTTPServer.doStop)));
+ if (@TypeOf(HTTPServer.doUpgrade) != CallbackType)
+ @compileLog("Expected HTTPServer.doUpgrade to be a callback but received " ++ @typeName(@TypeOf(HTTPServer.doUpgrade)));
+ if (!JSC.is_bindgen) {
+ @export(HTTPServer.doFetch, .{ .name = "HTTPServerPrototype__doFetch" });
+ @export(HTTPServer.doPublish, .{ .name = "HTTPServerPrototype__doPublish" });
+ @export(HTTPServer.doReload, .{ .name = "HTTPServerPrototype__doReload" });
+ @export(HTTPServer.doStop, .{ .name = "HTTPServerPrototype__doStop" });
+ @export(HTTPServer.doUpgrade, .{ .name = "HTTPServerPrototype__doUpgrade" });
+ @export(HTTPServer.finalize, .{ .name = "HTTPServerClass__finalize" });
+ @export(HTTPServer.getDevelopment, .{ .name = "HTTPServerPrototype__getDevelopment" });
+ @export(HTTPServer.getHostname, .{ .name = "HTTPServerPrototype__getHostname" });
+ @export(HTTPServer.getPendingRequests, .{ .name = "HTTPServerPrototype__getPendingRequests" });
+ @export(HTTPServer.getPendingWebSockets, .{ .name = "HTTPServerPrototype__getPendingWebSockets" });
+ @export(HTTPServer.getPort, .{ .name = "HTTPServerPrototype__getPort" });
+ @export(HTTPServer.getProtocol, .{ .name = "HTTPServerPrototype__getProtocol" });
+ }
+ }
+};
pub const JSListener = struct {
const Listener = Classes.Listener;
const GetterType = fn (*Listener, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
@@ -5797,7 +6440,10 @@ comptime {
_ = JSBuildArtifact;
_ = JSBuildMessage;
_ = JSComment;
+ _ = JSCrypto;
_ = JSCryptoHasher;
+ _ = JSDebugHTTPSServer;
+ _ = JSDebugHTTPServer;
_ = JSDirent;
_ = JSDocEnd;
_ = JSDocType;
@@ -5808,9 +6454,12 @@ comptime {
_ = JSExpectAnything;
_ = JSExpectStringContaining;
_ = JSExpectStringMatching;
+ _ = JSFFI;
_ = JSFSWatcher;
_ = JSFileSystemRouter;
_ = JSHTMLRewriter;
+ _ = JSHTTPSServer;
+ _ = JSHTTPServer;
_ = JSListener;
_ = JSMD4;
_ = JSMD5;
diff --git a/src/bun.js/bindings/generated_classes_list.zig b/src/bun.js/bindings/generated_classes_list.zig
index 2c2dc86ac..6033fc7ff 100644
--- a/src/bun.js/bindings/generated_classes_list.zig
+++ b/src/bun.js/bindings/generated_classes_list.zig
@@ -46,4 +46,10 @@ pub const Classes = struct {
pub const BuildMessage = JSC.BuildMessage;
pub const ResolveMessage = JSC.ResolveMessage;
pub const FSWatcher = JSC.Node.FSWatcher;
+ pub const HTTPServer = JSC.API.HTTPServer;
+ pub const HTTPSServer = JSC.API.HTTPSServer;
+ pub const DebugHTTPServer = JSC.API.DebugHTTPServer;
+ pub const DebugHTTPSServer = JSC.API.DebugHTTPSServer;
+ pub const Crypto = JSC.WebCore.Crypto;
+ pub const FFI = JSC.FFI;
};
diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h
index 8a4908c7c..29064ffab 100644
--- a/src/bun.js/bindings/headers.h
+++ b/src/bun.js/bindings/headers.h
@@ -583,7 +583,7 @@ ZIG_DECL JSC__JSValue Crypto__timingSafeEqual__slowpath(JSC__JSGlobalObject* arg
#pragma mark - Zig::GlobalObject
-CPP_DECL JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* arg0, int32_t arg1, void* arg2, int32_t arg3, bool arg4, void* arg5);
+CPP_DECL JSC__JSGlobalObject* Zig__GlobalObject__create(void* arg2, int32_t arg3, bool arg4, void* arg5);
CPP_DECL void* Zig__GlobalObject__getModuleRegistryMap(JSC__JSGlobalObject* arg0);
CPP_DECL bool Zig__GlobalObject__resetModuleRegistryMap(JSC__JSGlobalObject* arg0, void* arg1);
diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig
index 724450212..7794ac096 100644
--- a/src/bun.js/bindings/headers.zig
+++ b/src/bun.js/bindings/headers.zig
@@ -355,7 +355,7 @@ pub extern fn Reader__intptr__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC_
pub extern fn Crypto__getRandomValues__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
pub extern fn Crypto__randomUUID__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
pub extern fn Crypto__timingSafeEqual__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Zig__GlobalObject__create(arg0: [*c]JSClassRef, arg1: i32, arg2: ?*anyopaque, arg3: i32, arg4: bool, arg5: ?*anyopaque) *bindings.JSGlobalObject;
+pub extern fn Zig__GlobalObject__create(arg2: ?*anyopaque, arg3: i32, arg4: bool, arg5: ?*anyopaque) *bindings.JSGlobalObject;
pub extern fn Zig__GlobalObject__getModuleRegistryMap(arg0: *bindings.JSGlobalObject) ?*anyopaque;
pub extern fn Zig__GlobalObject__resetModuleRegistryMap(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) bool;
pub extern fn Bun__Path__create(arg0: *bindings.JSGlobalObject, arg1: bool) JSC__JSValue;
diff --git a/src/bun.js/bindings/webcore/JSDOMFormData.cpp b/src/bun.js/bindings/webcore/JSDOMFormData.cpp
index fb725faa3..09a0a6c08 100644
--- a/src/bun.js/bindings/webcore/JSDOMFormData.cpp
+++ b/src/bun.js/bindings/webcore/JSDOMFormData.cpp
@@ -504,74 +504,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDOMFormDataPrototypeFunction_set, (JSGlobalObject * l
**/
static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_toJSONBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSDOMFormData>::ClassParameter castedThis)
{
- auto& vm = JSC::getVM(lexicalGlobalObject);
- auto throwScope = DECLARE_THROW_SCOPE(vm);
-
- auto& impl = castedThis->wrapped();
- size_t size = impl.count();
- JSObject* obj;
- if (size == 0) {
- obj = constructEmptyObject(lexicalGlobalObject);
- RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
- RELEASE_AND_RETURN(throwScope, JSValue::encode(obj));
- } else if (size < 64) {
- obj = constructEmptyObject(lexicalGlobalObject, lexicalGlobalObject->objectPrototype(), size + 1);
- } else {
- obj = constructEmptyObject(lexicalGlobalObject);
- }
-
- obj->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("FormData"_s)), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
-
- auto iter = impl.items();
- WTF::HashSet<String> seenKeys;
-
- auto toJSValue = [&](const DOMFormData::FormDataEntryValue& entry) -> JSValue {
- return toJS<IDLNullable<IDLUnion<IDLUSVString, IDLInterface<Blob>>>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, entry);
- };
-
- for (auto& entry : iter) {
- auto& key = entry.name;
- auto& value = entry.data;
- auto ident = Identifier::fromString(vm, key);
- if (seenKeys.contains(key)) {
- JSValue jsValue = obj->getDirect(vm, ident);
- if (jsValue.isString() || jsValue.inherits<JSBlob>()) {
- // Make sure this runs before the deferral scope is called.
- JSValue resultValue = toJSValue(value);
- ensureStillAliveHere(resultValue);
-
- JSC::JSArray* array = nullptr;
-
- {
- GCDeferralContext deferralContext(lexicalGlobalObject->vm());
- JSC::ObjectInitializationScope initializationScope(lexicalGlobalObject->vm());
-
- array = JSC::JSArray::tryCreateUninitializedRestricted(
- initializationScope, &deferralContext,
- lexicalGlobalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
- 2);
- RELEASE_ASSERT(array);
-
- array->initializeIndex(initializationScope, 0, jsValue);
- array->initializeIndex(initializationScope, 1, resultValue);
- }
-
- obj->putDirect(vm, ident, array, 0);
- } else if (jsValue.isObject() && jsValue.getObject()->inherits<JSC::JSArray>()) {
- JSC::JSArray* array = jsCast<JSC::JSArray*>(jsValue.getObject());
- array->push(lexicalGlobalObject, toJSValue(value));
- RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-
- } else {
- RELEASE_ASSERT_NOT_REACHED();
- }
- } else {
- seenKeys.add(key);
- obj->putDirect(vm, ident, toJSValue(value), 0);
- }
- }
-
- RELEASE_AND_RETURN(throwScope, JSValue::encode(obj));
+ return JSValue::encode(getInternalProperties(lexicalGlobalObject->vm(), lexicalGlobalObject, castedThis));
}
JSC_DEFINE_HOST_FUNCTION(jsDOMFormDataPrototypeFunction_toJSON, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
@@ -672,6 +605,77 @@ JSC_DEFINE_HOST_FUNCTION(jsDOMFormDataPrototypeFunction_forEach, (JSC::JSGlobalO
return IDLOperation<JSDOMFormData>::call<jsDOMFormDataPrototypeFunction_forEachCaller>(*lexicalGlobalObject, *callFrame, "forEach");
}
+JSC::JSValue getInternalProperties(JSC::VM& vm, JSGlobalObject* lexicalGlobalObject, JSDOMFormData* castedThis)
+{
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+ auto& impl = castedThis->wrapped();
+ size_t size = impl.count();
+ JSObject* obj;
+ if (size == 0) {
+ obj = constructEmptyObject(lexicalGlobalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, obj);
+ } else if (size < 64) {
+ obj = constructEmptyObject(lexicalGlobalObject, lexicalGlobalObject->objectPrototype(), size + 1);
+ } else {
+ obj = constructEmptyObject(lexicalGlobalObject);
+ }
+
+ obj->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("FormData"_s)), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
+
+ auto iter = impl.items();
+ WTF::HashSet<String> seenKeys;
+
+ auto toJSValue = [&](const DOMFormData::FormDataEntryValue& entry) -> JSValue {
+ return toJS<IDLNullable<IDLUnion<IDLUSVString, IDLInterface<Blob>>>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, entry);
+ };
+
+ for (auto& entry : iter) {
+ auto& key = entry.name;
+ auto& value = entry.data;
+ auto ident = Identifier::fromString(vm, key);
+ if (seenKeys.contains(key)) {
+ JSValue jsValue = obj->getDirect(vm, ident);
+ if (jsValue.isString() || jsValue.inherits<JSBlob>()) {
+ // Make sure this runs before the deferral scope is called.
+ JSValue resultValue = toJSValue(value);
+ ensureStillAliveHere(resultValue);
+
+ JSC::JSArray* array = nullptr;
+
+ {
+ GCDeferralContext deferralContext(lexicalGlobalObject->vm());
+ JSC::ObjectInitializationScope initializationScope(lexicalGlobalObject->vm());
+
+ array = JSC::JSArray::tryCreateUninitializedRestricted(
+ initializationScope, &deferralContext,
+ lexicalGlobalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
+ 2);
+ RELEASE_ASSERT(array);
+
+ array->initializeIndex(initializationScope, 0, jsValue);
+ array->initializeIndex(initializationScope, 1, resultValue);
+ }
+
+ obj->putDirect(vm, ident, array, 0);
+ } else if (jsValue.isObject() && jsValue.getObject()->inherits<JSC::JSArray>()) {
+ JSC::JSArray* array = jsCast<JSC::JSArray*>(jsValue.getObject());
+ array->push(lexicalGlobalObject, toJSValue(value));
+ RETURN_IF_EXCEPTION(throwScope, {});
+
+ } else {
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ } else {
+ seenKeys.add(key);
+ obj->putDirect(vm, ident, toJSValue(value), 0);
+ }
+ }
+
+ RELEASE_AND_RETURN(throwScope, obj);
+}
+
JSC::GCClient::IsoSubspace* JSDOMFormData::subspaceForImpl(JSC::VM& vm)
{
return WebCore::subspaceForImpl<JSDOMFormData, UseCustomHeapCellType::No>(
diff --git a/src/bun.js/bindings/webcore/JSDOMFormData.h b/src/bun.js/bindings/webcore/JSDOMFormData.h
index 511cbfd1b..f36fbcd42 100644
--- a/src/bun.js/bindings/webcore/JSDOMFormData.h
+++ b/src/bun.js/bindings/webcore/JSDOMFormData.h
@@ -64,6 +64,8 @@ protected:
void finishCreation(JSC::VM&);
};
+JSC::JSValue getInternalProperties(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSDOMFormData* castedThis);
+
class JSDOMFormDataOwner final : public JSC::WeakHandleOwner {
public:
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::AbstractSlotVisitor&, const char**) final;
diff --git a/src/bun.js/bindings/webcore/JSFetchHeaders.cpp b/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
index 08b5d8ee6..11e9157c1 100644
--- a/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
+++ b/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
@@ -371,61 +371,7 @@ static inline JSC::EncodedJSValue jsFetchHeadersPrototypeFunction_appendBody(JSC
**/
static inline JSC::EncodedJSValue jsFetchHeadersPrototypeFunction_toJSONBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSFetchHeaders>::ClassParameter castedThis)
{
- auto& vm = JSC::getVM(lexicalGlobalObject);
- auto throwScope = DECLARE_THROW_SCOPE(vm);
-
- auto& impl = castedThis->wrapped();
- size_t size = impl.size();
- JSObject* obj;
- if (size == 0) {
- obj = constructEmptyObject(lexicalGlobalObject);
- RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
- RELEASE_AND_RETURN(throwScope, JSValue::encode(obj));
- } else if (size < 64) {
- obj = constructEmptyObject(lexicalGlobalObject, lexicalGlobalObject->objectPrototype(), size);
- } else {
- obj = constructEmptyObject(lexicalGlobalObject);
- }
-
- auto& internal = impl.internalHeaders();
- {
- auto& vec = internal.commonHeaders();
- for (auto it = vec.begin(); it != vec.end(); ++it) {
- auto& name = it->key;
- auto& value = it->value;
- obj->putDirect(vm, Identifier::fromString(vm, WTF::httpHeaderNameStringImpl(name)), jsString(vm, value), 0);
- }
- }
-
- {
- auto& values = internal.getSetCookieHeaders();
-
- size_t count = values.size();
-
- if (count > 0) {
- JSC::JSArray* array = constructEmptyArray(lexicalGlobalObject, nullptr, count);
- RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined()));
-
- for (size_t i = 0; i < count; ++i) {
- array->putDirectIndex(lexicalGlobalObject, i, jsString(vm, values[i]));
- RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined()));
- }
-
- RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined()));
- obj->putDirect(vm, JSC::Identifier::fromString(vm, httpHeaderNameString(HTTPHeaderName::SetCookie).toStringWithoutCopying()), array, 0);
- }
- }
-
- {
- auto& vec = internal.uncommonHeaders();
- for (auto it = vec.begin(); it != vec.end(); ++it) {
- auto& name = it->key;
- auto& value = it->value;
- obj->putDirect(vm, Identifier::fromString(vm, name.convertToASCIILowercase()), jsString(vm, value), 0);
- }
- }
-
- RELEASE_AND_RETURN(throwScope, JSValue::encode(obj));
+ return JSValue::encode(WebCore::getInternalProperties(lexicalGlobalObject->vm(), lexicalGlobalObject, castedThis));
}
JSC_DEFINE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_toJSON, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
@@ -633,6 +579,64 @@ void JSFetchHeaders::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
Base::analyzeHeap(cell, analyzer);
}
+JSC::JSValue getInternalProperties(JSC::VM& vm, JSGlobalObject* lexicalGlobalObject, JSFetchHeaders* castedThis)
+{
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+ auto& impl = castedThis->wrapped();
+ size_t size = impl.size();
+ JSObject* obj;
+ if (size == 0) {
+ obj = constructEmptyObject(lexicalGlobalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ RELEASE_AND_RETURN(throwScope, obj);
+ } else if (size < 64) {
+ obj = constructEmptyObject(lexicalGlobalObject, lexicalGlobalObject->objectPrototype(), size);
+ } else {
+ obj = constructEmptyObject(lexicalGlobalObject);
+ }
+
+ auto& internal = impl.internalHeaders();
+ {
+ auto& vec = internal.commonHeaders();
+ for (auto it = vec.begin(); it != vec.end(); ++it) {
+ auto& name = it->key;
+ auto& value = it->value;
+ obj->putDirect(vm, Identifier::fromString(vm, WTF::httpHeaderNameStringImpl(name)), jsString(vm, value), 0);
+ }
+ }
+
+ {
+ auto& values = internal.getSetCookieHeaders();
+
+ size_t count = values.size();
+
+ if (count > 0) {
+ JSC::JSArray* array = constructEmptyArray(lexicalGlobalObject, nullptr, count);
+ RETURN_IF_EXCEPTION(throwScope, jsUndefined());
+
+ for (size_t i = 0; i < count; ++i) {
+ array->putDirectIndex(lexicalGlobalObject, i, jsString(vm, values[i]));
+ RETURN_IF_EXCEPTION(throwScope, jsUndefined());
+ }
+
+ RETURN_IF_EXCEPTION(throwScope, jsUndefined());
+ obj->putDirect(vm, JSC::Identifier::fromString(vm, httpHeaderNameString(HTTPHeaderName::SetCookie).toStringWithoutCopying()), array, 0);
+ }
+ }
+
+ {
+ auto& vec = internal.uncommonHeaders();
+ for (auto it = vec.begin(); it != vec.end(); ++it) {
+ auto& name = it->key;
+ auto& value = it->value;
+ obj->putDirect(vm, Identifier::fromString(vm, name.convertToASCIILowercase()), jsString(vm, value), 0);
+ }
+ }
+
+ RELEASE_AND_RETURN(throwScope, obj);
+}
+
bool JSFetchHeadersOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char** reason)
{
UNUSED_PARAM(handle);
diff --git a/src/bun.js/bindings/webcore/JSFetchHeaders.h b/src/bun.js/bindings/webcore/JSFetchHeaders.h
index 772adc546..1611772ca 100644
--- a/src/bun.js/bindings/webcore/JSFetchHeaders.h
+++ b/src/bun.js/bindings/webcore/JSFetchHeaders.h
@@ -64,6 +64,8 @@ protected:
void finishCreation(JSC::VM&);
};
+JSC::JSValue getInternalProperties(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSFetchHeaders* castedThis);
+
class JSFetchHeadersOwner final : public JSC::WeakHandleOwner {
public:
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::AbstractSlotVisitor&, const char**) final;
diff --git a/src/bun.js/bindings/webcore/JSURLSearchParams.cpp b/src/bun.js/bindings/webcore/JSURLSearchParams.cpp
index a988b0518..0d401fa00 100644
--- a/src/bun.js/bindings/webcore/JSURLSearchParams.cpp
+++ b/src/bun.js/bindings/webcore/JSURLSearchParams.cpp
@@ -396,14 +396,11 @@ JSC_DEFINE_HOST_FUNCTION(jsURLSearchParamsPrototypeFunction_toString, (JSGlobalO
return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunction_toStringBody>(*lexicalGlobalObject, *callFrame, "toString");
}
-static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_toJSONBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis)
+JSC::JSValue WebCore::getInternalProperties(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSURLSearchParams* castedThis)
{
- auto& vm = JSC::getVM(lexicalGlobalObject);
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- UNUSED_PARAM(throwScope);
- UNUSED_PARAM(callFrame);
auto& impl = castedThis->wrapped();
auto iter = impl.createIterator();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
JSObject* obj;
if (impl.size() + 1 < 64) {
@@ -414,7 +411,7 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_toJSONBody(
obj->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsNontrivialString(lexicalGlobalObject->vm(), "URLSearchParams"_s), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | 0);
- RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RETURN_IF_EXCEPTION(throwScope, {});
WTF::HashSet<String> seenKeys;
for (auto entry = iter.next(); entry.has_value(); entry = iter.next()) {
auto& key = entry.value().key;
@@ -440,7 +437,7 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_toJSONBody(
} else if (jsValue.isCell() && jsValue.asCell()->type() == ArrayType) {
JSC::JSArray* array = jsCast<JSC::JSArray*>(jsValue.getObject());
array->push(lexicalGlobalObject, jsString(vm, value));
- RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RETURN_IF_EXCEPTION(throwScope, {});
} else {
RELEASE_ASSERT_NOT_REACHED();
}
@@ -450,7 +447,15 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_toJSONBody(
}
}
- RELEASE_AND_RETURN(throwScope, JSValue::encode(obj));
+ RELEASE_AND_RETURN(throwScope, obj);
+}
+
+static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_toJSONBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ UNUSED_PARAM(callFrame);
+
+ return JSValue::encode(getInternalProperties(vm, lexicalGlobalObject, castedThis));
}
JSC_DEFINE_HOST_FUNCTION(jsURLSearchParamsPrototypeFunction_toJSON, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
diff --git a/src/bun.js/bindings/webcore/JSURLSearchParams.h b/src/bun.js/bindings/webcore/JSURLSearchParams.h
index 54abe1237..7ff247ed7 100644
--- a/src/bun.js/bindings/webcore/JSURLSearchParams.h
+++ b/src/bun.js/bindings/webcore/JSURLSearchParams.h
@@ -86,6 +86,8 @@ inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalOb
JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<URLSearchParams>&&);
inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<URLSearchParams>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+JSC::JSValue getInternalProperties(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSURLSearchParams* castedThis);
+
template<> struct JSDOMWrapperConverterTraits<URLSearchParams> {
using WrapperClass = JSURLSearchParams;
using ToWrappedReturnType = URLSearchParams*;
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index a6fa35517..41ede995b 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -88,20 +88,6 @@ const PackageManager = @import("../install/install.zig").PackageManager;
const ModuleLoader = JSC.ModuleLoader;
const FetchFlags = JSC.FetchFlags;
-pub const GlobalClasses = [_]type{
- Bun.Class,
- WebCore.Crypto.Class,
- // EventListenerMixin.addEventListener(VirtualMachine),
-
- // Fetch.Class,
- js_ast.Macro.JSNode.BunJSXCallbackFunction,
-
- WebCore.Crypto.Prototype,
-
- WebCore.Alert.Class,
- WebCore.Confirm.Class,
- WebCore.Prompt.Class,
-};
const TaggedPointerUnion = @import("../tagged_pointer.zig").TaggedPointerUnion;
const Task = JSC.Task;
const Blob = @import("../blob.zig");
@@ -383,7 +369,6 @@ pub const VirtualMachine = struct {
bun_watcher: ?*JSC.Watcher = null,
console: *ZigConsoleClient,
log: *logger.Log,
- event_listeners: EventListenerMixin.Map,
main: string = "",
main_hash: u32 = 0,
process: js.JSObjectRef = null,
@@ -868,17 +853,6 @@ pub const VirtualMachine = struct {
this.transpiler_store.enabled = true;
}
- pub fn getAPIGlobals() []js.JSClassRef {
- if (is_bindgen)
- return &[_]js.JSClassRef{};
- var classes = default_allocator.alloc(js.JSClassRef, GlobalClasses.len) catch return &[_]js.JSClassRef{};
- inline for (GlobalClasses, 0..) |Class, i| {
- classes[i] = Class.get().*;
- }
-
- return classes;
- }
-
pub fn isWatcherEnabled(this: *VirtualMachine) bool {
return this.bun_dev_watcher != null or this.bun_watcher != null;
}
@@ -925,7 +899,6 @@ pub const VirtualMachine = struct {
.transpiler_store = RuntimeTranspilerStore.init(allocator),
.allocator = allocator,
.entry_point = ServerEntryPoint{},
- .event_listeners = EventListenerMixin.Map.init(allocator),
.bundler = bundler,
.console = console,
.log = log,
@@ -970,13 +943,7 @@ pub const VirtualMachine = struct {
vm.bundler.macro_context = js_ast.Macro.MacroContext.init(&vm.bundler);
- var global_classes: [GlobalClasses.len]js.JSClassRef = undefined;
- inline for (GlobalClasses, 0..) |Class, i| {
- global_classes[i] = Class.get().*;
- }
vm.global = ZigGlobalObject.create(
- &global_classes,
- @as(i32, @intCast(global_classes.len)),
vm.console,
-1,
false,
@@ -1034,7 +1001,6 @@ pub const VirtualMachine = struct {
.transpiler_store = RuntimeTranspilerStore.init(allocator),
.allocator = allocator,
.entry_point = ServerEntryPoint{},
- .event_listeners = EventListenerMixin.Map.init(allocator),
.bundler = bundler,
.console = console,
.log = log,
@@ -1079,13 +1045,7 @@ pub const VirtualMachine = struct {
vm.bundler.linker.onImportCSS = Bun.onImportCSS;
}
- var global_classes: [GlobalClasses.len]js.JSClassRef = undefined;
- inline for (GlobalClasses, 0..) |Class, i| {
- global_classes[i] = Class.get().*;
- }
vm.global = ZigGlobalObject.create(
- &global_classes,
- @as(i32, @intCast(global_classes.len)),
vm.console,
-1,
opts.smol,
@@ -1156,7 +1116,6 @@ pub const VirtualMachine = struct {
.allocator = allocator,
.transpiler_store = RuntimeTranspilerStore.init(allocator),
.entry_point = ServerEntryPoint{},
- .event_listeners = EventListenerMixin.Map.init(allocator),
.bundler = bundler,
.console = console,
.log = log,
@@ -1202,13 +1161,7 @@ pub const VirtualMachine = struct {
vm.bundler.linker.onImportCSS = Bun.onImportCSS;
}
- var global_classes: [GlobalClasses.len]js.JSClassRef = undefined;
- inline for (GlobalClasses, 0..) |Class, i| {
- global_classes[i] = Class.get().*;
- }
vm.global = ZigGlobalObject.create(
- &global_classes,
- @as(i32, @intCast(global_classes.len)),
vm.console,
@as(i32, @intCast(worker.execution_context_id)),
worker.mini,
@@ -2615,168 +2568,6 @@ pub const VirtualMachine = struct {
}
};
-const GetterFn = *const fn (
- this: anytype,
- ctx: js.JSContextRef,
- thisObject: js.JSValueRef,
- prop: js.JSStringRef,
- exception: js.ExceptionRef,
-) js.JSValueRef;
-const SetterFn = *const fn (
- this: anytype,
- ctx: js.JSContextRef,
- thisObject: js.JSValueRef,
- prop: js.JSStringRef,
- value: js.JSValueRef,
- exception: js.ExceptionRef,
-) js.JSValueRef;
-
-const JSProp = struct {
- get: ?GetterFn = null,
- set: ?SetterFn = null,
- ro: bool = false,
-};
-
-pub const EventListenerMixin = struct {
- threadlocal var event_listener_names_buf: [128]u8 = undefined;
- pub const List = std.ArrayList(js.JSObjectRef);
- pub const Map = std.AutoHashMap(EventListenerMixin.EventType, EventListenerMixin.List);
-
- pub const EventType = enum {
- fetch,
- err,
-
- const SizeMatcher = strings.ExactSizeMatcher(8);
-
- pub fn match(str: string) ?EventType {
- return switch (SizeMatcher.match(str)) {
- SizeMatcher.case("fetch") => EventType.fetch,
- SizeMatcher.case("error") => EventType.err,
- else => null,
- };
- }
- };
-
- pub fn emitFetchEvent(
- vm: *VirtualMachine,
- request_context: *http.RequestContext,
- comptime CtxType: type,
- ctx: *CtxType,
- comptime onError: fn (ctx: *CtxType, err: anyerror, value: JSValue, request_ctx: *http.RequestContext) anyerror!void,
- ) !void {
- JSC.markBinding(@src());
-
- var listeners = vm.event_listeners.get(EventType.fetch) orelse (return onError(ctx, error.NoListeners, JSValue.jsUndefined(), request_context) catch {});
- if (listeners.items.len == 0) return onError(ctx, error.NoListeners, JSValue.jsUndefined(), request_context) catch {};
- const FetchEventRejectionHandler = struct {
- pub fn onRejection(_ctx: *anyopaque, err: anyerror, fetch_event: *FetchEvent, value: JSValue) void {
- onError(
- @as(*CtxType, @ptrFromInt(@intFromPtr(_ctx))),
- err,
- value,
- fetch_event.request_context.?,
- ) catch {};
- }
- };
-
- // Rely on JS finalizer
- var fetch_event = try vm.allocator.create(FetchEvent);
-
- fetch_event.* = FetchEvent{
- .request_context = request_context,
- .request = try Request.fromRequestContext(request_context),
- .onPromiseRejectionCtx = @as(*anyopaque, ctx),
- .onPromiseRejectionHandler = FetchEventRejectionHandler.onRejection,
- };
-
- var fetch_args: [1]js.JSObjectRef = undefined;
- fetch_args[0] = FetchEvent.Class.make(vm.global, fetch_event);
- JSC.C.JSValueProtect(vm.global, fetch_args[0]);
- defer JSC.C.JSValueUnprotect(vm.global, fetch_args[0]);
-
- for (listeners.items) |listener_ref| {
- vm.tick();
- var result = js.JSObjectCallAsFunctionReturnValue(vm.global, JSValue.fromRef(listener_ref), JSValue.zero, 1, &fetch_args);
- vm.tick();
- var promise = JSInternalPromise.resolvedPromise(vm.global, result);
-
- vm.event_loop.waitForPromise(JSC.AnyPromise{
- .Internal = promise,
- });
-
- if (fetch_event.rejected) return;
-
- if (promise.status(vm.global.vm()) == .Rejected) {
- onError(ctx, error.JSError, promise.result(vm.global.vm()), request_context) catch {};
- return;
- }
-
- _ = promise.result(vm.global.vm());
-
- vm.waitForTasks();
-
- if (request_context.has_called_done) {
- break;
- }
- }
-
- if (!request_context.has_called_done) {
- onError(ctx, error.FetchHandlerRespondWithNeverCalled, JSValue.jsUndefined(), request_context) catch {};
- return;
- }
- }
-
- pub fn addEventListener(
- comptime Struct: type,
- ) type {
- const Handler = struct {
- pub fn addListener(
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- argumentCount: usize,
- _arguments: [*c]const js.JSValueRef,
- _: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- const arguments = _arguments[0..argumentCount];
- if (arguments.len == 0 or arguments.len == 1 or !js.JSValueIsString(ctx, arguments[0]) or !js.JSValueIsObject(ctx, arguments[arguments.len - 1]) or !js.JSObjectIsFunction(ctx, arguments[arguments.len - 1])) {
- return js.JSValueMakeUndefined(ctx);
- }
- var name_slice = JSValue.c(arguments[0]).toSlice(ctx, ctx.allocator());
- defer name_slice.deinit();
- const name = name_slice.slice();
- const event = EventType.match(name) orelse return js.JSValueMakeUndefined(ctx);
- var entry = VirtualMachine.get().event_listeners.getOrPut(event) catch unreachable;
-
- if (!entry.found_existing) {
- entry.value_ptr.* = List.initCapacity(VirtualMachine.get().allocator, 1) catch unreachable;
- }
-
- var callback = arguments[arguments.len - 1];
- js.JSValueProtect(ctx, callback);
- entry.value_ptr.append(callback) catch unreachable;
-
- return js.JSValueMakeUndefined(ctx);
- }
- };
-
- return NewClass(
- Struct,
- .{
- .name = "addEventListener",
- .read_only = true,
- },
- .{
- .callAsFunction = .{
- .rfn = Handler.addListener,
- },
- },
- .{},
- );
- }
-};
-
-pub const JSPrivateDataTag = JSPrivateDataPtr.Tag;
pub const HotReloader = NewHotReloader(VirtualMachine, JSC.EventLoop, false);
pub const Watcher = HotReloader.Watcher;
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig
index 01eb029c3..38d6baeb3 100644
--- a/src/bun.js/node/types.zig
+++ b/src/bun.js/node/types.zig
@@ -225,6 +225,7 @@ pub const StringOrBuffer = union(Tag) {
}
pub fn fromJS(global: *JSC.JSGlobalObject, allocator: std.mem.Allocator, value: JSC.JSValue, exception: JSC.C.ExceptionRef) ?StringOrBuffer {
+ _ = exception;
return switch (value.jsType()) {
JSC.JSValue.JSType.String, JSC.JSValue.JSType.StringObject, JSC.JSValue.JSType.DerivedStringObject, JSC.JSValue.JSType.Object => {
var zig_str = value.toSlice(global, allocator);
@@ -245,7 +246,7 @@ pub const StringOrBuffer = union(Tag) {
.BigUint64Array,
.DataView,
=> StringOrBuffer{
- .buffer = Buffer.fromArrayBuffer(global, value, exception),
+ .buffer = Buffer.fromArrayBuffer(global, value),
},
else => null,
};
@@ -280,6 +281,7 @@ pub const StringOrBunStringOrBuffer = union(enum) {
}
pub fn fromJS(global: *JSC.JSGlobalObject, allocator: std.mem.Allocator, value: JSC.JSValue, exception: JSC.C.ExceptionRef) ?StringOrBuffer {
+ _ = exception;
return switch (value.jsType()) {
JSC.JSValue.JSType.String, JSC.JSValue.JSType.StringObject, JSC.JSValue.JSType.DerivedStringObject, JSC.JSValue.JSType.Object => {
var zig_str = value.toSlice(global, allocator);
@@ -300,7 +302,7 @@ pub const StringOrBunStringOrBuffer = union(enum) {
.BigUint64Array,
.DataView,
=> StringOrBuffer{
- .buffer = Buffer.fromArrayBuffer(global, value, exception),
+ .buffer = Buffer.fromArrayBuffer(global, value),
},
else => null,
};
@@ -340,6 +342,7 @@ pub const StringOrNodeBuffer = union(Tag) {
}
pub fn fromJS(global: *JSC.JSGlobalObject, allocator: std.mem.Allocator, value: JSC.JSValue, exception: JSC.C.ExceptionRef) ?StringOrBuffer {
+ _ = exception;
return switch (value.jsType()) {
JSC.JSValue.JSType.String, JSC.JSValue.JSType.StringObject, JSC.JSValue.JSType.DerivedStringObject, JSC.JSValue.JSType.Object => {
var zig_str = value.toSlice(global, allocator);
@@ -360,7 +363,7 @@ pub const StringOrNodeBuffer = union(Tag) {
.BigUint64Array,
.DataView,
=> StringOrBuffer{
- .buffer = Buffer.fromArrayBuffer(global, value, exception),
+ .buffer = Buffer.fromArrayBuffer(global, value),
},
else => null,
};
@@ -701,7 +704,7 @@ pub const PathLike = union(Tag) {
JSC.JSValue.JSType.Uint8Array,
JSC.JSValue.JSType.DataView,
=> {
- const buffer = Buffer.fromTypedArray(ctx, arg, exception);
+ const buffer = Buffer.fromTypedArray(ctx, arg);
if (exception.* != null) return null;
if (!Valid.pathBuffer(buffer, ctx, exception)) return null;
@@ -710,7 +713,7 @@ pub const PathLike = union(Tag) {
},
JSC.JSValue.JSType.ArrayBuffer => {
- const buffer = Buffer.fromArrayBuffer(ctx, arg, exception);
+ const buffer = Buffer.fromArrayBuffer(ctx, arg);
if (exception.* != null) return null;
if (!Valid.pathBuffer(buffer, ctx, exception)) return null;
diff --git a/src/bun.js/rare_data.zig b/src/bun.js/rare_data.zig
index 3b29896a4..216b56eda 100644
--- a/src/bun.js/rare_data.zig
+++ b/src/bun.js/rare_data.zig
@@ -54,8 +54,6 @@ pub fn nextUUID(this: *RareData) UUID {
this.entropy_cache.?.init();
}
- this.entropy_cache.?.fill();
-
const bytes = this.entropy_cache.?.get();
return UUID.initWith(&bytes);
}
diff --git a/src/bun.js/scripts/class-definitions.ts b/src/bun.js/scripts/class-definitions.ts
index d9c327f6b..e7dd8bd4c 100644
--- a/src/bun.js/scripts/class-definitions.ts
+++ b/src/bun.js/scripts/class-definitions.ts
@@ -37,6 +37,8 @@ export interface ClassDefinition {
hasPendingActivity?: boolean;
isEventEmitter?: boolean;
+ getInternalProperties?: boolean;
+
custom?: Record<string, CustomField>;
configurable?: boolean;
diff --git a/src/bun.js/scripts/generate-classes.ts b/src/bun.js/scripts/generate-classes.ts
index ec0021637..0b88a3eb1 100644
--- a/src/bun.js/scripts/generate-classes.ts
+++ b/src/bun.js/scripts/generate-classes.ts
@@ -739,7 +739,7 @@ JSC_DEFINE_CUSTOM_GETTER(js${typeName}Constructor, (JSGlobalObject * lexicalGlob
auto* prototype = jsDynamicCast<${prototypeName(typeName)}*>(JSValue::decode(thisValue));
if (UNLIKELY(!prototype))
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return throwVMTypeError(lexicalGlobalObject, throwScope, "Cannot get constructor for ${typeName}"_s);
return JSValue::encode(globalObject->${className(typeName)}Constructor());
}
@@ -832,7 +832,8 @@ JSC_DEFINE_CUSTOM_SETTER(${symbolName(
if (UNLIKELY(!thisObject)) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof ${typeName}"_s);
+ return JSValue::encode({});
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -910,6 +911,11 @@ function generateClassHeader(typeName, obj: ClassDefinition) {
}
`;
}
+ var suffix = "";
+
+ if (obj.getInternalProperties) {
+ suffix += `JSC::JSValue getInternalProperties(JSC::VM &vm, JSC::JSGlobalObject *globalObject, ${name}*);`;
+ }
return `
class ${name} final : public JSC::JSDestructibleObject {
@@ -992,11 +998,20 @@ function generateClassHeader(typeName, obj: ClassDefinition) {
${renderCachedFieldsHeader(typeName, klass, proto, values)}
};
+ ${suffix}
`;
}
function generateClassImpl(typeName, obj: ClassDefinition) {
- const { klass: fields, finalize, proto, construct, estimatedSize, hasPendingActivity = false } = obj;
+ const {
+ klass: fields,
+ finalize,
+ proto,
+ construct,
+ estimatedSize,
+ hasPendingActivity = false,
+ getInternalProperties = false,
+ } = obj;
const name = className(typeName);
const DEFINE_VISIT_CHILDREN_LIST = [...Object.entries(fields), ...Object.entries(proto)]
@@ -1076,6 +1091,24 @@ DEFINE_VISIT_OUTPUT_CONSTRAINTS(${name});
`;
}
+ if (getInternalProperties) {
+ output += `
+ extern "C" EncodedJSValue ${symbolName(
+ typeName,
+ "getInternalProperties",
+ )}(void* ptr, JSC::JSGlobalObject *globalObject, EncodedJSValue thisValue);
+
+ JSC::JSValue getInternalProperties(JSC::VM &, JSC::JSGlobalObject *globalObject, ${name}* castedThis)
+ {
+ return JSValue::decode(${symbolName(
+ typeName,
+ "getInternalProperties",
+ )}(castedThis->impl(), globalObject, JSValue::encode(castedThis)));
+ }
+
+ `;
+ }
+
if (finalize) {
output += `
${name}::~${name}()
@@ -1220,6 +1253,7 @@ function generateZig(
values = [],
hasPendingActivity = false,
structuredClone = false,
+ getInternalProperties = false,
} = {} as ClassDefinition,
) {
const exports = new Map<string, string>();
@@ -1246,6 +1280,10 @@ function generateZig(
Object.values(klass).map(a => appendSymbols(exports, name => classSymbolName(typeName, name), a));
Object.values(proto).map(a => appendSymbols(exports, name => protoSymbolName(typeName, name), a));
+ if (getInternalProperties) {
+ exports.set("getInternalProperties", symbolName(typeName, "getInternalProperties"));
+ }
+
if (structuredClone) {
exports.set("onStructuredCloneSerialize", symbolName(typeName, "onStructuredCloneSerialize"));
@@ -1306,6 +1344,14 @@ function generateZig(
}
`;
+ if (getInternalProperties) {
+ output += `
+ if (@TypeOf(${typeName}.getInternalProperties) != (fn(*${typeName}, globalThis: *JSC.JSGlobalObject, JSC.JSValue thisValue) callconv(.C) JSC.JSValue {
+ @compileLog("${typeName}.getInternalProperties is not a getInternalProperties function");
+ }
+ `;
+ }
+
if (structuredClone === "transferable") {
exports.set("structuredClone", symbolName(typeName, "onTransferableStructuredClone"));
output += `
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index 5600f5338..7e194f7c1 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -506,35 +506,31 @@ pub const Jest = struct {
extern fn JSMock__jsUseRealTimers(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue;
pub fn call(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments_: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
+ globalObject: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
JSC.markBinding(@src());
+ const arguments = callframe.arguments(2).slice();
var runner_ = runner orelse {
- JSError(getAllocator(ctx), "Run \"bun test\" to run a test", .{}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ globalObject.throw("Run \"bun test\" to run a test", .{});
+ return .undefined;
};
- const arguments = @as([]const JSC.JSValue, @ptrCast(arguments_));
if (arguments.len < 1 or !arguments[0].isString()) {
- JSError(getAllocator(ctx), "Bun.jest() expects a string filename", .{}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ globalObject.throw("Bun.jest() expects a string filename", .{});
+ return .undefined;
}
- var str = arguments[0].toSlice(ctx, bun.default_allocator);
+ var str = arguments[0].toSlice(globalObject, bun.default_allocator);
defer str.deinit();
var slice = str.slice();
if (str.len == 0 or slice[0] != '/') {
- JSError(getAllocator(ctx), "Bun.jest() expects an absolute file path", .{}, ctx, exception);
- return js.JSValueMakeUndefined(ctx);
+ globalObject.throw("Bun.jest() expects an absolute file path", .{});
+ return .undefined;
}
- var vm = ctx.bunVM();
+ var vm = globalObject.bunVM();
if (vm.is_in_preload) {
- return Bun__Jest__testPreloadObject(ctx).asObjectRef();
+ return Bun__Jest__testPreloadObject(globalObject);
}
var filepath = Fs.FileSystem.instance.filename_store.append([]const u8, slice) catch unreachable;
@@ -542,7 +538,7 @@ pub const Jest = struct {
var scope = runner_.getOrPutFile(filepath);
scope.push();
- return Bun__Jest__testModuleObject(ctx).asObjectRef();
+ return Bun__Jest__testModuleObject(globalObject);
}
comptime {
diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig
index 5fdc64c82..8adff53d3 100644
--- a/src/bun.js/webcore.zig
+++ b/src/bun.js/webcore.zig
@@ -20,38 +20,20 @@ pub const Lifetime = enum {
temporary,
};
-pub const Alert = struct {
- pub const Class = JSC.NewClass(
- void,
- .{ .name = "alert" },
- .{
- .call = .{ .rfn = call },
- },
- .{},
- );
-
- /// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-alert
- pub fn call(
- // this
- _: void,
- ctx: JSC.C.JSContextRef,
- // function
- _: JSC.C.JSObjectRef,
- // thisObject
- _: JSC.C.JSObjectRef,
- arguments: []const JSC.C.JSValueRef,
- _: JSC.C.ExceptionRef,
- ) JSC.C.JSValueRef {
- var output = bun.Output.writer();
- const has_message = arguments.len != 0;
-
- // 2. If the method was invoked with no arguments, then let message be the empty string; otherwise, let message be the method's first argument.
- if (has_message) {
- var state = std.heap.stackFallback(2048, bun.default_allocator);
- const allocator = state.get();
- const message = arguments[0].?.value().toSlice(ctx.ptr(), allocator);
- defer message.deinit();
+/// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-alert
+fn alert(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1).slice();
+ var output = bun.Output.writer();
+ const has_message = arguments.len != 0;
+
+ // 2. If the method was invoked with no arguments, then let message be the empty string; otherwise, let message be the method's first argument.
+ if (has_message) {
+ var state = std.heap.stackFallback(2048, bun.default_allocator);
+ const allocator = state.get();
+ const message = arguments[0].toSlice(globalObject, allocator);
+ defer message.deinit();
+ if (message.len > 0) {
// 3. Set message to the result of normalizing newlines given message.
// * We skip step 3 because they are already done in most terminals by default.
@@ -61,137 +43,107 @@ pub const Alert = struct {
// 5. Show message to the user, treating U+000A LF as a line break.
output.writeAll(message.slice()) catch {
// 1. If we cannot show simple dialogs for this, then return.
- return JSC.JSValue.jsUndefined().asObjectRef();
+ return .undefined;
};
}
+ }
- output.writeAll(if (has_message) " [Enter] " else "Alert [Enter] ") catch {
- // 1. If we cannot show simple dialogs for this, then return.
- return JSC.JSValue.jsUndefined().asObjectRef();
- };
-
- // 6. Invoke WebDriver BiDi user prompt opened with this, "alert", and message.
- // * Not pertinent to use their complex system in a server context.
- bun.Output.flush();
-
- // 7. Optionally, pause while waiting for the user to acknowledge the message.
- var stdin = std.io.getStdIn();
- var reader = stdin.reader();
- while (true) {
- const byte = reader.readByte() catch break;
- if (byte == '\n') break;
- }
-
- // 8. Invoke WebDriver BiDi user prompt closed with this and true.
- // * Again, not necessary in a server context.
-
- return JSC.JSValue.jsUndefined().asObjectRef();
+ output.writeAll(if (has_message) " [Enter] " else "Alert [Enter] ") catch {
+ // 1. If we cannot show simple dialogs for this, then return.
+ return .undefined;
+ };
+
+ // 6. Invoke WebDriver BiDi user prompt opened with this, "alert", and message.
+ // * Not pertinent to use their complex system in a server context.
+ bun.Output.flush();
+
+ // 7. Optionally, pause while waiting for the user to acknowledge the message.
+ var stdin = std.io.getStdIn();
+ var reader = stdin.reader();
+ while (true) {
+ const byte = reader.readByte() catch break;
+ if (byte == '\n') break;
}
-};
-pub const Confirm = struct {
- pub const Class = JSC.NewClass(
- void,
- .{ .name = "confirm" },
- .{
- .call = .{ .rfn = call },
- },
- .{},
- );
+ // 8. Invoke WebDriver BiDi user prompt closed with this and true.
+ // * Again, not necessary in a server context.
- /// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-confirm
- pub fn call(
- // this
- _: void,
- ctx: JSC.C.JSContextRef,
- // function
- _: JSC.C.JSObjectRef,
- // thisObject
- _: JSC.C.JSObjectRef,
- arguments: []const JSC.C.JSValueRef,
- _: JSC.C.ExceptionRef,
- ) JSC.C.JSValueRef {
- var output = bun.Output.writer();
- const has_message = arguments.len != 0;
+ return .undefined;
+}
- if (has_message) {
- var state = std.heap.stackFallback(1024, bun.default_allocator);
- const allocator = state.get();
- // 2. Set message to the result of normalizing newlines given message.
- // * Not pertinent to a server runtime so we will just let the terminal handle this.
+fn confirm(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1).slice();
+ var output = bun.Output.writer();
+ const has_message = arguments.len != 0;
- // 3. Set message to the result of optionally truncating message.
- // * Not necessary so we won't do it.
- const message = arguments[0].?.value().toSlice(ctx.ptr(), allocator);
- defer message.deinit();
+ if (has_message) {
+ var state = std.heap.stackFallback(1024, bun.default_allocator);
+ const allocator = state.get();
+ // 2. Set message to the result of normalizing newlines given message.
+ // * Not pertinent to a server runtime so we will just let the terminal handle this.
- output.writeAll(message.slice()) catch {
- // 1. If we cannot show simple dialogs for this, then return false.
- return JSC.JSValue.jsBoolean(false).asObjectRef();
- };
- }
+ // 3. Set message to the result of optionally truncating message.
+ // * Not necessary so we won't do it.
+ const message = arguments[0].toSlice(globalObject, allocator);
+ defer message.deinit();
- // 4. Show message to the user, treating U+000A LF as a line break,
- // and ask the user to respond with a positive or negative
- // response.
- output.writeAll(if (has_message) " [y/N] " else "Confirm [y/N] ") catch {
+ output.writeAll(message.slice()) catch {
// 1. If we cannot show simple dialogs for this, then return false.
- return JSC.JSValue.jsBoolean(false).asObjectRef();
+ return .false;
};
+ }
- // 5. Invoke WebDriver BiDi user prompt opened with this, "confirm", and message.
- // * Not relevant in a server context.
- bun.Output.flush();
-
- // 6. Pause until the user responds either positively or negatively.
- var stdin = std.io.getStdIn();
- var reader = stdin.reader();
-
- const first_byte = reader.readByte() catch {
- return JSC.JSValue.jsBoolean(false).asObjectRef();
- };
-
- // 7. Invoke WebDriver BiDi user prompt closed with this, and true if
- // the user responded positively or false otherwise.
- // * Not relevant in a server context.
-
- switch (first_byte) {
- '\n' => return JSC.JSValue.jsBoolean(false).asObjectRef(),
- 'y', 'Y' => {
- const next_byte = reader.readByte() catch {
- // They may have said yes, but the stdin is invalid.
- return JSC.JSValue.jsBoolean(false).asObjectRef();
- };
+ // 4. Show message to the user, treating U+000A LF as a line break,
+ // and ask the user to respond with a positive or negative
+ // response.
+ output.writeAll(if (has_message) " [y/N] " else "Confirm [y/N] ") catch {
+ // 1. If we cannot show simple dialogs for this, then return false.
+ return .false;
+ };
+
+ // 5. Invoke WebDriver BiDi user prompt opened with this, "confirm", and message.
+ // * Not relevant in a server context.
+ bun.Output.flush();
+
+ // 6. Pause until the user responds either positively or negatively.
+ var stdin = std.io.getStdIn();
+ var reader = stdin.reader();
+
+ const first_byte = reader.readByte() catch {
+ return .false;
+ };
+
+ // 7. Invoke WebDriver BiDi user prompt closed with this, and true if
+ // the user responded positively or false otherwise.
+ // * Not relevant in a server context.
+
+ switch (first_byte) {
+ '\n' => return .false,
+ 'y', 'Y' => {
+ const next_byte = reader.readByte() catch {
+ // They may have said yes, but the stdin is invalid.
+ return .false;
+ };
- if (next_byte == '\n') {
- // 8. If the user responded positively, return true;
- // otherwise, the user responded negatively: return false.
- return JSC.JSValue.jsBoolean(true).asObjectRef();
- }
- },
- else => {},
- }
+ if (next_byte == '\n') {
+ // 8. If the user responded positively, return true;
+ // otherwise, the user responded negatively: return false.
+ return .false;
+ }
+ },
+ else => {},
+ }
- while (reader.readByte()) |b| {
- if (b == '\n') break;
- } else |_| {}
+ while (reader.readByte()) |b| {
+ if (b == '\n') break;
+ } else |_| {}
- // 8. If the user responded positively, return true; otherwise, the user
- // responded negatively: return false.
- return JSC.JSValue.jsBoolean(false).asObjectRef();
- }
-};
+ // 8. If the user responded positively, return true; otherwise, the user
+ // responded negatively: return false.
+ return .false;
+}
pub const Prompt = struct {
- pub const Class = JSC.NewClass(
- void,
- .{ .name = "prompt" },
- .{
- .call = .{ .rfn = call },
- },
- .{},
- );
-
/// Adapted from `std.io.Reader.readUntilDelimiterArrayList` to only append
/// and assume capacity.
pub fn readUntilDelimiterArrayListAppendAssumeCapacity(
@@ -235,16 +187,10 @@ pub const Prompt = struct {
/// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-prompt
pub fn call(
- // this
- _: void,
- ctx: JSC.C.JSContextRef,
- // function
- _: JSC.C.JSObjectRef,
- // thisObject
- _: JSC.C.JSObjectRef,
- arguments: []const JSC.C.JSValueRef,
- _: JSC.C.ExceptionRef,
- ) JSC.C.JSValueRef {
+ globalObject: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(3).slice();
var state = std.heap.stackFallback(2048, bun.default_allocator);
const allocator = state.get();
var output = bun.Output.writer();
@@ -252,7 +198,7 @@ pub const Prompt = struct {
const has_default = arguments.len >= 2;
// 4. Set default to the result of optionally truncating default.
// * We don't really need to do this.
- const default = if (has_default) arguments[1] else JSC.JSValue.jsNull().asObjectRef();
+ const default = if (has_default) arguments[1] else JSC.JSValue.jsNull();
if (has_message) {
// 2. Set message to the result of normalizing newlines given message.
@@ -260,12 +206,12 @@ pub const Prompt = struct {
// 3. Set message to the result of optionally truncating message.
// * Not necessary so we won't do it.
- const message = arguments[0].?.value().toSlice(ctx.ptr(), allocator);
+ const message = arguments[0].toSlice(globalObject, allocator);
defer message.deinit();
output.writeAll(message.slice()) catch {
// 1. If we cannot show simple dialogs for this, then return null.
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
};
}
@@ -277,16 +223,16 @@ pub const Prompt = struct {
// default.
output.writeAll(if (has_message) " " else "Prompt ") catch {
// 1. If we cannot show simple dialogs for this, then return false.
- return JSC.JSValue.jsBoolean(false).asObjectRef();
+ return JSC.JSValue.jsBoolean(false);
};
if (has_default) {
- const default_string = arguments[1].?.value().toSlice(ctx.ptr(), allocator);
+ const default_string = arguments[1].toSlice(globalObject, allocator);
defer default_string.deinit();
output.print("[{s}] ", .{default_string.slice()}) catch {
// 1. If we cannot show simple dialogs for this, then return false.
- return JSC.JSValue.jsBoolean(false).asObjectRef();
+ return JSC.JSValue.jsBoolean(false);
};
}
@@ -301,7 +247,7 @@ pub const Prompt = struct {
const first_byte = reader.readByte() catch {
// 8. Let result be null if the user aborts, or otherwise the string
// that the user responded with.
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
};
if (first_byte == '\n') {
@@ -313,7 +259,7 @@ pub const Prompt = struct {
var input = std.ArrayList(u8).initCapacity(allocator, 2048) catch {
// 8. Let result be null if the user aborts, or otherwise the string
// that the user responded with.
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
};
defer input.deinit();
@@ -327,26 +273,26 @@ pub const Prompt = struct {
if (e != error.StreamTooLong) {
// 8. Let result be null if the user aborts, or otherwise the string
// that the user responded with.
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
}
input.ensureTotalCapacity(4096) catch {
// 8. Let result be null if the user aborts, or otherwise the string
// that the user responded with.
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
};
readUntilDelimiterArrayListAppendAssumeCapacity(reader, &input, '\n', 4096) catch |e2| {
if (e2 != error.StreamTooLong) {
// 8. Let result be null if the user aborts, or otherwise the string
// that the user responded with.
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
}
readUntilDelimiterArrayListInfinity(reader, &input, '\n') catch {
// 8. Let result be null if the user aborts, or otherwise the string
// that the user responded with.
- return JSC.JSValue.jsNull().asObjectRef();
+ return JSC.JSValue.jsNull();
};
};
};
@@ -361,34 +307,15 @@ pub const Prompt = struct {
// * Too complex for server context.
// 9. Return result.
- return result.toValueGC(ctx.ptr()).asObjectRef();
+ return result.toValueGC(globalObject);
}
};
pub const Crypto = struct {
+ garbage: i32 = 0,
const BoringSSL = @import("root").bun.BoringSSL;
- pub const Class = JSC.NewClass(
- void,
- .{ .name = "crypto" },
- .{
- .getRandomValues = JSC.DOMCall("Crypto", @This(), "getRandomValues", JSC.JSValue, JSC.DOMEffect.top),
- .randomUUID = JSC.DOMCall("Crypto", @This(), "randomUUID", *JSC.JSString, JSC.DOMEffect.top),
- .timingSafeEqual = JSC.DOMCall("Crypto", @This(), "timingSafeEqual", JSC.JSValue, JSC.DOMEffect.top),
- .randomInt = .{ .rfn = &JSC.wrapWithHasContainer(Crypto, "randomInt", false, false, false) },
- .scryptSync = .{ .rfn = &JSC.wrapWithHasContainer(Crypto, "scryptSync", false, false, false) },
- },
- .{},
- );
- pub const Prototype = JSC.NewClass(
- void,
- .{ .name = "Crypto" },
- .{
- .call = .{
- .rfn = call,
- },
- },
- .{},
- );
+
+ pub const doScryptSync = JSC.wrapInstanceMethod(Crypto, "scryptSync", false);
pub fn scryptSync(
globalThis: *JSC.JSGlobalObject,
@@ -589,10 +516,12 @@ pub const Crypto = struct {
}
pub fn timingSafeEqual(
+ _: *@This(),
globalThis: *JSC.JSGlobalObject,
- _: JSC.JSValue,
- arguments: []const JSC.JSValue,
- ) JSC.JSValue {
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(2).slice();
+
if (arguments.len < 2) {
globalThis.throwInvalidArguments("Expected 2 typed arrays but got nothing", .{});
return JSC.JSValue.jsUndefined();
@@ -619,8 +548,8 @@ pub const Crypto = struct {
}
pub fn timingSafeEqualWithoutTypeChecks(
+ _: *@This(),
globalThis: *JSC.JSGlobalObject,
- _: *anyopaque,
array_a: *JSC.JSUint8Array,
array_b: *JSC.JSUint8Array,
) callconv(.C) JSC.JSValue {
@@ -637,10 +566,11 @@ pub const Crypto = struct {
}
pub fn getRandomValues(
+ _: *@This(),
globalThis: *JSC.JSGlobalObject,
- _: JSC.JSValue,
- arguments: []const JSC.JSValue,
- ) JSC.JSValue {
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(1).slice();
if (arguments.len == 0) {
globalThis.throwInvalidArguments("Expected typed array but got nothing", .{});
return JSC.JSValue.jsUndefined();
@@ -658,8 +588,8 @@ pub const Crypto = struct {
}
pub fn getRandomValuesWithoutTypeChecks(
+ _: *@This(),
globalThis: *JSC.JSGlobalObject,
- _: *anyopaque,
array: *JSC.JSUint8Array,
) callconv(.C) JSC.JSValue {
var slice = array.slice();
@@ -687,10 +617,10 @@ pub const Crypto = struct {
}
pub fn randomUUID(
+ _: *@This(),
globalThis: *JSC.JSGlobalObject,
- _: JSC.JSValue,
- _: []const JSC.JSValue,
- ) JSC.JSValue {
+ _: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
var out: [36]u8 = undefined;
const uuid = globalThis.bunVM().rareData().nextUUID();
@@ -698,8 +628,11 @@ pub const Crypto = struct {
return JSC.ZigString.init(&out).toValueGC(globalThis);
}
- pub fn randomInt(globalThis: *JSC.JSGlobalObject, min_value: ?JSValue, max_value: ?JSValue) JSValue {
- _ = globalThis;
+ pub fn randomInt(_: *@This(), _: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
+ const arguments = callframe.arguments(2).slice();
+
+ const min_value: ?JSValue = if (arguments.len > 0 and !arguments[0].isEmptyOrUndefinedOrNull()) arguments[0] else null;
+ const max_value: ?JSValue = if (arguments.len > 1 and !arguments[1].isEmptyOrUndefinedOrNull()) arguments[1] else null;
var at_least: u52 = 0;
var at_most: u52 = std.math.maxInt(u52);
@@ -717,8 +650,8 @@ pub const Crypto = struct {
}
pub fn randomUUIDWithoutTypeChecks(
+ _: *Crypto,
globalThis: *JSC.JSGlobalObject,
- _: *anyopaque,
) callconv(.C) JSC.JSValue {
var out: [36]u8 = undefined;
const uuid = globalThis.bunVM().rareData().nextUUID();
@@ -727,17 +660,35 @@ pub const Crypto = struct {
return JSC.ZigString.init(&out).toValueGC(globalThis);
}
- pub fn call(
- // this
- _: void,
- _: JSC.C.JSContextRef,
- // function
- _: JSC.C.JSObjectRef,
- // thisObject
- _: JSC.C.JSObjectRef,
- _: []const JSC.C.JSValueRef,
- _: JSC.C.ExceptionRef,
- ) JSC.C.JSValueRef {
- return JSC.JSValue.jsUndefined().asObjectRef();
+ pub fn constructor(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) ?*Crypto {
+ globalThis.throw("Crypto is not constructable", .{});
+ return null;
+ }
+
+ pub export fn CryptoObject__create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+
+ var ptr = bun.default_allocator.create(Crypto) catch {
+ globalThis.throwOutOfMemory();
+ return .zero;
+ };
+
+ return ptr.toJS(globalThis);
+ }
+
+ pub usingnamespace JSC.Codegen.JSCrypto;
+
+ comptime {
+ if (!JSC.is_bindgen) {
+ _ = CryptoObject__create;
+ }
}
};
+
+comptime {
+ if (!JSC.is_bindgen) {
+ @export(alert, .{ .name = "WebCore__alert" });
+ @export(Prompt.call, .{ .name = "WebCore__prompt" });
+ @export(confirm, .{ .name = "WebCore__confirm" });
+ }
+}
diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig
index b384048ce..8abc87713 100644
--- a/src/bun.js/webcore/blob.zig
+++ b/src/bun.js/webcore/blob.zig
@@ -22,12 +22,9 @@ const default_allocator = @import("root").bun.default_allocator;
const FeatureFlags = @import("root").bun.FeatureFlags;
const ArrayBuffer = @import("../base.zig").ArrayBuffer;
const Properties = @import("../base.zig").Properties;
-const NewClass = @import("../base.zig").NewClass;
-const d = @import("../base.zig").d;
-const castObj = @import("../base.zig").castObj;
+
const getAllocator = @import("../base.zig").getAllocator;
-const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
-const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;
+
const Environment = @import("../../env.zig");
const ZigString = JSC.ZigString;
const IdentityContext = @import("../../identity_context.zig").IdentityContext;
@@ -646,12 +643,12 @@ pub const Blob = struct {
var blob = value.use();
// TODO: this should be one promise not two!
const new_promise = writeFileWithSourceDestination(globalThis, &blob, &file_blob);
- if (JSC.JSValue.fromRef(new_promise.?).asAnyPromise()) |_promise| {
+ if (new_promise.asAnyPromise()) |_promise| {
switch (_promise.status(globalThis.vm())) {
.Pending => {
promise.resolve(
globalThis,
- JSC.JSValue.fromRef(new_promise.?),
+ new_promise,
);
},
.Rejected => {
@@ -678,13 +675,13 @@ pub const Blob = struct {
ctx: JSC.C.JSContextRef,
source_blob: *Blob,
destination_blob: *Blob,
- ) js.JSObjectRef {
+ ) JSC.JSValue {
const destination_type = std.meta.activeTag(destination_blob.store.?.data);
// Writing an empty string to a file is a no-op
if (source_blob.store == null) {
destination_blob.detach();
- return JSC.JSPromise.resolvedPromiseValue(ctx.ptr(), JSC.JSValue.jsNumber(0)).asObjectRef();
+ return JSC.JSPromise.resolvedPromiseValue(ctx.ptr(), JSC.JSValue.jsNumber(0));
}
const source_type = std.meta.activeTag(source_blob.store.?.data);
@@ -711,7 +708,7 @@ pub const Blob = struct {
write_file_promise.promise.strong.set(ctx, promise_value);
promise_value.ensureStillAlive();
task.schedule();
- return promise_value.asObjectRef();
+ return promise_value;
}
// If this is file <> file, we can just copy the file
else if (destination_type == .file and source_type == .file) {
@@ -725,7 +722,7 @@ pub const Blob = struct {
ctx.ptr(),
) catch unreachable;
file_copier.schedule();
- return file_copier.promise.value().asObjectRef();
+ return file_copier.promise.value();
} else if (destination_type == .bytes and source_type == .bytes) {
// If this is bytes <> bytes, we can just duplicate it
// this is an edgecase
@@ -735,7 +732,7 @@ pub const Blob = struct {
clone.allocator = bun.default_allocator;
var cloned = bun.default_allocator.create(Blob) catch unreachable;
cloned.* = clone;
- return JSPromise.resolvedPromiseValue(ctx.ptr(), cloned.toJS(ctx)).asObjectRef();
+ return JSPromise.resolvedPromiseValue(ctx.ptr(), cloned.toJS(ctx));
} else if (destination_type == .bytes and source_type == .file) {
var fake_call_frame: [8]JSC.JSValue = undefined;
@memset(@as([*]u8, @ptrCast(&fake_call_frame))[0..@sizeOf(@TypeOf(fake_call_frame))], 0);
@@ -745,41 +742,46 @@ pub const Blob = struct {
return JSPromise.resolvedPromiseValue(
ctx.ptr(),
blob_value,
- ).asObjectRef();
+ );
}
unreachable;
}
+
pub fn writeFile(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(2).slice();
+ var args = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments);
defer args.deinit();
+ var exception_ = [1]JSC.JSValueRef{null};
+ var exception = &exception_;
+
// accept a path or a blob
- var path_or_blob = PathOrBlob.fromJSNoCopy(ctx, &args, exception) orelse {
- exception.* = JSC.toInvalidArguments("Bun.write expects a path, file descriptor or a blob", .{}, ctx).asObjectRef();
- return null;
+ var path_or_blob = PathOrBlob.fromJSNoCopy(globalThis, &args, exception) orelse {
+ if (exception[0] != null) {
+ globalThis.throwValue(exception[0].?.value());
+ } else {
+ globalThis.throwInvalidArguments("Bun.write expects a path, file descriptor or a blob", .{});
+ }
+ return .zero;
};
var data = args.nextEat() orelse {
- exception.* = JSC.toInvalidArguments("Bun.write(pathOrFdOrBlob, blob) expects a Blob-y thing to write", .{}, ctx).asObjectRef();
- return null;
+ globalThis.throwInvalidArguments("Bun.write(pathOrFdOrBlob, blob) expects a Blob-y thing to write", .{});
+ return .zero;
};
if (data.isEmptyOrUndefinedOrNull()) {
- exception.* = JSC.toInvalidArguments("Bun.write(pathOrFdOrBlob, blob) expects a Blob-y thing to write", .{}, ctx).asObjectRef();
- return null;
+ globalThis.throwInvalidArguments("Bun.write(pathOrFdOrBlob, blob) expects a Blob-y thing to write", .{});
+ return .zero;
}
if (path_or_blob == .blob) {
if (path_or_blob.blob.store == null) {
- exception.* = JSC.toInvalidArguments("Blob is detached", .{}, ctx).asObjectRef();
- return null;
+ globalThis.throwInvalidArguments("Blob is detached", .{});
+ return .zero;
} else {
// TODO only reset last_modified on success pathes instead of
// resetting last_modified at the beginning for better performance.
@@ -799,10 +801,10 @@ pub const Blob = struct {
if (data.isString()) {
defer if (!needs_async and path_or_blob == .path) path_or_blob.path.deinit();
- const len = data.getLength(ctx);
+ const len = data.getLength(globalThis);
if (len < 256 * 1024 or bun.isMissingIOUring()) {
- const str = data.toBunString(ctx);
+ const str = data.toBunString(globalThis);
const pathlike: JSC.Node.PathOrFileDescriptor = if (path_or_blob == .path)
path_or_blob.path
@@ -811,29 +813,29 @@ pub const Blob = struct {
if (pathlike == .path) {
const result = writeStringToFileFast(
- ctx,
+ globalThis,
pathlike,
str,
&needs_async,
true,
);
if (!needs_async) {
- return result.asObjectRef();
+ return result;
}
} else {
const result = writeStringToFileFast(
- ctx,
+ globalThis,
pathlike,
str,
&needs_async,
false,
);
if (!needs_async) {
- return result.asObjectRef();
+ return result;
}
}
}
- } else if (data.asArrayBuffer(ctx)) |buffer_view| {
+ } else if (data.asArrayBuffer(globalThis)) |buffer_view| {
defer if (!needs_async and path_or_blob == .path) path_or_blob.path.deinit();
if (buffer_view.byte_len < 256 * 1024 or bun.isMissingIOUring()) {
@@ -844,7 +846,7 @@ pub const Blob = struct {
if (pathlike == .path) {
const result = writeBytesToFileFast(
- ctx,
+ globalThis,
pathlike,
buffer_view.byteSlice(),
&needs_async,
@@ -852,11 +854,11 @@ pub const Blob = struct {
);
if (!needs_async) {
- return result.asObjectRef();
+ return result;
}
} else {
const result = writeBytesToFileFast(
- ctx,
+ globalThis,
pathlike,
buffer_view.byteSlice(),
&needs_async,
@@ -864,7 +866,7 @@ pub const Blob = struct {
);
if (!needs_async) {
- return result.asObjectRef();
+ return result;
}
}
}
@@ -872,13 +874,13 @@ pub const Blob = struct {
// if path_or_blob is a path, convert it into a file blob
var destination_blob: Blob = if (path_or_blob == .path)
- Blob.findOrCreateFileFromPath(path_or_blob.path, ctx.ptr())
+ Blob.findOrCreateFileFromPath(path_or_blob.path, globalThis)
else
path_or_blob.blob.dupe();
if (destination_blob.store == null) {
- exception.* = JSC.toInvalidArguments("Writing to an empty blob is not implemented yet", .{}, ctx).asObjectRef();
- return null;
+ globalThis.throwInvalidArguments("Writing to an empty blob is not implemented yet", .{});
+ return .zero;
}
// TODO: implement a writeev() fast path
@@ -897,15 +899,15 @@ pub const Blob = struct {
.Error => {
destination_blob.detach();
const err = response.body.value.Error;
- JSC.C.JSValueUnprotect(ctx, err.asObjectRef());
+ err.unprotect();
_ = response.body.value.use();
- return JSC.JSPromise.rejectedPromiseValue(ctx.ptr(), err).asObjectRef();
+ return JSC.JSPromise.rejectedPromiseValue(globalThis, err);
},
.Locked => {
var task = bun.default_allocator.create(WriteFileWaitFromLockedValueTask) catch unreachable;
- var promise = JSC.JSPromise.create(ctx.ptr());
+ var promise = JSC.JSPromise.create(globalThis);
task.* = WriteFileWaitFromLockedValueTask{
- .globalThis = ctx.ptr(),
+ .globalThis = globalThis,
.file_blob = destination_blob,
.promise = promise,
};
@@ -913,7 +915,7 @@ pub const Blob = struct {
response.body.value.Locked.task = task;
response.body.value.Locked.onReceiveValue = WriteFileWaitFromLockedValueTask.thenWrap;
- return promise.asValue(ctx.ptr()).asObjectRef();
+ return promise.asValue(globalThis);
},
}
}
@@ -932,15 +934,15 @@ pub const Blob = struct {
.Error => {
destination_blob.detach();
const err = request.body.value.Error;
- JSC.C.JSValueUnprotect(ctx, err.asObjectRef());
+ err.unprotect();
_ = request.body.value.use();
- return JSC.JSPromise.rejectedPromiseValue(ctx.ptr(), err).asObjectRef();
+ return JSC.JSPromise.rejectedPromiseValue(globalThis, err);
},
.Locked => {
var task = bun.default_allocator.create(WriteFileWaitFromLockedValueTask) catch unreachable;
- var promise = JSC.JSPromise.create(ctx.ptr());
+ var promise = JSC.JSPromise.create(globalThis);
task.* = WriteFileWaitFromLockedValueTask{
- .globalThis = ctx.ptr(),
+ .globalThis = globalThis,
.file_blob = destination_blob,
.promise = promise,
};
@@ -948,32 +950,27 @@ pub const Blob = struct {
request.body.value.Locked.task = task;
request.body.value.Locked.onReceiveValue = WriteFileWaitFromLockedValueTask.thenWrap;
- return promise.asValue(ctx.ptr()).asObjectRef();
+ return promise.asValue(globalThis);
},
}
}
break :brk Blob.get(
- ctx.ptr(),
+ globalThis,
data,
false,
false,
) catch |err| {
if (err == error.InvalidArguments) {
- exception.* = JSC.toInvalidArguments(
+ globalThis.throwInvalidArguments(
"Expected an Array",
.{},
- ctx,
- ).asObjectRef();
- return null;
+ );
+ return .zero;
}
- exception.* = JSC.toInvalidArguments(
- "Out of memory",
- .{},
- ctx,
- ).asObjectRef();
- return null;
+ globalThis.throwOutOfMemory();
+ return .zero;
};
};
@@ -988,7 +985,7 @@ pub const Blob = struct {
}
}
- return writeFileWithSourceDestination(ctx, &source_blob, &destination_blob);
+ return writeFileWithSourceDestination(globalThis, &source_blob, &destination_blob);
}
const write_permissions = 0o664;
@@ -1127,28 +1124,32 @@ pub const Blob = struct {
}
pub fn constructFile(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- var vm = ctx.bunVM();
- var args = JSC.Node.ArgumentsSlice.from(vm, arguments);
+ globalObject: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ var vm = globalObject.bunVM();
+ const arguments = callframe.arguments(2).slice();
+ var args = JSC.Node.ArgumentsSlice.init(vm, arguments);
defer args.deinit();
+ var exception_ = [1]JSC.JSValueRef{null};
+ var exception = &exception_;
+
+ const path = JSC.Node.PathOrFileDescriptor.fromJS(globalObject, &args, args.arena.allocator(), exception) orelse {
+ if (exception_[0] == null) {
+ globalObject.throwInvalidArguments("Expected file path string or file descriptor", .{});
+ } else {
+ globalObject.throwValue(exception_[0].?.value());
+ }
- const path = JSC.Node.PathOrFileDescriptor.fromJS(ctx, &args, args.arena.allocator(), exception) orelse {
- exception.* = JSC.toInvalidArguments("Expected file path string or file descriptor", .{}, ctx).asObjectRef();
- return js.JSValueMakeUndefined(ctx);
+ return .undefined;
};
- const blob = Blob.findOrCreateFileFromPath(path, ctx.ptr());
+ const blob = Blob.findOrCreateFileFromPath(path, globalObject);
- var ptr = vm.allocator.create(Blob) catch unreachable;
+ var ptr = bun.default_allocator.create(Blob) catch unreachable;
ptr.* = blob;
- ptr.allocator = vm.allocator;
- return ptr.toJS(ctx).asObjectRef();
+ ptr.allocator = bun.default_allocator;
+ return ptr.toJS(globalObject);
}
pub fn findOrCreateFileFromPath(path_: JSC.Node.PathOrFileDescriptor, globalThis: *JSGlobalObject) Blob {
diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig
index 0dea0579d..b59125bc6 100644
--- a/src/bun.js/webcore/body.zig
+++ b/src/bun.js/webcore/body.zig
@@ -22,11 +22,10 @@ const default_allocator = @import("root").bun.default_allocator;
const FeatureFlags = @import("root").bun.FeatureFlags;
const ArrayBuffer = @import("../base.zig").ArrayBuffer;
const Properties = @import("../base.zig").Properties;
-const NewClass = @import("../base.zig").NewClass;
-const d = @import("../base.zig").d;
+
const castObj = @import("../base.zig").castObj;
const getAllocator = @import("../base.zig").getAllocator;
-const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
+
const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;
const Environment = @import("../../env.zig");
const ZigString = JSC.ZigString;
diff --git a/src/bun.js/webcore/encoding.zig b/src/bun.js/webcore/encoding.zig
index f2525348f..32efb3168 100644
--- a/src/bun.js/webcore/encoding.zig
+++ b/src/bun.js/webcore/encoding.zig
@@ -21,11 +21,10 @@ const default_allocator = @import("root").bun.default_allocator;
const FeatureFlags = @import("root").bun.FeatureFlags;
const ArrayBuffer = @import("../base.zig").ArrayBuffer;
const Properties = @import("../base.zig").Properties;
-const NewClass = @import("../base.zig").NewClass;
-const d = @import("../base.zig").d;
+
const castObj = @import("../base.zig").castObj;
const getAllocator = @import("../base.zig").getAllocator;
-const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
+
const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;
const Environment = @import("../../env.zig");
const ZigString = JSC.ZigString;
diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig
index e2b104016..c01e72d60 100644
--- a/src/bun.js/webcore/request.zig
+++ b/src/bun.js/webcore/request.zig
@@ -23,11 +23,10 @@ const default_allocator = @import("root").bun.default_allocator;
const FeatureFlags = @import("root").bun.FeatureFlags;
const ArrayBuffer = @import("../base.zig").ArrayBuffer;
const Properties = @import("../base.zig").Properties;
-const NewClass = @import("../base.zig").NewClass;
-const d = @import("../base.zig").d;
+
const castObj = @import("../base.zig").castObj;
const getAllocator = @import("../base.zig").getAllocator;
-const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
+
const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;
const Environment = @import("../../env.zig");
const ZigString = JSC.ZigString;
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index 5d56c59d9..4b15efc0e 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -23,11 +23,10 @@ const default_allocator = @import("root").bun.default_allocator;
const FeatureFlags = @import("root").bun.FeatureFlags;
const ArrayBuffer = @import("../base.zig").ArrayBuffer;
const Properties = @import("../base.zig").Properties;
-const NewClass = @import("../base.zig").NewClass;
-const d = @import("../base.zig").d;
+
const castObj = @import("../base.zig").castObj;
const getAllocator = @import("../base.zig").getAllocator;
-const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
+
const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;
const Environment = @import("../../env.zig");
const ZigString = JSC.ZigString;
@@ -1683,250 +1682,3 @@ pub const Headers = struct {
return headers;
}
};
-
-// https://github.com/WebKit/WebKit/blob/main/Source/WebCore/workers/service/FetchEvent.h
-pub const FetchEvent = struct {
- started_waiting_at: u64 = 0,
- response: ?*Response = null,
- request_context: ?*RequestContext = null,
- request: Request,
- pending_promise: JSValue = JSValue.zero,
-
- onPromiseRejectionCtx: *anyopaque = undefined,
- onPromiseRejectionHandler: ?*const fn (ctx: *anyopaque, err: anyerror, fetch_event: *FetchEvent, value: JSValue) void = null,
- rejected: bool = false,
-
- pub const Class = NewClass(
- FetchEvent,
- .{
- .name = "FetchEvent",
- .read_only = true,
- .ts = .{ .class = d.ts.class{ .interface = true } },
- },
- .{
- .respondWith = .{
- .rfn = respondWith,
- .ts = d.ts{
- .tsdoc = "Render the response in the active HTTP request",
- .@"return" = "void",
- .args = &[_]d.ts.arg{
- .{ .name = "response", .@"return" = "Response" },
- },
- },
- },
- .waitUntil = waitUntil,
- .finalize = finalize,
- },
- .{
- .client = .{
- .get = getClient,
- .ro = true,
- .ts = d.ts{
- .tsdoc = "HTTP client metadata. This is not implemented yet, do not use.",
- .@"return" = "undefined",
- },
- },
- .request = .{
- .get = getRequest,
- .ro = true,
- .ts = d.ts{
- .tsdoc = "HTTP request",
- .@"return" = "InstanceType<Request>",
- },
- },
- },
- );
-
- pub fn finalize(
- this: *FetchEvent,
- ) void {
- VirtualMachine.get().allocator.destroy(this);
- }
-
- pub fn getClient(
- _: *FetchEvent,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- Output.prettyErrorln("FetchEvent.client is not implemented yet - sorry!!", .{});
- Output.flush();
- return js.JSValueMakeUndefined(ctx);
- }
- pub fn getRequest(
- this: *FetchEvent,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- var req = bun.default_allocator.create(Request) catch unreachable;
- req.* = this.request;
-
- return req.toJS(
- ctx,
- ).asObjectRef();
- }
-
- // https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith
- pub fn respondWith(
- this: *FetchEvent,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- var request_context = this.request_context orelse return js.JSValueMakeUndefined(ctx);
- if (request_context.has_called_done) return js.JSValueMakeUndefined(ctx);
- var globalThis = ctx.ptr();
- // A Response or a Promise that resolves to a Response. Otherwise, a network error is returned to Fetch.
- if (arguments.len == 0) {
- JSError(getAllocator(ctx), "event.respondWith() must be a Response or a Promise<Response>.", .{}, ctx, exception);
- request_context.sendInternalError(error.respondWithWasEmpty) catch {};
- return js.JSValueMakeUndefined(ctx);
- }
-
- var arg = arguments[0];
-
- var existing_response: ?*Response = arguments[0].?.value().as(Response);
-
- if (existing_response == null) {
- switch (JSValue.fromRef(arg).jsTypeLoose()) {
- .JSPromise => {
- this.pending_promise = JSValue.fromRef(arg);
- },
- else => {
- JSError(getAllocator(ctx), "event.respondWith() must be a Response or a Promise<Response>.", .{}, ctx, exception);
- request_context.sendInternalError(error.respondWithWasNotResponse) catch {};
- return js.JSValueMakeUndefined(ctx);
- },
- }
- }
-
- if (this.pending_promise.asAnyPromise()) |promise| {
- globalThis.bunVM().waitForPromise(promise);
-
- switch (promise.status(ctx.ptr().vm())) {
- .Fulfilled => {},
- else => {
- this.rejected = true;
- this.pending_promise = JSValue.zero;
- this.onPromiseRejectionHandler.?(
- this.onPromiseRejectionCtx,
- error.PromiseRejection,
- this,
- promise.result(globalThis.vm()),
- );
- return js.JSValueMakeUndefined(ctx);
- },
- }
-
- arg = promise.result(ctx.ptr().vm()).asRef();
- }
-
- var response: *Response = JSValue.c(arg.?).as(Response) orelse {
- this.rejected = true;
- this.pending_promise = JSValue.zero;
- JSError(getAllocator(ctx), "event.respondWith() expects Response or Promise<Response>", .{}, ctx, exception);
- this.onPromiseRejectionHandler.?(this.onPromiseRejectionCtx, error.RespondWithInvalidTypeInternal, this, JSValue.fromRef(exception.*));
- return js.JSValueMakeUndefined(ctx);
- };
-
- defer {
- if (!VirtualMachine.get().had_errors) {
- Output.printElapsed(@as(f64, @floatFromInt((request_context.timer.lap()))) / std.time.ns_per_ms);
-
- Output.prettyError(
- " <b>{s}<r><d> - <b>{d}<r> <d>transpiled, <d><b>{d}<r> <d>imports<r>\n",
- .{
- request_context.matched_route.?.name,
- VirtualMachine.get().transpiled_count,
- VirtualMachine.get().resolved_count,
- },
- );
- }
- }
-
- defer this.pending_promise = JSValue.zero;
- var needs_mime_type = true;
- var content_length: ?usize = null;
-
- if (response.body.init.headers) |headers_ref| {
- var headers = Headers.from(headers_ref, request_context.allocator, .{}) catch unreachable;
-
- var i: usize = 0;
- while (i < headers.entries.len) : (i += 1) {
- var header = headers.entries.get(i);
- const name = headers.asStr(header.name);
- if (strings.eqlComptime(name, "content-type") and headers.asStr(header.value).len > 0) {
- needs_mime_type = false;
- }
-
- if (strings.eqlComptime(name, "content-length")) {
- content_length = std.fmt.parseInt(usize, headers.asStr(header.value), 10) catch null;
- continue;
- }
-
- // Some headers need to be managed by bun
- if (strings.eqlComptime(name, "transfer-encoding") or
- strings.eqlComptime(name, "content-encoding") or
- strings.eqlComptime(name, "strict-transport-security") or
- strings.eqlComptime(name, "content-security-policy"))
- {
- continue;
- }
-
- request_context.appendHeaderSlow(
- name,
- headers.asStr(header.value),
- ) catch unreachable;
- }
- }
-
- if (needs_mime_type) {
- request_context.appendHeader("Content-Type", response.mimeTypeWithDefault(MimeType.html, request_context));
- }
-
- var blob = response.body.value.use();
- defer blob.deinit();
-
- const content_length_ = content_length orelse blob.size;
-
- if (content_length_ == 0) {
- request_context.sendNoContent() catch return js.JSValueMakeUndefined(ctx);
- return js.JSValueMakeUndefined(ctx);
- }
-
- if (FeatureFlags.strong_etags_for_built_files) {
- const did_send = request_context.writeETag(blob.sharedView()) catch false;
- if (did_send) {
- // defer getAllocator(ctx).destroy(str.ptr);
- return js.JSValueMakeUndefined(ctx);
- }
- }
-
- defer request_context.done();
-
- request_context.writeStatusSlow(response.body.init.status_code) catch return js.JSValueMakeUndefined(ctx);
- request_context.prepareToSendBody(content_length_, false) catch return js.JSValueMakeUndefined(ctx);
-
- request_context.writeBodyBuf(blob.sharedView()) catch return js.JSValueMakeUndefined(ctx);
-
- return js.JSValueMakeUndefined(ctx);
- }
-
- // our implementation of the event listener already does this
- // so this is a no-op for us
- pub fn waitUntil(
- _: *FetchEvent,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return js.JSValueMakeUndefined(ctx);
- }
-};
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig
index f2c5914ef..be6942392 100644
--- a/src/bun.js/webcore/streams.zig
+++ b/src/bun.js/webcore/streams.zig
@@ -22,11 +22,10 @@ const default_allocator = @import("root").bun.default_allocator;
const FeatureFlags = @import("root").bun.FeatureFlags;
const ArrayBuffer = @import("../base.zig").ArrayBuffer;
const Properties = @import("../base.zig").Properties;
-const NewClass = @import("../base.zig").NewClass;
-const d = @import("../base.zig").d;
+
const castObj = @import("../base.zig").castObj;
const getAllocator = @import("../base.zig").getAllocator;
-const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
+
const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;
const Environment = @import("../../env.zig");
const ZigString = JSC.ZigString;
diff --git a/src/bun.zig b/src/bun.zig
index b274efaaf..a4715a862 100644
--- a/src/bun.zig
+++ b/src/bun.zig
@@ -1587,3 +1587,8 @@ pub const ArenaAllocator = @import("./ArenaAllocator.zig").ArenaAllocator;
pub const Wyhash = @import("./wyhash.zig").Wyhash;
pub const RegularExpression = @import("./bun.js/bindings/RegularExpression.zig").RegularExpression;
+pub inline fn assertComptime() void {
+ if (comptime !@inComptime()) {
+ @compileError("This function can only be called in comptime.");
+ }
+}
diff --git a/src/http.zig b/src/http.zig
index 37a7158bb..f29b7cad9 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -1128,463 +1128,6 @@ pub const RequestContext = struct {
}
};
- pub const JavaScriptHandler = struct {
- ctx: RequestContext,
- conn: std.net.Stream,
- params: Router.Param.List,
-
- pub fn deinit(this: *JavaScriptHandler) void {
- this.params.deinit(bun.default_allocator);
- bun.default_allocator.destroy(this);
- }
-
- pub var javascript_vm: ?*JavaScript.VirtualMachine = null;
-
- pub const HandlerThread = struct {
- args: Api.TransformOptions,
- framework: Options.Framework,
- log: *logger.Log = undefined,
- watcher: *Watcher,
- env_loader: *DotEnv.Loader,
- origin: ZigURL,
- client_bundler: Bundler,
- vm: *JavaScript.VirtualMachine = undefined,
- start_timer: std.time.Timer = undefined,
- entry_point: string = "",
-
- pub fn handleJSError(
- this: *HandlerThread,
- comptime step: Api.FallbackStep,
- err: anyerror,
- ) !void {
- return try this.handleJSErrorFmt(
- step,
- err,
-
- "<r>JavaScript VM failed to start due to <red>{s}<r>.",
- .{
- @errorName(err),
- },
- );
- }
-
- pub fn handleJSErrorFmt(this: *HandlerThread, comptime step: Api.FallbackStep, err: anyerror, comptime fmt: string, args: anytype) !void {
- var arena = ThreadlocalArena.init() catch unreachable;
- var allocator = arena.allocator();
- defer arena.deinit();
-
- defer this.log.msgs.clearRetainingCapacity();
-
- if (Output.enable_ansi_colors) {
- if (this.log.msgs.items.len > 0) {
- for (this.log.msgs.items) |msg| {
- msg.writeFormat(Output.errorWriter(), true) catch continue;
- }
- }
- } else {
- if (this.log.msgs.items.len > 0) {
- for (this.log.msgs.items) |msg| {
- msg.writeFormat(Output.errorWriter(), false) catch continue;
- }
- }
- }
-
- Output.prettyErrorln(fmt, args);
- Output.flush();
-
- while (channel.tryReadItem() catch null) |item| {
- item.ctx.renderFallback(
- allocator,
- &this.client_bundler,
- step,
- this.log,
- err,
- &[_]Api.JsException{},
- comptime Output.prettyFmt(fmt, false),
- args,
- ) catch {};
- }
- }
-
- pub fn handleRuntimeJSError(this: *HandlerThread, js_value: JavaScript.JSValue, comptime step: Api.FallbackStep, comptime fmt: string, args: anytype) !void {
- var arena = ThreadlocalArena.init() catch unreachable;
- var allocator = arena.allocator();
- defer arena.deinit();
- defer this.log.msgs.clearRetainingCapacity();
-
- var exception_list: std.ArrayList(Api.JsException) = std.ArrayList(Api.JsException).init(allocator);
- defer exception_list.deinit();
-
- if (!js_value.isUndefinedOrNull()) {
- javascript_vm.?.runErrorHandler(
- js_value,
- &exception_list,
- );
- } else {
- if (Output.enable_ansi_colors) {
- if (this.log.msgs.items.len > 0) {
- for (this.log.msgs.items) |msg| {
- msg.writeFormat(Output.errorWriter(), true) catch continue;
- }
- }
- } else {
- if (this.log.msgs.items.len > 0) {
- for (this.log.msgs.items) |msg| {
- msg.writeFormat(Output.errorWriter(), false) catch continue;
- }
- }
- }
-
- Output.flush();
- }
-
- while (channel.tryReadItem() catch null) |item| {
- item.ctx.renderFallback(
- allocator,
- &this.client_bundler,
- step,
- this.log,
- error.JSError,
- exception_list.items,
- comptime Output.prettyFmt(fmt, false),
- args,
- ) catch {};
- }
- }
-
- pub fn handleFetchEventError(this: *HandlerThread, err: anyerror, js_value: JavaScript.JSValue, ctx: *RequestContext) !void {
- var arena = ThreadlocalArena.init() catch unreachable;
- var allocator = arena.allocator();
- defer arena.deinit();
-
- defer this.log.msgs.clearRetainingCapacity();
-
- var exception_list: std.ArrayList(Api.JsException) = std.ArrayList(Api.JsException).init(allocator);
- defer exception_list.deinit();
- var did_log_messages = false;
- if (!js_value.isUndefinedOrNull()) {
- var start_count = this.log.msgs.items.len;
- javascript_vm.?.runErrorHandler(
- js_value,
- &exception_list,
- );
- did_log_messages = start_count != this.log.msgs.items.len and exception_list.items.len == 0;
- } else {
- if (Output.enable_ansi_colors) {
- if (this.log.msgs.items.len > 0) {
- for (this.log.msgs.items) |msg| {
- msg.writeFormat(Output.errorWriter(), true) catch continue;
- }
- }
- } else {
- if (this.log.msgs.items.len > 0) {
- for (this.log.msgs.items) |msg| {
- msg.writeFormat(Output.errorWriter(), false) catch continue;
- }
- }
- }
-
- Output.flush();
- }
-
- ctx.renderFallback(
- allocator,
- &this.client_bundler,
- Api.FallbackStep.fetch_event_handler,
- this.log,
- if (did_log_messages) error.BuildTimeError else err,
- exception_list.items,
- "",
- .{},
- ) catch {};
- }
- };
-
- pub const Channel = sync.Channel(*JavaScriptHandler, .{ .Static = 100 });
- pub var channel: Channel = undefined;
- var has_loaded_channel = false;
- pub var javascript_disabled = false;
- var js_thread: std.Thread = undefined;
- pub fn spawnThread(handler: *HandlerThread) !void {
- js_thread = try std.Thread.spawn(.{ .stack_size = 64 * 1024 * 1024 }, spawn, .{handler});
- if (!Environment.isMac) js_thread.setName("JavaScript SSR") catch {};
- js_thread.detach();
- }
-
- pub fn spawn(handler: *HandlerThread) void {
- _spawn(handler) catch {};
- }
-
- pub fn startJavaScript(handler: *HandlerThread) void {
- defer {
- javascript_disabled = true;
- }
- var vm = handler.vm;
- const entry_point = handler.entry_point;
- {
- var load_result = vm.loadEntryPoint(
- entry_point,
- ) catch |err| {
- handler.handleJSErrorFmt(
- .load_entry_point,
- err,
- "<r>JavaScript VM failed to start.\n<red>{s}:<r> while loading <r><b>\"{s}\"",
- .{ @errorName(err), entry_point },
- ) catch {};
- vm.flush();
-
- return;
- };
-
- switch (load_result.status(vm.global.vm())) {
- JavaScript.JSPromise.Status.Fulfilled => {},
- else => {
- var result = load_result.result(vm.global.vm());
-
- handler.handleRuntimeJSError(
- result,
- .eval_entry_point,
- "<r>JavaScript VM failed to start.\nwhile loading <r><b>\"{s}\"",
- .{entry_point},
- ) catch {};
- vm.flush();
- return;
- },
- }
-
- if (vm.event_listeners.count() == 0) {
- handler.handleJSErrorFmt(
- .eval_entry_point,
- error.MissingFetchHandler,
- "<r><red>error<r>: Framework didn't run <b><cyan>addEventListener(\"fetch\", callback)<r>, which means it can't accept HTTP requests.\nShutting down JS.",
- .{},
- ) catch {};
- vm.flush();
- return;
- }
- }
-
- js_ast.Stmt.Data.Store.reset();
- js_ast.Expr.Data.Store.reset();
- JavaScript.API.Bun.flushCSSImports();
- vm.flush();
-
- Output.printElapsed(@as(f64, @floatFromInt((handler.start_timer.read()))) / std.time.ns_per_ms);
-
- if (vm.bundler.options.framework.?.display_name.len > 0) {
- Output.prettyError(
- " {s} ready<d>! (powered by bun)\n<r>",
- .{
- vm.bundler.options.framework.?.display_name,
- },
- );
- } else {
- Output.prettyError(
- " bun.js started\n<r>",
- .{},
- );
- }
-
- Output.flush();
-
- runLoop(
- vm,
- handler,
- ) catch {};
- }
-
- pub fn _spawn(handler: *HandlerThread) !void {
- handler.start_timer = std.time.Timer.start() catch unreachable;
-
- Output.Source.configureThread();
- bun.JSC.initialize();
-
- js_ast.Stmt.Data.Store.create(bun.default_allocator);
- js_ast.Expr.Data.Store.create(bun.default_allocator);
-
- var vm: *JavaScript.VirtualMachine = JavaScript.VirtualMachine.init(.{
- .allocator = bun.default_allocator,
- .args = handler.args,
- .log = handler.log,
- .env_loader = handler.env_loader,
- .store_fd = true,
- }) catch |err| {
- handler.handleJSError(.create_vm, err) catch {};
- javascript_disabled = true;
- return;
- };
- vm.bundler.options.macro_remap = try handler.client_bundler.options.macro_remap.clone(bun.default_allocator);
- vm.bundler.macro_context = js_ast.Macro.MacroContext.init(&vm.bundler);
-
- vm.is_from_devserver = true;
- vm.bundler.log = handler.log;
- std.debug.assert(JavaScript.VirtualMachine.isLoaded());
- javascript_vm = vm;
- vm.bundler.options.origin = handler.origin;
- vm.bundler.options.no_macros = handler.client_bundler.options.no_macros;
- const boot = vm.bundler.options.framework.?.server.path;
- std.debug.assert(boot.len > 0);
- errdefer vm.deinit();
- vm.bun_dev_watcher = handler.watcher;
- {
- vm.bundler.configureRouter(false) catch |err| {
- handler.handleJSError(.configure_router, err) catch {};
- vm.flush();
- javascript_disabled = true;
- return;
- };
- vm.bundler.configureDefines() catch |err| {
- handler.handleJSError(.configure_defines, err) catch {};
- vm.flush();
- javascript_disabled = true;
- return;
- };
-
- var entry_point = boot;
- if (!std.fs.path.isAbsolute(entry_point)) {
- const resolved_entry_point = vm.bundler.resolver.resolve(
- std.fs.path.dirname(boot) orelse vm.bundler.fs.top_level_dir,
- vm.bundler.normalizeEntryPointPath(boot),
- .entry_point,
- ) catch |err| {
- try handler.handleJSError(
- .resolve_entry_point,
- err,
- );
- javascript_disabled = true;
- return;
- };
- entry_point = (resolved_entry_point.pathConst() orelse {
- handler.handleJSErrorFmt(
- .resolve_entry_point,
- error.EntryPointDisabled,
- "<r>JavaScript VM failed to start due to disabled entry point: <r><b>\"{s}\"",
- .{resolved_entry_point.path_pair.primary.text},
- ) catch {};
- javascript_disabled = true;
- return;
- }).text;
- }
-
- handler.entry_point = entry_point;
- }
- handler.vm = vm;
- vm.global.vm().holdAPILock(handler, JavaScript.OpaqueWrap(HandlerThread, startJavaScript));
- }
-
- var __arena: ThreadlocalArena = undefined;
-
- pub fn runLoop(vm: *JavaScript.VirtualMachine, thread: *HandlerThread) !void {
- var module_map = JavaScript.ZigGlobalObject.getModuleRegistryMap(vm.global);
-
- if (!JavaScript.VM.isJITEnabled()) {
- Output.prettyErrorln("<red><r>warn:<r> JIT is disabled,,,this is a bug in bun and/or a permissions problem. JS will run slower.", .{});
- if (vm.bundler.env.map.get("BUN_CRASH_WITHOUT_JIT") != null) {
- Global.crash();
- }
- }
-
- while (true) {
- __arena = ThreadlocalArena.init() catch unreachable;
- JavaScript.VirtualMachine.get().arena = &__arena;
- JavaScript.VirtualMachine.get().has_loaded = true;
- JavaScript.VirtualMachine.get().tick();
- defer {
- JavaScript.VirtualMachine.get().flush();
- std.debug.assert(
- JavaScript.ZigGlobalObject.resetModuleRegistryMap(vm.global, module_map),
- );
- js_ast.Stmt.Data.Store.reset();
- js_ast.Expr.Data.Store.reset();
- JavaScript.API.Bun.flushCSSImports();
- Output.flush();
- JavaScript.VirtualMachine.get().arena.deinit();
- JavaScript.VirtualMachine.get().has_loaded = false;
- }
-
- var handler: *JavaScriptHandler = try channel.readItem();
- JavaScript.VirtualMachine.get().tick();
- JavaScript.VirtualMachine.get().preflush();
- const original_origin = vm.origin;
- vm.origin = handler.ctx.origin;
- defer vm.origin = original_origin;
- handler.ctx.arena = __arena;
- handler.ctx.allocator = __arena.allocator();
- var req_body = handler.ctx.req_body_node;
- JavaScript.EventListenerMixin.emitFetchEvent(
- vm,
- &handler.ctx,
- HandlerThread,
- thread,
- HandlerThread.handleFetchEventError,
- ) catch {};
- Server.current.releaseRequestDataPoolNode(req_body);
- JavaScript.VirtualMachine.get().tick();
- handler.deinit();
- }
- }
-
- var one: [1]*JavaScriptHandler = undefined;
- pub fn enqueue(ctx: *RequestContext, server: *Server, params: *Router.Param.List) !void {
- if (JavaScriptHandler.javascript_disabled) {
- try ctx.renderFallback(
- ctx.allocator,
- ctx.bundler,
- Api.FallbackStep.ssr_disabled,
- &ctx.log,
- error.JSDisabled,
- &.{},
- "",
- .{},
- );
- return;
- }
-
- var clone = try server.allocator.create(JavaScriptHandler);
- clone.* = JavaScriptHandler{
- .ctx = ctx.*,
- .conn = ctx.conn,
- .params = if (params.len > 0)
- try params.clone(server.allocator)
- else
- Router.Param.List{},
- };
-
- clone.ctx.conn = clone.conn;
- clone.ctx.matched_route.?.params = &clone.params;
-
- // this is a threadlocal arena
- clone.ctx.arena.deinit();
- clone.ctx.allocator = undefined;
-
- if (!has_loaded_channel) {
- var handler_thread = try server.allocator.create(HandlerThread);
-
- has_loaded_channel = true;
- channel = Channel.init();
-
- handler_thread.* = HandlerThread{
- .args = server.transform_options,
- .framework = server.bundler.options.framework.?,
- .watcher = server.watcher,
- .env_loader = server.bundler.env,
- .log = undefined,
- .origin = server.bundler.options.origin,
- .client_bundler = undefined,
- };
- try server.bundler.clone(server.allocator, &handler_thread.client_bundler);
- handler_thread.log = try server.allocator.create(logger.Log);
- handler_thread.log.* = logger.Log.init(server.allocator);
-
- try JavaScriptHandler.spawnThread(handler_thread);
- }
-
- defer ctx.controlled = true;
- one[0] = clone;
- _ = try channel.write(&one);
- }
- };
-
pub const WebsocketHandler = struct {
accept_key: [28]u8 = undefined,
ctx: RequestContext,
@@ -2592,88 +2135,6 @@ pub const RequestContext = struct {
}
}
- fn handleBlobURL(ctx: *RequestContext, _: *Server) !void {
- var id = ctx.url.path["blob:".len..];
-
- var line: string = "";
- var column: string = "";
-
- // This makes it Just Work if you pass a line/column number
- if (strings.indexOfChar(id, ':')) |colon| {
- line = id[@min(id.len, colon + 1)..];
- id = id[0..colon];
-
- if (strings.indexOfChar(line, ':')) |col| {
- column = line[@min(line.len, col + 1)..];
- line = line[0..col];
- }
- }
-
- const Blob = @import("./blob.zig");
-
- const blob: Blob = brk: {
- // It could be a blob either for macros or for JS thread
- if (JavaScriptHandler.javascript_vm) |vm| {
- if (vm.blobs.?.get(id)) |blob| {
- break :brk blob;
- }
- }
-
- if (JavaScript.VirtualMachine.isLoaded()) {
- var vm = JavaScript.VirtualMachine.get();
- if (vm.blobs.?.get(id)) |blob| {
- break :brk blob;
- }
- }
-
- return try ctx.sendNotFound();
- };
-
- if (blob.len == 0) {
- try ctx.sendNoContent();
- return;
- }
-
- if (ctx.header("Open-In-Editor") != null) {
- if (http_editor_context.editor == null) {
- http_editor_context.detectEditor(ctx.bundler.env);
- }
-
- if (line.len == 0) {
- if (ctx.header("Editor-Line")) |_line| {
- line = _line;
- }
- }
-
- if (column.len == 0) {
- if (ctx.header("Editor-Column")) |_column| {
- column = _column;
- }
- }
-
- if (http_editor_context.editor) |editor| {
- if (editor != .none) {
- http_editor_context.openInEditor(editor, blob.ptr[0..blob.len], id, Fs.FileSystem.instance.tmpdir(), line, column);
- if (http_editor_context.editor.? != .none) {
- defer ctx.done();
- try ctx.writeStatus(200);
- ctx.appendHeader("Content-Type", MimeType.html.value);
- const auto_close = "<html><body><h1>Opened in editor!</h1><script>window.close();</script></body></html>";
- try ctx.prepareToSendBody(auto_close.len, false);
- try ctx.writeBodyBuf(auto_close);
- return;
- }
- }
- }
- }
-
- defer ctx.done();
- try ctx.writeStatus(200);
- ctx.appendHeader("Content-Type", MimeType.text.value);
- try ctx.prepareToSendBody(blob.len, false);
- try ctx.writeBodyBuf(blob.ptr[0..blob.len]);
- }
-
fn handleBunURL(ctx: *RequestContext, server: *Server) !void {
const path = ctx.url.path["bun:".len..];
@@ -2983,10 +2444,6 @@ pub const RequestContext = struct {
}
pub fn handleReservedRoutes(ctx: *RequestContext, server: *Server) !bool {
- if (strings.hasPrefixComptime(ctx.url.path, "blob:")) {
- try ctx.handleBlobURL(server);
- return true;
- }
// From HTTP, we serve files with a hash modkey
// The format is
@@ -3870,10 +3327,7 @@ pub const Server = struct {
.unspecified => {},
}
- if (debug.fallback_only or server.bundler.env.map.get("BUN_DISABLE_BUN_JS") != null) {
- RequestContext.fallback_only = true;
- RequestContext.JavaScriptHandler.javascript_disabled = true;
- }
+ RequestContext.fallback_only = true;
Analytics.Features.filesystem_router = server.bundler.router != null;
diff --git a/src/js/_codegen/build-functions.ts b/src/js/_codegen/build-functions.ts
index b5c0eeee9..761682d44 100644
--- a/src/js/_codegen/build-functions.ts
+++ b/src/js/_codegen/build-functions.ts
@@ -6,7 +6,7 @@ import { cap, fmtCPPString, low } from "./helpers";
import { spawn } from "bun";
async function createStaticHashtables() {
- const STATIC_HASH_TABLES = ["src/bun.js/bindings/Process.cpp"];
+ const STATIC_HASH_TABLES = ["src/bun.js/bindings/Process.cpp", "src/bun.js/bindings/BunObject.cpp"];
console.time("Creating static hash tables...");
const create_hash_table = path.join(import.meta.dir, "../../../src/bun.js/scripts/create_hash_table");
if (!create_hash_table) {
diff --git a/src/js/bun/ffi.ts b/src/js/bun/ffi.ts
index 3db685bb3..e7a9f469d 100644
--- a/src/js/bun/ffi.ts
+++ b/src/js/bun/ffi.ts
@@ -113,8 +113,8 @@ class CString extends String {
super(
ptr
? typeof byteLength === "number" && Number.isSafeInteger(byteLength)
- ? new BunCString(ptr, byteOffset || 0, byteLength)
- : new BunCString(ptr)
+ ? BunCString(ptr, byteOffset || 0, byteLength)
+ : BunCString(ptr)
: "",
);
this.ptr = typeof ptr === "number" ? ptr : 0;
@@ -403,6 +403,10 @@ function dlopen(path, options) {
}
}
+ // Bind it because it's a breaking change to not do so
+ // Previously, it didn't need to be bound
+ result.close = result.close.bind(result);
+
return result;
}
@@ -433,7 +437,7 @@ function CFunction(options) {
[identifier]: options,
});
var hasClosed = false;
- var close = result.close;
+ var close = result.close.bind(result);
result.symbols[identifier].close = () => {
if (hasClosed || !close) return;
hasClosed = true;
diff --git a/src/js/internal/debugger.ts b/src/js/internal/debugger.ts
index 2fd875d10..2b121949a 100644
--- a/src/js/internal/debugger.ts
+++ b/src/js/internal/debugger.ts
@@ -100,28 +100,35 @@ class WebSocketListener {
idleTimeout: 0,
open: socket => {
var connection = new DebuggerWithMessageQueue();
+ // @ts-expect-error
+ const shouldRefEventLoop = !!socket.data?.shouldRefEventLoop;
+
socket.data = connection;
this.activeConnections.add(socket);
- connection.debugger = this.createInspectorConnection(this.scriptExecutionContextId, (...msgs: string[]) => {
- if (socket.readyState > 1) {
- connection.disconnect();
- return;
- }
+ connection.debugger = this.createInspectorConnection(
+ this.scriptExecutionContextId,
+ shouldRefEventLoop,
+ (...msgs: string[]) => {
+ if (socket.readyState > 1) {
+ connection.disconnect();
+ return;
+ }
- if (connection.messageQueue.length > 0) {
- connection.messageQueue.push(...msgs);
- return;
- }
+ if (connection.messageQueue.length > 0) {
+ connection.messageQueue.push(...msgs);
+ return;
+ }
- for (let i = 0; i < msgs.length; i++) {
- if (!socket.sendText(msgs[i])) {
- if (socket.readyState < 2) {
- connection.messageQueue.push(...msgs.slice(i));
+ for (let i = 0; i < msgs.length; i++) {
+ if (!socket.sendText(msgs[i])) {
+ if (socket.readyState < 2) {
+ connection.messageQueue.push(...msgs.slice(i));
+ }
+ return;
}
- return;
}
- }
- });
+ },
+ );
console.log(
"[Inspector]",
@@ -180,7 +187,14 @@ class WebSocketListener {
}
if (pathname === this.url) {
- if (server.upgrade(req)) {
+ const refHeader = req.headers.get("Ref-Event-Loop");
+ if (
+ server.upgrade(req, {
+ data: {
+ shouldRefEventLoop: !!refHeader && refHeader !== "0",
+ },
+ })
+ ) {
return new Response();
}
diff --git a/src/js/out/InternalModuleRegistryConstants.h b/src/js/out/InternalModuleRegistryConstants.h
index 4e03279fa..0b6561e86 100644
--- a/src/js/out/InternalModuleRegistryConstants.h
+++ b/src/js/out/InternalModuleRegistryConstants.h
@@ -6,7 +6,7 @@ namespace InternalModuleRegistryConstants {
#if __APPLE__
//
-static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";// src/js/out/tmp/bun/ffi.ts\nvar FFIBuilder = function(params, returnType, functionToCall, name) {\n const hasReturnType = typeof FFIType[returnType] === \"number\" && FFIType[returnType] !== FFIType.void;\n var paramNames = new Array(params.length), args = new Array(params.length);\n for (let i = 0;i < params.length; i++) {\n paramNames[i] = `p${i}`;\n const wrapper = ffiWrappers[FFIType[params[i]]];\n if (wrapper)\n args[i] = `(val=>${wrapper})(p${i})`;\n else\n @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`);\n }\n var code = `functionToCall(${args.join(\", \")})`;\n if (hasReturnType)\n if (FFIType[returnType] === FFIType.cstring)\n code = `return new __GlobalBunCString(${code})`;\n else\n code = `return ${code}`;\n var func = new Function(\"functionToCall\", ...paramNames, code);\n Object.defineProperty(func, \"name\", {\n value: name\n });\n var wrap;\n switch (paramNames.length) {\n case 0:\n wrap = () => func(functionToCall);\n break;\n case 1:\n wrap = (arg1) => func(functionToCall, arg1);\n break;\n case 2:\n wrap = (arg1, arg2) => func(functionToCall, arg1, arg2);\n break;\n case 3:\n wrap = (arg1, arg2, arg3) => func(functionToCall, arg1, arg2, arg3);\n break;\n case 4:\n wrap = (arg1, arg2, arg3, arg4) => func(functionToCall, arg1, arg2, arg3, arg4);\n break;\n case 5:\n wrap = (arg1, arg2, arg3, arg4, arg5) => func(functionToCall, arg1, arg2, arg3, arg4, arg5);\n break;\n case 6:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6);\n break;\n case 7:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n break;\n case 8:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n break;\n case 9:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);\n break;\n default: {\n wrap = (...args2) => func(functionToCall, ...args2);\n break;\n }\n }\n return wrap.native = functionToCall, wrap.ptr = functionToCall.ptr, wrap;\n}, dlopen = function(path, options) {\n const result = nativeDLOpen(path, options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, path.includes(\"/\") \? `${key} (${path.split(\"/\").pop()})` : `${key} (${path})`);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, linkSymbols = function(options) {\n const result = nativeLinkSymbols(options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, key);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, onCloseCFunction = function(close) {\n close();\n}, CFunction = function(options) {\n const identifier = `CFunction${cFunctionI++}`;\n var result = linkSymbols({\n [identifier]: options\n }), hasClosed = !1, close = result.close;\n return result.symbols[identifier].close = () => {\n if (hasClosed || !close)\n return;\n hasClosed = !0, close(), close = void 0;\n }, cFunctionRegistry ||= new FinalizationRegistry(onCloseCFunction), cFunctionRegistry.register(result.symbols[identifier], result.symbols[identifier].close), result.symbols[identifier];\n}, $, FFIType = {\n \"0\": 0,\n \"1\": 1,\n \"2\": 2,\n \"3\": 3,\n \"4\": 4,\n \"5\": 5,\n \"6\": 6,\n \"7\": 7,\n \"8\": 8,\n \"9\": 9,\n \"10\": 10,\n \"11\": 11,\n \"12\": 12,\n \"13\": 13,\n \"14\": 14,\n \"15\": 15,\n \"16\": 16,\n \"17\": 17,\n bool: 11,\n c_int: 5,\n c_uint: 6,\n char: 0,\n \"char*\": 12,\n double: 9,\n f32: 10,\n f64: 9,\n float: 10,\n i16: 3,\n i32: 5,\n i64: 7,\n i8: 1,\n int: 5,\n int16_t: 3,\n int32_t: 5,\n int64_t: 7,\n int8_t: 1,\n isize: 7,\n u16: 4,\n u32: 6,\n u64: 8,\n u8: 2,\n uint16_t: 4,\n uint32_t: 6,\n uint64_t: 8,\n uint8_t: 2,\n usize: 8,\n \"void*\": 12,\n ptr: 12,\n pointer: 12,\n void: 13,\n cstring: 14,\n i64_fast: 15,\n u64_fast: 16,\n function: 17,\n callback: 17,\n fn: 17\n};\nvar ffi = globalThis.Bun.FFI, ptr = (arg1, arg2) => typeof arg2 === \"undefined\" \? ffi.ptr(arg1) : ffi.ptr(arg1, arg2), toBuffer = ffi.toBuffer, toArrayBuffer = ffi.toArrayBuffer, viewSource = ffi.viewSource, BunCString = ffi.CString, nativeLinkSymbols = ffi.linkSymbols, nativeDLOpen = ffi.dlopen, nativeCallback = ffi.callback, closeCallback = ffi.closeCallback;\ndelete ffi.callback;\ndelete ffi.closeCallback;\n\nclass JSCallback {\n constructor(cb, options) {\n const { ctx, ptr: ptr2 } = nativeCallback(options, cb);\n this.#ctx = ctx, this.ptr = ptr2, this.#threadsafe = !!options\?.threadsafe;\n }\n ptr;\n #ctx;\n #threadsafe;\n get threadsafe() {\n return this.#threadsafe;\n }\n [Symbol.toPrimitive]() {\n const { ptr: ptr2 } = this;\n return typeof ptr2 === \"number\" \? ptr2 : 0;\n }\n close() {\n const ctx = this.#ctx;\n if (this.ptr = null, this.#ctx = null, ctx)\n closeCallback(ctx);\n }\n}\n\nclass CString extends String {\n constructor(ptr2, byteOffset, byteLength) {\n super(ptr2 \? typeof byteLength === \"number\" && Number.isSafeInteger(byteLength) \? new BunCString(ptr2, byteOffset || 0, byteLength) : new BunCString(ptr2) : \"\");\n if (this.ptr = typeof ptr2 === \"number\" \? ptr2 : 0, typeof byteOffset !== \"undefined\")\n this.byteOffset = byteOffset;\n if (typeof byteLength !== \"undefined\")\n this.byteLength = byteLength;\n }\n ptr;\n byteOffset;\n byteLength;\n #cachedArrayBuffer;\n get arrayBuffer() {\n if (this.#cachedArrayBuffer)\n return this.#cachedArrayBuffer;\n if (!this.ptr)\n return this.#cachedArrayBuffer = new ArrayBuffer(0);\n return this.#cachedArrayBuffer = toArrayBuffer(this.ptr, this.byteOffset, this.byteLength);\n }\n}\nObject.defineProperty(globalThis, \"__GlobalBunCString\", {\n value: CString,\n enumerable: !1,\n configurable: !1\n});\nvar ffiWrappers = new Array(18), char = \"val|0\";\nffiWrappers.fill(char);\nffiWrappers[FFIType.uint8_t] = \"val<0\?0:val>=255\?255:val|0\";\nffiWrappers[FFIType.int16_t] = \"val<=-32768\?-32768:val>=32768\?32768:val|0\";\nffiWrappers[FFIType.uint16_t] = \"val<=0\?0:val>=65536\?65536:val|0\";\nffiWrappers[FFIType.int32_t] = \"val|0\";\nffiWrappers[FFIType.uint32_t] = \"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\";\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.int64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.uint64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`;\nffiWrappers[FFIType.uint16_t] = `{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`;\nffiWrappers[FFIType.double] = `{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`;\nffiWrappers[FFIType.float] = ffiWrappers[10] = `{\n return Math.fround(val);\n}`;\nffiWrappers[FFIType.bool] = `{\n return !!val;\n}`;\nObject.defineProperty(globalThis, \"__GlobalBunFFIPtrFunctionForWrapper\", {\n value: ptr,\n enumerable: !1,\n configurable: !0\n});\nffiWrappers[FFIType.cstring] = ffiWrappers[FFIType.pointer] = `{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`;\nffiWrappers[FFIType.function] = `{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;\nvar native = {\n dlopen: nativeDLOpen,\n callback: () => {\n throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\");\n }\n}, cFunctionI = 0, cFunctionRegistry, read = ffi.read;\n$ = {\n CFunction,\n CString,\n FFIType,\n JSCallback,\n dlopen,\n linkSymbols,\n native,\n ptr,\n read,\n suffix: \"dylib\",\n toArrayBuffer,\n toBuffer,\n viewSource\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";// src/js/out/tmp/bun/ffi.ts\nvar FFIBuilder = function(params, returnType, functionToCall, name) {\n const hasReturnType = typeof FFIType[returnType] === \"number\" && FFIType[returnType] !== FFIType.void;\n var paramNames = new Array(params.length), args = new Array(params.length);\n for (let i = 0;i < params.length; i++) {\n paramNames[i] = `p${i}`;\n const wrapper = ffiWrappers[FFIType[params[i]]];\n if (wrapper)\n args[i] = `(val=>${wrapper})(p${i})`;\n else\n @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`);\n }\n var code = `functionToCall(${args.join(\", \")})`;\n if (hasReturnType)\n if (FFIType[returnType] === FFIType.cstring)\n code = `return new __GlobalBunCString(${code})`;\n else\n code = `return ${code}`;\n var func = new Function(\"functionToCall\", ...paramNames, code);\n Object.defineProperty(func, \"name\", {\n value: name\n });\n var wrap;\n switch (paramNames.length) {\n case 0:\n wrap = () => func(functionToCall);\n break;\n case 1:\n wrap = (arg1) => func(functionToCall, arg1);\n break;\n case 2:\n wrap = (arg1, arg2) => func(functionToCall, arg1, arg2);\n break;\n case 3:\n wrap = (arg1, arg2, arg3) => func(functionToCall, arg1, arg2, arg3);\n break;\n case 4:\n wrap = (arg1, arg2, arg3, arg4) => func(functionToCall, arg1, arg2, arg3, arg4);\n break;\n case 5:\n wrap = (arg1, arg2, arg3, arg4, arg5) => func(functionToCall, arg1, arg2, arg3, arg4, arg5);\n break;\n case 6:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6);\n break;\n case 7:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n break;\n case 8:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n break;\n case 9:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);\n break;\n default: {\n wrap = (...args2) => func(functionToCall, ...args2);\n break;\n }\n }\n return wrap.native = functionToCall, wrap.ptr = functionToCall.ptr, wrap;\n}, dlopen = function(path, options) {\n const result = nativeDLOpen(path, options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, path.includes(\"/\") \? `${key} (${path.split(\"/\").pop()})` : `${key} (${path})`);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result.close = result.close.bind(result), result;\n}, linkSymbols = function(options) {\n const result = nativeLinkSymbols(options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, key);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, onCloseCFunction = function(close) {\n close();\n}, CFunction = function(options) {\n const identifier = `CFunction${cFunctionI++}`;\n var result = linkSymbols({\n [identifier]: options\n }), hasClosed = !1, close = result.close.bind(result);\n return result.symbols[identifier].close = () => {\n if (hasClosed || !close)\n return;\n hasClosed = !0, close(), close = void 0;\n }, cFunctionRegistry ||= new FinalizationRegistry(onCloseCFunction), cFunctionRegistry.register(result.symbols[identifier], result.symbols[identifier].close), result.symbols[identifier];\n}, $, FFIType = {\n \"0\": 0,\n \"1\": 1,\n \"2\": 2,\n \"3\": 3,\n \"4\": 4,\n \"5\": 5,\n \"6\": 6,\n \"7\": 7,\n \"8\": 8,\n \"9\": 9,\n \"10\": 10,\n \"11\": 11,\n \"12\": 12,\n \"13\": 13,\n \"14\": 14,\n \"15\": 15,\n \"16\": 16,\n \"17\": 17,\n bool: 11,\n c_int: 5,\n c_uint: 6,\n char: 0,\n \"char*\": 12,\n double: 9,\n f32: 10,\n f64: 9,\n float: 10,\n i16: 3,\n i32: 5,\n i64: 7,\n i8: 1,\n int: 5,\n int16_t: 3,\n int32_t: 5,\n int64_t: 7,\n int8_t: 1,\n isize: 7,\n u16: 4,\n u32: 6,\n u64: 8,\n u8: 2,\n uint16_t: 4,\n uint32_t: 6,\n uint64_t: 8,\n uint8_t: 2,\n usize: 8,\n \"void*\": 12,\n ptr: 12,\n pointer: 12,\n void: 13,\n cstring: 14,\n i64_fast: 15,\n u64_fast: 16,\n function: 17,\n callback: 17,\n fn: 17\n};\nvar ffi = globalThis.Bun.FFI, ptr = (arg1, arg2) => typeof arg2 === \"undefined\" \? ffi.ptr(arg1) : ffi.ptr(arg1, arg2), toBuffer = ffi.toBuffer, toArrayBuffer = ffi.toArrayBuffer, viewSource = ffi.viewSource, BunCString = ffi.CString, nativeLinkSymbols = ffi.linkSymbols, nativeDLOpen = ffi.dlopen, nativeCallback = ffi.callback, closeCallback = ffi.closeCallback;\ndelete ffi.callback;\ndelete ffi.closeCallback;\n\nclass JSCallback {\n constructor(cb, options) {\n const { ctx, ptr: ptr2 } = nativeCallback(options, cb);\n this.#ctx = ctx, this.ptr = ptr2, this.#threadsafe = !!options\?.threadsafe;\n }\n ptr;\n #ctx;\n #threadsafe;\n get threadsafe() {\n return this.#threadsafe;\n }\n [Symbol.toPrimitive]() {\n const { ptr: ptr2 } = this;\n return typeof ptr2 === \"number\" \? ptr2 : 0;\n }\n close() {\n const ctx = this.#ctx;\n if (this.ptr = null, this.#ctx = null, ctx)\n closeCallback(ctx);\n }\n}\n\nclass CString extends String {\n constructor(ptr2, byteOffset, byteLength) {\n super(ptr2 \? typeof byteLength === \"number\" && Number.isSafeInteger(byteLength) \? BunCString(ptr2, byteOffset || 0, byteLength) : BunCString(ptr2) : \"\");\n if (this.ptr = typeof ptr2 === \"number\" \? ptr2 : 0, typeof byteOffset !== \"undefined\")\n this.byteOffset = byteOffset;\n if (typeof byteLength !== \"undefined\")\n this.byteLength = byteLength;\n }\n ptr;\n byteOffset;\n byteLength;\n #cachedArrayBuffer;\n get arrayBuffer() {\n if (this.#cachedArrayBuffer)\n return this.#cachedArrayBuffer;\n if (!this.ptr)\n return this.#cachedArrayBuffer = new ArrayBuffer(0);\n return this.#cachedArrayBuffer = toArrayBuffer(this.ptr, this.byteOffset, this.byteLength);\n }\n}\nObject.defineProperty(globalThis, \"__GlobalBunCString\", {\n value: CString,\n enumerable: !1,\n configurable: !1\n});\nvar ffiWrappers = new Array(18), char = \"val|0\";\nffiWrappers.fill(char);\nffiWrappers[FFIType.uint8_t] = \"val<0\?0:val>=255\?255:val|0\";\nffiWrappers[FFIType.int16_t] = \"val<=-32768\?-32768:val>=32768\?32768:val|0\";\nffiWrappers[FFIType.uint16_t] = \"val<=0\?0:val>=65536\?65536:val|0\";\nffiWrappers[FFIType.int32_t] = \"val|0\";\nffiWrappers[FFIType.uint32_t] = \"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\";\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.int64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.uint64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`;\nffiWrappers[FFIType.uint16_t] = `{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`;\nffiWrappers[FFIType.double] = `{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`;\nffiWrappers[FFIType.float] = ffiWrappers[10] = `{\n return Math.fround(val);\n}`;\nffiWrappers[FFIType.bool] = `{\n return !!val;\n}`;\nObject.defineProperty(globalThis, \"__GlobalBunFFIPtrFunctionForWrapper\", {\n value: ptr,\n enumerable: !1,\n configurable: !0\n});\nffiWrappers[FFIType.cstring] = ffiWrappers[FFIType.pointer] = `{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`;\nffiWrappers[FFIType.function] = `{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;\nvar native = {\n dlopen: nativeDLOpen,\n callback: () => {\n throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\");\n }\n}, cFunctionI = 0, cFunctionRegistry, read = ffi.read;\n$ = {\n CFunction,\n CString,\n FFIType,\n JSCallback,\n dlopen,\n linkSymbols,\n native,\n ptr,\n read,\n suffix: \"dylib\",\n toArrayBuffer,\n toBuffer,\n viewSource\n};\nreturn $})\n"_s;
//
//
@@ -14,7 +14,7 @@ static constexpr ASCIILiteral BunSqliteCode = "(function (){\"use strict\";// sr
//
//
-static constexpr ASCIILiteral InternalDebuggerCode = "(function (){\"use strict\";// src/js/out/tmp/internal/debugger.ts\nvar generatePath = function() {\n if (!generatedPath)\n generatedPath = \"/\" + Math.random().toString(36).slice(2);\n return generatedPath;\n}, terminalLink = function(url) {\n if (Bun.enableANSIColors)\n return \"\\x1B[1m\\x1B]8;;\" + url + \"\\x1B\\\\\" + url + \"\\x1B]8;;\\x1B\\\\\" + \"\\x1B[22m\";\n return url;\n}, dim = function(text) {\n if (Bun.enableANSIColors)\n return \"\\x1B[2m\" + text + \"\\x1B[22m\";\n return text;\n}, $, sendFn_, disconnectFn_, debuggerCounter = 1;\n\nclass DebuggerWithMessageQueue {\n debugger = void 0;\n messageQueue = [];\n count = debuggerCounter++;\n send(msg) {\n sendFn_.call(this.debugger, msg);\n }\n disconnect() {\n disconnectFn_.call(this.debugger), this.messageQueue.length = 0;\n }\n}\nvar defaultPort = 6499, generatedPath = \"\";\n\nclass WebSocketListener {\n server;\n url = \"\";\n createInspectorConnection;\n scriptExecutionContextId = 0;\n activeConnections = new Set;\n constructor(scriptExecutionContextId = 0, url, createInspectorConnection) {\n this.scriptExecutionContextId = scriptExecutionContextId, this.createInspectorConnection = createInspectorConnection, this.server = this.start(url);\n }\n start(url) {\n let defaultHostname = \"localhost\", usingDefaultPort = !1;\n if (/^[0-9]*$/.test(url))\n url = \"ws://\" + defaultHostname + \":\" + url + generatePath();\n else if (!url || url.startsWith(\"/\"))\n url = \"ws://\" + defaultHostname + \":\" + defaultPort + generatePath(), usingDefaultPort = !0;\n else if (url.includes(\":\") && !url.includes(\"://\"))\n try {\n const insertSlash = !url.includes(\"/\");\n if (url = new URL(\"ws://\" + url).href, insertSlash)\n url += generatePath().slice(1);\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n try {\n var { hostname, port, pathname } = new URL(url);\n this.url = pathname.toLowerCase();\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n const serveOptions = {\n hostname,\n development: !1,\n reusePort: !1,\n websocket: {\n idleTimeout: 0,\n open: (socket) => {\n var connection = new DebuggerWithMessageQueue;\n socket.data = connection, this.activeConnections.add(socket), connection.debugger = this.createInspectorConnection(this.scriptExecutionContextId, (...msgs) => {\n if (socket.readyState > 1) {\n connection.disconnect();\n return;\n }\n if (connection.messageQueue.length > 0) {\n connection.messageQueue.push(...msgs);\n return;\n }\n for (let i = 0;i < msgs.length; i++)\n if (!socket.sendText(msgs[i])) {\n if (socket.readyState < 2)\n connection.messageQueue.push(...msgs.slice(i));\n return;\n }\n }), console.log(\"[Inspector]\", \"Connection #\" + connection.count + \" opened\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\");\n },\n drain: (socket) => {\n const queue = socket.data.messageQueue;\n for (let i = 0;i < queue.length; i++)\n if (!socket.sendText(queue[i])) {\n socket.data.messageQueue = queue.slice(i);\n return;\n }\n queue.length = 0;\n },\n message: (socket, message) => {\n if (typeof message !== \"string\") {\n console.warn(\"[Inspector]\", \"Received non-string message\");\n return;\n }\n socket.data.send(message);\n },\n close: (socket) => {\n socket.data.disconnect(), console.log(\"[Inspector]\", \"Connection #\" + socket.data.count + \" closed\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\"), this.activeConnections.delete(socket);\n }\n },\n fetch: (req, server2) => {\n let { pathname: pathname2 } = new URL(req.url);\n if (pathname2 = pathname2.toLowerCase(), pathname2 === \"/json/version\")\n return Response.json({\n Browser: navigator.userAgent,\n \"WebKit-Version\": process.versions.webkit,\n \"Bun-Version\": Bun.version,\n \"Bun-Revision\": Bun.revision\n });\n if (pathname2 === this.url) {\n if (server2.upgrade(req))\n return new Response;\n return new Response(\"WebSocket expected\", {\n status: 400\n });\n }\n return new Response(\"Not found\", {\n status: 404\n });\n }\n };\n if (port === \"\")\n port = defaultPort + \"\";\n let portNumber = Number(port);\n var server, lastError;\n if (usingDefaultPort)\n for (let tries = 0;tries < 10 && !server; tries++)\n try {\n lastError = void 0, server = Bun.serve({\n ...serveOptions,\n port: portNumber++\n });\n } catch (e) {\n lastError = e;\n }\n else\n try {\n server = Bun.serve({\n ...serveOptions,\n port: portNumber\n });\n } catch (e) {\n lastError = e;\n }\n if (!server) {\n if (console.error(\"[Inspector]\", \"Failed to start server\"), lastError)\n console.error(lastError);\n process.exit(1);\n }\n let textToWrite = \"\";\n function writeToConsole(text) {\n textToWrite += text;\n }\n function flushToConsole() {\n console.write(textToWrite);\n }\n return writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), writeToConsole(\"\\x1B[49m\"), writeToConsole(\"Listening at:\\n \" + `ws://${hostname}:${server.port}${this.url}` + \"\\n\\nInspect in browser:\\n \" + terminalLink(new URL(`https://debug.bun.sh#${server.hostname}:${server.port}${this.url}`).href) + \"\\n\"), writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), flushToConsole(), server;\n }\n}\nvar listener;\n$ = function start(debuggerId, hostOrPort, createInspectorConnection, sendFn, disconnectFn) {\n try {\n sendFn_ = sendFn, disconnectFn_ = disconnectFn, globalThis.listener = listener ||= new WebSocketListener(debuggerId, hostOrPort, createInspectorConnection);\n } catch (e) {\n console.error(\"Bun Inspector threw an exception\\n\", e), process.exit(1);\n }\n return `http://${listener.server.hostname}:${listener.server.port}${listener.url}`;\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral InternalDebuggerCode = "(function (){\"use strict\";// src/js/out/tmp/internal/debugger.ts\nvar generatePath = function() {\n if (!generatedPath)\n generatedPath = \"/\" + Math.random().toString(36).slice(2);\n return generatedPath;\n}, terminalLink = function(url) {\n if (Bun.enableANSIColors)\n return \"\\x1B[1m\\x1B]8;;\" + url + \"\\x1B\\\\\" + url + \"\\x1B]8;;\\x1B\\\\\" + \"\\x1B[22m\";\n return url;\n}, dim = function(text) {\n if (Bun.enableANSIColors)\n return \"\\x1B[2m\" + text + \"\\x1B[22m\";\n return text;\n}, $, sendFn_, disconnectFn_, debuggerCounter = 1;\n\nclass DebuggerWithMessageQueue {\n debugger = void 0;\n messageQueue = [];\n count = debuggerCounter++;\n send(msg) {\n sendFn_.call(this.debugger, msg);\n }\n disconnect() {\n disconnectFn_.call(this.debugger), this.messageQueue.length = 0;\n }\n}\nvar defaultPort = 6499, generatedPath = \"\";\n\nclass WebSocketListener {\n server;\n url = \"\";\n createInspectorConnection;\n scriptExecutionContextId = 0;\n activeConnections = new Set;\n constructor(scriptExecutionContextId = 0, url, createInspectorConnection) {\n this.scriptExecutionContextId = scriptExecutionContextId, this.createInspectorConnection = createInspectorConnection, this.server = this.start(url);\n }\n start(url) {\n let defaultHostname = \"localhost\", usingDefaultPort = !1;\n if (/^[0-9]*$/.test(url))\n url = \"ws://\" + defaultHostname + \":\" + url + generatePath();\n else if (!url || url.startsWith(\"/\"))\n url = \"ws://\" + defaultHostname + \":\" + defaultPort + generatePath(), usingDefaultPort = !0;\n else if (url.includes(\":\") && !url.includes(\"://\"))\n try {\n const insertSlash = !url.includes(\"/\");\n if (url = new URL(\"ws://\" + url).href, insertSlash)\n url += generatePath().slice(1);\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n try {\n var { hostname, port, pathname } = new URL(url);\n this.url = pathname.toLowerCase();\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n const serveOptions = {\n hostname,\n development: !1,\n reusePort: !1,\n websocket: {\n idleTimeout: 0,\n open: (socket) => {\n var connection = new DebuggerWithMessageQueue;\n const shouldRefEventLoop = !!socket.data\?.shouldRefEventLoop;\n socket.data = connection, this.activeConnections.add(socket), connection.debugger = this.createInspectorConnection(this.scriptExecutionContextId, shouldRefEventLoop, (...msgs) => {\n if (socket.readyState > 1) {\n connection.disconnect();\n return;\n }\n if (connection.messageQueue.length > 0) {\n connection.messageQueue.push(...msgs);\n return;\n }\n for (let i = 0;i < msgs.length; i++)\n if (!socket.sendText(msgs[i])) {\n if (socket.readyState < 2)\n connection.messageQueue.push(...msgs.slice(i));\n return;\n }\n }), console.log(\"[Inspector]\", \"Connection #\" + connection.count + \" opened\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\");\n },\n drain: (socket) => {\n const queue = socket.data.messageQueue;\n for (let i = 0;i < queue.length; i++)\n if (!socket.sendText(queue[i])) {\n socket.data.messageQueue = queue.slice(i);\n return;\n }\n queue.length = 0;\n },\n message: (socket, message) => {\n if (typeof message !== \"string\") {\n console.warn(\"[Inspector]\", \"Received non-string message\");\n return;\n }\n socket.data.send(message);\n },\n close: (socket) => {\n socket.data.disconnect(), console.log(\"[Inspector]\", \"Connection #\" + socket.data.count + \" closed\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\"), this.activeConnections.delete(socket);\n }\n },\n fetch: (req, server2) => {\n let { pathname: pathname2 } = new URL(req.url);\n if (pathname2 = pathname2.toLowerCase(), pathname2 === \"/json/version\")\n return Response.json({\n Browser: navigator.userAgent,\n \"WebKit-Version\": process.versions.webkit,\n \"Bun-Version\": Bun.version,\n \"Bun-Revision\": Bun.revision\n });\n if (pathname2 === this.url) {\n const refHeader = req.headers.get(\"Ref-Event-Loop\");\n if (server2.upgrade(req, {\n data: {\n shouldRefEventLoop: !!refHeader && refHeader !== \"0\"\n }\n }))\n return new Response;\n return new Response(\"WebSocket expected\", {\n status: 400\n });\n }\n return new Response(\"Not found\", {\n status: 404\n });\n }\n };\n if (port === \"\")\n port = defaultPort + \"\";\n let portNumber = Number(port);\n var server, lastError;\n if (usingDefaultPort)\n for (let tries = 0;tries < 10 && !server; tries++)\n try {\n lastError = void 0, server = Bun.serve({\n ...serveOptions,\n port: portNumber++\n });\n } catch (e) {\n lastError = e;\n }\n else\n try {\n server = Bun.serve({\n ...serveOptions,\n port: portNumber\n });\n } catch (e) {\n lastError = e;\n }\n if (!server) {\n if (console.error(\"[Inspector]\", \"Failed to start server\"), lastError)\n console.error(lastError);\n process.exit(1);\n }\n let textToWrite = \"\";\n function writeToConsole(text) {\n textToWrite += text;\n }\n function flushToConsole() {\n console.write(textToWrite);\n }\n return writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), writeToConsole(\"\\x1B[49m\"), writeToConsole(\"Listening at:\\n \" + `ws://${hostname}:${server.port}${this.url}` + \"\\n\\nInspect in browser:\\n \" + terminalLink(new URL(`https://debug.bun.sh#${server.hostname}:${server.port}${this.url}`).href) + \"\\n\"), writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), flushToConsole(), server;\n }\n}\nvar listener;\n$ = function start(debuggerId, hostOrPort, createInspectorConnection, sendFn, disconnectFn) {\n try {\n sendFn_ = sendFn, disconnectFn_ = disconnectFn, globalThis.listener = listener ||= new WebSocketListener(debuggerId, hostOrPort, createInspectorConnection);\n } catch (e) {\n console.error(\"Bun Inspector threw an exception\\n\", e), process.exit(1);\n }\n return `http://${listener.server.hostname}:${listener.server.port}${listener.url}`;\n};\nreturn $})\n"_s;
//
//
@@ -235,7 +235,7 @@ static constexpr ASCIILiteral ThirdpartyWSCode = "(function (){\"use strict\";//
#elif _WIN32
//
-static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";// src/js/out/tmp/bun/ffi.ts\nvar FFIBuilder = function(params, returnType, functionToCall, name) {\n const hasReturnType = typeof FFIType[returnType] === \"number\" && FFIType[returnType] !== FFIType.void;\n var paramNames = new Array(params.length), args = new Array(params.length);\n for (let i = 0;i < params.length; i++) {\n paramNames[i] = `p${i}`;\n const wrapper = ffiWrappers[FFIType[params[i]]];\n if (wrapper)\n args[i] = `(val=>${wrapper})(p${i})`;\n else\n @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`);\n }\n var code = `functionToCall(${args.join(\", \")})`;\n if (hasReturnType)\n if (FFIType[returnType] === FFIType.cstring)\n code = `return new __GlobalBunCString(${code})`;\n else\n code = `return ${code}`;\n var func = new Function(\"functionToCall\", ...paramNames, code);\n Object.defineProperty(func, \"name\", {\n value: name\n });\n var wrap;\n switch (paramNames.length) {\n case 0:\n wrap = () => func(functionToCall);\n break;\n case 1:\n wrap = (arg1) => func(functionToCall, arg1);\n break;\n case 2:\n wrap = (arg1, arg2) => func(functionToCall, arg1, arg2);\n break;\n case 3:\n wrap = (arg1, arg2, arg3) => func(functionToCall, arg1, arg2, arg3);\n break;\n case 4:\n wrap = (arg1, arg2, arg3, arg4) => func(functionToCall, arg1, arg2, arg3, arg4);\n break;\n case 5:\n wrap = (arg1, arg2, arg3, arg4, arg5) => func(functionToCall, arg1, arg2, arg3, arg4, arg5);\n break;\n case 6:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6);\n break;\n case 7:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n break;\n case 8:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n break;\n case 9:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);\n break;\n default: {\n wrap = (...args2) => func(functionToCall, ...args2);\n break;\n }\n }\n return wrap.native = functionToCall, wrap.ptr = functionToCall.ptr, wrap;\n}, dlopen = function(path, options) {\n const result = nativeDLOpen(path, options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, path.includes(\"/\") \? `${key} (${path.split(\"/\").pop()})` : `${key} (${path})`);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, linkSymbols = function(options) {\n const result = nativeLinkSymbols(options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, key);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, onCloseCFunction = function(close) {\n close();\n}, CFunction = function(options) {\n const identifier = `CFunction${cFunctionI++}`;\n var result = linkSymbols({\n [identifier]: options\n }), hasClosed = !1, close = result.close;\n return result.symbols[identifier].close = () => {\n if (hasClosed || !close)\n return;\n hasClosed = !0, close(), close = void 0;\n }, cFunctionRegistry ||= new FinalizationRegistry(onCloseCFunction), cFunctionRegistry.register(result.symbols[identifier], result.symbols[identifier].close), result.symbols[identifier];\n}, $, FFIType = {\n \"0\": 0,\n \"1\": 1,\n \"2\": 2,\n \"3\": 3,\n \"4\": 4,\n \"5\": 5,\n \"6\": 6,\n \"7\": 7,\n \"8\": 8,\n \"9\": 9,\n \"10\": 10,\n \"11\": 11,\n \"12\": 12,\n \"13\": 13,\n \"14\": 14,\n \"15\": 15,\n \"16\": 16,\n \"17\": 17,\n bool: 11,\n c_int: 5,\n c_uint: 6,\n char: 0,\n \"char*\": 12,\n double: 9,\n f32: 10,\n f64: 9,\n float: 10,\n i16: 3,\n i32: 5,\n i64: 7,\n i8: 1,\n int: 5,\n int16_t: 3,\n int32_t: 5,\n int64_t: 7,\n int8_t: 1,\n isize: 7,\n u16: 4,\n u32: 6,\n u64: 8,\n u8: 2,\n uint16_t: 4,\n uint32_t: 6,\n uint64_t: 8,\n uint8_t: 2,\n usize: 8,\n \"void*\": 12,\n ptr: 12,\n pointer: 12,\n void: 13,\n cstring: 14,\n i64_fast: 15,\n u64_fast: 16,\n function: 17,\n callback: 17,\n fn: 17\n};\nvar ffi = globalThis.Bun.FFI, ptr = (arg1, arg2) => typeof arg2 === \"undefined\" \? ffi.ptr(arg1) : ffi.ptr(arg1, arg2), toBuffer = ffi.toBuffer, toArrayBuffer = ffi.toArrayBuffer, viewSource = ffi.viewSource, BunCString = ffi.CString, nativeLinkSymbols = ffi.linkSymbols, nativeDLOpen = ffi.dlopen, nativeCallback = ffi.callback, closeCallback = ffi.closeCallback;\ndelete ffi.callback;\ndelete ffi.closeCallback;\n\nclass JSCallback {\n constructor(cb, options) {\n const { ctx, ptr: ptr2 } = nativeCallback(options, cb);\n this.#ctx = ctx, this.ptr = ptr2, this.#threadsafe = !!options\?.threadsafe;\n }\n ptr;\n #ctx;\n #threadsafe;\n get threadsafe() {\n return this.#threadsafe;\n }\n [Symbol.toPrimitive]() {\n const { ptr: ptr2 } = this;\n return typeof ptr2 === \"number\" \? ptr2 : 0;\n }\n close() {\n const ctx = this.#ctx;\n if (this.ptr = null, this.#ctx = null, ctx)\n closeCallback(ctx);\n }\n}\n\nclass CString extends String {\n constructor(ptr2, byteOffset, byteLength) {\n super(ptr2 \? typeof byteLength === \"number\" && Number.isSafeInteger(byteLength) \? new BunCString(ptr2, byteOffset || 0, byteLength) : new BunCString(ptr2) : \"\");\n if (this.ptr = typeof ptr2 === \"number\" \? ptr2 : 0, typeof byteOffset !== \"undefined\")\n this.byteOffset = byteOffset;\n if (typeof byteLength !== \"undefined\")\n this.byteLength = byteLength;\n }\n ptr;\n byteOffset;\n byteLength;\n #cachedArrayBuffer;\n get arrayBuffer() {\n if (this.#cachedArrayBuffer)\n return this.#cachedArrayBuffer;\n if (!this.ptr)\n return this.#cachedArrayBuffer = new ArrayBuffer(0);\n return this.#cachedArrayBuffer = toArrayBuffer(this.ptr, this.byteOffset, this.byteLength);\n }\n}\nObject.defineProperty(globalThis, \"__GlobalBunCString\", {\n value: CString,\n enumerable: !1,\n configurable: !1\n});\nvar ffiWrappers = new Array(18), char = \"val|0\";\nffiWrappers.fill(char);\nffiWrappers[FFIType.uint8_t] = \"val<0\?0:val>=255\?255:val|0\";\nffiWrappers[FFIType.int16_t] = \"val<=-32768\?-32768:val>=32768\?32768:val|0\";\nffiWrappers[FFIType.uint16_t] = \"val<=0\?0:val>=65536\?65536:val|0\";\nffiWrappers[FFIType.int32_t] = \"val|0\";\nffiWrappers[FFIType.uint32_t] = \"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\";\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.int64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.uint64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`;\nffiWrappers[FFIType.uint16_t] = `{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`;\nffiWrappers[FFIType.double] = `{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`;\nffiWrappers[FFIType.float] = ffiWrappers[10] = `{\n return Math.fround(val);\n}`;\nffiWrappers[FFIType.bool] = `{\n return !!val;\n}`;\nObject.defineProperty(globalThis, \"__GlobalBunFFIPtrFunctionForWrapper\", {\n value: ptr,\n enumerable: !1,\n configurable: !0\n});\nffiWrappers[FFIType.cstring] = ffiWrappers[FFIType.pointer] = `{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`;\nffiWrappers[FFIType.function] = `{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;\nvar native = {\n dlopen: nativeDLOpen,\n callback: () => {\n throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\");\n }\n}, cFunctionI = 0, cFunctionRegistry, read = ffi.read;\n$ = {\n CFunction,\n CString,\n FFIType,\n JSCallback,\n dlopen,\n linkSymbols,\n native,\n ptr,\n read,\n suffix: \"dll\",\n toArrayBuffer,\n toBuffer,\n viewSource\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";// src/js/out/tmp/bun/ffi.ts\nvar FFIBuilder = function(params, returnType, functionToCall, name) {\n const hasReturnType = typeof FFIType[returnType] === \"number\" && FFIType[returnType] !== FFIType.void;\n var paramNames = new Array(params.length), args = new Array(params.length);\n for (let i = 0;i < params.length; i++) {\n paramNames[i] = `p${i}`;\n const wrapper = ffiWrappers[FFIType[params[i]]];\n if (wrapper)\n args[i] = `(val=>${wrapper})(p${i})`;\n else\n @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`);\n }\n var code = `functionToCall(${args.join(\", \")})`;\n if (hasReturnType)\n if (FFIType[returnType] === FFIType.cstring)\n code = `return new __GlobalBunCString(${code})`;\n else\n code = `return ${code}`;\n var func = new Function(\"functionToCall\", ...paramNames, code);\n Object.defineProperty(func, \"name\", {\n value: name\n });\n var wrap;\n switch (paramNames.length) {\n case 0:\n wrap = () => func(functionToCall);\n break;\n case 1:\n wrap = (arg1) => func(functionToCall, arg1);\n break;\n case 2:\n wrap = (arg1, arg2) => func(functionToCall, arg1, arg2);\n break;\n case 3:\n wrap = (arg1, arg2, arg3) => func(functionToCall, arg1, arg2, arg3);\n break;\n case 4:\n wrap = (arg1, arg2, arg3, arg4) => func(functionToCall, arg1, arg2, arg3, arg4);\n break;\n case 5:\n wrap = (arg1, arg2, arg3, arg4, arg5) => func(functionToCall, arg1, arg2, arg3, arg4, arg5);\n break;\n case 6:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6);\n break;\n case 7:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n break;\n case 8:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n break;\n case 9:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);\n break;\n default: {\n wrap = (...args2) => func(functionToCall, ...args2);\n break;\n }\n }\n return wrap.native = functionToCall, wrap.ptr = functionToCall.ptr, wrap;\n}, dlopen = function(path, options) {\n const result = nativeDLOpen(path, options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, path.includes(\"/\") \? `${key} (${path.split(\"/\").pop()})` : `${key} (${path})`);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result.close = result.close.bind(result), result;\n}, linkSymbols = function(options) {\n const result = nativeLinkSymbols(options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, key);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, onCloseCFunction = function(close) {\n close();\n}, CFunction = function(options) {\n const identifier = `CFunction${cFunctionI++}`;\n var result = linkSymbols({\n [identifier]: options\n }), hasClosed = !1, close = result.close.bind(result);\n return result.symbols[identifier].close = () => {\n if (hasClosed || !close)\n return;\n hasClosed = !0, close(), close = void 0;\n }, cFunctionRegistry ||= new FinalizationRegistry(onCloseCFunction), cFunctionRegistry.register(result.symbols[identifier], result.symbols[identifier].close), result.symbols[identifier];\n}, $, FFIType = {\n \"0\": 0,\n \"1\": 1,\n \"2\": 2,\n \"3\": 3,\n \"4\": 4,\n \"5\": 5,\n \"6\": 6,\n \"7\": 7,\n \"8\": 8,\n \"9\": 9,\n \"10\": 10,\n \"11\": 11,\n \"12\": 12,\n \"13\": 13,\n \"14\": 14,\n \"15\": 15,\n \"16\": 16,\n \"17\": 17,\n bool: 11,\n c_int: 5,\n c_uint: 6,\n char: 0,\n \"char*\": 12,\n double: 9,\n f32: 10,\n f64: 9,\n float: 10,\n i16: 3,\n i32: 5,\n i64: 7,\n i8: 1,\n int: 5,\n int16_t: 3,\n int32_t: 5,\n int64_t: 7,\n int8_t: 1,\n isize: 7,\n u16: 4,\n u32: 6,\n u64: 8,\n u8: 2,\n uint16_t: 4,\n uint32_t: 6,\n uint64_t: 8,\n uint8_t: 2,\n usize: 8,\n \"void*\": 12,\n ptr: 12,\n pointer: 12,\n void: 13,\n cstring: 14,\n i64_fast: 15,\n u64_fast: 16,\n function: 17,\n callback: 17,\n fn: 17\n};\nvar ffi = globalThis.Bun.FFI, ptr = (arg1, arg2) => typeof arg2 === \"undefined\" \? ffi.ptr(arg1) : ffi.ptr(arg1, arg2), toBuffer = ffi.toBuffer, toArrayBuffer = ffi.toArrayBuffer, viewSource = ffi.viewSource, BunCString = ffi.CString, nativeLinkSymbols = ffi.linkSymbols, nativeDLOpen = ffi.dlopen, nativeCallback = ffi.callback, closeCallback = ffi.closeCallback;\ndelete ffi.callback;\ndelete ffi.closeCallback;\n\nclass JSCallback {\n constructor(cb, options) {\n const { ctx, ptr: ptr2 } = nativeCallback(options, cb);\n this.#ctx = ctx, this.ptr = ptr2, this.#threadsafe = !!options\?.threadsafe;\n }\n ptr;\n #ctx;\n #threadsafe;\n get threadsafe() {\n return this.#threadsafe;\n }\n [Symbol.toPrimitive]() {\n const { ptr: ptr2 } = this;\n return typeof ptr2 === \"number\" \? ptr2 : 0;\n }\n close() {\n const ctx = this.#ctx;\n if (this.ptr = null, this.#ctx = null, ctx)\n closeCallback(ctx);\n }\n}\n\nclass CString extends String {\n constructor(ptr2, byteOffset, byteLength) {\n super(ptr2 \? typeof byteLength === \"number\" && Number.isSafeInteger(byteLength) \? BunCString(ptr2, byteOffset || 0, byteLength) : BunCString(ptr2) : \"\");\n if (this.ptr = typeof ptr2 === \"number\" \? ptr2 : 0, typeof byteOffset !== \"undefined\")\n this.byteOffset = byteOffset;\n if (typeof byteLength !== \"undefined\")\n this.byteLength = byteLength;\n }\n ptr;\n byteOffset;\n byteLength;\n #cachedArrayBuffer;\n get arrayBuffer() {\n if (this.#cachedArrayBuffer)\n return this.#cachedArrayBuffer;\n if (!this.ptr)\n return this.#cachedArrayBuffer = new ArrayBuffer(0);\n return this.#cachedArrayBuffer = toArrayBuffer(this.ptr, this.byteOffset, this.byteLength);\n }\n}\nObject.defineProperty(globalThis, \"__GlobalBunCString\", {\n value: CString,\n enumerable: !1,\n configurable: !1\n});\nvar ffiWrappers = new Array(18), char = \"val|0\";\nffiWrappers.fill(char);\nffiWrappers[FFIType.uint8_t] = \"val<0\?0:val>=255\?255:val|0\";\nffiWrappers[FFIType.int16_t] = \"val<=-32768\?-32768:val>=32768\?32768:val|0\";\nffiWrappers[FFIType.uint16_t] = \"val<=0\?0:val>=65536\?65536:val|0\";\nffiWrappers[FFIType.int32_t] = \"val|0\";\nffiWrappers[FFIType.uint32_t] = \"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\";\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.int64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.uint64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`;\nffiWrappers[FFIType.uint16_t] = `{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`;\nffiWrappers[FFIType.double] = `{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`;\nffiWrappers[FFIType.float] = ffiWrappers[10] = `{\n return Math.fround(val);\n}`;\nffiWrappers[FFIType.bool] = `{\n return !!val;\n}`;\nObject.defineProperty(globalThis, \"__GlobalBunFFIPtrFunctionForWrapper\", {\n value: ptr,\n enumerable: !1,\n configurable: !0\n});\nffiWrappers[FFIType.cstring] = ffiWrappers[FFIType.pointer] = `{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`;\nffiWrappers[FFIType.function] = `{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;\nvar native = {\n dlopen: nativeDLOpen,\n callback: () => {\n throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\");\n }\n}, cFunctionI = 0, cFunctionRegistry, read = ffi.read;\n$ = {\n CFunction,\n CString,\n FFIType,\n JSCallback,\n dlopen,\n linkSymbols,\n native,\n ptr,\n read,\n suffix: \"dll\",\n toArrayBuffer,\n toBuffer,\n viewSource\n};\nreturn $})\n"_s;
//
//
@@ -243,7 +243,7 @@ static constexpr ASCIILiteral BunSqliteCode = "(function (){\"use strict\";// sr
//
//
-static constexpr ASCIILiteral InternalDebuggerCode = "(function (){\"use strict\";// src/js/out/tmp/internal/debugger.ts\nvar generatePath = function() {\n if (!generatedPath)\n generatedPath = \"/\" + Math.random().toString(36).slice(2);\n return generatedPath;\n}, terminalLink = function(url) {\n if (Bun.enableANSIColors)\n return \"\\x1B[1m\\x1B]8;;\" + url + \"\\x1B\\\\\" + url + \"\\x1B]8;;\\x1B\\\\\" + \"\\x1B[22m\";\n return url;\n}, dim = function(text) {\n if (Bun.enableANSIColors)\n return \"\\x1B[2m\" + text + \"\\x1B[22m\";\n return text;\n}, $, sendFn_, disconnectFn_, debuggerCounter = 1;\n\nclass DebuggerWithMessageQueue {\n debugger = void 0;\n messageQueue = [];\n count = debuggerCounter++;\n send(msg) {\n sendFn_.call(this.debugger, msg);\n }\n disconnect() {\n disconnectFn_.call(this.debugger), this.messageQueue.length = 0;\n }\n}\nvar defaultPort = 6499, generatedPath = \"\";\n\nclass WebSocketListener {\n server;\n url = \"\";\n createInspectorConnection;\n scriptExecutionContextId = 0;\n activeConnections = new Set;\n constructor(scriptExecutionContextId = 0, url, createInspectorConnection) {\n this.scriptExecutionContextId = scriptExecutionContextId, this.createInspectorConnection = createInspectorConnection, this.server = this.start(url);\n }\n start(url) {\n let defaultHostname = \"localhost\", usingDefaultPort = !1;\n if (/^[0-9]*$/.test(url))\n url = \"ws://\" + defaultHostname + \":\" + url + generatePath();\n else if (!url || url.startsWith(\"/\"))\n url = \"ws://\" + defaultHostname + \":\" + defaultPort + generatePath(), usingDefaultPort = !0;\n else if (url.includes(\":\") && !url.includes(\"://\"))\n try {\n const insertSlash = !url.includes(\"/\");\n if (url = new URL(\"ws://\" + url).href, insertSlash)\n url += generatePath().slice(1);\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n try {\n var { hostname, port, pathname } = new URL(url);\n this.url = pathname.toLowerCase();\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n const serveOptions = {\n hostname,\n development: !1,\n reusePort: !1,\n websocket: {\n idleTimeout: 0,\n open: (socket) => {\n var connection = new DebuggerWithMessageQueue;\n socket.data = connection, this.activeConnections.add(socket), connection.debugger = this.createInspectorConnection(this.scriptExecutionContextId, (...msgs) => {\n if (socket.readyState > 1) {\n connection.disconnect();\n return;\n }\n if (connection.messageQueue.length > 0) {\n connection.messageQueue.push(...msgs);\n return;\n }\n for (let i = 0;i < msgs.length; i++)\n if (!socket.sendText(msgs[i])) {\n if (socket.readyState < 2)\n connection.messageQueue.push(...msgs.slice(i));\n return;\n }\n }), console.log(\"[Inspector]\", \"Connection #\" + connection.count + \" opened\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\");\n },\n drain: (socket) => {\n const queue = socket.data.messageQueue;\n for (let i = 0;i < queue.length; i++)\n if (!socket.sendText(queue[i])) {\n socket.data.messageQueue = queue.slice(i);\n return;\n }\n queue.length = 0;\n },\n message: (socket, message) => {\n if (typeof message !== \"string\") {\n console.warn(\"[Inspector]\", \"Received non-string message\");\n return;\n }\n socket.data.send(message);\n },\n close: (socket) => {\n socket.data.disconnect(), console.log(\"[Inspector]\", \"Connection #\" + socket.data.count + \" closed\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\"), this.activeConnections.delete(socket);\n }\n },\n fetch: (req, server2) => {\n let { pathname: pathname2 } = new URL(req.url);\n if (pathname2 = pathname2.toLowerCase(), pathname2 === \"/json/version\")\n return Response.json({\n Browser: navigator.userAgent,\n \"WebKit-Version\": process.versions.webkit,\n \"Bun-Version\": Bun.version,\n \"Bun-Revision\": Bun.revision\n });\n if (pathname2 === this.url) {\n if (server2.upgrade(req))\n return new Response;\n return new Response(\"WebSocket expected\", {\n status: 400\n });\n }\n return new Response(\"Not found\", {\n status: 404\n });\n }\n };\n if (port === \"\")\n port = defaultPort + \"\";\n let portNumber = Number(port);\n var server, lastError;\n if (usingDefaultPort)\n for (let tries = 0;tries < 10 && !server; tries++)\n try {\n lastError = void 0, server = Bun.serve({\n ...serveOptions,\n port: portNumber++\n });\n } catch (e) {\n lastError = e;\n }\n else\n try {\n server = Bun.serve({\n ...serveOptions,\n port: portNumber\n });\n } catch (e) {\n lastError = e;\n }\n if (!server) {\n if (console.error(\"[Inspector]\", \"Failed to start server\"), lastError)\n console.error(lastError);\n process.exit(1);\n }\n let textToWrite = \"\";\n function writeToConsole(text) {\n textToWrite += text;\n }\n function flushToConsole() {\n console.write(textToWrite);\n }\n return writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), writeToConsole(\"\\x1B[49m\"), writeToConsole(\"Listening at:\\n \" + `ws://${hostname}:${server.port}${this.url}` + \"\\n\\nInspect in browser:\\n \" + terminalLink(new URL(`https://debug.bun.sh#${server.hostname}:${server.port}${this.url}`).href) + \"\\n\"), writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), flushToConsole(), server;\n }\n}\nvar listener;\n$ = function start(debuggerId, hostOrPort, createInspectorConnection, sendFn, disconnectFn) {\n try {\n sendFn_ = sendFn, disconnectFn_ = disconnectFn, globalThis.listener = listener ||= new WebSocketListener(debuggerId, hostOrPort, createInspectorConnection);\n } catch (e) {\n console.error(\"Bun Inspector threw an exception\\n\", e), process.exit(1);\n }\n return `http://${listener.server.hostname}:${listener.server.port}${listener.url}`;\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral InternalDebuggerCode = "(function (){\"use strict\";// src/js/out/tmp/internal/debugger.ts\nvar generatePath = function() {\n if (!generatedPath)\n generatedPath = \"/\" + Math.random().toString(36).slice(2);\n return generatedPath;\n}, terminalLink = function(url) {\n if (Bun.enableANSIColors)\n return \"\\x1B[1m\\x1B]8;;\" + url + \"\\x1B\\\\\" + url + \"\\x1B]8;;\\x1B\\\\\" + \"\\x1B[22m\";\n return url;\n}, dim = function(text) {\n if (Bun.enableANSIColors)\n return \"\\x1B[2m\" + text + \"\\x1B[22m\";\n return text;\n}, $, sendFn_, disconnectFn_, debuggerCounter = 1;\n\nclass DebuggerWithMessageQueue {\n debugger = void 0;\n messageQueue = [];\n count = debuggerCounter++;\n send(msg) {\n sendFn_.call(this.debugger, msg);\n }\n disconnect() {\n disconnectFn_.call(this.debugger), this.messageQueue.length = 0;\n }\n}\nvar defaultPort = 6499, generatedPath = \"\";\n\nclass WebSocketListener {\n server;\n url = \"\";\n createInspectorConnection;\n scriptExecutionContextId = 0;\n activeConnections = new Set;\n constructor(scriptExecutionContextId = 0, url, createInspectorConnection) {\n this.scriptExecutionContextId = scriptExecutionContextId, this.createInspectorConnection = createInspectorConnection, this.server = this.start(url);\n }\n start(url) {\n let defaultHostname = \"localhost\", usingDefaultPort = !1;\n if (/^[0-9]*$/.test(url))\n url = \"ws://\" + defaultHostname + \":\" + url + generatePath();\n else if (!url || url.startsWith(\"/\"))\n url = \"ws://\" + defaultHostname + \":\" + defaultPort + generatePath(), usingDefaultPort = !0;\n else if (url.includes(\":\") && !url.includes(\"://\"))\n try {\n const insertSlash = !url.includes(\"/\");\n if (url = new URL(\"ws://\" + url).href, insertSlash)\n url += generatePath().slice(1);\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n try {\n var { hostname, port, pathname } = new URL(url);\n this.url = pathname.toLowerCase();\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n const serveOptions = {\n hostname,\n development: !1,\n reusePort: !1,\n websocket: {\n idleTimeout: 0,\n open: (socket) => {\n var connection = new DebuggerWithMessageQueue;\n const shouldRefEventLoop = !!socket.data\?.shouldRefEventLoop;\n socket.data = connection, this.activeConnections.add(socket), connection.debugger = this.createInspectorConnection(this.scriptExecutionContextId, shouldRefEventLoop, (...msgs) => {\n if (socket.readyState > 1) {\n connection.disconnect();\n return;\n }\n if (connection.messageQueue.length > 0) {\n connection.messageQueue.push(...msgs);\n return;\n }\n for (let i = 0;i < msgs.length; i++)\n if (!socket.sendText(msgs[i])) {\n if (socket.readyState < 2)\n connection.messageQueue.push(...msgs.slice(i));\n return;\n }\n }), console.log(\"[Inspector]\", \"Connection #\" + connection.count + \" opened\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\");\n },\n drain: (socket) => {\n const queue = socket.data.messageQueue;\n for (let i = 0;i < queue.length; i++)\n if (!socket.sendText(queue[i])) {\n socket.data.messageQueue = queue.slice(i);\n return;\n }\n queue.length = 0;\n },\n message: (socket, message) => {\n if (typeof message !== \"string\") {\n console.warn(\"[Inspector]\", \"Received non-string message\");\n return;\n }\n socket.data.send(message);\n },\n close: (socket) => {\n socket.data.disconnect(), console.log(\"[Inspector]\", \"Connection #\" + socket.data.count + \" closed\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\"), this.activeConnections.delete(socket);\n }\n },\n fetch: (req, server2) => {\n let { pathname: pathname2 } = new URL(req.url);\n if (pathname2 = pathname2.toLowerCase(), pathname2 === \"/json/version\")\n return Response.json({\n Browser: navigator.userAgent,\n \"WebKit-Version\": process.versions.webkit,\n \"Bun-Version\": Bun.version,\n \"Bun-Revision\": Bun.revision\n });\n if (pathname2 === this.url) {\n const refHeader = req.headers.get(\"Ref-Event-Loop\");\n if (server2.upgrade(req, {\n data: {\n shouldRefEventLoop: !!refHeader && refHeader !== \"0\"\n }\n }))\n return new Response;\n return new Response(\"WebSocket expected\", {\n status: 400\n });\n }\n return new Response(\"Not found\", {\n status: 404\n });\n }\n };\n if (port === \"\")\n port = defaultPort + \"\";\n let portNumber = Number(port);\n var server, lastError;\n if (usingDefaultPort)\n for (let tries = 0;tries < 10 && !server; tries++)\n try {\n lastError = void 0, server = Bun.serve({\n ...serveOptions,\n port: portNumber++\n });\n } catch (e) {\n lastError = e;\n }\n else\n try {\n server = Bun.serve({\n ...serveOptions,\n port: portNumber\n });\n } catch (e) {\n lastError = e;\n }\n if (!server) {\n if (console.error(\"[Inspector]\", \"Failed to start server\"), lastError)\n console.error(lastError);\n process.exit(1);\n }\n let textToWrite = \"\";\n function writeToConsole(text) {\n textToWrite += text;\n }\n function flushToConsole() {\n console.write(textToWrite);\n }\n return writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), writeToConsole(\"\\x1B[49m\"), writeToConsole(\"Listening at:\\n \" + `ws://${hostname}:${server.port}${this.url}` + \"\\n\\nInspect in browser:\\n \" + terminalLink(new URL(`https://debug.bun.sh#${server.hostname}:${server.port}${this.url}`).href) + \"\\n\"), writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), flushToConsole(), server;\n }\n}\nvar listener;\n$ = function start(debuggerId, hostOrPort, createInspectorConnection, sendFn, disconnectFn) {\n try {\n sendFn_ = sendFn, disconnectFn_ = disconnectFn, globalThis.listener = listener ||= new WebSocketListener(debuggerId, hostOrPort, createInspectorConnection);\n } catch (e) {\n console.error(\"Bun Inspector threw an exception\\n\", e), process.exit(1);\n }\n return `http://${listener.server.hostname}:${listener.server.port}${listener.url}`;\n};\nreturn $})\n"_s;
//
//
@@ -465,7 +465,7 @@ static constexpr ASCIILiteral ThirdpartyWSCode = "(function (){\"use strict\";//
#else
// Not 100% accurate, but basically inlining linux on non-windows non-mac platforms.
//
-static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";// src/js/out/tmp/bun/ffi.ts\nvar FFIBuilder = function(params, returnType, functionToCall, name) {\n const hasReturnType = typeof FFIType[returnType] === \"number\" && FFIType[returnType] !== FFIType.void;\n var paramNames = new Array(params.length), args = new Array(params.length);\n for (let i = 0;i < params.length; i++) {\n paramNames[i] = `p${i}`;\n const wrapper = ffiWrappers[FFIType[params[i]]];\n if (wrapper)\n args[i] = `(val=>${wrapper})(p${i})`;\n else\n @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`);\n }\n var code = `functionToCall(${args.join(\", \")})`;\n if (hasReturnType)\n if (FFIType[returnType] === FFIType.cstring)\n code = `return new __GlobalBunCString(${code})`;\n else\n code = `return ${code}`;\n var func = new Function(\"functionToCall\", ...paramNames, code);\n Object.defineProperty(func, \"name\", {\n value: name\n });\n var wrap;\n switch (paramNames.length) {\n case 0:\n wrap = () => func(functionToCall);\n break;\n case 1:\n wrap = (arg1) => func(functionToCall, arg1);\n break;\n case 2:\n wrap = (arg1, arg2) => func(functionToCall, arg1, arg2);\n break;\n case 3:\n wrap = (arg1, arg2, arg3) => func(functionToCall, arg1, arg2, arg3);\n break;\n case 4:\n wrap = (arg1, arg2, arg3, arg4) => func(functionToCall, arg1, arg2, arg3, arg4);\n break;\n case 5:\n wrap = (arg1, arg2, arg3, arg4, arg5) => func(functionToCall, arg1, arg2, arg3, arg4, arg5);\n break;\n case 6:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6);\n break;\n case 7:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n break;\n case 8:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n break;\n case 9:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);\n break;\n default: {\n wrap = (...args2) => func(functionToCall, ...args2);\n break;\n }\n }\n return wrap.native = functionToCall, wrap.ptr = functionToCall.ptr, wrap;\n}, dlopen = function(path, options) {\n const result = nativeDLOpen(path, options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, path.includes(\"/\") \? `${key} (${path.split(\"/\").pop()})` : `${key} (${path})`);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, linkSymbols = function(options) {\n const result = nativeLinkSymbols(options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, key);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, onCloseCFunction = function(close) {\n close();\n}, CFunction = function(options) {\n const identifier = `CFunction${cFunctionI++}`;\n var result = linkSymbols({\n [identifier]: options\n }), hasClosed = !1, close = result.close;\n return result.symbols[identifier].close = () => {\n if (hasClosed || !close)\n return;\n hasClosed = !0, close(), close = void 0;\n }, cFunctionRegistry ||= new FinalizationRegistry(onCloseCFunction), cFunctionRegistry.register(result.symbols[identifier], result.symbols[identifier].close), result.symbols[identifier];\n}, $, FFIType = {\n \"0\": 0,\n \"1\": 1,\n \"2\": 2,\n \"3\": 3,\n \"4\": 4,\n \"5\": 5,\n \"6\": 6,\n \"7\": 7,\n \"8\": 8,\n \"9\": 9,\n \"10\": 10,\n \"11\": 11,\n \"12\": 12,\n \"13\": 13,\n \"14\": 14,\n \"15\": 15,\n \"16\": 16,\n \"17\": 17,\n bool: 11,\n c_int: 5,\n c_uint: 6,\n char: 0,\n \"char*\": 12,\n double: 9,\n f32: 10,\n f64: 9,\n float: 10,\n i16: 3,\n i32: 5,\n i64: 7,\n i8: 1,\n int: 5,\n int16_t: 3,\n int32_t: 5,\n int64_t: 7,\n int8_t: 1,\n isize: 7,\n u16: 4,\n u32: 6,\n u64: 8,\n u8: 2,\n uint16_t: 4,\n uint32_t: 6,\n uint64_t: 8,\n uint8_t: 2,\n usize: 8,\n \"void*\": 12,\n ptr: 12,\n pointer: 12,\n void: 13,\n cstring: 14,\n i64_fast: 15,\n u64_fast: 16,\n function: 17,\n callback: 17,\n fn: 17\n};\nvar ffi = globalThis.Bun.FFI, ptr = (arg1, arg2) => typeof arg2 === \"undefined\" \? ffi.ptr(arg1) : ffi.ptr(arg1, arg2), toBuffer = ffi.toBuffer, toArrayBuffer = ffi.toArrayBuffer, viewSource = ffi.viewSource, BunCString = ffi.CString, nativeLinkSymbols = ffi.linkSymbols, nativeDLOpen = ffi.dlopen, nativeCallback = ffi.callback, closeCallback = ffi.closeCallback;\ndelete ffi.callback;\ndelete ffi.closeCallback;\n\nclass JSCallback {\n constructor(cb, options) {\n const { ctx, ptr: ptr2 } = nativeCallback(options, cb);\n this.#ctx = ctx, this.ptr = ptr2, this.#threadsafe = !!options\?.threadsafe;\n }\n ptr;\n #ctx;\n #threadsafe;\n get threadsafe() {\n return this.#threadsafe;\n }\n [Symbol.toPrimitive]() {\n const { ptr: ptr2 } = this;\n return typeof ptr2 === \"number\" \? ptr2 : 0;\n }\n close() {\n const ctx = this.#ctx;\n if (this.ptr = null, this.#ctx = null, ctx)\n closeCallback(ctx);\n }\n}\n\nclass CString extends String {\n constructor(ptr2, byteOffset, byteLength) {\n super(ptr2 \? typeof byteLength === \"number\" && Number.isSafeInteger(byteLength) \? new BunCString(ptr2, byteOffset || 0, byteLength) : new BunCString(ptr2) : \"\");\n if (this.ptr = typeof ptr2 === \"number\" \? ptr2 : 0, typeof byteOffset !== \"undefined\")\n this.byteOffset = byteOffset;\n if (typeof byteLength !== \"undefined\")\n this.byteLength = byteLength;\n }\n ptr;\n byteOffset;\n byteLength;\n #cachedArrayBuffer;\n get arrayBuffer() {\n if (this.#cachedArrayBuffer)\n return this.#cachedArrayBuffer;\n if (!this.ptr)\n return this.#cachedArrayBuffer = new ArrayBuffer(0);\n return this.#cachedArrayBuffer = toArrayBuffer(this.ptr, this.byteOffset, this.byteLength);\n }\n}\nObject.defineProperty(globalThis, \"__GlobalBunCString\", {\n value: CString,\n enumerable: !1,\n configurable: !1\n});\nvar ffiWrappers = new Array(18), char = \"val|0\";\nffiWrappers.fill(char);\nffiWrappers[FFIType.uint8_t] = \"val<0\?0:val>=255\?255:val|0\";\nffiWrappers[FFIType.int16_t] = \"val<=-32768\?-32768:val>=32768\?32768:val|0\";\nffiWrappers[FFIType.uint16_t] = \"val<=0\?0:val>=65536\?65536:val|0\";\nffiWrappers[FFIType.int32_t] = \"val|0\";\nffiWrappers[FFIType.uint32_t] = \"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\";\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.int64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.uint64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`;\nffiWrappers[FFIType.uint16_t] = `{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`;\nffiWrappers[FFIType.double] = `{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`;\nffiWrappers[FFIType.float] = ffiWrappers[10] = `{\n return Math.fround(val);\n}`;\nffiWrappers[FFIType.bool] = `{\n return !!val;\n}`;\nObject.defineProperty(globalThis, \"__GlobalBunFFIPtrFunctionForWrapper\", {\n value: ptr,\n enumerable: !1,\n configurable: !0\n});\nffiWrappers[FFIType.cstring] = ffiWrappers[FFIType.pointer] = `{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`;\nffiWrappers[FFIType.function] = `{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;\nvar native = {\n dlopen: nativeDLOpen,\n callback: () => {\n throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\");\n }\n}, cFunctionI = 0, cFunctionRegistry, read = ffi.read;\n$ = {\n CFunction,\n CString,\n FFIType,\n JSCallback,\n dlopen,\n linkSymbols,\n native,\n ptr,\n read,\n suffix: \"so\",\n toArrayBuffer,\n toBuffer,\n viewSource\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";// src/js/out/tmp/bun/ffi.ts\nvar FFIBuilder = function(params, returnType, functionToCall, name) {\n const hasReturnType = typeof FFIType[returnType] === \"number\" && FFIType[returnType] !== FFIType.void;\n var paramNames = new Array(params.length), args = new Array(params.length);\n for (let i = 0;i < params.length; i++) {\n paramNames[i] = `p${i}`;\n const wrapper = ffiWrappers[FFIType[params[i]]];\n if (wrapper)\n args[i] = `(val=>${wrapper})(p${i})`;\n else\n @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`);\n }\n var code = `functionToCall(${args.join(\", \")})`;\n if (hasReturnType)\n if (FFIType[returnType] === FFIType.cstring)\n code = `return new __GlobalBunCString(${code})`;\n else\n code = `return ${code}`;\n var func = new Function(\"functionToCall\", ...paramNames, code);\n Object.defineProperty(func, \"name\", {\n value: name\n });\n var wrap;\n switch (paramNames.length) {\n case 0:\n wrap = () => func(functionToCall);\n break;\n case 1:\n wrap = (arg1) => func(functionToCall, arg1);\n break;\n case 2:\n wrap = (arg1, arg2) => func(functionToCall, arg1, arg2);\n break;\n case 3:\n wrap = (arg1, arg2, arg3) => func(functionToCall, arg1, arg2, arg3);\n break;\n case 4:\n wrap = (arg1, arg2, arg3, arg4) => func(functionToCall, arg1, arg2, arg3, arg4);\n break;\n case 5:\n wrap = (arg1, arg2, arg3, arg4, arg5) => func(functionToCall, arg1, arg2, arg3, arg4, arg5);\n break;\n case 6:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6);\n break;\n case 7:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n break;\n case 8:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n break;\n case 9:\n wrap = (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => func(functionToCall, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);\n break;\n default: {\n wrap = (...args2) => func(functionToCall, ...args2);\n break;\n }\n }\n return wrap.native = functionToCall, wrap.ptr = functionToCall.ptr, wrap;\n}, dlopen = function(path, options) {\n const result = nativeDLOpen(path, options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, path.includes(\"/\") \? `${key} (${path.split(\"/\").pop()})` : `${key} (${path})`);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result.close = result.close.bind(result), result;\n}, linkSymbols = function(options) {\n const result = nativeLinkSymbols(options);\n for (let key in result.symbols) {\n var symbol = result.symbols[key];\n if (options[key]\?.args\?.length || FFIType[options[key]\?.returns] === FFIType.cstring)\n result.symbols[key] = FFIBuilder(options[key].args \?\? [], options[key].returns \?\? FFIType.void, symbol, key);\n else\n result.symbols[key].native = result.symbols[key];\n }\n return result;\n}, onCloseCFunction = function(close) {\n close();\n}, CFunction = function(options) {\n const identifier = `CFunction${cFunctionI++}`;\n var result = linkSymbols({\n [identifier]: options\n }), hasClosed = !1, close = result.close.bind(result);\n return result.symbols[identifier].close = () => {\n if (hasClosed || !close)\n return;\n hasClosed = !0, close(), close = void 0;\n }, cFunctionRegistry ||= new FinalizationRegistry(onCloseCFunction), cFunctionRegistry.register(result.symbols[identifier], result.symbols[identifier].close), result.symbols[identifier];\n}, $, FFIType = {\n \"0\": 0,\n \"1\": 1,\n \"2\": 2,\n \"3\": 3,\n \"4\": 4,\n \"5\": 5,\n \"6\": 6,\n \"7\": 7,\n \"8\": 8,\n \"9\": 9,\n \"10\": 10,\n \"11\": 11,\n \"12\": 12,\n \"13\": 13,\n \"14\": 14,\n \"15\": 15,\n \"16\": 16,\n \"17\": 17,\n bool: 11,\n c_int: 5,\n c_uint: 6,\n char: 0,\n \"char*\": 12,\n double: 9,\n f32: 10,\n f64: 9,\n float: 10,\n i16: 3,\n i32: 5,\n i64: 7,\n i8: 1,\n int: 5,\n int16_t: 3,\n int32_t: 5,\n int64_t: 7,\n int8_t: 1,\n isize: 7,\n u16: 4,\n u32: 6,\n u64: 8,\n u8: 2,\n uint16_t: 4,\n uint32_t: 6,\n uint64_t: 8,\n uint8_t: 2,\n usize: 8,\n \"void*\": 12,\n ptr: 12,\n pointer: 12,\n void: 13,\n cstring: 14,\n i64_fast: 15,\n u64_fast: 16,\n function: 17,\n callback: 17,\n fn: 17\n};\nvar ffi = globalThis.Bun.FFI, ptr = (arg1, arg2) => typeof arg2 === \"undefined\" \? ffi.ptr(arg1) : ffi.ptr(arg1, arg2), toBuffer = ffi.toBuffer, toArrayBuffer = ffi.toArrayBuffer, viewSource = ffi.viewSource, BunCString = ffi.CString, nativeLinkSymbols = ffi.linkSymbols, nativeDLOpen = ffi.dlopen, nativeCallback = ffi.callback, closeCallback = ffi.closeCallback;\ndelete ffi.callback;\ndelete ffi.closeCallback;\n\nclass JSCallback {\n constructor(cb, options) {\n const { ctx, ptr: ptr2 } = nativeCallback(options, cb);\n this.#ctx = ctx, this.ptr = ptr2, this.#threadsafe = !!options\?.threadsafe;\n }\n ptr;\n #ctx;\n #threadsafe;\n get threadsafe() {\n return this.#threadsafe;\n }\n [Symbol.toPrimitive]() {\n const { ptr: ptr2 } = this;\n return typeof ptr2 === \"number\" \? ptr2 : 0;\n }\n close() {\n const ctx = this.#ctx;\n if (this.ptr = null, this.#ctx = null, ctx)\n closeCallback(ctx);\n }\n}\n\nclass CString extends String {\n constructor(ptr2, byteOffset, byteLength) {\n super(ptr2 \? typeof byteLength === \"number\" && Number.isSafeInteger(byteLength) \? BunCString(ptr2, byteOffset || 0, byteLength) : BunCString(ptr2) : \"\");\n if (this.ptr = typeof ptr2 === \"number\" \? ptr2 : 0, typeof byteOffset !== \"undefined\")\n this.byteOffset = byteOffset;\n if (typeof byteLength !== \"undefined\")\n this.byteLength = byteLength;\n }\n ptr;\n byteOffset;\n byteLength;\n #cachedArrayBuffer;\n get arrayBuffer() {\n if (this.#cachedArrayBuffer)\n return this.#cachedArrayBuffer;\n if (!this.ptr)\n return this.#cachedArrayBuffer = new ArrayBuffer(0);\n return this.#cachedArrayBuffer = toArrayBuffer(this.ptr, this.byteOffset, this.byteLength);\n }\n}\nObject.defineProperty(globalThis, \"__GlobalBunCString\", {\n value: CString,\n enumerable: !1,\n configurable: !1\n});\nvar ffiWrappers = new Array(18), char = \"val|0\";\nffiWrappers.fill(char);\nffiWrappers[FFIType.uint8_t] = \"val<0\?0:val>=255\?255:val|0\";\nffiWrappers[FFIType.int16_t] = \"val<=-32768\?-32768:val>=32768\?32768:val|0\";\nffiWrappers[FFIType.uint16_t] = \"val<=0\?0:val>=65536\?65536:val|0\";\nffiWrappers[FFIType.int32_t] = \"val|0\";\nffiWrappers[FFIType.uint32_t] = \"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\";\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.i64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`;\nffiWrappers[FFIType.int64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.uint64_t] = `{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`;\nffiWrappers[FFIType.u64_fast] = `{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`;\nffiWrappers[FFIType.uint16_t] = `{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`;\nffiWrappers[FFIType.double] = `{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`;\nffiWrappers[FFIType.float] = ffiWrappers[10] = `{\n return Math.fround(val);\n}`;\nffiWrappers[FFIType.bool] = `{\n return !!val;\n}`;\nObject.defineProperty(globalThis, \"__GlobalBunFFIPtrFunctionForWrapper\", {\n value: ptr,\n enumerable: !1,\n configurable: !0\n});\nffiWrappers[FFIType.cstring] = ffiWrappers[FFIType.pointer] = `{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`;\nffiWrappers[FFIType.function] = `{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;\nvar native = {\n dlopen: nativeDLOpen,\n callback: () => {\n throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\");\n }\n}, cFunctionI = 0, cFunctionRegistry, read = ffi.read;\n$ = {\n CFunction,\n CString,\n FFIType,\n JSCallback,\n dlopen,\n linkSymbols,\n native,\n ptr,\n read,\n suffix: \"so\",\n toArrayBuffer,\n toBuffer,\n viewSource\n};\nreturn $})\n"_s;
//
//
@@ -473,7 +473,7 @@ static constexpr ASCIILiteral BunSqliteCode = "(function (){\"use strict\";// sr
//
//
-static constexpr ASCIILiteral InternalDebuggerCode = "(function (){\"use strict\";// src/js/out/tmp/internal/debugger.ts\nvar generatePath = function() {\n if (!generatedPath)\n generatedPath = \"/\" + Math.random().toString(36).slice(2);\n return generatedPath;\n}, terminalLink = function(url) {\n if (Bun.enableANSIColors)\n return \"\\x1B[1m\\x1B]8;;\" + url + \"\\x1B\\\\\" + url + \"\\x1B]8;;\\x1B\\\\\" + \"\\x1B[22m\";\n return url;\n}, dim = function(text) {\n if (Bun.enableANSIColors)\n return \"\\x1B[2m\" + text + \"\\x1B[22m\";\n return text;\n}, $, sendFn_, disconnectFn_, debuggerCounter = 1;\n\nclass DebuggerWithMessageQueue {\n debugger = void 0;\n messageQueue = [];\n count = debuggerCounter++;\n send(msg) {\n sendFn_.call(this.debugger, msg);\n }\n disconnect() {\n disconnectFn_.call(this.debugger), this.messageQueue.length = 0;\n }\n}\nvar defaultPort = 6499, generatedPath = \"\";\n\nclass WebSocketListener {\n server;\n url = \"\";\n createInspectorConnection;\n scriptExecutionContextId = 0;\n activeConnections = new Set;\n constructor(scriptExecutionContextId = 0, url, createInspectorConnection) {\n this.scriptExecutionContextId = scriptExecutionContextId, this.createInspectorConnection = createInspectorConnection, this.server = this.start(url);\n }\n start(url) {\n let defaultHostname = \"localhost\", usingDefaultPort = !1;\n if (/^[0-9]*$/.test(url))\n url = \"ws://\" + defaultHostname + \":\" + url + generatePath();\n else if (!url || url.startsWith(\"/\"))\n url = \"ws://\" + defaultHostname + \":\" + defaultPort + generatePath(), usingDefaultPort = !0;\n else if (url.includes(\":\") && !url.includes(\"://\"))\n try {\n const insertSlash = !url.includes(\"/\");\n if (url = new URL(\"ws://\" + url).href, insertSlash)\n url += generatePath().slice(1);\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n try {\n var { hostname, port, pathname } = new URL(url);\n this.url = pathname.toLowerCase();\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n const serveOptions = {\n hostname,\n development: !1,\n reusePort: !1,\n websocket: {\n idleTimeout: 0,\n open: (socket) => {\n var connection = new DebuggerWithMessageQueue;\n socket.data = connection, this.activeConnections.add(socket), connection.debugger = this.createInspectorConnection(this.scriptExecutionContextId, (...msgs) => {\n if (socket.readyState > 1) {\n connection.disconnect();\n return;\n }\n if (connection.messageQueue.length > 0) {\n connection.messageQueue.push(...msgs);\n return;\n }\n for (let i = 0;i < msgs.length; i++)\n if (!socket.sendText(msgs[i])) {\n if (socket.readyState < 2)\n connection.messageQueue.push(...msgs.slice(i));\n return;\n }\n }), console.log(\"[Inspector]\", \"Connection #\" + connection.count + \" opened\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\");\n },\n drain: (socket) => {\n const queue = socket.data.messageQueue;\n for (let i = 0;i < queue.length; i++)\n if (!socket.sendText(queue[i])) {\n socket.data.messageQueue = queue.slice(i);\n return;\n }\n queue.length = 0;\n },\n message: (socket, message) => {\n if (typeof message !== \"string\") {\n console.warn(\"[Inspector]\", \"Received non-string message\");\n return;\n }\n socket.data.send(message);\n },\n close: (socket) => {\n socket.data.disconnect(), console.log(\"[Inspector]\", \"Connection #\" + socket.data.count + \" closed\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\"), this.activeConnections.delete(socket);\n }\n },\n fetch: (req, server2) => {\n let { pathname: pathname2 } = new URL(req.url);\n if (pathname2 = pathname2.toLowerCase(), pathname2 === \"/json/version\")\n return Response.json({\n Browser: navigator.userAgent,\n \"WebKit-Version\": process.versions.webkit,\n \"Bun-Version\": Bun.version,\n \"Bun-Revision\": Bun.revision\n });\n if (pathname2 === this.url) {\n if (server2.upgrade(req))\n return new Response;\n return new Response(\"WebSocket expected\", {\n status: 400\n });\n }\n return new Response(\"Not found\", {\n status: 404\n });\n }\n };\n if (port === \"\")\n port = defaultPort + \"\";\n let portNumber = Number(port);\n var server, lastError;\n if (usingDefaultPort)\n for (let tries = 0;tries < 10 && !server; tries++)\n try {\n lastError = void 0, server = Bun.serve({\n ...serveOptions,\n port: portNumber++\n });\n } catch (e) {\n lastError = e;\n }\n else\n try {\n server = Bun.serve({\n ...serveOptions,\n port: portNumber\n });\n } catch (e) {\n lastError = e;\n }\n if (!server) {\n if (console.error(\"[Inspector]\", \"Failed to start server\"), lastError)\n console.error(lastError);\n process.exit(1);\n }\n let textToWrite = \"\";\n function writeToConsole(text) {\n textToWrite += text;\n }\n function flushToConsole() {\n console.write(textToWrite);\n }\n return writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), writeToConsole(\"\\x1B[49m\"), writeToConsole(\"Listening at:\\n \" + `ws://${hostname}:${server.port}${this.url}` + \"\\n\\nInspect in browser:\\n \" + terminalLink(new URL(`https://debug.bun.sh#${server.hostname}:${server.port}${this.url}`).href) + \"\\n\"), writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), flushToConsole(), server;\n }\n}\nvar listener;\n$ = function start(debuggerId, hostOrPort, createInspectorConnection, sendFn, disconnectFn) {\n try {\n sendFn_ = sendFn, disconnectFn_ = disconnectFn, globalThis.listener = listener ||= new WebSocketListener(debuggerId, hostOrPort, createInspectorConnection);\n } catch (e) {\n console.error(\"Bun Inspector threw an exception\\n\", e), process.exit(1);\n }\n return `http://${listener.server.hostname}:${listener.server.port}${listener.url}`;\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral InternalDebuggerCode = "(function (){\"use strict\";// src/js/out/tmp/internal/debugger.ts\nvar generatePath = function() {\n if (!generatedPath)\n generatedPath = \"/\" + Math.random().toString(36).slice(2);\n return generatedPath;\n}, terminalLink = function(url) {\n if (Bun.enableANSIColors)\n return \"\\x1B[1m\\x1B]8;;\" + url + \"\\x1B\\\\\" + url + \"\\x1B]8;;\\x1B\\\\\" + \"\\x1B[22m\";\n return url;\n}, dim = function(text) {\n if (Bun.enableANSIColors)\n return \"\\x1B[2m\" + text + \"\\x1B[22m\";\n return text;\n}, $, sendFn_, disconnectFn_, debuggerCounter = 1;\n\nclass DebuggerWithMessageQueue {\n debugger = void 0;\n messageQueue = [];\n count = debuggerCounter++;\n send(msg) {\n sendFn_.call(this.debugger, msg);\n }\n disconnect() {\n disconnectFn_.call(this.debugger), this.messageQueue.length = 0;\n }\n}\nvar defaultPort = 6499, generatedPath = \"\";\n\nclass WebSocketListener {\n server;\n url = \"\";\n createInspectorConnection;\n scriptExecutionContextId = 0;\n activeConnections = new Set;\n constructor(scriptExecutionContextId = 0, url, createInspectorConnection) {\n this.scriptExecutionContextId = scriptExecutionContextId, this.createInspectorConnection = createInspectorConnection, this.server = this.start(url);\n }\n start(url) {\n let defaultHostname = \"localhost\", usingDefaultPort = !1;\n if (/^[0-9]*$/.test(url))\n url = \"ws://\" + defaultHostname + \":\" + url + generatePath();\n else if (!url || url.startsWith(\"/\"))\n url = \"ws://\" + defaultHostname + \":\" + defaultPort + generatePath(), usingDefaultPort = !0;\n else if (url.includes(\":\") && !url.includes(\"://\"))\n try {\n const insertSlash = !url.includes(\"/\");\n if (url = new URL(\"ws://\" + url).href, insertSlash)\n url += generatePath().slice(1);\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n try {\n var { hostname, port, pathname } = new URL(url);\n this.url = pathname.toLowerCase();\n } catch (e) {\n console.error(\"[Inspector]\", \"Failed to parse url\", '\"' + url + '\"'), process.exit(1);\n }\n const serveOptions = {\n hostname,\n development: !1,\n reusePort: !1,\n websocket: {\n idleTimeout: 0,\n open: (socket) => {\n var connection = new DebuggerWithMessageQueue;\n const shouldRefEventLoop = !!socket.data\?.shouldRefEventLoop;\n socket.data = connection, this.activeConnections.add(socket), connection.debugger = this.createInspectorConnection(this.scriptExecutionContextId, shouldRefEventLoop, (...msgs) => {\n if (socket.readyState > 1) {\n connection.disconnect();\n return;\n }\n if (connection.messageQueue.length > 0) {\n connection.messageQueue.push(...msgs);\n return;\n }\n for (let i = 0;i < msgs.length; i++)\n if (!socket.sendText(msgs[i])) {\n if (socket.readyState < 2)\n connection.messageQueue.push(...msgs.slice(i));\n return;\n }\n }), console.log(\"[Inspector]\", \"Connection #\" + connection.count + \" opened\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\");\n },\n drain: (socket) => {\n const queue = socket.data.messageQueue;\n for (let i = 0;i < queue.length; i++)\n if (!socket.sendText(queue[i])) {\n socket.data.messageQueue = queue.slice(i);\n return;\n }\n queue.length = 0;\n },\n message: (socket, message) => {\n if (typeof message !== \"string\") {\n console.warn(\"[Inspector]\", \"Received non-string message\");\n return;\n }\n socket.data.send(message);\n },\n close: (socket) => {\n socket.data.disconnect(), console.log(\"[Inspector]\", \"Connection #\" + socket.data.count + \" closed\", \"(\" + new Intl.DateTimeFormat(void 0, {\n timeStyle: \"long\",\n dateStyle: \"short\"\n }).format(new Date) + \")\"), this.activeConnections.delete(socket);\n }\n },\n fetch: (req, server2) => {\n let { pathname: pathname2 } = new URL(req.url);\n if (pathname2 = pathname2.toLowerCase(), pathname2 === \"/json/version\")\n return Response.json({\n Browser: navigator.userAgent,\n \"WebKit-Version\": process.versions.webkit,\n \"Bun-Version\": Bun.version,\n \"Bun-Revision\": Bun.revision\n });\n if (pathname2 === this.url) {\n const refHeader = req.headers.get(\"Ref-Event-Loop\");\n if (server2.upgrade(req, {\n data: {\n shouldRefEventLoop: !!refHeader && refHeader !== \"0\"\n }\n }))\n return new Response;\n return new Response(\"WebSocket expected\", {\n status: 400\n });\n }\n return new Response(\"Not found\", {\n status: 404\n });\n }\n };\n if (port === \"\")\n port = defaultPort + \"\";\n let portNumber = Number(port);\n var server, lastError;\n if (usingDefaultPort)\n for (let tries = 0;tries < 10 && !server; tries++)\n try {\n lastError = void 0, server = Bun.serve({\n ...serveOptions,\n port: portNumber++\n });\n } catch (e) {\n lastError = e;\n }\n else\n try {\n server = Bun.serve({\n ...serveOptions,\n port: portNumber\n });\n } catch (e) {\n lastError = e;\n }\n if (!server) {\n if (console.error(\"[Inspector]\", \"Failed to start server\"), lastError)\n console.error(lastError);\n process.exit(1);\n }\n let textToWrite = \"\";\n function writeToConsole(text) {\n textToWrite += text;\n }\n function flushToConsole() {\n console.write(textToWrite);\n }\n return writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), writeToConsole(\"\\x1B[49m\"), writeToConsole(\"Listening at:\\n \" + `ws://${hostname}:${server.port}${this.url}` + \"\\n\\nInspect in browser:\\n \" + terminalLink(new URL(`https://debug.bun.sh#${server.hostname}:${server.port}${this.url}`).href) + \"\\n\"), writeToConsole(dim(\"------------------ Bun Inspector ------------------\\n\")), flushToConsole(), server;\n }\n}\nvar listener;\n$ = function start(debuggerId, hostOrPort, createInspectorConnection, sendFn, disconnectFn) {\n try {\n sendFn_ = sendFn, disconnectFn_ = disconnectFn, globalThis.listener = listener ||= new WebSocketListener(debuggerId, hostOrPort, createInspectorConnection);\n } catch (e) {\n console.error(\"Bun Inspector threw an exception\\n\", e), process.exit(1);\n }\n return `http://${listener.server.hostname}:${listener.server.port}${listener.url}`;\n};\nreturn $})\n"_s;
//
//
diff --git a/src/js_ast.zig b/src/js_ast.zig
index 19e64336b..6c946b9d1 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -6852,2762 +6852,6 @@ pub const Macro = struct {
replacement: Expr,
};
- pub const JSNode = struct {
- loc: logger.Loc,
- data: Data,
- visited: bool = false,
-
- pub const Class = JSCBase.NewClass(
- JSNode,
- .{
- .name = "JSNode",
- .read_only = true,
- },
- .{
- .toString = .{
- .rfn = JSBindings.toString,
- },
-
- // .getAt = .{
- // .rfn = JSBindings.getAt,
- // },
- // .valueAt = .{
- // .rfn = JSBindings.valueAt,
- // },
- // .toNumber = .{
- // .rfn = toNumber,
- // },
- .get = .{
- .rfn = JSBindings.get,
- .ro = true,
- },
- },
- .{
- .tag = .{
- .get = JSBindings.getTag,
- .ro = true,
- },
-
- .tagName = .{
- .get = JSBindings.getTagName,
- .ro = true,
- },
- .position = .{
- .get = JSBindings.getPosition,
- .ro = true,
- },
- .value = .{
- .get = JSBindings.getValue,
- .ro = true,
- },
- .arguments = .{
- .get = JSBindings.getCallArgs,
- .ro = true,
- },
- .properties = .{
- .get = JSBindings.getProperties,
- .ro = true,
- },
- .propertyNodes = .{
- .get = JSBindings.getPropertyNodes,
- .ro = true,
- },
-
- .namespace = .{
- .get = JSBindings.getModuleNamespace,
- .ro = true,
- },
- },
- );
-
- pub fn makeFromExpr(ctx: js.JSContextRef, allocator: std.mem.Allocator, expr: Expr) js.JSObjectRef {
- var ptr = allocator.create(JSNode) catch unreachable;
- ptr.* = JSNode.initExpr(expr);
- // If we look at JSObjectMake, we can see that all it does with the ctx value is lookup what the global object is
- // so it's safe to just avoid that and do it here like this:
- return JSNode.Class.make(ctx, ptr);
- }
-
- pub fn updateSymbolsMap(this: *const JSNode, comptime Visitor: type, visitor: Visitor) void {
- switch (this.data) {
- Tag.fragment => |frag| {
- for (frag) |child| {
- if (child.data == .inline_inject) {
- child.updateSymbolsMap(Visitor, visitor);
- }
- }
- },
- Tag.inline_inject => |inject| {
- for (inject) |child| {
- child.updateSymbolsMap(Visitor, visitor);
- }
- },
-
- Tag.s_import => |import| {
- visitor.visitImport(import.*);
- },
-
- else => {},
- }
- }
-
- pub const JSBindings = struct {
- const getAllocator = JSCBase.getAllocator;
-
- threadlocal var temporary_call_args_array: [256]js.JSValueRef = undefined;
- pub fn getCallArgs(
- this: *JSNode,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- const args = this.data.callArgs();
-
- switch (args.len) {
- 0 => return js.JSObjectMakeArray(ctx, 0, null, exception),
- 1...255 => {
- var slice = temporary_call_args_array[0..args.len];
- for (slice, 0..) |_, i| {
- var node = JSCBase.getAllocator(ctx).create(JSNode) catch unreachable;
- node.* = JSNode.initExpr(args.ptr[i]);
- slice[i] = JSNode.Class.make(ctx, node);
- }
- return js.JSObjectMakeArray(ctx, args.len, slice.ptr, exception);
- },
- else => {
- Output.prettyErrorln("are you for real? {d} args to your call expression? that has to be a bug.\n", .{args.len});
- Output.flush();
- return js.JSObjectMakeArray(ctx, 0, null, exception);
- },
- }
- }
-
- pub fn getProperties(
- this: *JSNode,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- if (this.data != .e_object) {
- return js.JSObjectMake(ctx, null, null);
- }
-
- var lazy = getAllocator(ctx).create(LazyPropertiesObject) catch unreachable;
- lazy.* = LazyPropertiesObject{ .node = this.* };
- return LazyPropertiesObject.Class.make(ctx, lazy);
- }
-
- pub fn getPropertyNodes(
- this: *JSNode,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- const args: []G.Property = if (this.data == .e_object) this.data.e_object.properties.slice() else &[_]G.Property{};
-
- switch (args.len) {
- 0 => return js.JSObjectMakeArray(ctx, 0, null, exception),
- 1...255 => {
- var slice = temporary_call_args_array[0..args.len];
- for (slice, 0..) |_, i| {
- var node = JSCBase.getAllocator(ctx).create(JSNode) catch unreachable;
- node.* = JSNode{ .data = .{ .g_property = &args[i] }, .loc = this.loc };
- slice[i] = JSNode.Class.make(ctx, node);
- }
- return js.JSObjectMakeArray(ctx, args.len, slice.ptr, exception);
- },
- else => {
- return js.JSObjectMakeArray(ctx, 0, null, exception);
- },
- }
- }
-
- pub fn getModuleNamespace(
- this: *JSNode,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- if (this.data != .s_import) return js.JSValueMakeUndefined(ctx);
-
- var module_namespace = getAllocator(ctx).create(ModuleNamespace) catch unreachable;
- module_namespace.* = ModuleNamespace{ .import_data = this.data.s_import.* };
- return ModuleNamespace.Class.make(ctx, module_namespace);
- }
-
- fn toNumberValue(_: *JSNode, number: E.Number) js.JSValueRef {
- return JSC.JSValue.jsNumberFromDouble(number.value).asRef();
- }
-
- fn toStringValue(_: *JSNode, ctx: js.JSContextRef, str: E.String) js.JSObjectRef {
- if (str.isBlank()) {
- return JSC.ZigString.init("").toValue(ctx.ptr()).asRef();
- }
-
- if (str.isUTF8()) {
- return JSC.ZigString.init(str.data).toValue(ctx.ptr()).asRef();
- } else {
- return js.JSValueMakeString(ctx, js.JSStringCreateWithCharactersNoCopy(str.slice16().ptr, str.slice16().len));
- }
- }
-
- threadlocal var regex_value_array: [2]js.JSValueRef = undefined;
-
- fn toRegexValue(_: *JSNode, ctx: js.JSContextRef, regex: *E.RegExp, exception: js.ExceptionRef) js.JSObjectRef {
- if (regex.value.len == 0) {
- return js.JSObjectMakeRegExp(ctx, 0, null, exception);
- }
-
- regex_value_array[0] = JSC.ZigString.init(regex.pattern()).toValue(ctx.ptr()).asRef();
- regex_value_array[1] = JSC.ZigString.init(regex.flags()).toValue(ctx.ptr()).asRef();
-
- return js.JSObjectMakeRegExp(ctx, 2, &regex_value_array, exception);
- }
-
- fn toArrayValue(_: *JSNode, ctx: js.JSContextRef, array: E.Array, exception: js.ExceptionRef) js.JSObjectRef {
- const items = array.slice();
-
- if (items.len == 0) {
- return js.JSObjectMakeArray(ctx, 0, null, exception);
- }
-
- for (items, 0..) |expr, i| {
- var node = JSCBase.getAllocator(ctx).create(JSNode) catch unreachable;
- node.* = JSNode.initExpr(expr);
- temporary_call_args_array[i] = JSNode.Class.make(ctx, node);
- }
-
- return js.JSObjectMakeArray(ctx, items.len, &temporary_call_args_array, exception);
- }
-
- fn toArrayPrimitive(_: *JSNode, ctx: js.JSContextRef, array: E.Array, exception: js.ExceptionRef) js.JSObjectRef {
- const items = array.slice();
- if (items.len == 0) {
- return js.JSObjectMakeArray(ctx, 0, null, exception);
- }
-
- var node: JSNode = undefined;
- for (items, 0..) |expr, i| {
- node = JSNode.initExpr(expr);
- temporary_call_args_array[i] = toPrimitive(&node, ctx, exception);
- }
-
- return js.JSObjectMakeArray(ctx, items.len, temporary_call_args_array[0..items.len].ptr, exception);
- }
-
- fn toObjectValue(this: *JSNode, ctx: js.JSContextRef, obj: E.Object, exception: js.ExceptionRef) js.JSObjectRef {
- if (obj.properties.len == 0) {
- return js.JSObjectMakeArray(ctx, 0, null, exception);
- }
-
- var object_properties_array: [64]js.JSObjectRef = undefined;
-
- var did_allocate = false;
- var properties_list = if (obj.properties.len < object_properties_array.len)
- object_properties_array[0..obj.properties.len]
- else brk: {
- did_allocate = true;
- break :brk getAllocator(ctx).alloc(js.JSObjectRef, obj.properties.len) catch unreachable;
- };
-
- defer if (did_allocate) getAllocator(ctx).free(properties_list);
-
- for (obj.properties.slice(), 0..) |_, i| {
- var node = JSCBase.getAllocator(ctx).create(JSNode) catch unreachable;
- node.* = JSNode{
- .data = .{
- .g_property = &obj.properties.ptr[i],
- },
- .loc = this.loc,
- };
- properties_list[i] = JSNode.Class.make(ctx, node);
- }
-
- return js.JSObjectMakeArray(ctx, properties_list.len, properties_list.ptr, exception);
- }
-
- fn toObjectPrimitive(this: *JSNode, ctx: js.JSContextRef, _: E.Object, _: js.ExceptionRef) js.JSObjectRef {
- var lazy = getAllocator(ctx).create(LazyPropertiesObject) catch unreachable;
- lazy.* = LazyPropertiesObject{ .node = this.* };
- return LazyPropertiesObject.Class.make(ctx, lazy);
- }
-
- fn toPropertyPrimitive(_: *JSNode, ctx: js.JSContextRef, prop: G.Property, exception: js.ExceptionRef) js.JSObjectRef {
- var entries: [3]js.JSValueRef = undefined;
-
- entries[0] = js.JSValueMakeUndefined(ctx);
- entries[1] = entries[0];
- entries[2] = entries[0];
-
- var other: JSNode = undefined;
-
- if (prop.key) |key| {
- other = JSNode.initExpr(key);
- entries[0] = toPrimitive(
- &other,
- ctx,
- exception,
- ) orelse js.JSValueMakeUndefined(ctx);
- }
-
- if (prop.value) |value| {
- other = JSNode.initExpr(value);
- entries[1] = toPrimitive(
- &other,
- ctx,
- exception,
- ) orelse js.JSValueMakeUndefined(ctx);
- }
-
- if (prop.initializer) |value| {
- other = JSNode.initExpr(value);
- entries[2] = toPrimitive(
- &other,
- ctx,
- exception,
- ) orelse js.JSValueMakeUndefined(ctx);
- }
-
- const out = js.JSObjectMakeArray(ctx, 3, &entries, exception);
- return out;
- }
-
- pub fn toString(
- this: *JSNode,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- switch (this.data) {
- .e_string => |str| {
- return toStringValue(this, ctx, str.*);
- },
- .e_template => |template| {
- const str = switch (template.head) {
- .cooked => |cooked| cooked,
- .raw => |raw| E.String.init(raw),
- };
-
- if (str.isBlank()) {
- return JSC.ZigString.init("").toValue(ctx.ptr()).asRef();
- }
-
- if (str.isUTF8()) {
- return JSC.ZigString.init(str.data).toValue(ctx.ptr()).asRef();
- } else {
- return js.JSValueMakeString(ctx, js.JSStringCreateWithCharactersNoCopy(str.slice16().ptr, str.slice16().len));
- }
- },
- // .e_number => |number| {
-
- // },
- else => {
- return JSC.ZigString.init("").toValue(ctx.ptr()).asRef();
- },
- }
- }
-
- fn toPrimitive(
- this: *JSNode,
- ctx: js.JSContextRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- return @call(.always_inline, toPrimitiveAllowRecursion, .{ this, ctx, exception, false });
- }
-
- fn toPrimitiveWithRecursion(
- this: *JSNode,
- ctx: js.JSContextRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- return @call(.always_inline, toPrimitiveAllowRecursion, .{ this, ctx, exception, true });
- }
-
- fn toPrimitiveAllowRecursion(this: *JSNode, ctx: js.JSContextRef, exception: js.ExceptionRef, comptime _: bool) js.JSValueRef {
- switch (this.data) {
- .e_string => |str| {
- return JSBindings.toStringValue(this, ctx, str.*);
- },
- .e_template => |template| {
- return switch (template.head) {
- .cooked => |cooked| JSBindings.toStringValue(this, ctx, cooked),
- .raw => |raw| JSBindings.toStringValue(this, ctx, E.String.init(raw)),
- };
- },
- .e_number => |number| {
- return JSBindings.toNumberValue(this, number);
- },
- .e_reg_exp => |regex| {
- return JSBindings.toRegexValue(this, ctx, regex, exception);
- },
- .e_object => |object| {
- return JSBindings.toObjectPrimitive(this, ctx, object.*, exception);
- },
- .e_array => |array| {
- return JSBindings.toArrayPrimitive(this, ctx, array.*, exception);
- },
-
- // Returns an Entry
- // [string, number | regex | object | string | null | undefined]
- .g_property => |property| {
- return JSBindings.toPropertyPrimitive(this, ctx, property.*, exception);
- },
- .e_null => {
- return js.JSValueMakeNull(ctx);
- },
- else => {
- return js.JSValueMakeUndefined(ctx);
- },
- }
- }
-
- fn toValue(this: *JSNode, ctx: js.JSContextRef, exception: js.ExceptionRef) js.JSObjectRef {
- switch (this.data) {
- .e_await => |aw| {
- return JSNode.makeFromExpr(ctx, getAllocator(ctx), aw.value);
- },
- .e_yield => |yi| {
- return JSNode.makeFromExpr(ctx, getAllocator(ctx), yi.value orelse return null);
- },
- .e_spread => |spread| {
- return JSNode.makeFromExpr(ctx, getAllocator(ctx), spread.value);
- },
- .e_reg_exp => |reg| {
- return JSC.ZigString.toRef(reg.value, ctx.ptr());
- },
-
- .e_array => |array| {
- return toArrayValue(this, ctx, array.*, exception);
- },
- .e_object => |obj| {
- return toObjectValue(this, ctx, obj.*, exception);
- },
- else => {
- return null;
- },
- }
- }
-
- pub fn getValue(
- this: *JSNode,
- ctx: js.JSContextRef,
- thisObject: js.JSValueRef,
- _: js.JSStringRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- return toValue(this, ctx, exception) orelse return thisObject;
- }
-
- pub fn get(
- this: *JSNode,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- return toPrimitiveWithRecursion(this, ctx, exception) orelse return js.JSValueMakeUndefined(ctx);
- }
-
- pub fn getTag(
- this: *JSNode,
- _: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- return JSC.JSValue.jsNumberFromU16(@as(u16, @intCast(@intFromEnum(std.meta.activeTag(this.data))))).asRef();
- }
- pub fn getTagName(
- this: *JSNode,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- return JSC.ZigString.init(@tagName(this.data)).toValue(ctx.ptr()).asRef();
- }
- pub fn getPosition(
- this: *JSNode,
- _: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- return JSC.JSValue.jsNumberFromInt32(this.loc.start).asRef();
- }
- };
-
- pub fn initExpr(this: Expr) JSNode {
- switch (this.data) {
- .e_array => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_array = value } };
- },
- .e_unary => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_unary = value } };
- },
- .e_binary => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_binary = value } };
- },
- .e_function => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_function = value } };
- },
- .e_new_target => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_new_target = value } };
- },
- .e_import_meta => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_import_meta = value } };
- },
- .e_call => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_call = value } };
- },
- .e_dot => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_dot = value } };
- },
- .e_index => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_index = value } };
- },
- .e_arrow => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_arrow = value } };
- },
- .e_identifier => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_identifier = value } };
- },
- .e_import_identifier => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_import_identifier = value } };
- },
- .e_private_identifier => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_private_identifier = value } };
- },
- .e_jsx_element => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_jsx_element = value } };
- },
- .e_big_int => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_big_int = value } };
- },
- .e_object => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_object = value } };
- },
- .e_spread => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_spread = value } };
- },
- .e_string => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_string = value } };
- },
- .e_template_part => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_template_part = value } };
- },
- .e_template => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_template = value } };
- },
- .e_reg_exp => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_reg_exp = value } };
- },
- .e_await => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_await = value } };
- },
- .e_yield => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_yield = value } };
- },
- .e_if => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_if = value } };
- },
- .e_require_resolve_string => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_require_resolve_string = value } };
- },
- .e_import => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_import = value } };
- },
- .e_this => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_this = value } };
- },
- .e_class => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_class = value } };
- },
- .e_require_string => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_require_string = value } };
- },
- .e_missing => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_missing = value } };
- },
- .e_boolean => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_boolean = value } };
- },
- .e_super => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_super = value } };
- },
- .e_null => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_null = value } };
- },
- .e_number => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_number = value } };
- },
- .e_undefined => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .e_undefined = value } };
- },
- .inline_identifier => |value| {
- return JSNode{ .loc = this.loc, .data = .{ .inline_identifier = value } };
- },
- else => {
- if (comptime Environment.isDebug) {
- Output.prettyWarnln("initExpr fail: {s}", .{@tagName(this.data)});
- }
- return JSNode{ .loc = this.loc, .data = .{ .e_missing = .{} } };
- },
- }
- }
-
- pub fn toExpr(this: JSNode) Expr {
- switch (this.data) {
- .e_array => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_array = value } };
- },
- .e_unary => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_unary = value } };
- },
- .e_binary => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_binary = value } };
- },
- .e_function => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_function = value } };
- },
- .e_new_target => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_new_target = value } };
- },
- .e_import_meta => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_import_meta = value } };
- },
- .e_call => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_call = value } };
- },
- .e_dot => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_dot = value } };
- },
- .e_index => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_index = value } };
- },
- .e_arrow => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_arrow = value } };
- },
- .e_identifier => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_identifier = value } };
- },
- .e_import_identifier => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_import_identifier = value } };
- },
- .e_private_identifier => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_private_identifier = value } };
- },
- .e_jsx_element => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_jsx_element = value } };
- },
- .e_big_int => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_big_int = value } };
- },
- .e_object => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_object = value } };
- },
- .e_spread => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_spread = value } };
- },
- .e_string => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_string = value } };
- },
- .e_template_part => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_template_part = value } };
- },
- .e_template => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_template = value } };
- },
- .e_reg_exp => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_reg_exp = value } };
- },
- .e_await => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_await = value } };
- },
- .e_yield => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_yield = value } };
- },
- .e_if => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_if = value } };
- },
- .e_require_resolve_string => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_require_resolve_string = value } };
- },
- .e_import => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_import = value } };
- },
- .e_this => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_this = value } };
- },
- .e_class => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_class = value } };
- },
- .e_require_string => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_require_string = value } };
- },
- .e_missing => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_missing = value } };
- },
- .e_boolean => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_boolean = value } };
- },
- .e_super => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_super = value } };
- },
- .e_null => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_null = value } };
- },
- .e_number => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_number = value } };
- },
- .e_undefined => |value| {
- return Expr{ .loc = this.loc, .data = .{ .e_undefined = value } };
- },
- .inline_identifier => |value| {
- return Expr{ .loc = this.loc, .data = .{ .inline_identifier = value } };
- },
- .fragment => |fragment| {
- if (fragment.len == 0) return Expr{ .loc = this.loc, .data = .{ .e_missing = E.Missing{} } };
-
- var left = toExpr(fragment[0]);
-
- if (fragment.len == 1) return left;
-
- for (fragment[1..]) |item| {
- const right = toExpr(item);
- left = Expr.joinWithComma(left, right, default_allocator);
- }
-
- return left;
- },
- else => {
- return Expr{ .loc = this.loc, .data = .{ .e_missing = .{} } };
- },
- }
- }
-
- // S.Import but with the path
- pub const ImportData = struct {
- import: S.Import,
- path: string,
- };
-
- pub const Data = union(Tag) {
- inline_false: void,
- inline_true: void,
- e_boolean: E.Boolean,
- fragment: []JSNode,
-
- e_super: E.Super,
- e_null: E.Null,
- e_number: E.Number,
- e_undefined: E.Undefined,
- e_new_target: E.NewTarget,
- e_import_meta: E.ImportMeta,
- e_missing: E.Missing,
- e_this: E.This,
-
- e_array: *E.Array,
- e_unary: *E.Unary,
- e_binary: *E.Binary,
- e_function: *E.Function,
-
- e_call: *E.Call,
- e_dot: *E.Dot,
- e_index: *E.Index,
- e_arrow: *E.Arrow,
-
- e_identifier: E.Identifier,
- e_import_identifier: E.ImportIdentifier,
- e_private_identifier: E.PrivateIdentifier,
-
- e_jsx_element: *E.JSXElement,
-
- e_big_int: *E.BigInt,
- e_object: *E.Object,
- e_spread: *E.Spread,
- e_string: *E.String,
- e_template_part: *E.TemplatePart,
- e_template: *E.Template,
-
- e_await: *E.Await,
- e_yield: *E.Yield,
- e_if: *E.If,
-
- e_import: *E.Import,
-
- e_class: *E.Class,
-
- s_import: *ImportData,
- s_block: *S.Block,
-
- e_reg_exp: *E.RegExp,
- e_require_resolve_string: E.RequireResolveString,
- e_require_string: E.RequireString,
- e_require_call_target: void,
- e_require_resolve_call_target: void,
-
- g_property: *G.Property,
-
- inline_inject: []JSNode,
- inline_identifier: i32,
-
- pub fn callArgs(this: Data) ExprNodeList {
- if (this == .e_call)
- return this.e_call.args
- else
- return ExprNodeList{};
- }
-
- pub fn booleanValue(this: Data) bool {
- return switch (this) {
- .inline_false => false,
- .inline_true => true,
- .e_boolean => this.e_boolean.value,
- };
- }
- };
- pub const Tag = enum(u8) {
- e_array,
- e_unary,
- e_binary,
- e_function,
- e_new_target,
- e_import_meta,
- e_call,
- e_dot,
- e_index,
- e_arrow,
- e_identifier,
- e_import_identifier,
- e_private_identifier,
- e_jsx_element,
- e_big_int,
- e_object,
- e_spread,
- e_string,
- e_template_part,
- e_template,
- e_reg_exp,
- e_await,
- e_yield,
- e_if,
- e_require_resolve_string,
- e_require_call_target,
- e_require_resolve_call_target,
- e_import,
- e_this,
- e_class,
- e_require_string,
- s_import,
- s_block,
-
- g_property,
-
- e_missing,
- e_boolean,
- e_super,
- e_null,
- e_number,
- e_undefined,
-
- inline_true,
- inline_false,
- inline_inject,
- inline_identifier,
-
- fragment,
-
- pub const ids: std.EnumArray(Tag, Expr.Data) = brk: {
- var list = std.EnumArray(Tag, Expr.Data).initFill(Expr.Data{ .e_number = E.Number{ .value = 0.0 } });
- const fields: []const std.builtin.Type.EnumField = @typeInfo(Tag).Enum.fields;
- for (fields) |field| {
- list.set(@as(Tag, @enumFromInt(field.value)), Expr.Data{ .e_number = E.Number{ .value = @as(f64, @floatFromInt(field.value)) } });
- }
-
- break :brk list;
- };
-
- pub const names = ComptimeStringMap(Tag, .{
- .{ "array", Tag.e_array },
- .{ "unary", Tag.e_unary },
- .{ "binary", Tag.e_binary },
- .{ "bool", Tag.e_boolean },
- .{ "super", Tag.e_super },
- .{ "null", Tag.e_null },
- .{ "undefined", Tag.e_undefined },
- .{ "function", Tag.e_function },
- .{ "new_target", Tag.e_new_target },
- .{ "import-meta", Tag.e_import_meta },
- .{ "call", Tag.e_call },
- .{ "dot", Tag.e_dot },
- .{ "index", Tag.e_index },
- .{ "arrow", Tag.e_arrow },
- .{ "import-id", Tag.e_import_identifier },
- .{ "private-id", Tag.e_private_identifier },
- .{ "jsx", Tag.e_jsx_element },
- .{ "missing", Tag.e_missing },
- .{ "number", Tag.e_number },
- .{ "bigint", Tag.e_big_int },
- .{ "object", Tag.e_object },
- .{ "spread", Tag.e_spread },
- .{ "string", Tag.e_string },
- .{ "template-part", Tag.e_template_part },
- .{ "template", Tag.e_template },
- .{ "regex", Tag.e_reg_exp },
- .{ "await", Tag.e_await },
- .{ "yield", Tag.e_yield },
- .{ "if", Tag.e_if },
- .{ "dynamic", Tag.e_import },
- .{ "this", Tag.e_this },
- .{ "class", Tag.e_class },
- .{ "require", Tag.e_require_string },
- .{ "import", Tag.s_import },
- .{ "property", Tag.g_property },
- .{ "block", Tag.s_block },
- .{ "true", Tag.inline_true },
- .{ "false", Tag.inline_false },
- .{ "inject", Tag.inline_inject },
-
- .{ "id", Tag.inline_identifier },
- });
-
- pub const as_expr_tag: std.EnumArray(Tag, Expr.Tag) = brk: {
- var list = std.EnumArray(Tag, Expr.Tag).initFill(Expr.Tag.e_missing);
- list.set(Tag.e_array, Expr.Tag.e_array);
- list.set(Tag.e_unary, Expr.Tag.e_unary);
- list.set(Tag.e_binary, Expr.Tag.e_binary);
- list.set(Tag.e_boolean, Expr.Tag.e_boolean);
- list.set(Tag.e_super, Expr.Tag.e_super);
- list.set(Tag.e_null, Expr.Tag.e_null);
- list.set(Tag.e_undefined, Expr.Tag.e_undefined);
- list.set(Tag.e_function, Expr.Tag.e_function);
- list.set(Tag.e_new_target, Expr.Tag.e_new_target);
- list.set(Tag.e_import_meta, Expr.Tag.e_import_meta);
- list.set(Tag.e_call, Expr.Tag.e_call);
- list.set(Tag.e_dot, Expr.Tag.e_dot);
- list.set(Tag.e_index, Expr.Tag.e_index);
- list.set(Tag.e_arrow, Expr.Tag.e_arrow);
- list.set(Tag.e_identifier, Expr.Tag.e_identifier);
- list.set(Tag.e_import_identifier, Expr.Tag.e_import_identifier);
- list.set(Tag.e_private_identifier, Expr.Tag.e_private_identifier);
- list.set(Tag.e_jsx_element, Expr.Tag.e_jsx_element);
- list.set(Tag.e_missing, Expr.Tag.e_missing);
- list.set(Tag.e_number, Expr.Tag.e_number);
- list.set(Tag.e_big_int, Expr.Tag.e_big_int);
- list.set(Tag.e_object, Expr.Tag.e_object);
- list.set(Tag.e_spread, Expr.Tag.e_spread);
- list.set(Tag.e_string, Expr.Tag.e_string);
- list.set(Tag.e_template_part, Expr.Tag.e_template_part);
- list.set(Tag.e_template, Expr.Tag.e_template);
- list.set(Tag.e_reg_exp, Expr.Tag.e_reg_exp);
- list.set(Tag.e_await, Expr.Tag.e_await);
- list.set(Tag.e_yield, Expr.Tag.e_yield);
- list.set(Tag.e_if, Expr.Tag.e_if);
- list.set(Tag.e_require_resolve_string, Expr.Tag.e_require_resolve_string);
- list.set(Tag.e_import, Expr.Tag.e_import);
- list.set(Tag.e_this, Expr.Tag.e_this);
- list.set(Tag.e_class, Expr.Tag.e_class);
- list.set(Tag.e_require_string, Expr.Tag.e_require_string);
- break :brk list;
- };
-
- pub const to_expr_tag: std.EnumArray(Expr.Tag, Tag) = brk: {
- var list = std.EnumArray(Expr.Tag, Tag).initFill(Tag.wip);
- list.set(Expr.Tag.e_array, Tag.e_array);
- list.set(Expr.Tag.e_unary, Tag.e_unary);
- list.set(Expr.Tag.e_binary, Tag.e_binary);
- list.set(Expr.Tag.e_boolean, Tag.e_boolean);
- list.set(Expr.Tag.e_super, Tag.e_super);
- list.set(Expr.Tag.e_null, Tag.e_null);
- list.set(Expr.Tag.e_undefined, Tag.e_undefined);
- list.set(Expr.Tag.e_function, Tag.e_function);
- list.set(Expr.Tag.e_new_target, Tag.e_new_target);
- list.set(Expr.Tag.e_import_meta, Tag.e_import_meta);
- list.set(Expr.Tag.e_call, Tag.e_call);
- list.set(Expr.Tag.e_dot, Tag.e_dot);
- list.set(Expr.Tag.e_index, Tag.e_index);
- list.set(Expr.Tag.e_arrow, Tag.e_arrow);
- list.set(Expr.Tag.e_identifier, Tag.e_identifier);
- list.set(Expr.Tag.e_import_identifier, Tag.e_import_identifier);
- list.set(Expr.Tag.e_private_identifier, Tag.e_private_identifier);
- list.set(Expr.Tag.e_jsx_element, Tag.e_jsx_element);
- list.set(Expr.Tag.e_missing, Tag.e_missing);
- list.set(Expr.Tag.e_number, Tag.e_number);
- list.set(Expr.Tag.e_big_int, Tag.e_big_int);
- list.set(Expr.Tag.e_object, Tag.e_object);
- list.set(Expr.Tag.e_spread, Tag.e_spread);
- list.set(Expr.Tag.e_string, Tag.e_string);
- list.set(Expr.Tag.e_template_part, Tag.e_template_part);
- list.set(Expr.Tag.e_template, Tag.e_template);
- list.set(Expr.Tag.e_reg_exp, Tag.e_reg_exp);
- list.set(Expr.Tag.e_await, Tag.e_await);
- list.set(Expr.Tag.e_yield, Tag.e_yield);
- list.set(Expr.Tag.e_if, Tag.e_if);
- list.set(Expr.Tag.e_require_resolve_string, Tag.e_require_resolve_string);
- list.set(Expr.Tag.e_import, Tag.e_import);
- list.set(Expr.Tag.e_this, Tag.e_this);
- list.set(Expr.Tag.e_class, Tag.e_class);
- list.set(Expr.Tag.e_require_string, Tag.e_require_string);
- break :brk list;
- };
-
- pub const Validator = struct {
- pub const List = std.EnumArray(JSNode.Tag, bool);
- fn NewList(comptime valid_tags: anytype) List {
- return comptime brk: {
- var list = List.initFill(false);
- for (std.meta.fieldNames(@TypeOf(valid_tags))) |index| {
- const name = @tagName(@field(valid_tags, index));
-
- if (!@hasField(JSNode.Tag, name)) {
- @compileError(
- "JSNode.Tag does not have a \"" ++ name ++ "\" field. Valid fields are " ++ std.fmt.comptimePrint(
- "{s}",
- .{
- std.meta.fieldNames(@TypeOf(valid_tags)),
- },
- ),
- );
- }
- list.set(@field(JSNode.Tag, name), true);
- }
-
- break :brk list;
- };
- }
-
- pub const valid_object_tags = Tag.Validator.NewList(.{
- .g_property,
- .e_spread,
- .e_identifier,
- .e_import_identifier,
- .e_index,
- .e_call,
- .e_private_identifier,
- .e_dot,
- .e_unary,
- .e_binary,
- });
-
- pub const valid_inject_tags = Tag.Validator.NewList(.{
- .s_import,
- });
- };
-
- pub const max_tag: u8 = brk: {
- const Enum: std.builtin.Type.Enum = @typeInfo(Tag).Enum;
- var max_value: u8 = 0;
- for (Enum.fields) |field| {
- max_value = @max(@as(u8, field.value), max_value);
- }
- break :brk max_value;
- };
-
- pub const min_tag: u8 = brk: {
- const Enum: std.builtin.Type.Enum = @typeInfo(Tag).Enum;
- var min: u8 = 255;
- for (Enum.fields) |field| {
- min = @min(@as(u8, field.value), min);
- }
- break :brk min;
- };
- };
-
- pub const JSNodeList = std.ArrayListUnmanaged(JSNode);
-
- pub fn NewJSXWriter(comptime P: type) type {
- return struct {
- const JSXWriter = @This();
- p: *P,
- bun_jsx_ref: Ref,
- log: *logger.Log,
- args: ExprList,
- bun_identifier: *E.Identifier,
- allocator: std.mem.Allocator,
- parent_tag: Tag = Tag.e_missing,
-
- pub fn initWriter(p: *P, bun_identifier: *E.Identifier) JSXWriter {
- return JSXWriter{
- .p = p,
- .log = p.log,
- .bun_jsx_ref = p.bun_jsx_ref,
- .args = ExprList.init(p.allocator),
- .allocator = p.allocator,
- .bun_identifier = bun_identifier,
- };
- }
-
- fn hasPropertyNamed(props: []G.Property, comptime name: string) bool {
- return indexOfPropertyByName(props, name) != null;
- }
-
- fn indexOfPropertyByName(props: []G.Property, comptime name: string) ?u32 {
- for (props, 0..) |prop, i| {
- const key = prop.key orelse continue;
- if (key.data != .e_string or !key.data.e_string.isUTF8()) continue;
- if (strings.eqlComptime(key.data.e_string.data, name)) return @as(u32, @intCast(i));
- }
-
- return null;
- }
-
- fn propertyValueNamed(props: []G.Property, comptime name: string) ?Expr {
- for (props) |prop| {
- const key = prop.key orelse continue;
- if (key.data != .e_string or !key.data.e_string.isUTF8()) continue;
- if (strings.eqlComptime(key.data.e_string.data, name)) return prop.value;
- }
-
- return null;
- }
-
- pub fn writeNodeType(self: *JSXWriter, tag: JSNode.Tag, props: []G.Property, children: []Expr, loc: logger.Loc) bool {
- switch (tag) {
-
- // <bool value={foo} />
- // intended for dynamic values
- Tag.e_boolean => {
- self.args.ensureUnusedCapacity(2) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_boolean) });
- const value_i = indexOfPropertyByName(props, "value") orelse {
- self.log.addError(self.p.source, loc, "<bool> should have a \"value\" prop") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_boolean = .{ .value = true } }, .loc = loc }) catch unreachable;
- return true;
- };
- const value = props[value_i].value orelse Expr{ .data = .{ .e_boolean = .{ .value = true } }, .loc = loc };
-
- switch (value.data) {
- .e_jsx_element => |el| {
- return self.writeElement(el.*);
- },
- .e_string => {
- self.log.addError(self.p.source, value.loc, "\"value\" shouldn't be a string") catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .data = .{ .e_boolean = .{ .value = true } }, .loc = value.loc });
- },
- .e_boolean => {
- self.args.appendAssumeCapacity(value);
- },
- .e_missing => {
- self.args.appendAssumeCapacity(Expr{ .data = .{ .e_boolean = .{ .value = true } }, .loc = value.loc });
- },
- // null and undefined literals are coerced to false
- .e_null, .e_undefined => {
- self.args.appendAssumeCapacity(Expr{ .data = .{ .e_boolean = .{ .value = false } }, .loc = value.loc });
- },
- .e_number => {
- // Numbers are cooerced to booleans
- self.args.appendAssumeCapacity(Expr{ .data = .{ .e_boolean = .{ .value = value.data.e_number.value > 0.0 } }, .loc = value.loc });
- },
- // these ones are not statically analyzable so we just leave them in as-is
- .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(self.p.visitExpr(value));
- },
- // everything else is invalid
- else => {
- self.log.addError(self.p.source, value.loc, "\"value\" should be a bool, jsx element, number, identifier, index, call, private identifier, or dot") catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .data = .{ .e_boolean = .{ .value = false } }, .loc = value.loc });
- },
- }
-
- return true;
- },
- // <number value={1.0} />
- Tag.e_number => {
- self.args.ensureUnusedCapacity(2) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_number) });
- const invalid_value = Expr{ .data = .{ .e_number = .{ .value = 0.0 } }, .loc = loc };
- const value_i = indexOfPropertyByName(props, "value") orelse {
- self.log.addError(self.p.source, loc, "<number> should have a \"value\" prop") catch unreachable;
- self.args.append(invalid_value) catch unreachable;
- return true;
- };
- const value = props[value_i].value orelse invalid_value;
-
- switch (value.data) {
- .e_jsx_element => |el| {
- return self.writeElement(el.*);
- },
- .e_string => {
- self.log.addError(self.p.source, loc, "<number> should not be a string.") catch unreachable;
- self.args.appendAssumeCapacity(invalid_value);
- },
- .e_boolean => {
- // Booleans are cooerced to numbers
- self.args.appendAssumeCapacity(
- Expr{
- .data = .{
- .e_number = E.Number{
- .value = @as(f64, @floatFromInt(@intFromBool(value.data.e_boolean.value))),
- },
- },
- .loc = value.loc,
- },
- );
- },
- .e_missing => {
- self.args.appendAssumeCapacity(invalid_value);
- },
- // null and undefined literals are coerced to 0
- .e_null, .e_undefined => {
- self.args.appendAssumeCapacity(Expr{ .data = .{ .e_number = .{ .value = 0 } }, .loc = value.loc });
- },
- // <number>123</number>
- .e_number => {
- // Numbers are cooerced to booleans
- self.args.appendAssumeCapacity(value);
- },
- // these ones are not statically analyzable so we just leave them in as-is
- .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(self.p.visitExpr(value));
- },
- // everything else is invalid
- else => {
- self.log.addError(self.p.source, value.loc, "<number value> should be a number, jsx element, identifier, index, call, private identifier, or dot expression") catch unreachable;
- self.args.appendAssumeCapacity(invalid_value);
- },
- }
-
- return true;
- },
- Tag.e_big_int => {
- self.args.ensureUnusedCapacity(2) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_big_int) });
- const invalid_value = Expr{ .data = .{ .e_big_int = &E.BigInt.empty }, .loc = loc };
- const value_i = indexOfPropertyByName(props, "value") orelse {
- self.log.addError(self.p.source, loc, "<big-int> should have a \"value\" prop") catch unreachable;
- self.args.append(invalid_value) catch unreachable;
- return true;
- };
- const value = props[value_i].value orelse invalid_value;
-
- switch (value.data) {
- .e_jsx_element => |el| {
- return self.writeElement(el.*);
- },
- .e_string => |str| {
- self.args.appendAssumeCapacity(Expr.init(E.BigInt, E.BigInt{ .value = std.mem.trimRight(u8, str.data, "n") }, value.loc));
- },
- .e_big_int => {
- self.args.appendAssumeCapacity(value);
- },
- .e_missing => {
- self.args.appendAssumeCapacity(invalid_value);
- },
- // null and undefined literals are coerced to 0
- .e_null, .e_undefined => {
- self.args.appendAssumeCapacity(Expr{ .data = .{ .e_big_int = &E.BigInt.empty }, .loc = value.loc });
- },
- // these ones are not statically analyzable so we just leave them in as-is
- .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(self.p.visitExpr(value));
- },
- // everything else is invalid
- else => {
- self.log.addError(self.p.source, value.loc, "\"value\" should be a BigInt, jsx element, identifier, index, call, private identifier, or dot expression") catch unreachable;
- self.args.appendAssumeCapacity(invalid_value);
- },
- }
-
- return true;
- },
- Tag.e_array => {
- self.args.ensureUnusedCapacity(2 + children.len) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_array) });
- const children_count = @as(u16, @truncate(children.len));
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = E.Number{ .value = @as(f64, @floatFromInt(children_count)) } } });
-
- var old_parent = self.parent_tag;
- self.parent_tag = Tag.e_array;
- defer self.parent_tag = old_parent;
- for (children) |child| {
- switch (child.data) {
- .e_jsx_element => |el| {
- if (!self.writeElement(el.*)) return false;
- },
- // TODO: handle when simplification changes the expr type
- .e_template, .e_if, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- const visited_expr = self.p.visitExpr(child);
- switch (visited_expr.data) {
- .e_jsx_element => |el| {
- if (!self.writeElement(el.*)) return false;
- },
- .e_template, .e_if, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.append(visited_expr) catch unreachable;
- },
- else => {
- self.log.addError(self.p.source, visited_expr.loc, "<array> should only contain other jsx elements") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = visited_expr.loc }) catch unreachable;
- },
- }
- },
- else => {
- self.log.addError(self.p.source, child.loc, "<array> should only contain other jsx elements") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = child.loc }) catch unreachable;
- },
- }
- }
-
- return true;
- },
- Tag.e_object => {
- self.args.ensureUnusedCapacity(2 + children.len) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_object) });
- const children_count = @as(u16, @truncate(children.len));
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = E.Number{ .value = @as(f64, @floatFromInt(children_count)) } } });
-
- var old_parent = self.parent_tag;
- self.parent_tag = Tag.e_object;
- defer self.parent_tag = old_parent;
-
- for (children) |child| {
- switch (child.data) {
- .e_jsx_element => |el| {
- if (!self.writeElementWithValidTagList(el.*, comptime Tag.Validator.valid_object_tags)) return false;
- },
- .e_template, .e_if, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- const visited = self.p.visitExpr(child);
- switch (visited.data) {
- .e_jsx_element => |el| {
- if (!self.writeElementWithValidTagList(el.*, comptime Tag.Validator.valid_object_tags)) return false;
- },
- .e_template, .e_if, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.append(visited) catch unreachable;
- },
- else => {
- self.log.addError(self.p.source, child.loc, "<object> should only contain other jsx elements") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = child.loc }) catch unreachable;
- },
- }
- },
- else => {
- self.log.addError(self.p.source, child.loc, "<object> should only contain other jsx elements") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = child.loc }) catch unreachable;
- },
- }
- }
-
- return true;
- },
-
- Tag.g_property => {
- const name_property = propertyValueNamed(props, "name");
- const value_property = propertyValueNamed(props, "value");
- const init_property = propertyValueNamed(props, "init");
-
- var old_parent = self.parent_tag;
- if (old_parent != .e_object) {
- self.args.append(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.g_property) }) catch unreachable;
- }
-
- self.parent_tag = Tag.g_property;
- defer self.parent_tag = old_parent;
-
- if (value_property) |prop| {
- switch (prop.data) {
- .e_jsx_element => |el| {
- if (!self.writeElement(el.*)) return false;
- },
- .e_template, .e_if, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.append(self.p.visitExpr(prop)) catch unreachable;
- },
- else => {
- self.log.addError(self.p.source, prop.loc, "value should only contain other jsx elements") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = prop.loc }) catch unreachable;
- },
- }
- } else {
- self.args.append(Expr{ .data = comptime Tag.ids.get(.e_undefined), .loc = loc }) catch unreachable;
- }
-
- if (init_property) |prop| {
- switch (prop.data) {
- .e_jsx_element => |el| {
- if (!self.writeElement(el.*)) return false;
- },
-
- .e_template, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.append(self.p.visitExpr(prop)) catch unreachable;
- },
- else => {
- self.log.addError(self.p.source, prop.loc, "init should only contain other jsx elements") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = prop.loc }) catch unreachable;
- },
- }
- } else {
- self.args.append(Expr{ .data = comptime Tag.ids.get(.e_undefined), .loc = loc }) catch unreachable;
- }
-
- if (name_property) |prop| {
- switch (prop.data) {
- .e_jsx_element => |el| {
- if (!self.writeElement(el.*)) return false;
- },
- .e_string => {
- self.args.append(prop) catch unreachable;
- },
- .e_template, .e_if, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.append(self.p.visitExpr(prop)) catch unreachable;
- },
- else => {
- self.log.addError(self.p.source, prop.loc, "should only contain other jsx elements or a string") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = prop.loc }) catch unreachable;
- },
- }
- }
-
- return true;
- },
- Tag.e_string => {
- self.args.ensureUnusedCapacity(2) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_string) });
- const invalid_value = Expr{ .data = .{ .e_string = &E.String.empty }, .loc = loc };
- const value_i = indexOfPropertyByName(props, "value") orelse {
- self.log.addError(self.p.source, loc, "<string> should have a \"value\" prop") catch unreachable;
- self.args.append(invalid_value) catch unreachable;
- return true;
- };
- const value = props[value_i].value orelse invalid_value;
-
- switch (value.data) {
- .e_jsx_element => |el| {
- return self.writeElement(el.*);
- },
- .e_string => {
- self.args.appendAssumeCapacity(value);
- },
- .e_missing => {
- self.args.appendAssumeCapacity(invalid_value);
- },
- // null is cooerced to "null"
- .e_null => {
- self.args.appendAssumeCapacity(Expr{ .loc = value.loc, .data = .{ .e_string = &E.String.null } });
- },
- // undefined is cooerced to "undefined"
- .e_undefined => {
- self.args.appendAssumeCapacity(Expr{ .loc = value.loc, .data = .{ .e_string = &E.String.undefined } });
- },
- .e_boolean => |boolean| {
- self.args.appendAssumeCapacity(Expr{ .loc = value.loc, .data = .{ .e_string = if (boolean.value) &E.String.true else &E.String.false } });
- },
- // these ones are not statically analyzable so we just leave them in as-is
- .e_template, .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(self.p.visitExpr(value));
- },
- // everything else is invalid
- else => {
- self.log.addError(self.p.source, value.loc, "<string value> should be a string, jsx element, identifier, index, call, private identifier, or dot expression") catch unreachable;
- self.args.appendAssumeCapacity(invalid_value);
- },
- }
- },
- Tag.e_reg_exp => {
- self.args.ensureUnusedCapacity(2) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_reg_exp) });
- const invalid_value = Expr{ .data = .{ .e_reg_exp = &E.RegExp.empty }, .loc = loc };
-
- const value_i = indexOfPropertyByName(props, "value") orelse {
- self.log.addError(self.p.source, loc, "<regex> should have a \"value\" prop") catch unreachable;
- self.args.append(invalid_value) catch unreachable;
- return true;
- };
-
- const value = props[value_i].value orelse invalid_value;
-
- switch (value.data) {
- .e_string => |str| {
- self.args.appendAssumeCapacity(Expr.init(E.RegExp, E.RegExp{ .value = str.data }, value.loc));
- },
- .e_reg_exp => {
- self.args.appendAssumeCapacity(value);
- },
- .e_missing, .e_null, .e_undefined => {
- self.args.appendAssumeCapacity(invalid_value);
- },
- // these ones are not statically analyzable so we just leave them in as-is
- .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(self.p.visitExpr(value));
- },
- // everything else is invalid
- else => {
- self.log.addError(self.p.source, value.loc, "<regex value> should be a string, jsx element, identifier, index, call, private identifier, or dot expression") catch unreachable;
- self.args.appendAssumeCapacity(invalid_value);
- },
- }
-
- return true;
- },
- Tag.inline_inject => {
-
- // For <inject>, immediate children must be JSX types or arrays
- if (props.len > 0) {
- self.log.addError(
- self.p.source,
- loc,
- "<inject> does not accept props",
- ) catch unreachable;
- }
-
- var count: usize = children.len;
- for (children) |c| {
- count += switch (c.data) {
- .e_jsx_element => if (c.data.e_jsx_element.tag != null) 1 else brk: {
- break :brk c.data.e_jsx_element.children.len;
- },
- else => 1,
- };
- }
- self.args.ensureUnusedCapacity(2 + count) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.inline_inject) });
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = .{ .value = @as(f64, @floatFromInt(@as(u32, @intCast(children.len)))) } } });
-
- const old_parent_tag = self.parent_tag;
- self.parent_tag = Tag.inline_inject;
- defer self.parent_tag = old_parent_tag;
-
- for (children) |child| {
- switch (child.data) {
- .e_jsx_element => |el| {
- if (!self.writeElementWithValidTagList(el.*, comptime Tag.Validator.valid_inject_tags)) return false;
- },
- else => {
- self.args.append(self.p.visitExpr(child)) catch unreachable;
- },
- }
- }
-
- return true;
- },
-
- Tag.inline_identifier => {
- // id only accepts "to" and it must be a int32
- self.args.ensureUnusedCapacity(2) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.inline_identifier) });
-
- if (propertyValueNamed(props, "to")) |prop| {
- switch (prop.data) {
- .e_number, .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(self.p.visitExpr(prop));
- },
- else => {
- self.log.addError(
- self.p.source,
- prop.loc,
- "\"to\" prop must be a number",
- ) catch unreachable;
- self.args.appendAssumeCapacity(prop);
- },
- }
- } else {
- self.log.addError(
- self.p.source,
- loc,
- "\"to\" prop is required",
- ) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = .{ .value = 0 } } });
- }
-
- return true;
- },
-
- Tag.s_import => {
- var p = self.p;
- const default_property_ = propertyValueNamed(props, "default");
- const path_property = propertyValueNamed(props, "path") orelse {
- self.log.addError(
- self.p.source,
- loc,
- "<import> must have a path",
- ) catch unreachable;
- return false;
- };
- const namespace_ = propertyValueNamed(props, "namespace");
-
- const items_count: u32 = 1 +
- @as(u32, @intCast(@intFromBool(namespace_ != null)));
-
- self.args.ensureUnusedCapacity(items_count) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.s_import) });
-
- switch (path_property.data) {
- .e_string => {
- self.args.appendAssumeCapacity(path_property);
- },
- .e_jsx_element => {
- self.log.addError(
- self.p.source,
- path_property.loc,
- "import path cannot be JSX",
- ) catch unreachable;
- return false;
- },
- .e_template, .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(p.visitExpr(path_property));
- },
- else => {
- self.log.addError(
- self.p.source,
- path_property.loc,
- "import path must be a string or identifier",
- ) catch unreachable;
- self.args.appendAssumeCapacity(path_property);
- },
- }
-
- if (namespace_) |namespace_expr| {
- switch (namespace_expr.data) {
- .e_string => {
- self.log.addError(
- self.p.source,
- namespace_expr.loc,
- "import * as is not supported in macros yet",
- ) catch unreachable;
- self.args.appendAssumeCapacity(p.visitExpr(namespace_expr));
- return false;
- },
- .e_jsx_element => {
- self.log.addError(
- self.p.source,
- namespace_expr.loc,
- "namespace cannot be JSX",
- ) catch unreachable;
- return false;
- },
-
- .e_object, .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(p.visitExpr(namespace_expr));
- },
-
- else => {
- self.log.addError(
- self.p.source,
- namespace_expr.loc,
- "namespace must be an object shaped like {\"fromName\": \"toName\"}",
- ) catch unreachable;
- self.args.appendAssumeCapacity(namespace_expr);
- },
- }
- } else {
- self.args.appendAssumeCapacity(Expr{
- .loc = loc,
- .data = .{
- .e_null = E.Null{},
- },
- });
- }
-
- if (default_property_) |default| {
- switch (default.data) {
- .e_string => {
- self.args.appendAssumeCapacity(default);
- },
- .e_jsx_element => {
- self.log.addError(
- self.p.source,
- default.loc,
- "default import cannot be JSX",
- ) catch unreachable;
- return false;
- },
- .e_template, .e_if, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.appendAssumeCapacity(p.visitExpr(default));
- },
- else => {
- self.log.addError(self.p.source, default.loc, "default import must be a string or identifier") catch unreachable;
- self.args.appendAssumeCapacity(default);
- },
- }
- } else {
- self.args.appendAssumeCapacity(Expr{
- .loc = loc,
- .data = .{
- .e_null = E.Null{},
- },
- });
- }
-
- return true;
- },
- Tag.fragment => {
- self.args.ensureUnusedCapacity(children.len + 2) catch unreachable;
- self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.fragment) });
- self.args.appendAssumeCapacity(Expr{
- .loc = loc,
- .data = .{
- .e_number = E.Number{
- .value = @as(f64, @floatFromInt(children.len)),
- },
- },
- });
-
- for (children) |child| {
- switch (child.data) {
- .e_jsx_element => |el| {
- if (!self.writeElement(el.*)) return false;
- },
-
- .e_if, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- const visited = self.p.visitExpr(child);
- switch (visited.data) {
- .e_jsx_element => |el| {
- if (!self.writeElement(el.*)) return false;
- },
- .e_if, .e_spread, .e_identifier, .e_import_identifier, .e_index, .e_call, .e_private_identifier, .e_dot, .e_unary, .e_binary => {
- self.args.append(visited) catch unreachable;
- },
- else => {
- self.log.addError(self.p.source, child.loc, "<> should only contain other jsx elements") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = child.loc }) catch unreachable;
- },
- }
- },
- else => {
- self.log.addError(self.p.source, child.loc, "<> should only contain other jsx elements") catch unreachable;
- self.args.append(Expr{ .data = .{ .e_missing = E.Missing{} }, .loc = child.loc }) catch unreachable;
- },
- }
- }
-
- return true;
- },
- // Tag.e_jsx_element => unreachable,
- // Tag.e_identifier => {
- // // self.args.ensureUnusedCapacity(2) catch unreachable;
- // Global.notimpl();
- // },
- // Tag.e_import_identifier => {
- // Global.notimpl();
- // },
- // Tag.e_private_identifier => {
- // Global.notimpl();
- // },
-
- // Tag.e_unary => {
-
- // },
- // Tag.e_binary => {},
-
- // Tag.e_function => {},
- // Tag.e_new_target => {},
- // Tag.e_import_meta => {},
- // Tag.e_call => {},
- // Tag.e_dot => {},
- // Tag.e_index => {},
- // Tag.e_arrow => {},
-
- // Tag.e_spread => {},
-
- // Tag.e_template_part => {},
- // Tag.e_template => {},
- // Tag.e_regex => {},
- // Tag.e_await => {},
- // Tag.e_yield => {},
- // Tag.e_if => {},
- // Tag.e_import => {},
-
- // Tag.e_class => {},
- // Tag.e_require_string => {},
- // Tag.s_import => {},
-
- // Tag.s_block => {},
-
- // The valueless ones
- Tag.e_super, Tag.e_null, Tag.e_undefined, Tag.e_missing, Tag.inline_true, Tag.inline_false, Tag.e_this => {
- self.args.append(Expr{ .loc = loc, .data = Tag.ids.get(tag) }) catch unreachable;
- },
- else => Global.panic("Tag \"{s}\" is not implemented yet.", .{@tagName(tag)}),
- }
-
- return true;
- }
-
- pub fn writeFunctionCall(self: *JSXWriter, element: E.JSXElement) Expr {
- if (element.tag) |tag_expr| {
- switch (tag_expr.data) {
- .e_string => {
- self.p.recordUsage(self.bun_jsx_ref);
- _ = self.writeElement(element);
- var call_args = ExprNodeList.one(
- self.allocator,
- Expr.init(
- E.Array,
- E.Array{ .items = ExprNodeList.fromList(self.args) },
- tag_expr.loc,
- ),
- ) catch unreachable;
-
- return Expr.init(
- E.Call,
- E.Call{
- .target = Expr{
- .data = .{
- .e_identifier = self.bun_identifier.*,
- },
- .loc = tag_expr.loc,
- },
- .can_be_unwrapped_if_unused = true,
- .args = call_args,
- },
- tag_expr.loc,
- );
- },
- else => Global.panic("Not implemented yet top-level jsx element: {s}", .{@tagName(tag_expr.data)}),
- }
- } else {
- const loc = logger.Loc.Empty;
- self.p.recordUsage(self.bun_jsx_ref);
- _ = self.writeNodeType(JSNode.Tag.fragment, element.properties.slice(), element.children.slice(), loc);
- var call_args = ExprNodeList.one(
- self.allocator,
- Expr.init(E.Array, E.Array{ .items = ExprNodeList.init(self.args.items) }, loc),
- ) catch unreachable;
-
- return Expr.init(
- E.Call,
- E.Call{
- .target = Expr{
- .data = .{
- .e_identifier = self.bun_identifier.*,
- },
- .loc = loc,
- },
- .can_be_unwrapped_if_unused = true,
- .args = call_args,
- },
- loc,
- );
- }
-
- return Expr{ .data = .{ .e_missing = .{} }, .loc = logger.Loc.Empty };
- }
-
- fn writeElementWithValidTagList(self: *JSXWriter, element: E.JSXElement, comptime valid_tags: Tag.Validator.List) bool {
- const tag_expr = element.tag orelse return false;
- if (tag_expr.data != .e_string) return false;
- const str = tag_expr.data.e_string;
- var p = self.p;
-
- const node_type: JSNode.Tag = JSNode.Tag.names.get(str.data) orelse {
- self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{s}\" is invalid", .{
- str.string(self.p.allocator) catch unreachable,
- }) catch unreachable;
- return false;
- };
-
- if (!valid_tags.get(node_type)) {
- self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{s}\" is invalid here", .{str.data}) catch unreachable;
- }
-
- return self.writeNodeType(node_type, element.properties.slice(), element.children.slice(), tag_expr.loc);
- }
-
- pub fn writeElement(self: *JSXWriter, element: E.JSXElement) bool {
- const tag_expr = element.tag orelse return false;
- if (tag_expr.data != .e_string) return false;
- const str = tag_expr.data.e_string;
- var p = self.p;
-
- const node_type: JSNode.Tag = JSNode.Tag.names.get(str.data) orelse {
- self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{s}\" is invalid", .{
- str.string(self.p.allocator) catch unreachable,
- }) catch unreachable;
- return false;
- };
-
- return self.writeNodeType(node_type, element.properties.slice(), element.children.slice(), tag_expr.loc);
- }
- };
- }
-
- pub const SymbolMap = struct {
- pub fn generateImportHash(name: string, path: string) i32 {
- var hasher = std.hash.Wyhash.init(8);
- hasher.update(path);
- hasher.update("#");
- hasher.update(name);
- return @as(i32, @bitCast(@as(u32, @truncate(hasher.final()))));
- }
- };
-
- pub const Writer = struct {
- log: *logger.Log,
- exception: JSCBase.ExceptionValueRef = null,
- ctx: js.JSContextRef,
- errored: bool = false,
- allocator: std.mem.Allocator,
- loc: logger.Loc,
- args_value: JSC.JSValue,
- args_i: u32 = 0,
- args_len: u32 = 0,
-
- inject: std.ArrayList(JSNode),
-
- pub inline fn eatArg(this: *Writer) ?JSC.JSValue {
- if (this.args_i >= this.args_len) return null;
- const i = this.args_i;
-
- this.args_i += 1;
- return JSC.JSObject.getIndex(this.args_value, this.ctx.ptr(), i);
- }
-
- pub inline fn peekArg(this: *Writer) ?JSC.JSValue {
- if (this.args_i >= this.args_len) return null;
- return JSC.JSObject.getIndex(this.args_value, this.ctx.ptr(), this.args_i);
- }
-
- pub inline fn nextJSValue(this: *Writer) ?JSC.JSValue {
- return this.eatArg();
- }
-
- pub const TagOrJSNode = union(TagOrNodeType) {
- tag: JSNode.Tag,
- node: JSNode,
- invalid: void,
-
- pub const TagOrNodeType = enum {
- tag,
- node,
- invalid,
- };
-
- pub fn fromJSValueRefNoValidate(ctx: js.JSContextRef, value: js.JSValueRef) TagOrJSNode {
- switch (js.JSValueGetType(ctx, value)) {
- js.JSType.kJSTypeNumber => {
- const tag_int = @as(u8, @intFromFloat(JSC.JSValue.fromRef(value).asNumber()));
- if (tag_int < Tag.min_tag or tag_int > Tag.max_tag) {
- return TagOrJSNode{ .invalid = {} };
- }
- return TagOrJSNode{ .tag = @as(JSNode.Tag, @enumFromInt(tag_int)) };
- },
- js.JSType.kJSTypeObject => {
- if (JSCBase.GetJSPrivateData(JSNode, value)) |node| {
- return TagOrJSNode{ .node = node.* };
- }
-
- return TagOrJSNode{ .invalid = {} };
- },
- else => {
- return TagOrJSNode{ .invalid = {} };
- },
- }
- }
-
- pub fn fromJSValueRef(writer: *Writer, ctx: js.JSContextRef, value: js.JSValueRef) TagOrJSNode {
- switch (js.JSValueGetType(ctx, value)) {
- js.JSType.kJSTypeNumber => {
- const tag_int = @as(u8, @intFromFloat(JSC.JSValue.fromRef(value).asNumber()));
- if (tag_int < Tag.min_tag or tag_int > Tag.max_tag) {
- throwTypeError(ctx, "Node type has invalid value", writer.exception);
- writer.errored = true;
- return TagOrJSNode{ .invalid = {} };
- }
- return TagOrJSNode{ .tag = @as(JSNode.Tag, @enumFromInt(tag_int)) };
- },
- js.JSType.kJSTypeObject => {
- if (JSCBase.GetJSPrivateData(JSNode, value)) |node| {
- return TagOrJSNode{ .node = node.* };
- }
-
- return TagOrJSNode{ .invalid = {} };
- },
- else => {
- throwTypeError(writer.ctx, "Invalid bun AST", writer.exception);
- return TagOrJSNode{ .invalid = {} };
- },
- }
- }
-
- pub fn fromJSValue(writer: *Writer, value: JSC.JSValue) TagOrJSNode {
- return fromJSValueRef(writer, writer.ctx, value.asRef());
- }
- };
-
- fn writeProperty(writer: *Writer, property: *G.Property) bool {
-
- // Property is
- // value
- // initializer
- // if property value is an e.spread, then key is skipped
- // key
-
- // value is first
- var expect_key = true;
- switch (TagOrJSNode.fromJSValue(writer, writer.eatArg() orelse return false)) {
- TagOrJSNode.tag => |tag| {
- var expr: Expr = Expr{ .loc = writer.loc, .data = .{ .e_null = E.Null{} } };
-
- if (!writer.writeFromJSWithTagInExpr(tag, &expr)) return false;
- property.value = switch (expr.data) {
- .e_missing, .e_undefined => null,
- else => expr,
- };
- property.flags.setPresent(.is_spread, expr.data == .e_spread);
- expect_key = property.value == null or !property.flags.contains(.is_spread);
- },
- TagOrJSNode.node => |node| {
- const expr = node.toExpr();
- property.value = switch (expr.data) {
- .e_missing, .e_undefined => null,
- else => expr,
- };
- property.flags.setPresent(.is_spread, expr.data == .e_spread);
- expect_key = property.value == null or !property.flags.contains(.is_spread);
- },
- TagOrJSNode.invalid => {
- return false;
- },
- }
-
- switch (TagOrJSNode.fromJSValue(writer, writer.eatArg() orelse return false)) {
- TagOrJSNode.tag => |tag| {
- var expr: Expr = Expr{ .loc = writer.loc, .data = .{ .e_null = E.Null{} } };
-
- if (!writer.writeFromJSWithTagInExpr(tag, &expr)) return false;
- property.initializer = switch (expr.data) {
- .e_missing, .e_undefined => null,
- else => expr,
- };
- },
- TagOrJSNode.node => |node| {
- const expr = node.toExpr();
- property.initializer = switch (expr.data) {
- .e_missing, .e_undefined => null,
- else => expr,
- };
- },
- TagOrJSNode.invalid => {
- return false;
- },
- }
-
- if (expect_key) {
- var next_arg = writer.peekArg() orelse return false;
- // its okay for property keys to literally be strings
- // <property name="foo">
- if (next_arg.isString()) {
- var expr: Expr = Expr{ .loc = writer.loc, .data = .{ .e_string = &E.String.empty } };
- if (!writer.writeFromJSWithTagInExpr(JSNode.Tag.e_string, &expr)) return false;
- property.key = expr;
- } else {
- switch (TagOrJSNode.fromJSValue(writer, writer.eatArg() orelse return false)) {
- TagOrJSNode.tag => |tag| {
- var expr: Expr = Expr{ .loc = writer.loc, .data = .{ .e_null = E.Null{} } };
- if (!writer.writeFromJSWithTagInExpr(tag, &expr)) return false;
- property.key = expr;
- },
- TagOrJSNode.node => |node| {
- property.key = node.toExpr();
- },
- TagOrJSNode.invalid => {
- return false;
- },
- }
- }
- }
-
- return true;
- }
-
- fn writeFromJSWithTagInNode(writer: *Writer, tag: JSNode.Tag) bool {
- switch (tag) {
- .s_import => {
- const path_arg = writer.eatArg() orelse return false;
- // path should be a plain old JS string
- if (!path_arg.isString()) {
- throwTypeError(writer.ctx, "Import path must be a string", writer.exception);
- return false;
- }
-
- var path_zig_string = JSC.ZigString.Empty;
- path_arg.toZigString(&path_zig_string, writer.ctx.ptr());
- const import_path = path_zig_string.trimmedSlice();
-
- if (import_path.len == 0) {
- throwTypeError(writer.ctx, "Import path must be a non-empty string", writer.exception);
- return false;
- }
-
- var import = ImportData{
- .import = S.Import{
- .namespace_ref = Ref.None,
- .import_record_index = std.math.maxInt(u32),
- },
- .path = import_path,
- };
- var import_namespace_arg = writer.eatArg() orelse return false;
- var import_default_arg = writer.eatArg() orelse return false;
-
- const has_default = import_default_arg.isString();
-
- var import_default_name_string = JSC.ZigString.Empty;
- if (has_default) import_default_arg.toZigString(&import_default_name_string, writer.ctx.ptr());
-
- const import_default_name = import_default_name_string.slice();
-
- var import_item_i: u32 = 0;
-
- // TODO: verify it's safe to reuse the memory here
- if (!import_namespace_arg.isNull()) {
- if (import_namespace_arg.isObject()) {
- throwTypeError(writer.ctx, "Import namespace should be an object where the keys are import names and the values are aliases.", writer.exception);
- return false;
- }
-
- const JSLexer = bun.js_lexer;
-
- var array_iter = JSC.JSPropertyIterator(.{
- .skip_empty_name = true,
- .include_value = true,
- }).init(writer.ctx, import_namespace_arg.asObjectRef());
- defer array_iter.deinit();
-
- import.import.items = writer.allocator.alloc(
- ClauseItem,
- @as(u32, @intCast(@intFromBool(has_default))) + array_iter.len,
- ) catch return false;
-
- while (array_iter.next()) |name| {
- const property_value = array_iter.value;
-
- if (!property_value.isString()) {
- return false;
- }
-
- var property_value_zig_string = JSC.ZigString.Empty;
- property_value.toZigString(&property_value_zig_string, writer.ctx.ptr());
-
- const alias = property_value_zig_string.slice();
-
- if (!JSLexer.isIdentifier(alias)) throwTypeError(writer.ctx, "import alias must be an identifier", writer.exception);
-
- import.import.items[import_item_i] = ClauseItem{
- .alias = name.toOwnedSlice(writer.allocator) catch return false,
- .original_name = alias,
- .name = .{ .loc = writer.loc, .ref = Ref.None },
- .alias_loc = writer.loc,
- };
-
- import_item_i += 1;
- }
- } else {
- import.import.items = writer.allocator.alloc(
- ClauseItem,
- @as(u32, @intCast(@intFromBool(has_default))),
- ) catch return false;
- }
-
- if (has_default) {
- import.import.items[import_item_i] = ClauseItem{
- .alias = ClauseItem.default_alias,
- .name = .{ .loc = writer.loc, .ref = Ref.None },
- .original_name = import_default_name,
- .alias_loc = writer.loc,
- };
- import_item_i += 1;
- }
-
- import.import.items = import.import.items[0..import_item_i];
-
- var import_ = writer.allocator.create(ImportData) catch return false;
- import_.* = import;
- writer.inject.append(JSNode{ .data = .{ .s_import = import_ }, .loc = writer.loc }) catch unreachable;
- return true;
- },
- else => {
- return false;
- },
- }
- }
-
- fn writeFromJSWithTagInExpr(writer: *Writer, tag: JSNode.Tag, expr: *Expr) bool {
- switch (tag) {
- .e_array => {
- // var e_array: E.Array = E.Array{ .items = writer.allocator.alloc(E.Array, args.len) catch return false };
- var count = (writer.nextJSValue() orelse return false).toU32();
- var i: @TypeOf(count) = 0;
- var items = ExprList.initCapacity(writer.allocator, count) catch unreachable;
-
- while (i < count) {
- var nextArg = writer.eatArg() orelse return false;
- if (js.JSValueIsArray(writer.ctx, nextArg.asRef())) {
- const extras = @as(u32, @truncate(nextArg.getLength(writer.ctx.ptr())));
- count += @max(@as(@TypeOf(count), @truncate(extras)), 1) - 1;
- items.ensureUnusedCapacity(extras) catch unreachable;
- items.expandToCapacity();
- var new_writer = writer.*;
- new_writer.args_i = 0;
- new_writer.args_len = extras;
- new_writer.args_value = nextArg;
-
- while (new_writer.nextJSValue()) |value| {
- defer i += 1;
- switch (TagOrJSNode.fromJSValue(&new_writer, value)) {
- TagOrJSNode.tag => |tag_| {
- if (!new_writer.writeFromJSWithTagInExpr(
- tag_,
- &items.items[i],
- )) return false;
- },
- TagOrJSNode.node => |node_| {
- const node: JSNode = node_;
- switch (node.data) {
- JSNode.Tag.s_import => return false,
- else => {
- items.items[i] = node.toExpr();
- },
- }
- },
- TagOrJSNode.invalid => {
- return false;
- },
- }
- }
- } else {
- defer i += 1;
-
- switch (TagOrJSNode.fromJSValue(writer, nextArg)) {
- TagOrJSNode.tag => |tag_| {
- if (!writer.writeFromJSWithTagInExpr(tag_, &items.items[i])) return false;
- },
- TagOrJSNode.node => |node_| {
- const node: JSNode = node_;
- switch (node.data) {
- JSNode.Tag.s_import => return false,
- else => {
- items.items[i] = node.toExpr();
- },
- }
- },
- TagOrJSNode.invalid => {
- return false;
- },
- }
- }
- }
- items.items = items.items[0..i];
- expr.* = Expr.init(E.Array, E.Array{ .items = ExprNodeList.fromList(items) }, writer.loc);
- return true;
- },
- .e_boolean => {
- expr.* = Expr{ .loc = writer.loc, .data = .{ .e_boolean = .{
- .value = JSC.JSValue.toBoolean(writer.nextJSValue() orelse return false),
- } } };
- return true;
- },
- .inline_true => {
- expr.* = Expr{ .loc = writer.loc, .data = .{ .e_boolean = .{ .value = true } } };
- return true;
- },
- .inline_false => {
- expr.* = Expr{ .loc = writer.loc, .data = .{ .e_boolean = .{ .value = false } } };
- return true;
- },
- .e_null => {
- expr.* = Expr{ .loc = writer.loc, .data = .{ .e_null = E.Null{} } };
- return true;
- },
- .e_undefined => {
- expr.* = Expr{ .loc = writer.loc, .data = .{ .e_undefined = E.Undefined{} } };
- return true;
- },
- .e_number => {
- expr.* = Expr{
- .loc = writer.loc,
- .data = .{
- .e_number = .{
- .value = JSC.JSValue.asNumber(writer.nextJSValue() orelse return false),
- },
- },
- };
- return true;
- },
- .e_string => {
- var str = (writer.nextJSValue() orelse return false).toSlice(writer.ctx.ptr(), writer.allocator);
- if (str.len == 0) {
- expr.* = Expr{
- .loc = writer.loc,
- .data = .{
- .e_string = &E.String.empty,
- },
- };
- } else {
- expr.* = Expr.init(E.String, E.String.init(
- (str.cloneIfNeeded(writer.allocator) catch unreachable).slice(),
- ), writer.loc);
- }
- return true;
- },
- .e_reg_exp => {
- var jsstring = js.JSValueToStringCopy(writer.ctx, (writer.eatArg() orelse return false).asRef(), writer.exception);
- defer js.JSStringRelease(jsstring);
-
- const len = js.JSStringGetLength(jsstring);
- var str = writer.allocator.alloc(u8, len + 1) catch unreachable;
- const outlen = js.JSStringGetUTF8CString(jsstring, str.ptr, len + 1);
- expr.* = Expr.init(E.RegExp, E.RegExp{ .value = str[0..outlen] }, writer.loc);
- return true;
- },
- .e_object => {
- const len = (writer.nextJSValue() orelse return false).toU32();
-
- var properties = writer.allocator.alloc(G.Property, len) catch return false;
- var property_i: u32 = 0;
-
- while (property_i < properties.len) : (property_i += 1) {
- switch (TagOrJSNode.fromJSValue(writer, writer.eatArg() orelse return false)) {
- TagOrJSNode.tag => |tag_| {
- if (tag_ != JSNode.Tag.g_property) return false;
-
- if (!writer.writeProperty(
- &properties[property_i],
- )) return false;
- },
- TagOrJSNode.node => |node_| {
- const node: JSNode = node_;
- switch (node.data) {
- .g_property => |property| {
- properties[property_i] = property.*;
- },
- else => {
- return false;
- },
- }
- },
- TagOrJSNode.invalid => {
- return false;
- },
- }
- }
-
- return true;
- },
- .inline_identifier => {
- const to = (writer.nextJSValue() orelse return false).toInt32();
- expr.* = Expr{ .data = .{ .inline_identifier = to }, .loc = writer.loc };
- return true;
- },
-
- else => {
- return false;
- },
-
- // .e_call => {},
-
- // .e_dot => {},
- // .e_index => {},
- // .e_identifier => {},
- // .e_import_identifier => {},
-
- // .e_spread => {},
-
- // .e_template_part => {},
- // .e_template => {},
-
- // .e_await => {},
- // .e_yield => {},
- // .e_if => {},
- // .e_import => {},
- // .e_this => {},
- // .e_class => {},
- // s_import => {},
- }
-
- return false;
- }
-
- pub fn writeFromJS(writer: *Writer) ?JSNode {
- switch (TagOrJSNode.fromJSValueRef(writer, writer.ctx, (writer.eatArg() orelse return null).asRef())) {
- TagOrJSNode.tag => |tag| {
- if (tag == Tag.inline_inject) {
- const count: u32 = (writer.eatArg() orelse return null).toU32();
- var i: u32 = 0;
- while (i < count) : (i += 1) {
- const next_value = (writer.eatArg() orelse return null);
- const next_value_ref = next_value.asRef();
- if (js.JSValueIsArray(writer.ctx, next_value_ref)) {
- var iter = JSC.JSArrayIterator.init(next_value, writer.ctx.ptr());
- while (iter.next()) |current_value| {
- switch (TagOrJSNode.fromJSValueRef(writer, writer.ctx, current_value.asRef())) {
- .node => |node| {
- if (node.data != .s_import) {
- throwTypeError(writer.ctx, "inject must only contain imports", writer.exception);
- return null;
- }
- writer.inject.append(node) catch unreachable;
- },
- .tag => |t| {
- if (!writer.writeFromJSWithTagInNode(t)) return null;
- },
- .invalid => {
- return null;
- },
- }
- }
- i += 1;
- continue;
- } else {
- switch (TagOrJSNode.fromJSValueRef(writer, writer.ctx, next_value_ref)) {
- .tag => |tag2| {
- if (!writer.writeFromJSWithTagInNode(tag2)) return null;
- },
- TagOrJSNode.node => |node| {
- writer.inject.append(node) catch unreachable;
- },
- TagOrJSNode.invalid => {
- return null;
- },
- }
- }
- }
- return JSNode{ .data = .{ .inline_inject = writer.inject.toOwnedSlice() catch @panic("TODO") }, .loc = writer.loc };
- }
-
- if (tag == Tag.s_import) {
- if (!writer.writeFromJSWithTagInNode(tag)) return null;
- return writer.inject.items[0];
- }
-
- if (tag == Tag.fragment) {
- const count: u32 = (writer.eatArg() orelse return null).toU32();
- // collapse single-item fragments
- switch (count) {
- 0 => {
- return JSNode{ .data = .{ .fragment = &[_]JSNode{} }, .loc = writer.loc };
- },
-
- 1 => {
- var _node = writer.writeFromJS() orelse return null;
- while (true) {
- switch (_node.data) {
- .fragment => |fragment| {
- if (fragment.len == 1) {
- _node = fragment[0];
- continue;
- }
-
- return _node;
- },
- else => {
- return _node;
- },
- }
- }
- },
- else => {},
- }
-
- var i: u32 = 0;
- var fragment = std.ArrayList(JSNode).initCapacity(writer.allocator, count) catch return null;
- while (i < count) : (i += 1) {
- const node = writer.writeFromJS() orelse return null;
- fragment.append(node) catch unreachable;
- }
-
- return JSNode{ .data = .{ .fragment = fragment.toOwnedSlice() catch @panic("TODO") }, .loc = writer.loc };
- }
-
- var expr: Expr = Expr{ .loc = writer.loc, .data = .{ .e_null = E.Null{} } };
-
- if (!writer.writeFromJSWithTagInExpr(tag, &expr)) return null;
- return JSNode.initExpr(expr);
- },
- TagOrJSNode.node => |node| {
- return node;
- },
- TagOrJSNode.invalid => {
- return null;
- },
- }
- }
- };
-
- // pub fn isInstanceOf(
- // ctx: js.JSContextRef,
- // obj: js.JSObjectRef,
- // value: js.JSValueRef,
- // exception: js.ExceptionRef,
- // ) bool {
- // js.JSValueToNumber(ctx, value, exception);
- // }
-
- fn throwTypeError(ctx: js.JSContextRef, comptime msg: string, exception: js.ExceptionRef) void {
- JSCBase.JSError(JSCBase.getAllocator(ctx), msg, .{}, ctx, exception);
- }
-
- pub const BunJSXCallbackFunction = JSCBase.NewClass(
- void,
- .{ .name = "bunJSX" },
- .{
- .call = .{
- .rfn = createFromJavaScript,
- .ro = true,
- },
- .isNodeType = .{
- .rfn = isNodeType,
- .ro = true,
- },
- },
- .{},
- );
-
- pub fn isNodeType(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- if (arguments.len != 2) {
- throwTypeError(ctx, "bunJSX.isNodeType() requires 2 arguments", exception);
- return null;
- }
-
- const TagOrNodeType = Writer.TagOrJSNode.TagOrNodeType;
-
- const left = Writer.TagOrJSNode.fromJSValueRefNoValidate(ctx, arguments[0]);
- const right = Writer.TagOrJSNode.fromJSValueRefNoValidate(ctx, arguments[1]);
-
- if (left == TagOrNodeType.invalid or right == TagOrNodeType.invalid) {
- return js.JSValueMakeBoolean(ctx, false);
- }
-
- if (left == TagOrNodeType.node and right == TagOrNodeType.node) {
- return js.JSValueMakeBoolean(ctx, @as(Tag, left.node.data) == @as(Tag, right.node.data));
- }
-
- if (left == TagOrNodeType.node) {
- return js.JSValueMakeBoolean(ctx, @as(Tag, left.node.data) == right.tag);
- }
-
- if (right == TagOrNodeType.node) {
- return js.JSValueMakeBoolean(ctx, @as(Tag, right.node.data) == left.tag);
- }
-
- unreachable;
- }
-
- pub fn createFromJavaScript(
- _: void,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- arguments: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSObjectRef {
- if (arguments.len != 1 or !js.JSValueIsArray(ctx, arguments[0])) {
- throwTypeError(ctx, "bunJSX requires one array argument", exception);
- return null;
- }
-
- js.JSValueProtect(ctx, arguments[0]);
- defer Output.flush();
- const args_value = JSC.JSValue.fromRef(arguments[0]);
- var writer = Writer{
- .inject = std.ArrayList(JSNode).init(JSCBase.getAllocator(ctx)),
- .log = JavaScript.VirtualMachine.get().log,
- .ctx = ctx,
- .loc = logger.Loc.Empty,
- .allocator = JSCBase.getAllocator(ctx),
- .exception = exception,
- .args_value = args_value,
- .args_len = @as(u32, @truncate(args_value.getLength(ctx.ptr()))),
- .args_i = 0,
- .errored = false,
- };
-
- if (writer.writeFromJS()) |node| {
- var ptr = writer.allocator.create(JSNode) catch unreachable;
- ptr.* = node;
- var result = JSNode.Class.make(ctx, ptr);
- js.JSValueProtect(ctx, result);
- return result;
- }
-
- return null;
- }
- };
-
- pub const LazyPropertiesObject = struct {
- node: JSNode,
-
- pub const Class = JSCBase.NewClass(
- LazyPropertiesObject,
- .{
- .name = "LazyPropertiesObject",
- .read_only = true,
- },
- .{
- .getProperty = .{
- .rfn = &getProperty,
- },
- .hasProperty = .{
- .rfn = &hasProperty,
- },
- .getPropertyNames = .{
- .rfn = &getPropertyNames,
- },
- },
- .{},
- );
-
- pub fn getProperty(
- ctx: js.JSContextRef,
- thisObject: js.JSObjectRef,
- propertyName: js.JSStringRef,
- exception: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- var this: *LazyPropertiesObject = JSCBase.GetJSPrivateData(LazyPropertiesObject, thisObject) orelse return null;
-
- const len = js.JSStringGetLength(propertyName);
- const properties = this.node.data.e_object.properties.slice();
- var ptr = js.JSStringGetCharacters8Ptr(propertyName);
- var property_slice = ptr[0..len];
- var value_node: JSNode = undefined;
-
- for (properties) |property| {
- const key = property.key orelse continue;
- if (key.data != .e_string) continue;
- const str = key.data.e_string.data;
-
- if (strings.eql(property_slice, str)) {
- const value = property.value orelse return js.JSValueMakeUndefined(ctx);
- value_node = JSNode.initExpr(value);
- return JSNode.JSBindings.toPrimitive(&value_node, ctx, exception);
- }
- }
-
- return js.JSValueMakeUndefined(ctx);
- }
-
- pub fn hasProperty(
- _: js.JSContextRef,
- thisObject: js.JSObjectRef,
- propertyName: js.JSStringRef,
- ) callconv(.C) bool {
- var this: *LazyPropertiesObject = JSCBase.GetJSPrivateData(LazyPropertiesObject, thisObject) orelse return false;
-
- const len = js.JSStringGetLength(propertyName);
- const properties = this.node.data.e_object.properties.slice();
- var ptr = js.JSStringGetCharacters8Ptr(propertyName);
- var property_slice = ptr[0..len];
-
- for (properties) |property| {
- const key = property.key orelse continue;
- if (key.data != .e_string) continue;
- const str = key.data.e_string.data;
-
- if (strings.eql(property_slice, str)) return true;
- }
-
- return false;
- }
-
- pub fn getPropertyNames(
- _: js.JSContextRef,
- thisObject: js.JSObjectRef,
- props: js.JSPropertyNameAccumulatorRef,
- ) callconv(.C) void {
- var this: *LazyPropertiesObject = JSCBase.GetJSPrivateData(LazyPropertiesObject, thisObject) orelse return;
-
- const properties = this.node.data.e_object.properties.slice();
-
- for (properties) |property| {
- const key = property.key orelse continue;
- if (key.data != .e_string) continue;
- const str = key.data.e_string.data;
- js.JSPropertyNameAccumulatorAddName(props, js.JSStringCreate(str.ptr, str.len));
- }
- }
- };
-
- pub const ModuleNamespace = struct {
- import_data: JSNode.ImportData,
-
- pub const Class = JSCBase.NewClass(
- ModuleNamespace,
- .{
- .name = "ModuleNamespace",
- .read_only = true,
- },
- .{
- .getProperty = .{
- .rfn = &getProperty,
- },
- .hasProperty = .{
- .rfn = &hasProperty,
- },
- .getPropertyNames = .{
- .rfn = &getPropertyNames,
- },
- },
- .{},
- );
-
- pub fn getProperty(
- ctx: js.JSContextRef,
- thisObject: js.JSObjectRef,
- propertyName: js.JSStringRef,
- _: js.ExceptionRef,
- ) callconv(.C) js.JSValueRef {
- var this: *ModuleNamespace = JSCBase.GetJSPrivateData(ModuleNamespace, thisObject) orelse return null;
-
- const len = js.JSStringGetLength(propertyName);
- const properties = this.import_data.import.items;
- var ptr = js.JSStringGetCharacters8Ptr(propertyName);
- var property_slice = ptr[0..len];
-
- for (properties) |property| {
- if (strings.eql(property.original_name, property_slice)) {
- return JSC.JSValue.jsNumberFromInt32(JSNode.SymbolMap.generateImportHash(property.original_name, this.import_data.path)).asRef();
- }
- }
-
- return js.JSValueMakeUndefined(ctx);
- }
-
- pub fn hasProperty(
- _: js.JSContextRef,
- thisObject: js.JSObjectRef,
- propertyName: js.JSStringRef,
- ) callconv(.C) bool {
- var this: *ModuleNamespace = JSCBase.GetJSPrivateData(ModuleNamespace, thisObject) orelse return false;
-
- const len = js.JSStringGetLength(propertyName);
- const properties = this.import_data.import.items;
- var ptr = js.JSStringGetCharacters8Ptr(propertyName);
- var property_slice = ptr[0..len];
-
- for (properties) |property| {
- if (strings.eql(property.original_name, property_slice)) return true;
- }
-
- return false;
- }
-
- pub fn getPropertyNames(
- _: js.JSContextRef,
- thisObject: js.JSObjectRef,
- props: js.JSPropertyNameAccumulatorRef,
- ) callconv(.C) void {
- var this: *ModuleNamespace = JSCBase.GetJSPrivateData(ModuleNamespace, thisObject) orelse return;
-
- const items = this.import_data.import.items;
-
- for (items) |clause| {
- const str = clause.original_name;
- js.JSPropertyNameAccumulatorAddName(props, js.JSStringCreateStatic(str.ptr, str.len));
- }
- }
- };
-
resolver: *Resolver,
vm: *JavaScript.VirtualMachine = undefined,
@@ -9670,7 +6914,6 @@ pub const Macro = struct {
const VisitMap = std.AutoHashMapUnmanaged(JSC.JSValue, Expr);
threadlocal var args_buf: [3]js.JSObjectRef = undefined;
- threadlocal var expr_nodes_buf: [1]JSNode = undefined;
threadlocal var exception_holder: Zig.ZigException.Holder = undefined;
pub const MacroError = error{ MacroFailed, OutOfMemory } || ToJSError;
@@ -9801,20 +7044,6 @@ pub const Macro = struct {
this.macro.vm.runErrorHandler(value, null);
return error.MacroFailed;
}
- } else {
- var private_data = JSCBase.JSPrivateDataPtr.from(JSC.C.JSObjectGetPrivate(value.asObjectRef()).?);
-
- switch (private_data.tag()) {
- .JSNode => {
- var node = private_data.as(JSNode);
- _entry.value_ptr.* = node.toExpr();
- node.visited = true;
- node.updateSymbolsMap(Visitor, this.visitor);
- return _entry.value_ptr.*;
- },
-
- else => {},
- }
}
if (blob_) |*blob| {
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 0ba935c98..bb767d875 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -2786,16 +2786,9 @@ pub const Parser = struct {
if (comptime Environment.isWasm) {
self.options.ts = true;
self.options.jsx.parse = true;
- // if (self.options.features.is_macro_runtime) {
- // return try self._parse(TSParserMacro);
- // }
-
return try self._parse(TSXParser);
}
- if (self.options.ts and self.options.features.is_macro_runtime) return try self._parse(TSParserMacro);
- if (!self.options.ts and self.options.features.is_macro_runtime) return try self._parse(JSParserMacro);
-
if (self.options.ts and self.options.jsx.parse) {
return try self._parse(TSXParser);
} else if (self.options.ts) {
@@ -3865,7 +3858,6 @@ pub const ImportOrRequireScanResults = struct {
const JSXTransformType = enum {
none,
react,
- macro,
};
const ParserFeatures = struct {
@@ -4177,7 +4169,7 @@ fn NewParser_(
// P is for Parser!
return struct {
- const js_parser_jsx = if (FeatureFlags.force_macro) JSXTransformType.macro else js_parser_features.jsx;
+ const js_parser_jsx = js_parser_features.jsx;
const is_typescript_enabled = js_parser_features.typescript;
const is_jsx_enabled = js_parser_jsx != .none;
const only_scan_imports_and_do_not_visit = js_parser_features.scan_only;
@@ -4190,7 +4182,7 @@ fn NewParser_(
pub const parser_features: ParserFeatures = js_parser_features;
const P = @This();
pub const jsx_transform_type: JSXTransformType = js_parser_jsx;
- const allow_macros = FeatureFlags.is_macro_enabled and jsx_transform_type != .macro;
+ const allow_macros = FeatureFlags.is_macro_enabled;
const MacroCallCountType = if (allow_macros) u32 else u0;
macro: MacroState = undefined,
allocator: Allocator,
@@ -6019,17 +6011,6 @@ fn NewParser_(
}
},
- .macro => {
- if (!p.options.bundle) {
- p.bun_jsx_ref = p.declareSymbol(.other, logger.Loc.Empty, "bunJSX") catch unreachable;
- BunJSX.bun_jsx_identifier = E.Identifier{
- .ref = p.bun_jsx_ref,
- .can_be_removed_if_unused = true,
- .call_can_be_unwrapped_if_unused = true,
- };
- p.jsx_fragment = p.declareGeneratedSymbol(.other, "Fragment") catch unreachable;
- }
- },
else => {},
}
}
@@ -14447,11 +14428,6 @@ fn NewParser_(
.e_jsx_element => |e_| {
switch (comptime jsx_transform_type) {
- .macro => {
- const WriterType = js_ast.Macro.JSNode.NewJSXWriter(P);
- var writer = WriterType.initWriter(p, &BunJSX.bun_jsx_identifier);
- return writer.writeFunctionCall(e_.*);
- },
.react => {
const tag: Expr = tagger: {
if (e_.tag) |_tag| {
@@ -14793,7 +14769,7 @@ fn NewParser_(
e_.tag = p.visitExpr(tag);
if (comptime allow_macros) {
- if (e_.tag.?.data == .e_import_identifier) {
+ if (e_.tag.?.data == .e_import_identifier and !p.options.features.is_macro_runtime) {
const ref = e_.tag.?.data.e_import_identifier.ref;
if (p.macro.refs.get(ref)) |import_record_id| {
@@ -14902,89 +14878,6 @@ fn NewParser_(
// const is_stmt_expr = @as(Expr.Tag, p.stmt_expr_value) == .e_binary and expr.data.e_binary == p.stmt_expr_value.e_binary;
const was_anonymous_named_expr = e_.right.isAnonymousNamed();
- if (comptime jsx_transform_type == .macro) {
- if (e_.op == Op.Code.bin_instanceof and (e_.right.data == .e_jsx_element or e_.left.data == .e_jsx_element)) {
- // foo instanceof <string />
- // ->
- // bunJSX.isNodeType(foo, 13)
-
- // <string /> instanceof foo
- // ->
- // bunJSX.isNodeType(foo, 13)
- var call_args = p.allocator.alloc(Expr, 2) catch unreachable;
- call_args[0] = e_.left;
- call_args[1] = e_.right;
-
- if (e_.right.data == .e_jsx_element) {
- const jsx_element = e_.right.data.e_jsx_element;
- if (jsx_element.tag) |tag| {
- if (tag.data == .e_string) {
- const tag_string = tag.data.e_string.slice(p.allocator);
- if (js_ast.Macro.JSNode.Tag.names.get(tag_string)) |node_tag| {
- call_args[1] = Expr{ .loc = tag.loc, .data = js_ast.Macro.JSNode.Tag.ids.get(node_tag) };
- } else {
- p.log.addRangeErrorFmt(
- p.source,
- js_lexer.rangeOfIdentifier(p.source, tag.loc),
- p.allocator,
- "Invalid JSX tag: \"{s}\"",
- .{tag_string},
- ) catch unreachable;
- return expr;
- }
- }
- } else {
- call_args[1] = p.visitExpr(call_args[1]);
- }
- } else {
- call_args[1] = p.visitExpr(call_args[1]);
- }
-
- if (e_.left.data == .e_jsx_element) {
- const jsx_element = e_.left.data.e_jsx_element;
- if (jsx_element.tag) |tag| {
- if (tag.data == .e_string) {
- const tag_string = tag.data.e_string.slice(p.allocator);
- if (js_ast.Macro.JSNode.Tag.names.get(tag_string)) |node_tag| {
- call_args[0] = Expr{ .loc = tag.loc, .data = js_ast.Macro.JSNode.Tag.ids.get(node_tag) };
- } else {
- p.log.addRangeErrorFmt(
- p.source,
- js_lexer.rangeOfIdentifier(p.source, tag.loc),
- p.allocator,
- "Invalid JSX tag: \"{s}\"",
- .{tag_string},
- ) catch unreachable;
- return expr;
- }
- }
- } else {
- call_args[0] = p.visitExpr(call_args[0]);
- }
- } else {
- call_args[0] = p.visitExpr(call_args[0]);
- }
-
- return p.newExpr(
- E.Call{
- .target = p.newExpr(
- E.Dot{
- .name = "isNodeType",
- .name_loc = expr.loc,
- .target = p.newExpr(BunJSX.bun_jsx_identifier, expr.loc),
- .can_be_removed_if_unused = true,
- .call_can_be_unwrapped_if_unused = true,
- },
- expr.loc,
- ),
- .args = ExprNodeList.init(call_args),
- .can_be_unwrapped_if_unused = true,
- },
- expr.loc,
- );
- }
- }
-
e_.left = p.visitExprInOut(e_.left, ExprIn{
.assign_target = e_.op.binaryAssignTarget(),
});
@@ -15629,9 +15522,11 @@ fn NewParser_(
}
if (comptime allow_macros) {
- if (p.macro_call_count > 0 and e_.target.data == .e_object and e_.target.data.e_object.was_originally_macro) {
- if (e_.target.get(e_.name)) |obj| {
- return obj;
+ if (!p.options.features.is_macro_runtime) {
+ if (p.macro_call_count > 0 and e_.target.data == .e_object and e_.target.data.e_object.was_originally_macro) {
+ if (e_.target.get(e_.name)) |obj| {
+ return obj;
+ }
}
}
}
@@ -15861,8 +15756,7 @@ fn NewParser_(
else => {},
}
- const is_macro_ref: bool = if (comptime FeatureFlags.is_macro_enabled and
- jsx_transform_type != .macro)
+ const is_macro_ref: bool = if (comptime FeatureFlags.is_macro_enabled)
e_.target.data == .e_import_identifier and p.macro.refs.contains(e_.target.data.e_import_identifier.ref)
else
false;
@@ -15982,7 +15876,7 @@ fn NewParser_(
}
if (comptime allow_macros) {
- if (is_macro_ref) {
+ if (is_macro_ref and !p.options.features.is_macro_runtime) {
const ref = e_.target.data.e_import_identifier.ref;
const import_record_id = p.macro.refs.get(ref).?;
p.ignoreUsage(ref);
@@ -21438,16 +21332,6 @@ else
NewParser(.{ .jsx = .react });
pub const TSXParser = NewParser(.{ .jsx = .react, .typescript = true });
const TypeScriptParser = NewParser(.{ .typescript = true });
-const JSParserMacro = if (bun.fast_debug_build_mode)
- TSParserMacro
-else
- NewParser(.{
- .jsx = .macro,
- });
-const TSParserMacro = NewParser(.{
- .jsx = .macro,
- .typescript = true,
-});
const JavaScriptImportScanner = if (bun.fast_debug_build_mode) TSXImportScanner else NewParser(.{ .scan_only = true });
const JSXImportScanner = if (bun.fast_debug_build_mode) TSXImportScanner else NewParser(.{ .jsx = .react, .scan_only = true });
const TSXImportScanner = NewParser(.{ .jsx = .react, .typescript = true, .scan_only = true });
diff --git a/src/jsc.zig b/src/jsc.zig
index 2ee83f0f7..1e844464a 100644
--- a/src/jsc.zig
+++ b/src/jsc.zig
@@ -32,12 +32,12 @@ pub const API = struct {
pub const JSBundler = @import("./bun.js/api/JSBundler.zig").JSBundler;
pub const BuildArtifact = @import("./bun.js/api/JSBundler.zig").BuildArtifact;
pub const JSTranspiler = @import("./bun.js/api/JSTranspiler.zig");
- pub const Server = @import("./bun.js/api/server.zig").Server;
+ pub const HTTPServer = @import("./bun.js/api/server.zig").HTTPServer;
pub const ServerConfig = @import("./bun.js/api/server.zig").ServerConfig;
pub const ServerWebSocket = @import("./bun.js/api/server.zig").ServerWebSocket;
- pub const SSLServer = @import("./bun.js/api/server.zig").SSLServer;
- pub const DebugServer = @import("./bun.js/api/server.zig").DebugServer;
- pub const DebugSSLServer = @import("./bun.js/api/server.zig").DebugSSLServer;
+ pub const HTTPSServer = @import("./bun.js/api/server.zig").HTTPSServer;
+ pub const DebugHTTPServer = @import("./bun.js/api/server.zig").DebugHTTPServer;
+ pub const DebugHTTPSServer = @import("./bun.js/api/server.zig").DebugHTTPSServer;
pub const Bun = @import("./bun.js/api/bun.zig");
pub const FileSystemRouter = @import("./bun.js/api/filesystem_router.zig").FileSystemRouter;
pub const MatchedRoute = @import("./bun.js/api/filesystem_router.zig").MatchedRoute;
diff --git a/src/router.zig b/src/router.zig
index 685de061a..bd79b6fc6 100644
--- a/src/router.zig
+++ b/src/router.zig
@@ -815,10 +815,10 @@ pub fn match(app: *Router, comptime Server: type, server: Server, comptime Reque
}
}
- ctx.matched_route = route;
- RequestContextType.JavaScriptHandler.enqueue(ctx, server, &params_list) catch {
- server.javascript_enabled = false;
- };
+ // ctx.matched_route = route;
+ // RequestContextType.JavaScriptHandler.enqueue(ctx, server, &params_list) catch {
+ // server.javascript_enabled = false;
+ // };
}
if (!ctx.controlled and !ctx.has_called_done) {